@@ -70,7 +70,7 @@ public function handle(CodeEnvironmentsDetector $codeEnvironmentsDetector, Herd
7070 $ this ->discoverEnvironment ();
7171 $ this ->collectInstallationPreferences ();
7272 $ this ->performInstallation ();
73- $ this ->outro ();
73+ $ this ->displayInstallationComplete ();
7474 }
7575
7676 private function bootstrap (CodeEnvironmentsDetector $ codeEnvironmentsDetector , Herd $ herd , Terminal $ terminal ): void
@@ -155,34 +155,11 @@ private function discoverTools(): array
155155 return $ tools ;
156156 }
157157
158- private function outro (): void
158+ private function displayInstallationComplete (): void
159159 {
160- $ label = 'https://boost.laravel.com/installed ' ;
161-
162- $ ideNames = $ this ->selectedTargetMcpClient ->map (fn (McpClient $ mcpClient ) => 'i: ' .$ mcpClient ->mcpClientName ())
163- ->toArray ();
164- $ agentNames = $ this ->selectedTargetAgents ->map (fn (Agent $ agent ) => 'a: ' .$ agent ->agentName ())->toArray ();
165- $ boostFeatures = $ this ->selectedBoostFeatures ->map (fn ($ feature ) => 'b: ' .$ feature )->toArray ();
166-
167- $ guidelines = [];
168- if ($ this ->shouldInstallAiGuidelines ()) {
169- $ guidelines [] = 'g:ai ' ;
170- }
171-
172- if ($ this ->shouldInstallStyleGuidelines ()) {
173- $ guidelines [] = 'g:style ' ;
174- }
175-
176- $ allData = array_merge ($ ideNames , $ agentNames , $ boostFeatures , $ guidelines );
177- $ installData = base64_encode (implode (', ' , $ allData ));
178-
179- $ link = $ this ->hyperlink ($ label , 'https://boost.laravel.com/installed/?d= ' .$ installData );
180-
181- $ text = 'Enjoy the boost 🚀 ' ;
182- $ paddingLength = (int ) (floor (($ this ->terminal ->cols () - mb_strlen ($ text .$ label )) / 2 )) - 2 ;
183-
184- echo "\033[42m \033[2K " .str_repeat (' ' , $ paddingLength ); // Make the entire line have a green background
185- echo $ this ->black ($ this ->bold ($ text .$ link )).$ this ->reset (PHP_EOL );
160+ $ link = $ this ->trackInstallation ();
161+ $ successMessage = 'Enjoy the boost 🚀 ' ;
162+ note ($ this ->bgGreen ($ this ->black ($ successMessage .' ' .$ this ->bold ($ link ))));
186163 }
187164
188165 private function hyperlink (string $ label , string $ url ): string
@@ -380,7 +357,6 @@ private function installGuidelines(): void
380357 $ guidelineConfig = new GuidelineConfig ;
381358 $ guidelineConfig ->enforceTests = $ this ->enforceTests ;
382359 $ guidelineConfig ->laravelStyle = $ this ->shouldInstallStyleGuidelines ();
383- $ guidelineConfig ->caresAboutLocalization = $ this ->detectLocalization ();
384360 $ guidelineConfig ->hasAnApi = false ;
385361
386362 $ composer = app (GuidelineComposer::class)->config ($ guidelineConfig );
@@ -453,91 +429,101 @@ private function installMcpServerConfig(): void
453429 }
454430
455431 if ($ this ->selectedTargetMcpClient ->isEmpty ()) {
456- $ this ->info ('No agents selected for guideline installation. ' );
457-
432+ $ this ->info ('No MCP clients selected for installation. ' );
458433 return ;
459434 }
435+
436+ // Define MCP server configurations
437+ $ mcpServers = collect ([
438+ 'boost ' => [
439+ 'enabled ' => $ this ->shouldInstallMcp (),
440+ 'key ' => 'laravel-boost ' ,
441+ 'command ' => 'php ' ,
442+ 'args ' => ['./artisan ' , 'boost:mcp ' ],
443+ 'env ' => [],
444+ 'label ' => 'Boost ' ,
445+ ],
446+ 'herd ' => [
447+ 'enabled ' => $ this ->shouldInstallHerdMcp (),
448+ 'key ' => 'herd ' ,
449+ 'command ' => 'php ' ,
450+ 'args ' => [$ this ->herd ->mcpPath ()],
451+ 'env ' => ['SITE_PATH ' => base_path ()],
452+ 'label ' => 'Herd ' ,
453+ ],
454+ ])->filter (fn ($ server ) => $ server ['enabled ' ]);
455+
460456 $ this ->newLine ();
461457 $ this ->info (' Installing MCP servers to your selected IDEs ' );
462458 $ this ->newLine ();
463-
464459 usleep (750000 );
465460
466- $ failed = [];
467- $ longestIdeName = max (
468- 1 ,
469- ...$ this ->selectedTargetMcpClient ->map (
470- fn (McpClient $ mcpClient ) => Str::length ($ mcpClient ->mcpClientName ())
471- )->toArray ()
472- );
461+ // Calculate display formatting
462+ $ longestIdeName = $ this ->selectedTargetMcpClient ->max (fn (McpClient $ client ) => Str::length ($ client ->mcpClientName ()));
463+ $ failed = collect ();
473464
465+ // Install MCP servers for each client
474466 foreach ($ this ->selectedTargetMcpClient as $ mcpClient ) {
475467 $ ideName = $ mcpClient ->mcpClientName ();
476468 $ ideDisplay = str_pad ($ ideName , $ longestIdeName );
477469 $ this ->output ->write (" {$ ideDisplay }... " );
478- $ results = [];
479-
480- if ($ this ->shouldInstallMcp ()) {
481- try {
482- $ result = $ mcpClient ->installMcp ('laravel-boost ' , 'php ' , ['./artisan ' , 'boost:mcp ' ]);
483-
484- if ($ result ) {
485- $ results [] = $ this ->greenTick .' Boost ' ;
486- } else {
487- $ results [] = $ this ->redCross .' Boost ' ;
488- $ failed [$ ideName ]['boost ' ] = 'Failed to write configuration ' ;
489- }
490- } catch (Exception $ e ) {
491- $ results [] = $ this ->redCross .' Boost ' ;
492- $ failed [$ ideName ]['boost ' ] = $ e ->getMessage ();
493- }
494- }
495470
496- // Install Herd MCP if enabled
497- if ($ this ->shouldInstallHerdMcp ()) {
471+ $ results = $ mcpServers ->map (function ($ serverConfig , $ serverKey ) use ($ mcpClient , $ ideName , &$ failed ) {
498472 try {
499473 $ result = $ mcpClient ->installMcp (
500- key: ' herd ' ,
501- command: ' php ' ,
502- args: [ $ this -> herd -> mcpPath () ],
503- env: [ ' SITE_PATH ' => base_path () ]
474+ key: $ serverConfig [ ' key ' ] ,
475+ command: $ serverConfig [ ' command ' ] ,
476+ args: $ serverConfig [ ' args ' ],
477+ env: $ serverConfig [ ' env ' ]
504478 );
505479
506480 if ($ result ) {
507- $ results [] = $ this ->greenTick .' Herd ' ;
481+ return $ this ->greenTick .' ' . $ serverConfig [ ' label ' ] ;
508482 } else {
509- $ results [] = $ this -> redCross . ' Herd ' ;
510- $ failed [ $ ideName ][ ' herd ' ] = ' Failed to write configuration ' ;
483+ $ failed -> push ([ ' ide ' => $ ideName , ' server ' => $ serverKey , ' error ' => ' Failed to write configuration ' ]) ;
484+ return $ this -> redCross . ' ' . $ serverConfig [ ' label ' ] ;
511485 }
512486 } catch (Exception $ e ) {
513- $ results [] = $ this -> redCross . ' Herd ' ;
514- $ failed [ $ ideName ][ ' herd ' ] = $ e -> getMessage () ;
487+ $ failed -> push ([ ' ide ' => $ ideName , ' server ' => $ serverKey , ' error ' => $ e -> getMessage ()]) ;
488+ return $ this -> redCross . ' ' . $ serverConfig [ ' label ' ] ;
515489 }
516- }
490+ });
517491
518- $ this ->line (implode (' ' , $ results ));
492+ $ this ->line ($ results -> implode (' ' ));
519493 }
520494
521495 $ this ->newLine ();
522496
523- if (count ($ failed ) > 0 ) {
497+ // Display any installation failures
498+ $ failed ->whenNotEmpty (function ($ failures ) {
524499 $ this ->error (sprintf ('%s Some MCP servers failed to install: ' , $ this ->redCross ));
525- foreach ($ failed as $ ideName => $ errors ) {
526- foreach ($ errors as $ server => $ error ) {
527- $ this ->line (" - {$ ideName } ( {$ server }): {$ error }" );
528- }
529- }
530- }
500+ $ failures ->each (function ($ failure ) {
501+ $ this ->line (" - {$ failure ['ide ' ]} ( {$ failure ['server ' ]}): {$ failure ['error ' ]}" );
502+ });
503+ });
531504 }
532505
533- /**
534- * Is the project actually using localization for their new features?
535- */
536- private function detectLocalization (): bool
506+
507+ public function trackInstallation (): string
537508 {
538- $ actuallyUsing = false ;
509+ $ baseUrl = 'https://boost.laravel.com/installed ' ;
510+
511+ $ ideNames = $ this ->selectedTargetMcpClient ->map (fn (McpClient $ mcpClient ) => 'i: ' .$ mcpClient ->mcpClientName ())->toArray ();
512+ $ agentNames = $ this ->selectedTargetAgents ->map (fn (Agent $ agent ) => 'a: ' .$ agent ->agentName ())->toArray ();
513+ $ boostFeatures = $ this ->selectedBoostFeatures ->map (fn ($ feature ) => 'b: ' .$ feature )->toArray ();
539514
540- /** @phpstan-ignore-next-line */
541- return $ actuallyUsing && is_dir (base_path ('lang ' ));
515+ $ guidelines = [];
516+ if ($ this ->shouldInstallAiGuidelines ()) {
517+ $ guidelines [] = 'g:ai ' ;
518+ }
519+
520+ if ($ this ->shouldInstallStyleGuidelines ()) {
521+ $ guidelines [] = 'g:style ' ;
522+ }
523+ $ installationData = array_merge ($ ideNames , $ agentNames , $ boostFeatures , $ guidelines );
524+ $ encodedData = base64_encode (implode (', ' , $ installationData ));
525+ $ trackingUrl = $ baseUrl .'/?d= ' .$ encodedData ;
526+ return $ this ->hyperlink ($ baseUrl , $ trackingUrl );
542527 }
528+
543529}
0 commit comments