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" }, diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index d3a8fc993..4632a0f9a 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,50 @@ 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 features?', + options: collect([ + 'teams' => 'Team support', + 'api' => 'API support', + 'verification' => 'Email verification', + 'dark' => 'Dark mode', + ])->when( + $input->getArgument('stack') === 'inertia', + fn ($options) => $options->put('ssr', 'Inertia SSR') + )->sort()->all(), + ))->each(fn ($option) => $input->setOption($option, true)); + + $input->setOption('pest', select( + label: 'Which testing framework do you prefer?', + options: ['PHPUnit', 'Pest'], + ) === 'Pest'); + } }