#!/usr/bin/env node import { runCommand } from '../release-gate/runner.mjs'; import { resolveReleaseCiStatus } from '../release-gate/ci-status.mjs'; const ROOT = new URL('..', import.meta.url).pathname; function parseArgs(argv) { const options = { commit: null }; for (let index = 2; index < argv.length; index += 1) { const arg = argv[index]; if (arg === '--commit') options.commit = argv[++index] ?? ''; else throw new Error(`Unknown argument: ${arg}`); } return options; } async function git(...args) { const result = await runCommand('git', args, { cwd: ROOT, timeoutMs: 30_000 }); if (result.code !== 0) throw new Error(`git ${args.join(' ')} failed`); return result.stdout.trim(); } try { const options = parseArgs(process.argv); const commitSha = options.commit ?? await git('rev-parse', 'HEAD'); const status = await resolveReleaseCiStatus(commitSha); process.stdout.write(`${status}\n`); process.exit(status === 'success' ? 0 : 1); } catch (error) { console.error(error.message); process.exit(1); }