From c4f5b82ba8ad5794f1f612df80f9847cd017fbde Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 30 Jul 2026 21:34:56 -0400 Subject: [PATCH 1/4] use standard console output helpers in pro/license commands replaces the custom checkInfo/crossLine helpers with $this->components->info()/error()/warn(), matching the style already used elsewhere. also switches the license key prompt in `ProEnable` to Laravel Prompts' `text()`. --- src/Console/Commands/InstallSsg.php | 6 +++--- src/Console/Commands/LicenseSet.php | 2 +- src/Console/Commands/ProEnable.php | 23 ++++++++++++++--------- src/Console/Commands/StacheDoctor.php | 4 ++-- tests/Console/Commands/ProEnableTest.php | 24 ++++++++++++------------ 5 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/Console/Commands/InstallSsg.php b/src/Console/Commands/InstallSsg.php index 1fc25ece015..a58677c2907 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 6245ca3a618..a641ca4d3ec 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 ed111c006d6..00337e0f3c0 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 9d4bdd93c22..23fb858572a 100644 --- a/src/Console/Commands/StacheDoctor.php +++ b/src/Console/Commands/StacheDoctor.php @@ -37,7 +37,7 @@ 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.'); @@ -73,7 +73,7 @@ protected function outputDuplicateIds() $this->hasDuplicateIds = $duplicates->isNotEmpty(); if (! $this->hasDuplicateIds) { - $this->checkLine('No duplicate IDs detected.'); + $this->components->info('No duplicate IDs detected.'); return; } diff --git a/tests/Console/Commands/ProEnableTest.php b/tests/Console/Commands/ProEnableTest.php index 1679acf9216..6c7ebb042ed 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] From 669df9a748e857e81124b2ad98335bd47e70a2d9 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 30 Jul 2026 21:35:04 -0400 Subject: [PATCH 2/4] remove unused checkInfo/crossLine/checkLine helpers from EnhancesCommands no longer used now that commands use \$this->components for output. --- src/Console/EnhancesCommands.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/Console/EnhancesCommands.php b/src/Console/EnhancesCommands.php index 3eab6e4265c..1c8ead5358b 100644 --- a/src/Console/EnhancesCommands.php +++ b/src/Console/EnhancesCommands.php @@ -14,19 +14,4 @@ public function run(InputInterface $input, OutputInterface $output): int return parent::run($input, $output); } - - public function checkLine($message) - { - $this->line("[✓] $message"); - } - - public function checkInfo($message) - { - $this->info("[✓] $message"); - } - - public function crossLine($message) - { - $this->line("[✗] $message"); - } } From e541d60fe3027c245f66ca247e9be7e54b844d92 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Wed, 5 Aug 2026 11:55:41 -0400 Subject: [PATCH 3/4] Keep checkLine, checkInfo and crossLine on EnhancesCommands The call sites have moved to the standard console output components, but these are public methods on a public trait that addons may use for their own commands, so removing them in a minor would break them. Deprecated instead, for removal in the next major. Co-Authored-By: Claude Opus 5 (1M context) --- src/Console/EnhancesCommands.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Console/EnhancesCommands.php b/src/Console/EnhancesCommands.php index 1c8ead5358b..b58de558f42 100644 --- a/src/Console/EnhancesCommands.php +++ b/src/Console/EnhancesCommands.php @@ -14,4 +14,22 @@ 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"); + } } From d85d0040611192b8c1d04c493d2a0d64b6ea602b Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Wed, 5 Aug 2026 12:14:26 -0400 Subject: [PATCH 4/4] update stache doctor --- src/Console/Commands/StacheDoctor.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Console/Commands/StacheDoctor.php b/src/Console/Commands/StacheDoctor.php index 23fb858572a..8638a44f825 100644 --- a/src/Console/Commands/StacheDoctor.php +++ b/src/Console/Commands/StacheDoctor.php @@ -44,13 +44,9 @@ protected function outputUnconfiguredIndexes() 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->components->info('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().'/');