feat(release): add reversible production cutover gates

This commit is contained in:
chick
2026-07-18 17:24:51 +08:00
parent 3718c91706
commit 4a7e29cf06
18 changed files with 1468 additions and 8 deletions
+23
View File
@@ -0,0 +1,23 @@
import { readFile, stat } from 'node:fs/promises';
import {
cutover,
nodeCutoverSystem,
parseCutoverPlan,
preflight,
rollback,
} from './cutover-orchestrator.js';
const [action, planPath] = process.argv.slice(2);
if (!['preflight', 'cutover', 'rollback'].includes(action ?? '') || !planPath) {
throw new Error('Usage: pnpm cutover <preflight|cutover|rollback> <plan.json>');
}
const planInfo = await stat(planPath);
if (!planInfo.isFile() || (planInfo.mode & 0o077) !== 0) {
throw new Error('Cutover plan must be a regular file inaccessible to group and other users');
}
const plan = parseCutoverPlan(JSON.parse(await readFile(planPath, 'utf8')) as unknown);
const gatewayToken = process.env.MULTI_SIMADMIN_GATEWAY_TOKEN ?? '';
if (action === 'preflight') await preflight(plan, nodeCutoverSystem, gatewayToken);
else if (action === 'cutover') await cutover(plan, nodeCutoverSystem, gatewayToken);
else await rollback(plan, nodeCutoverSystem);
process.stdout.write(`${action} completed\n`);