From c07fff4f6d119237438baaeab4b9d3b0143c935d Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Tue, 8 Sep 2020 09:16:17 +0200 Subject: [PATCH 1/4] add stack and teams options --- src/NewCommand.php | 47 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/NewCommand.php b/src/NewCommand.php index f7524b7e..7bc6378d 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -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'); } @@ -46,18 +48,12 @@ 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); + die(); } else { $output->write(PHP_EOL.' _ _ | | | | @@ -244,4 +240,33 @@ 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); + + $stack = $helper->ask($input, new SymfonyStyle($input, $output), $question); + + return $stack; + } } From d19c9c3c8839a94f3c7f94a4899fca513808f87f Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Tue, 8 Sep 2020 13:32:14 +0200 Subject: [PATCH 2/4] wording --- src/NewCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NewCommand.php b/src/NewCommand.php index 7bc6378d..8ea9f1e7 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -28,7 +28,7 @@ protected function configure() ->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('teams', null, InputOption::VALUE_OPTIONAL, 'Install Jetstream teams') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces install even if the directory already exists'); } From 826e81acefb868395ab5f18fd72e0f7ced36f08b Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Tue, 8 Sep 2020 13:32:48 +0200 Subject: [PATCH 3/4] style --- src/NewCommand.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/NewCommand.php b/src/NewCommand.php index 8ea9f1e7..6af423d4 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -265,8 +265,6 @@ protected function jetstreamStack(InputInterface $input, OutputInterface $output $output->write(PHP_EOL); - $stack = $helper->ask($input, new SymfonyStyle($input, $output), $question); - - return $stack; + return $helper->ask($input, new SymfonyStyle($input, $output), $question); } } From 010a4bf891b0feaad329c1576b30a097e76939f7 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Tue, 8 Sep 2020 13:39:51 +0200 Subject: [PATCH 4/4] fix --- src/NewCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NewCommand.php b/src/NewCommand.php index 6af423d4..48870229 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -53,7 +53,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $teams = ! is_null($input->getOption('teams')) ? (bool) $input->getOption('teams') : (new SymfonyStyle($input, $output))->confirm('Will your application use teams?', false); - die(); } else { $output->write(PHP_EOL.' _ _ | | | |