Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Console/Commands/InstallSsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 (
Expand All @@ -78,7 +78,7 @@ function () {
'Installing the spatie/fork package...'
);

$this->checkLine('Installed spatie/fork package');
$this->components->info('Installed spatie/fork package');
}
}
}
2 changes: 1 addition & 1 deletion src/Console/Commands/LicenseSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function handle()

LicenseSetEvent::dispatch();

$this->checkInfo('Statamic license key set successfully.');
$this->components->info('Statamic license key set successfully.');
}

/**
Expand Down
23 changes: 14 additions & 9 deletions src/Console/Commands/ProEnable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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.');
}

/**
Expand Down
14 changes: 5 additions & 9 deletions src/Console/Commands/StacheDoctor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("<fg=red>[✗]</> Unconfigured indexes in <comment>{$key}</comment>");
$this->output->listing($item->all());
$this->components->warn("Unconfigured indexes in [{$key}]:");
$this->components->bulletList($item->all());
});
}

Expand All @@ -73,15 +69,15 @@ protected function outputDuplicateIds()
$this->hasDuplicateIds = $duplicates->isNotEmpty();

if (! $this->hasDuplicateIds) {
$this->checkLine('No duplicate IDs detected.');
$this->components->success('No duplicate IDs detected.');

return;
}

$duplicates->flatMap(function ($duplicates) {
return $duplicates;
})->each(function ($paths, $id) {
$this->line("<fg=red>[✗]</> Duplicate ID <comment>$id</comment>");
$this->components->error("Duplicate ID [{$id}]:");

$this->output->listing(collect($paths)->map(function ($path) {
return Str::after($path, base_path().'/');
Expand Down
3 changes: 3 additions & 0 deletions src/Console/EnhancesCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("<info>[✓]</info> $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("<fg=red>[✗]</> $message");
Expand Down
24 changes: 12 additions & 12 deletions tests/Console/Commands/ProEnableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand Down
Loading