Skip to content
Merged
Show file tree
Hide file tree
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
74 changes: 57 additions & 17 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Laravel\Boost\Support\Config;
use Laravel\Prompts\Concerns\Colors;
use Laravel\Prompts\Terminal;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;

Expand All @@ -31,11 +30,12 @@
use function Laravel\Prompts\multiselect;
use function Laravel\Prompts\note;

#[AsCommand('boost:install', 'Install Laravel Boost')]
class InstallCommand extends Command
{
use Colors;

protected $signature = 'boost:install {--ignore-guidelines : Skip installing AI guidelines} {--ignore-mcp : Skip installing MCP server configuration}';

private CodeEnvironmentsDetector $codeEnvironmentsDetector;

private Herd $herd;
Expand Down Expand Up @@ -69,20 +69,37 @@ class InstallCommand extends Command

private string $redCross;

private bool $installGuidelines;

private bool $installMcpConfig;

public function __construct(protected Config $config)
{
parent::__construct();
}

public function handle(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
{
$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
public function handle(
CodeEnvironmentsDetector $codeEnvironmentsDetector,
Herd $herd,
Terminal $terminal,
): int {
$this->installGuidelines = ! $this->option('ignore-guidelines');
$this->installMcpConfig = ! $this->option('ignore-mcp');

if (! $this->installGuidelines && ! $this->installMcpConfig) {
$this->error('You cannot ignore both guidelines and MCP config. Please select at least one option to proceed.');

return self::FAILURE;
}

$this->bootstrap($codeEnvironmentsDetector, $herd, $terminal);
$this->displayBoostHeader();
$this->discoverEnvironment();
$this->collectInstallationPreferences();
$this->performInstallation();
$this->outro();

return self::SUCCESS;
}

protected function bootstrap(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd $herd, Terminal $terminal): void
Expand Down Expand Up @@ -139,11 +156,13 @@ protected function collectInstallationPreferences(): void

protected function performInstallation(): void
{
$this->installGuidelines();
if ($this->installGuidelines) {
$this->installGuidelines();
}

usleep(750000);

if ($this->selectedTargetMcpClient->isNotEmpty()) {
if ($this->installMcpConfig && $this->selectedTargetMcpClient->isNotEmpty()) {
$this->installMcpServerConfig();
}
}
Expand Down Expand Up @@ -213,6 +232,10 @@ protected function hyperlink(string $label, string $url): string
*/
protected function determineTestEnforcement(): bool
{
if (! $this->installGuidelines) {
return false;
}

$hasMinimumTests = false;

if (file_exists(base_path('vendor/bin/phpunit'))) {
Expand All @@ -235,6 +258,10 @@ protected function determineTestEnforcement(): bool
*/
protected function selectBoostFeatures(): Collection
{
if (! $this->installMcpConfig) {
return collect();
}

$features = collect(['mcp_server', 'ai_guidelines']);

if ($this->herd->isMcpAvailable() && $this->shouldConfigureHerdMcp()) {
Expand Down Expand Up @@ -271,6 +298,10 @@ protected function shouldConfigureHerdMcp(): bool
*/
protected function selectAiGuidelines(): Collection
{
if (! $this->installGuidelines) {
return collect();
}

$options = app(GuidelineComposer::class)->guidelines()
->reject(fn (array $guideline): bool => $guideline['third_party'] === false);

Expand All @@ -297,6 +328,10 @@ protected function selectAiGuidelines(): Collection
*/
protected function selectTargetMcpClients(): Collection
{
if (! $this->installMcpConfig) {
return collect();
}

return $this->selectCodeEnvironments(
McpClient::class,
sprintf('Which code editors do you use to work on %s?', $this->projectName),
Expand All @@ -309,6 +344,10 @@ protected function selectTargetMcpClients(): Collection
*/
protected function selectTargetAgents(): Collection
{
if (! $this->installGuidelines) {
return collect();
}

return $this->selectCodeEnvironments(
Agent::class,
sprintf('Which agents need AI guidelines for %s?', $this->projectName),
Expand Down Expand Up @@ -453,17 +492,19 @@ protected function installGuidelines(): void
}
}

$this->config->setSail(
$this->shouldUseSail()
);
if ($this->installMcpConfig) {
$this->config->setSail(
$this->shouldUseSail()
);

$this->config->setHerdMcp(
$this->shouldInstallHerdMcp()
);
$this->config->setHerdMcp(
$this->shouldInstallHerdMcp()
);

$this->config->setEditors(
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient): string => $mcpClient->name())->values()->toArray()
);
$this->config->setEditors(
$this->selectedTargetMcpClient->map(fn (McpClient $mcpClient): string => $mcpClient->name())->values()->toArray()
);
}

$this->config->setAgents(
$this->selectedTargetAgents->map(fn (Agent $agent): string => $agent->name())->values()->toArray()
Expand Down Expand Up @@ -539,7 +580,6 @@ protected function installMcpServerConfig(): void
)->toArray()
);

/** @var McpClient $mcpClient */
foreach ($this->selectedTargetMcpClient as $mcpClient) {
$ideName = $mcpClient->mcpClientName();
$ideDisplay = str_pad((string) $ideName, $longestIdeName);
Expand Down
1 change: 1 addition & 0 deletions src/Console/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function handle(): void
{
$this->callSilently(InstallCommand::class, [
'--no-interaction' => true,
'--ignore-mcp' => true,
]);

$this->components->info('Boost guidelines updated successfully.');
Expand Down