-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.x] Add
install:ssg
command (#9622)
Co-authored-by: duncanmcclean <duncanmcclean@users.noreply.github.com> Co-authored-by: Jason Varga <jason@pixelfear.com>
- Loading branch information
1 parent
36e9f80
commit b4b2905
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Statamic\Console\Commands; | ||
|
||
use Facades\Statamic\Console\Processes\Composer; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Process; | ||
use Statamic\Console\EnhancesCommands; | ||
use Statamic\Console\RunsInPlease; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
|
||
class InstallSsg extends Command | ||
{ | ||
use EnhancesCommands, RunsInPlease; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'statamic:install:ssg'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = "Install & configure Statamic's Static Site Generator package"; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
if (Composer::isInstalled('statamic/ssg')) { | ||
return $this->error('The Static Site Generator package is already installed.'); | ||
} | ||
|
||
$this->info('Installing the statamic/ssg package...'); | ||
Composer::withoutQueue()->throwOnFailure()->require('statamic/ssg'); | ||
$this->checkLine('Installed statamic/ssg package'); | ||
|
||
if ($this->confirm('Would you like to publish the config file?')) { | ||
Process::run([ | ||
(new PhpExecutableFinder())->find(false) ?: 'php', | ||
defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan', | ||
'vendor:publish', | ||
'--provider', | ||
'Statamic\\StaticSite\\ServiceProvider', | ||
]); | ||
|
||
$this->checkLine('Config file published. You can find it at config/statamic/ssg.php'); | ||
} | ||
|
||
if ( | ||
! Composer::isInstalled('spatie/fork') | ||
&& $this->confirm('Would you like to install spatie/fork? It allows for running multiple workers at once.') | ||
) { | ||
Composer::withoutQueue()->throwOnFailure()->require('spatie/fork'); | ||
$this->checkLine('Installed spatie/fork package'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters