Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Add install:ssg command #9622

Merged
merged 6 commits into from
Mar 1, 2024
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
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
Loading