Skip to content

Commit dad0992

Browse files
Add Laravel Boost Installation Option (#446)
* Add Laravel Boost installation and configuration options * Fix Style * formatting * Clarify 'boost' option description in NewCommand.php Updated the description for the 'boost' option to clarify its purpose. * Update NewCommand.php * Update NewCommand.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com> Co-authored-by: Taylor Otwell <taylorotwell@gmail.com>
1 parent aa185c4 commit dad0992

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

src/NewCommand.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ protected function configure()
6868
->addOption('pnpm', null, InputOption::VALUE_NONE, 'Install and build NPM dependencies via PNPM')
6969
->addOption('bun', null, InputOption::VALUE_NONE, 'Install and build NPM dependencies via Bun')
7070
->addOption('yarn', null, InputOption::VALUE_NONE, 'Install and build NPM dependencies via Yarn')
71+
->addOption('boost', null, InputOption::VALUE_NONE, 'Install Laravel Boost to improve AI assisted coding')
7172
->addOption('using', null, InputOption::VALUE_OPTIONAL, 'Install a custom starter kit from a community maintained package')
7273
->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces install even if the directory already exists');
7374
}
@@ -174,6 +175,12 @@ protected function interact(InputInterface $input, OutputInterface $output)
174175
default: 'Pest',
175176
) === 'Pest');
176177
}
178+
179+
if (! $input->getOption('boost')) {
180+
$input->setOption('boost', confirm(
181+
label: 'Do you want to install Laravel Boost to improve AI assisted coding?',
182+
));
183+
}
177184
}
178185

179186
/**
@@ -498,6 +505,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
498505
$this->installPest($directory, $input, $output);
499506
}
500507

508+
if ($input->getOption('boost')) {
509+
$this->installBoost($directory, $input, $output);
510+
}
511+
501512
if ($input->getOption('github') !== false) {
502513
$this->pushToGitHub($name, $directory, $input, $output);
503514
$output->writeln('');
@@ -527,6 +538,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
527538
$this->runCommands([$packageManager->installCommand(), $packageManager->buildCommand()], $input, $output, workingPath: $directory);
528539
}
529540

541+
if ($input->getOption('boost')) {
542+
$this->configureBoostComposerScript();
543+
$this->commitChanges('Configure Boost post-update script', $directory, $input, $output);
544+
}
545+
530546
$output->writeln(" <bg=blue;fg=white> INFO </> Application ready in <options=bold>[{$name}]</>. You can start your local development using:".PHP_EOL);
531547
$output->writeln('<fg=gray>➜</> <options=bold>cd '.$name.'</>');
532548

@@ -882,6 +898,31 @@ protected function installPest(string $directory, InputInterface $input, OutputI
882898
$this->commitChanges('Install Pest', $directory, $input, $output);
883899
}
884900

901+
/**
902+
* Install Laravel Boost into the application.
903+
*
904+
* @param string $directory
905+
* @param \Symfony\Component\Console\Input\InputInterface $input
906+
* @param \Symfony\Component\Console\Output\OutputInterface $output
907+
* @return void
908+
*/
909+
protected function installBoost(string $directory, InputInterface $input, OutputInterface $output): void
910+
{
911+
$composerBinary = $this->findComposer();
912+
913+
$commands = [
914+
$composerBinary.' require laravel/boost --dev',
915+
trim(sprintf(
916+
$this->phpBinary().' artisan boost:install %s',
917+
! $input->isInteractive() ? '--no-interaction' : '',
918+
)),
919+
];
920+
921+
$this->runCommands($commands, $input, $output, workingPath: $directory);
922+
923+
$this->commitChanges('Install Laravel Boost', $directory, $input, $output);
924+
}
925+
885926
/**
886927
* Create a Git repository and commit the base Laravel skeleton.
887928
*
@@ -987,6 +1028,20 @@ protected function configureComposerScripts(NodePackageManager $packageManager):
9871028
});
9881029
}
9891030

1031+
/**
1032+
* Add boost:update command to the post-update-cmd Composer script.
1033+
*
1034+
* @return void
1035+
*/
1036+
protected function configureBoostComposerScript(): void
1037+
{
1038+
$this->composer->modify(function (array $content) {
1039+
$content['scripts']['post-update-cmd'][] = '@php artisan boost:update --ansi';
1040+
1041+
return $content;
1042+
});
1043+
}
1044+
9901045
/**
9911046
* Verify that the application does not already exist.
9921047
*

0 commit comments

Comments
 (0)