Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always prompt for optional features #423

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class InstallCommand extends Command implements PromptsForMissingInput
*/
public function handle()
{
$this->promptForOptionalFeatures();

if ($this->argument('stack') === 'vue') {
return $this->installInertiaVueStack();
} elseif ($this->argument('stack') === 'react') {
Expand Down Expand Up @@ -389,13 +391,13 @@ protected function promptForMissingArgumentsUsing()
}

/**
* Interact further with the user if they were prompted for missing arguments.
* Prompt for optional features after stack is set.
*
* @return void
*/
protected function afterPromptingForMissingArguments(InputInterface $input, OutputInterface $output)
protected function promptForOptionalFeatures()
{
$stack = $input->getArgument('stack');
$stack = $this->argument('stack');

if (in_array($stack, ['react', 'vue'])) {
collect(multiselect(
Expand All @@ -406,16 +408,21 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp
'typescript' => 'TypeScript',
'eslint' => 'ESLint with Prettier',
],
hint: 'Use the space bar to select options.'
))->each(fn ($option) => $input->setOption($option, true));
default: collect([
'dark' => $this->option('dark'),
'ssr' => $this->option('ssr'),
'typescript' => $this->option('typescript'),
'eslint' => $this->option('eslint'),
])->filter()->keys(),
))->each(fn ($option) => $this->input->setOption($option, true));
} elseif (in_array($stack, ['blade', 'livewire', 'livewire-functional'])) {
$input->setOption('dark', confirm(
$this->input->setOption('dark', confirm(
label: 'Would you like dark mode support?',
default: false
default: $this->option('dark')
));
}

$input->setOption('pest', select(
$this->input->setOption('pest', select(
label: 'Which testing framework do you prefer?',
options: ['Pest', 'PHPUnit'],
default: 'Pest',
Expand Down
Loading