Luigit
repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

scripts/release/cli.ts

Raw
import { buildExtension } from "../build/build.ts";
import { deliverGit, snapshot } from "./index.ts";

function usage(): never {
	console.error("usage: release <snapshot|publish> <extension>... [--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 !== "snapshot" && command !== "publish") ||
	!names.length ||
	(push && command !== "publish")
)
	usage();
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}`);
	}
}