diff --git a/src/NewCommand.php b/src/NewCommand.php index 8a0e3b9..aa5ff39 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -68,6 +68,7 @@ protected function configure() ->addOption('pnpm', null, InputOption::VALUE_NONE, 'Install and build NPM dependencies via PNPM') ->addOption('bun', null, InputOption::VALUE_NONE, 'Install and build NPM dependencies via Bun') ->addOption('yarn', null, InputOption::VALUE_NONE, 'Install and build NPM dependencies via Yarn') + ->addOption('boost', null, InputOption::VALUE_NONE, 'Install Laravel Boost to improve AI assisted coding') ->addOption('using', null, InputOption::VALUE_OPTIONAL, 'Install a custom starter kit from a community maintained package') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces install even if the directory already exists'); } @@ -174,6 +175,12 @@ protected function interact(InputInterface $input, OutputInterface $output) default: 'Pest', ) === 'Pest'); } + + if (! $input->getOption('boost')) { + $input->setOption('boost', confirm( + label: 'Do you want to install Laravel Boost to improve AI assisted coding?', + )); + } } /** @@ -498,6 +505,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->installPest($directory, $input, $output); } + if ($input->getOption('boost')) { + $this->installBoost($directory, $input, $output); + } + if ($input->getOption('github') !== false) { $this->pushToGitHub($name, $directory, $input, $output); $output->writeln(''); @@ -527,6 +538,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->runCommands([$packageManager->installCommand(), $packageManager->buildCommand()], $input, $output, workingPath: $directory); } + if ($input->getOption('boost')) { + $this->configureBoostComposerScript(); + $this->commitChanges('Configure Boost post-update script', $directory, $input, $output); + } + $output->writeln(" INFO Application ready in [{$name}]. You can start your local development using:".PHP_EOL); $output->writeln('cd '.$name.''); @@ -882,6 +898,31 @@ protected function installPest(string $directory, InputInterface $input, OutputI $this->commitChanges('Install Pest', $directory, $input, $output); } + /** + * Install Laravel Boost into the application. + * + * @param string $directory + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return void + */ + protected function installBoost(string $directory, InputInterface $input, OutputInterface $output): void + { + $composerBinary = $this->findComposer(); + + $commands = [ + $composerBinary.' require laravel/boost --dev', + trim(sprintf( + $this->phpBinary().' artisan boost:install %s', + ! $input->isInteractive() ? '--no-interaction' : '', + )), + ]; + + $this->runCommands($commands, $input, $output, workingPath: $directory); + + $this->commitChanges('Install Laravel Boost', $directory, $input, $output); + } + /** * Create a Git repository and commit the base Laravel skeleton. * @@ -987,6 +1028,20 @@ protected function configureComposerScripts(NodePackageManager $packageManager): }); } + /** + * Add boost:update command to the post-update-cmd Composer script. + * + * @return void + */ + protected function configureBoostComposerScript(): void + { + $this->composer->modify(function (array $content) { + $content['scripts']['post-update-cmd'][] = '@php artisan boost:update --ansi'; + + return $content; + }); + } + /** * Verify that the application does not already exist. *