diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index ceb7058b..3186e7ef 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -88,6 +88,7 @@ public function handle(): int $this->discoverEnvironment(); $this->collectInstallationPreferences(); $this->performInstallation(); + $this->displayGitignoreSuggestions(); $this->outro(); return self::SUCCESS; @@ -140,6 +141,18 @@ protected function performInstallation(): void $this->storeConfig(); } + protected function displayGitignoreSuggestions(): void + { + if (! $this->input->isInteractive()) { + return; + } + + $this->newLine(); + $this->info('Suggested .gitignore entry for Boost:'); + $this->line('# Laravel Boost'); + $this->line('boost.json'); + } + protected function outro(): void { $url = 'https://laravel.com/docs/boost'; diff --git a/tests/Feature/Console/InstallCommandGitignoreTest.php b/tests/Feature/Console/InstallCommandGitignoreTest.php new file mode 100644 index 00000000..28fbdbbe --- /dev/null +++ b/tests/Feature/Console/InstallCommandGitignoreTest.php @@ -0,0 +1,42 @@ +app->instance(InstallCommand::class, new class(app(AgentsDetector::class), app(Cloud::class), app(Config::class), app(Nightwatch::class), app(Sail::class), app(Terminal::class)) extends InstallCommand + { + protected function displayBoostHeader(string $featureName, string $projectName, ?Theme $theme = null): void {} + + protected function discoverEnvironment(): void {} + + protected function collectInstallationPreferences(): void {} + + protected function performInstallation(): void {} + + protected function outro(): void {} + }); +}); + +it('shows suggested gitignore entries in interactive installs', function (): void { + $this->artisan('boost:install') + ->expectsOutputToContain('Suggested .gitignore entry for Boost:') + ->expectsOutputToContain('# Laravel Boost') + ->expectsOutputToContain('boost.json') + ->assertSuccessful(); +}); + +it('does not show suggested gitignore entries in non-interactive installs', function (): void { + $this->artisan('boost:install', ['--no-interaction' => true]) + ->doesntExpectOutputToContain('Suggested .gitignore entry for Boost:') + ->doesntExpectOutputToContain('boost.json') + ->assertSuccessful(); +});