Skip to content

Commit

Permalink
Prompt when required installer argument is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher committed Jul 5, 2023
1 parent 1e3f32e commit 3159486
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 17 in src/Console/InstallCommand.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Used function Laravel\Prompts\multiselect not found.
use function Laravel\Prompts\select;

Check failure on line 18 in src/Console/InstallCommand.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Used function Laravel\Prompts\select not found.

class InstallCommand extends Command implements PromptsForMissingInput
{
/**
* The name and signature of the console command.
Expand Down Expand Up @@ -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(

Check failure on line 848 in src/Console/InstallCommand.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Function Laravel\Prompts\select not found.
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(

Check failure on line 867 in src/Console/InstallCommand.php

View workflow job for this annotation

GitHub Actions / Static Analysis

Function Laravel\Prompts\multiselect not found.
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));
}
}

0 comments on commit 3159486

Please sign in to comment.