import { buildExtension } from "../build/build.ts"; import { deliverGit, releasePlan, snapshot } from "./index.ts"; function usage(): never { console.error( "usage: release ... [--push]", ); process.exit(2); } const [command, ...args] = process.argv.slice(2); const push = args.includes("--push"); const names = args.filter((arg) => arg !== "--push"); if ( (command !== "plan" && command !== "snapshot" && command !== "publish") || !names.length || (push && command !== "publish") ) usage(); // Validate the whole selection before any snapshot builds or artifact writes. const plans = command === "publish" ? [] : names.map((name) => releasePlan(name)); if (command === "plan") { console.log(JSON.stringify(plans, null, "\t")); process.exit(0); } for (const name of names) { if (command === "publish") { console.log(`OK git ${deliverGit(name, { remote: push })}`); } else { await buildExtension(name, { release: true }); const receipt = snapshot(name); console.log(`OK snapshot ${name} ${receipt.digest}`); } }