import { spawnSync } from "node:child_process"; import { join } from "node:path"; import { describe, expect, it } from "vitest"; import { ROOT } from "../build/build.ts"; function release(...args: string[]) { return spawnSync( process.execPath, ["--no-warnings", join(ROOT, "scripts/release/cli.ts"), ...args], { cwd: ROOT, encoding: "utf8", }, ); } describe("release CLI gates", () => { it("rejects invalid commands before attempting a build", () => { const result = release("invalid", "__missing_release_cli_fixture__"); expect(result.status).toBe(2); expect(result.stderr).toContain("usage: release"); }); it("rejects pushing snapshots before attempting a build", () => { const result = release( "snapshot", "__missing_release_cli_fixture__", "--push", ); expect(result.status).toBe(2); expect(result.stderr).toContain("usage: release"); }); it("requires an existing receipt instead of rebuilding during publication", () => { const result = release("publish", "__missing_release_cli_fixture__"); expect(result.status).not.toBe(0); expect(result.stderr).toContain("has no verified snapshot receipt"); expect(result.stdout).not.toContain("OK snapshot"); }); });