Skip to content
Merged
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
44 changes: 33 additions & 11 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected function configure()
->addArgument('name', InputArgument::OPTIONAL)
->addOption('dev', null, InputOption::VALUE_NONE, 'Installs the latest "development" release')
->addOption('jet', null, InputOption::VALUE_NONE, 'Installs the Laravel Jetstream scaffolding')
->addOption('stack', null, InputOption::VALUE_OPTIONAL, 'The Jetstream stack')
->addOption('teams', null, InputOption::VALUE_OPTIONAL, 'Install Jetstream teams')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces install even if the directory already exists');
}

Expand All @@ -46,18 +48,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
||---'| `---.| | |---',---|| | |
`---'`---'`---'`---'`---'` `---'`---^` ' '</>".PHP_EOL.PHP_EOL);

$helper = $this->getHelper('question');
$stack = $this->jetstreamStack($input, $output);

$question = new ChoiceQuestion('Which Jetstream stack do you prefer?', [
'livewire',
'inertia',
]);

$output->write(PHP_EOL);

$stack = $helper->ask($input, new SymfonyStyle($input, $output), $question);

$teams = (new SymfonyStyle($input, $output))->confirm('Will your application use teams?', false);
$teams = ! is_null($input->getOption('teams'))
? (bool) $input->getOption('teams')
: (new SymfonyStyle($input, $output))->confirm('Will your application use teams?', false);
} else {
$output->write(PHP_EOL.'<fg=red> _ _
| | | |
Expand Down Expand Up @@ -244,4 +239,31 @@ protected function replaceInFile(string $search, string $replace, string $file)
str_replace($search, $replace, file_get_contents($file))
);
}

/**
* Determine the stack for Jetstream.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return string
*/
protected function jetstreamStack(InputInterface $input, OutputInterface $output)
{
$stacks = [
'livewire',
'inertia',
];

if ($input->getOption('stack') && in_array($input->getOption('stack'), $stacks)) {
return $input->getOption('stack');
}

$helper = $this->getHelper('question');

$question = new ChoiceQuestion('Which Jetstream stack do you prefer?', $stacks);

$output->write(PHP_EOL);

return $helper->ask($input, new SymfonyStyle($input, $output), $question);
}
}