From 23543aaf5b2b9b4f1c0d4b0d83bae2acb113773a Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Fri, 11 Aug 2023 18:09:35 +0200 Subject: [PATCH] Add simple license check (#143) Co-authored-by: Jason Varga Co-authored-by: Jack McDade --- src/Commands/StaticSiteGenerate.php | 12 ++++++++++++ tests/Concerns/RunsGeneratorCommand.php | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/Commands/StaticSiteGenerate.php b/src/Commands/StaticSiteGenerate.php index 054be48..0660f00 100644 --- a/src/Commands/StaticSiteGenerate.php +++ b/src/Commands/StaticSiteGenerate.php @@ -55,6 +55,18 @@ public function handle() { Partyline::bind($this); + if (config('statamic.editions.pro') && ! config('statamic.system.license_key')) { + $this->error('Statamic Pro is enabled but no site license was found.'); + $this->warn('Please set a valid Statamic License Key in your .env file.'); + $confirmationText = 'By continuing you agree that this build is for testing purposes only. Do you wish to continue?'; + + if (! $this->option('no-interaction') && ! $this->confirm($confirmationText)) { + $this->line('Static site generation canceled.'); + + return 0; + } + } + if (! $workers = $this->option('workers')) { $this->comment('You may be able to speed up site generation significantly by installing spatie/fork and using multiple workers (requires PHP 8+).'); } diff --git a/tests/Concerns/RunsGeneratorCommand.php b/tests/Concerns/RunsGeneratorCommand.php index eb7da72..1b12e7c 100644 --- a/tests/Concerns/RunsGeneratorCommand.php +++ b/tests/Concerns/RunsGeneratorCommand.php @@ -26,6 +26,8 @@ protected function generate($options = []) { $this->assertFalse($this->files->exists($this->destination)); + $options['--no-interaction'] ??= true; + $this ->artisan('statamic:ssg:generate', $options) ->doesntExpectOutputToContain('pages not generated');