diff --git a/src/Console/Commands/InstallSsg.php b/src/Console/Commands/InstallSsg.php index 1fc25ece01..a58677c290 100644 --- a/src/Console/Commands/InstallSsg.php +++ b/src/Console/Commands/InstallSsg.php @@ -49,7 +49,7 @@ public function handle() 'Installing the statamic/ssg package...' ); - $this->checkLine('Installed statamic/ssg package'); + $this->components->info('Installed statamic/ssg package'); if (confirm('Would you like to publish the config file?')) { spin( @@ -65,7 +65,7 @@ function () { message: 'Publishing the config file...' ); - $this->checkLine('Config file published. You can find it at config/statamic/ssg.php'); + $this->components->info('Config file published. You can find it at config/statamic/ssg.php'); } if ( @@ -78,7 +78,7 @@ function () { 'Installing the spatie/fork package...' ); - $this->checkLine('Installed spatie/fork package'); + $this->components->info('Installed spatie/fork package'); } } } diff --git a/src/Console/Commands/LicenseSet.php b/src/Console/Commands/LicenseSet.php index 6245ca3a61..a641ca4d3e 100644 --- a/src/Console/Commands/LicenseSet.php +++ b/src/Console/Commands/LicenseSet.php @@ -45,7 +45,7 @@ public function handle() LicenseSetEvent::dispatch(); - $this->checkInfo('Statamic license key set successfully.'); + $this->components->info('Statamic license key set successfully.'); } /** diff --git a/src/Console/Commands/ProEnable.php b/src/Console/Commands/ProEnable.php index ed111c006d..00337e0f3c 100644 --- a/src/Console/Commands/ProEnable.php +++ b/src/Console/Commands/ProEnable.php @@ -8,6 +8,8 @@ use Statamic\Console\RunsInPlease; use Statamic\Support\Str; +use function Laravel\Prompts\text; + class ProEnable extends Command { use ConfirmableTrait, EnhancesCommands, RunsInPlease; @@ -39,20 +41,20 @@ public function handle() return; } - $this->checkInfo('Statamic Pro successfully enabled in .env file!'); + $this->components->info('Statamic Pro successfully enabled in .env file!'); $this->promptToSetLicenseKey(); if ($this->option('update-config') && $this->updateConfig()) { - $this->checkInfo('Statamic editions config successfully updated to reference .env var!'); + $this->components->info('Statamic editions config successfully updated to reference .env var!'); } if ($this->option('update-config') && ! $this->isConfigReferencingEnv()) { - $this->crossLine('Could not reliably update editions config to reference .env var!'); - $this->comment(PHP_EOL.'For this setting to take effect, please modify your [config/statamic/editions.php] as follows:'); + $this->components->error('Could not reliably update editions config to reference .env var!'); + $this->line('For this setting to take effect, please modify your [config/statamic/editions.php] as follows:'); $this->line("'pro' => env('STATAMIC_PRO_ENABLED', false)"); } elseif (! $this->isConfigReferencingEnv()) { - $this->crossLine('Statamic editions config not currently referencing .env var!'); - $this->comment('Please re-run this command with the `--update-config` option.'); + $this->components->error('Statamic editions config not currently referencing .env var!'); + $this->line('Please re-run this command with the `--update-config` option.'); } else { config()->set('statamic.editions.pro', true); } @@ -127,10 +129,13 @@ protected function promptToSetLicenseKey() return; } - $licenseKey = trim((string) $this->ask('If you have a Statamic license key, paste it now (leave blank to add later)')); + $licenseKey = trim(text( + label: 'If you have a Statamic license key, paste it now', + hint: 'Leave blank to add later.', + )); if ($licenseKey === '') { - $this->comment('Add `STATAMIC_LICENSE_KEY=...` to your `.env` before or when your site goes live.'); + $this->components->warn('Add `STATAMIC_LICENSE_KEY=...` to your `.env` before or when your site goes live.'); return; } @@ -141,7 +146,7 @@ protected function promptToSetLicenseKey() $this->appendLicenseKeyToEnv($licenseKey); } - $this->checkInfo('Statamic license key saved in .env file.'); + $this->components->info('Statamic license key saved in .env file.'); } /** diff --git a/src/Console/Commands/StacheDoctor.php b/src/Console/Commands/StacheDoctor.php index 9d4bdd93c2..8638a44f82 100644 --- a/src/Console/Commands/StacheDoctor.php +++ b/src/Console/Commands/StacheDoctor.php @@ -37,20 +37,16 @@ protected function outputUnconfiguredIndexes() }); if ($missing->isEmpty()) { - $this->checkLine('No unconfigured indexes.'); + $this->components->info('No unconfigured indexes.'); $this->output->text('Indexes are created on demand through regular site usage.'); $this->output->text('You could consider trying again after browsing your site.'); return; } - if (! $this->hasDuplicateIds) { - $this->output->newLine(); - } - $missing->each(function ($item, $key) { - $this->line("[✗] Unconfigured indexes in {$key}"); - $this->output->listing($item->all()); + $this->components->warn("Unconfigured indexes in [{$key}]:"); + $this->components->bulletList($item->all()); }); } @@ -73,7 +69,7 @@ protected function outputDuplicateIds() $this->hasDuplicateIds = $duplicates->isNotEmpty(); if (! $this->hasDuplicateIds) { - $this->checkLine('No duplicate IDs detected.'); + $this->components->success('No duplicate IDs detected.'); return; } @@ -81,7 +77,7 @@ protected function outputDuplicateIds() $duplicates->flatMap(function ($duplicates) { return $duplicates; })->each(function ($paths, $id) { - $this->line("[✗] Duplicate ID $id"); + $this->components->error("Duplicate ID [{$id}]:"); $this->output->listing(collect($paths)->map(function ($path) { return Str::after($path, base_path().'/'); diff --git a/src/Console/EnhancesCommands.php b/src/Console/EnhancesCommands.php index 3eab6e4265..b58de558f4 100644 --- a/src/Console/EnhancesCommands.php +++ b/src/Console/EnhancesCommands.php @@ -15,16 +15,19 @@ public function run(InputInterface $input, OutputInterface $output): int return parent::run($input, $output); } + /** @deprecated Use $this->components->info() instead. */ public function checkLine($message) { $this->line("[✓] $message"); } + /** @deprecated Use $this->components->info() instead. */ public function checkInfo($message) { $this->info("[✓] $message"); } + /** @deprecated Use $this->components->error() instead. */ public function crossLine($message) { $this->line("[✗] $message"); diff --git a/tests/Console/Commands/ProEnableTest.php b/tests/Console/Commands/ProEnableTest.php index 1679acf921..6c7ebb042e 100644 --- a/tests/Console/Commands/ProEnableTest.php +++ b/tests/Console/Commands/ProEnableTest.php @@ -63,7 +63,7 @@ public function it_can_enable_pro_by_updating_existing_var_in_env() $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', ''); + ->expectsQuestion('If you have a Statamic license key, paste it now', ''); $this->assertTrue(Statamic::pro()); $this->assertEquals($this->defaultEditionsContents, $this->files->get($this->editionsPath)); @@ -87,7 +87,7 @@ public function it_can_enable_pro_by_appending_to_env() $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', ''); + ->expectsQuestion('If you have a Statamic license key, paste it now', ''); $this->assertTrue(Statamic::pro()); $this->assertEquals($this->defaultEditionsContents, $this->files->get($this->editionsPath)); @@ -109,7 +109,7 @@ public function it_replaces_commented_pro_enabled_var_in_env_instead_of_appendin $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', ''); + ->expectsQuestion('If you have a Statamic license key, paste it now', ''); $this->assertEquals(<<<'ENV' APP_NAME=Statamic @@ -140,7 +140,7 @@ public function if_config_is_not_referencing_env_var_it_should_prompt_user_to_ru $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', '') + ->expectsQuestion('If you have a Statamic license key, paste it now', '') ->expectsOutput('Please re-run this command with the `--update-config` option.'); // Though it should still update .env @@ -186,7 +186,7 @@ public function it_can_update_editions_config_to_reference_env_var($boolean) $this ->artisan('statamic:pro:enable', ['--update-config' => true]) - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', ''); + ->expectsQuestion('If you have a Statamic license key, paste it now', ''); $this->assertTrue(Statamic::pro()); $this->assertEquals($this->defaultEditionsContents, $this->files->get($this->editionsPath)); @@ -219,8 +219,8 @@ public function if_it_has_trouble_updating_editions_config_it_should_instruct_us $this ->artisan('statamic:pro:enable', ['--update-config' => true]) - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', '') - ->expectsOutput(PHP_EOL.'For this setting to take effect, please modify your [config/statamic/editions.php] as follows:') + ->expectsQuestion('If you have a Statamic license key, paste it now', '') + ->expectsOutput('For this setting to take effect, please modify your [config/statamic/editions.php] as follows:') ->expectsOutput("'pro' => env('STATAMIC_PRO_ENABLED', false)"); // Though it should still update .env @@ -239,7 +239,7 @@ public function it_can_set_license_key_while_enabling_pro() { $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', 'test-license-key'); + ->expectsQuestion('If you have a Statamic license key, paste it now', 'test-license-key'); $this->assertEquals(<<<'ENV' APP_NAME=Statamic @@ -259,7 +259,7 @@ public function it_replaces_commented_license_key_line_instead_of_appending() $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', 'test-license-key'); + ->expectsQuestion('If you have a Statamic license key, paste it now', 'test-license-key'); $this->assertEquals(<<<'ENV' APP_NAME=Statamic @@ -279,7 +279,7 @@ public function commented_non_empty_license_key_still_prompts_and_gets_replaced( $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', 'test-license-key'); + ->expectsQuestion('If you have a Statamic license key, paste it now', 'test-license-key'); $this->assertEquals(<<<'ENV' APP_NAME=Statamic @@ -293,8 +293,8 @@ public function it_mentions_setting_license_key_later_when_left_blank() { $this ->artisan('statamic:pro:enable') - ->expectsQuestion('If you have a Statamic license key, paste it now (leave blank to add later)', '') - ->expectsOutput('Add `STATAMIC_LICENSE_KEY=...` to your `.env` before or when your site goes live.'); + ->expectsQuestion('If you have a Statamic license key, paste it now', '') + ->expectsOutputToContain('Add `STATAMIC_LICENSE_KEY=...` to your `.env` before or when your site goes live.'); } #[Test]