44
55namespace Laravel \Boost \Console ;
66
7+ use Exception ;
78use Illuminate \Console \Command ;
89use Illuminate \Support \Arr ;
910use Illuminate \Support \Collection ;
10- use Illuminate \Support \Facades \Artisan ;
1111use Illuminate \Support \Str ;
1212use Laravel \Boost \Contracts \Agent ;
1313use Laravel \Boost \Contracts \Ide ;
1919use Laravel \Boost \Install \Herd ;
2020use Laravel \Prompts \Concerns \Colors ;
2121use Laravel \Prompts \Terminal ;
22+ use ReflectionClass ;
2223use Symfony \Component \Console \Attribute \AsCommand ;
2324use Symfony \Component \Finder \Finder ;
2425
@@ -162,9 +163,6 @@ private function outro(): void
162163 {
163164 $ label = 'https://boost.laravel.com/installed ' ;
164165
165- // Build install data - CSV format with type prefixes
166- $ data = [];
167-
168166 $ ideNames = $ this ->selectedTargetIdes ->map (fn ($ ide ) => 'i: ' .class_basename ($ ide ))->toArray ();
169167 $ agentNames = $ this ->selectedTargetAgents ->map (fn ($ agent ) => 'a: ' .class_basename ($ agent ))->toArray ();
170168 $ boostFeatures = $ this ->selectedBoostFeatures ->map (fn ($ feature ) => 'b: ' .$ feature )->toArray ();
@@ -182,7 +180,7 @@ private function outro(): void
182180 // Combine all data
183181 $ allData = array_merge ($ ideNames , $ agentNames , $ boostFeatures , $ guidelines );
184182
185- // Create compact CSV string and base64 encode
183+ // Create a compact CSV string and base64 encode
186184 $ installData = base64_encode (implode (', ' , $ allData ));
187185
188186 $ link = $ this ->hyperlink ($ label , 'https://boost.laravel.com/installed/?d= ' .$ installData );
@@ -191,12 +189,12 @@ private function outro(): void
191189 $ paddingLength = (int ) (floor (($ this ->terminal ->cols () - mb_strlen ($ text .$ label )) / 2 )) - 2 ;
192190
193191 echo "\033[42m \033[2K " .str_repeat (' ' , $ paddingLength ); // Make the entire line have a green background
194- echo $ this ->black ($ this ->bold ($ text .$ link )).$ this ->reset (). PHP_EOL ;
192+ echo $ this ->black ($ this ->bold ($ text .$ link )).$ this ->reset (PHP_EOL ) ;
195193 }
196194
197195 private function hyperlink (string $ label , string $ url ): string
198196 {
199- return "\033]8;; { $ url} \007{ $ label} \033]8;; \033\\" ;
197+ return "\033]8;; $ url \007$ label \033]8;; \033\\" ;
200198 }
201199
202200 /**
@@ -282,7 +280,6 @@ private function discoverProjectAgents(): array
282280 }
283281 }
284282
285- // Also check installed IDEs that might not have project files yet
286283 foreach ($ this ->systemInstalledCodeEnvironments as $ ide ) {
287284 if (isset ($ ideToAgentMap [$ ide ]) && ! in_array ($ ideToAgentMap [$ ide ], $ agents )) {
288285 $ agents [] = $ ideToAgentMap [$ ide ];
@@ -298,7 +295,7 @@ private function discoverProjectAgents(): array
298295 private function selectTargetIdes (): Collection
299296 {
300297 $ ides = [];
301- if (! $ this ->installingMcp () && ! $ this ->installingHerdMcp ()) {
298+ if (! $ this ->shouldInstallMcp () && ! $ this ->shouldInstallHerdMcp ()) {
302299 return collect ();
303300 }
304301
@@ -313,7 +310,7 @@ private function selectTargetIdes(): Collection
313310 $ className = 'Laravel \\Boost \\Install \\Agents \\' .$ ideFile ->getBasename ('.php ' );
314311
315312 if (class_exists ($ className )) {
316- $ reflection = new \ ReflectionClass ($ className );
313+ $ reflection = new ReflectionClass ($ className );
317314
318315 if ($ reflection ->implementsInterface (Ide::class) && ! $ reflection ->isAbstract ()) {
319316 $ ides [$ className ] = Str::headline ($ ideFile ->getBasename ('.php ' ));
@@ -323,7 +320,6 @@ private function selectTargetIdes(): Collection
323320
324321 ksort ($ ides );
325322
326- // Map detected IDE keys to class names
327323 $ detectedClasses = [];
328324 foreach ($ this ->projectInstalledCodeEnvironments as $ ideKey ) {
329325 foreach ($ ides as $ className => $ displayName ) {
@@ -352,7 +348,7 @@ private function selectTargetIdes(): Collection
352348 private function selectTargetAgents (): Collection
353349 {
354350 $ agents = [];
355- if (! $ this ->installingGuidelines ()) {
351+ if (! $ this ->shouldInstallAiGuidelines ()) {
356352 return collect ();
357353 }
358354
@@ -367,7 +363,7 @@ private function selectTargetAgents(): Collection
367363 $ className = 'Laravel \\Boost \\Install \\Agents \\' .$ agentFile ->getBasename ('.php ' );
368364
369365 if (class_exists ($ className )) {
370- $ reflection = new \ ReflectionClass ($ className );
366+ $ reflection = new ReflectionClass ($ className );
371367
372368 if ($ reflection ->implementsInterface (Agent::class)) {
373369 $ agents [$ className ] = Str::headline ($ agentFile ->getBasename ('.php ' ));
@@ -412,7 +408,7 @@ protected function enactGuidelines(): void
412408
413409 $ guidelineConfig = new GuidelineConfig ;
414410 $ guidelineConfig ->enforceTests = $ this ->enforceTests ;
415- $ guidelineConfig ->laravelStyle = $ this ->installingStyleGuidelines ();
411+ $ guidelineConfig ->laravelStyle = $ this ->shouldInstallStyleGuidelines ();
416412 $ guidelineConfig ->caresAboutLocalization = $ this ->detectLocalization ();
417413 $ guidelineConfig ->hasAnApi = false ;
418414
@@ -431,15 +427,15 @@ protected function enactGuidelines(): void
431427 $ longestAgentName = max (1 , ...$ this ->selectedTargetAgents ->map (fn ($ agent ) => Str::length (class_basename ($ agent )))->toArray ());
432428 foreach ($ this ->selectedTargetAgents as $ agent ) {
433429 $ agentName = class_basename ($ agent );
434- $ displayAgentName = str_pad ($ agentName , $ longestAgentName, ' ' , STR_PAD_RIGHT );
435- $ this ->output ->write (" { $ displayAgentName} ... " );
430+ $ displayAgentName = str_pad ($ agentName , $ longestAgentName );
431+ $ this ->output ->write (" $ displayAgentName... " );
436432
437433 try {
438434 (new GuidelineWriter ($ agent ))
439435 ->write ($ composedAiGuidelines );
440436
441437 $ this ->line ($ this ->greenTick );
442- } catch (\ Exception $ e ) {
438+ } catch (Exception $ e ) {
443439 $ failed [$ agentName ] = $ e ->getMessage ();
444440 $ this ->line ($ this ->redCross );
445441 }
@@ -453,7 +449,7 @@ protected function enactGuidelines(): void
453449 count ($ failed ) === 1 ? '' : 's '
454450 ));
455451 foreach ($ failed as $ agentName => $ error ) {
456- $ this ->line (" - { $ agentName} : { $ error} " );
452+ $ this ->line (" - $ agentName: $ error " );
457453 }
458454 }
459455 }
@@ -478,53 +474,7 @@ private function shouldInstallHerdMcp(): bool
478474 return $ this ->selectedBoostFeatures ->contains ('herd_mcp ' );
479475 }
480476
481- protected function publishAndUpdateConfig (): void
482- {
483- $ configPath = config_path ('boost.php ' );
484-
485- // Publish config if it doesn't exist
486- if (! file_exists ($ configPath )) {
487- $ this ->newLine ();
488- $ this ->info (' Publishing Boost configuration file... ' );
489-
490- Artisan::call ('vendor:publish ' , [
491- '--provider ' => 'Laravel \\Boost \\BoostServiceProvider ' ,
492- '--tag ' => 'boost-config ' ,
493- '--force ' => false ,
494- ]);
495-
496- $ this ->line (' Configuration published ' .$ this ->greenTick );
497- $ this ->newLine ();
498- }
499-
500- // $updated = $this->updateProjectPurposeInConfig($configPath, $this->projectPurpose);
501- }
502-
503- protected function updateProjectPurposeInConfig (string $ configPath , ?string $ purpose ): bool
504- {
505- if (empty ($ purpose ) || $ purpose === config ('boost.project_purpose ' , '' )) {
506- return false ;
507- }
508-
509- $ content = file_get_contents ($ configPath );
510- if ($ content === false ) {
511- return false ;
512- }
513-
514- $ purposeExists = preg_match ('/ \'project_purpose \'\s+\=\>\s+(.+),/ ' , $ content , $ matches );
515-
516- if (! $ purposeExists ) { // This shouldn't be possible
517- return false ;
518- }
519-
520- $ newPurpose = addcslashes ($ purpose , "' " );
521- $ newPurposeLine = "'project_purpose' => ' {$ newPurpose }', " ;
522- $ content = str_replace ($ matches [0 ], $ newPurposeLine , $ content );
523-
524- return file_put_contents ($ configPath , $ content ) !== false ;
525- }
526-
527- protected function enactMcpServers (): void
477+ private function enactMcpServers (): void
528478 {
529479 $ this ->newLine ();
530480 $ this ->info (' Installing MCP servers to your selected IDEs ' );
@@ -537,8 +487,8 @@ protected function enactMcpServers(): void
537487
538488 foreach ($ this ->selectedTargetIdes as $ ide ) {
539489 $ ideName = class_basename ($ ide );
540- $ ideDisplay = str_pad ($ ideName , $ longestIdeName, ' ' , STR_PAD_RIGHT );
541- $ this ->output ->write (" { $ ideDisplay} ... " );
490+ $ ideDisplay = str_pad ($ ideName , $ longestIdeName );
491+ $ this ->output ->write (" $ ideDisplay... " );
542492 $ results = [];
543493
544494 // Install Laravel Boost MCP if enabled
@@ -552,7 +502,7 @@ protected function enactMcpServers(): void
552502 $ results [] = $ this ->redCross .' Boost ' ;
553503 $ failed [$ ideName ]['boost ' ] = 'Failed to write configuration ' ;
554504 }
555- } catch (\ Exception $ e ) {
505+ } catch (Exception $ e ) {
556506 $ results [] = $ this ->redCross .' Boost ' ;
557507 $ failed [$ ideName ]['boost ' ] = $ e ->getMessage ();
558508 }
@@ -574,7 +524,7 @@ protected function enactMcpServers(): void
574524 $ results [] = $ this ->redCross .' Herd ' ;
575525 $ failed [$ ideName ]['herd ' ] = 'Failed to write configuration ' ;
576526 }
577- } catch (\ Exception $ e ) {
527+ } catch (Exception $ e ) {
578528 $ results [] = $ this ->redCross .' Herd ' ;
579529 $ failed [$ ideName ]['herd ' ] = $ e ->getMessage ();
580530 }
@@ -589,7 +539,7 @@ protected function enactMcpServers(): void
589539 $ this ->error (sprintf ('%s Some MCP servers failed to install: ' , $ this ->redCross ));
590540 foreach ($ failed as $ ideName => $ errors ) {
591541 foreach ($ errors as $ server => $ error ) {
592- $ this ->line (" - { $ ideName} ( { $ server} ): { $ error} " );
542+ $ this ->line (" - $ ideName ( $ server): $ error " );
593543 }
594544 }
595545 }
@@ -598,7 +548,7 @@ protected function enactMcpServers(): void
598548 /**
599549 * Is the project actually using localization for their new features?
600550 */
601- protected function detectLocalization (): bool
551+ private function detectLocalization (): bool
602552 {
603553 $ actuallyUsing = false ;
604554
0 commit comments