25 lines
1.2 KiB
PHP
25 lines
1.2 KiB
PHP
<?php
|
|
/** Server-side CLI. prepare only stages; publish/rollback are explicit mutations. */
|
|
declare(strict_types=1);
|
|
require dirname(__DIR__, 2).'/vendor/autoload.php';
|
|
$app = require dirname(__DIR__, 2).'/bootstrap/app.php';
|
|
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
use App\Services\Freenode\Pipeline;
|
|
try {
|
|
$action = $argv[1] ?? 'status';
|
|
$store = Pipeline::store();
|
|
$result = match ($action) {
|
|
'prepare' => Pipeline::prepare(),
|
|
'publish' => $store->publishPrepared(),
|
|
'rollback' => $store->activate($argv[2] ?? ($store->previous()['id'] ?? 'missing')),
|
|
'status' => ['engine' => config('freenode.engine'), 'current' => $store->current(), 'previous' => $store->previous()],
|
|
default => throw new RuntimeException('unknown_action'),
|
|
};
|
|
if (isset($result['files'])) $result['files'] = count($result['files']);
|
|
echo json_encode($result, JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR)."\n";
|
|
} catch (Throwable $e) {
|
|
// Do not print native-core output, node configurations or traces.
|
|
fwrite(STDERR, 'Freenode operation failed: '.get_class($e).' '.substr($e->getMessage(), 0, 160)."\n");
|
|
exit(1);
|
|
}
|