mustRun(); $result = Release::install($argv[2], $argv[3], $argv[4]); $result['runtime_probe'] = json_decode($probe->getOutput(), true, 32, JSON_THROW_ON_ERROR); } elseif ($action === 'status' && count($argv) === 3) { $result = Release::current($argv[2]) ?? ['installed' => false]; } elseif ($action === 'rollback' && count($argv) === 3) { $result = Release::rollback($argv[2]); } elseif ($action === 'check' && count($argv) === 5) { $candidate = Release::inspect($argv[3], $argv[4])['manifest']; $current = Release::current($argv[2]); if ($current !== null && $current['version'] === $candidate['version'] && $current['manifest_sha256'] !== $argv[4]) { throw new RuntimeException('A mesma versão tem conteúdo diferente; reconcilie o canal antes de actualizar.'); } $result = ['installed_version' => $current['version'] ?? null, 'candidate_version' => $candidate['version'], 'available' => $current === null || version_compare($candidate['version'], $current['version'], '>'), 'same_source' => ($current['source_sha256'] ?? null) === $candidate['source_sha256'], 'database_changes' => false, 'permissions_changed' => false]; } else { throw new RuntimeException('Uso: publish ; inspect ; check ; install ; status .'); } echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR)."\n"; } catch (Throwable $error) { fwrite(STDERR, $error->getMessage()."\n"); exit(1); }