From 31594869c74b5cafea7790abb265a60e8a586375 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Wed, 5 Jul 2023 14:16:29 +1000 Subject: [PATCH 1/4] Prompt when required installer argument is missing --- src/Console/InstallCommand.php | 50 +++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index d3a8fc993..08a477175 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -4,14 +4,20 @@ use Exception; use Illuminate\Console\Command; +use Illuminate\Contracts\Console\PromptsForMissingInput; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Str; use RuntimeException; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Finder\Finder; use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; -class InstallCommand extends Command +use function Laravel\Prompts\multiselect; +use function Laravel\Prompts\select; + +class InstallCommand extends Command implements PromptsForMissingInput { /** * The name and signature of the console command. @@ -830,4 +836,46 @@ protected function runCommands($commands) $this->output->write(' '.$line); }); } + + /** + * Prompt for missing input arguments using the returned questions. + * + * @return array + */ + protected function promptForMissingArgumentsUsing() + { + return [ + 'stack' => fn () => select( + label: 'Which Jetstream stack would you like to install?', + options: [ + 'inertia' => 'Vue with Inertia', + 'livewire' => 'Livewire', + ] + ), + ]; + } + + /** + * Interact further with the user if they were prompted for missing arguments. + * + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return void + */ + protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output) + { + collect(multiselect( + label: 'Would you like any optional extras?', + options: collect([ + 'teams' => 'Team support', + 'api' => 'API support', + 'verification' => 'Email verification', + 'dark' => 'Dark mode', + 'pest' => 'Pest tests instead of PHPUnit', + ])->when( + $input->getArgument('stack') === 'inertia', + fn ($options) => $options->put('ssr', 'Inertia SSR') + )->all(), + ))->each(fn ($option) => $input->setOption($option, true)); + } } From 32a101f7f13fdc69e05636bcbf217ef2480d970b Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Wed, 5 Jul 2023 15:15:35 +1000 Subject: [PATCH 2/4] Improve testing framework selection --- src/Console/InstallCommand.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 08a477175..09b3c4e41 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -865,17 +865,21 @@ protected function promptForMissingArgumentsUsing() protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output) { collect(multiselect( - label: 'Would you like any optional extras?', + label: 'Would you like any optional features?', options: collect([ 'teams' => 'Team support', 'api' => 'API support', 'verification' => 'Email verification', 'dark' => 'Dark mode', - 'pest' => 'Pest tests instead of PHPUnit', ])->when( $input->getArgument('stack') === 'inertia', fn ($options) => $options->put('ssr', 'Inertia SSR') )->all(), ))->each(fn ($option) => $input->setOption($option, true)); + + $input->setOption('pest', select( + label: 'Which testing framework do you prefer?', + options: ['PHPUnit', 'Pest'], + ) === 'Pest'); } } From c4634251ba5433fa10f23f3c38d9f5eb90caa6df Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Tue, 1 Aug 2023 14:20:35 +1000 Subject: [PATCH 3/4] Bump minimum Laravel requirement --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 634e399a0..1a8dd0f01 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ "require": { "php": "^8.1.0", "ext-json": "*", - "illuminate/console": "^10.0", - "illuminate/support": "^10.0", + "illuminate/console": "^10.17", + "illuminate/support": "^10.17", "jenssegers/agent": "^2.6", "laravel/fortify": "^1.15" }, From 0592537cee904915445a7340b4892c49a45fcfb0 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 2 Aug 2023 14:02:21 -0500 Subject: [PATCH 4/4] Update InstallCommand.php --- src/Console/InstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 09b3c4e41..4632a0f9a 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -874,7 +874,7 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp ])->when( $input->getArgument('stack') === 'inertia', fn ($options) => $options->put('ssr', 'Inertia SSR') - )->all(), + )->sort()->all(), ))->each(fn ($option) => $input->setOption($option, true)); $input->setOption('pest', select(