Skip to content

Commit

Permalink
[5.x] Add install:ssg command (#9622)
Browse files Browse the repository at this point in the history
Co-authored-by: duncanmcclean <duncanmcclean@users.noreply.github.com>
Co-authored-by: Jason Varga <jason@pixelfear.com>
  • Loading branch information
3 people authored Mar 1, 2024
1 parent 36e9f80 commit b4b2905
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/Console/Commands/InstallSsg.php
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');
}
}
}
1 change: 1 addition & 0 deletions src/Providers/ConsoleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ConsoleServiceProvider extends ServiceProvider
Commands\AssetsMeta::class,
Commands\GlideClear::class,
Commands\Install::class,
Commands\InstallSsg::class,
Commands\FlatCamp::class,
Commands\LicenseSet::class,
Commands\MakeAction::class,
Expand Down

0 comments on commit b4b2905

Please sign in to comment.