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
55 changes: 55 additions & 0 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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?',
));
}
}

/**
Expand Down Expand Up @@ -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('');
Expand Down Expand Up @@ -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(" <bg=blue;fg=white> INFO </> Application ready in <options=bold>[{$name}]</>. You can start your local development using:".PHP_EOL);
$output->writeln('<fg=gray>➜</> <options=bold>cd '.$name.'</>');

Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down