diff --git a/packages/cli/scripts/release.mjs b/packages/cli/scripts/release.mjs index 183232e..f50716e 100644 --- a/packages/cli/scripts/release.mjs +++ b/packages/cli/scripts/release.mjs @@ -230,6 +230,16 @@ export function compareVersions(a, b) { return 0; } +export const PACKED_SMOKE_COMMANDS = [ + "deploy track", + "deploy id", + "doctor track", + "doctor id", + "update track", + "update id", + "connect id track", +]; + /** Why a release stopped, said to whoever ran it without a stack. */ class Stop extends Error {} @@ -388,7 +398,7 @@ async function main() { env, }); if (said !== version) stop(`The packed command says it is ${said}, not ${version}.`); - for (const command of ["deploy track", "deploy id", "update track", "connect id track"]) { + for (const command of PACKED_SMOKE_COMMANDS) { const help = spawnSync( process.execPath, [npx, "--yes", spec, ...command.split(" "), "--help"], @@ -398,7 +408,12 @@ async function main() { encoding: "utf8", }, ); - if (help.status !== 0 || !help.stderr?.startsWith(`Usage: gateweave ${command} [options]`)) { + const first = help.stderr?.split(/\r?\n/, 1)[0]; + if ( + help.status !== 0 || + help.stdout !== "" || + first !== `Usage: gateweave ${command} [options]` + ) { stop(`The packed command did not show help for ${command}.`); } } @@ -413,7 +428,13 @@ async function main() { } catch { stop("The packed command did not return JSON for an invalid option."); } - if (invalid.status !== 2 || failure?.ok !== false || failure.code !== "usage") { + if ( + invalid.status !== 2 || + invalid.stderr !== "" || + failure?.ok !== false || + failure.code !== "usage" || + typeof failure.reason !== "string" + ) { stop("The packed command did not report an invalid option as a usage error."); } console.log( diff --git a/packages/cli/test/release.test.ts b/packages/cli/test/release.test.ts index 0953e1b..50fa4a4 100644 --- a/packages/cli/test/release.test.ts +++ b/packages/cli/test/release.test.ts @@ -4,6 +4,7 @@ import { checkPackage, compareNpmRelease, compareVersions, + PACKED_SMOKE_COMMANDS, readTar, releaseKeys, sha256sums, @@ -139,6 +140,18 @@ test("compareVersions orders versions as semver does", () => { assert.equal(compareVersions("1.2.3", "1.2.3"), 0); }); +test("the packed smoke covers every shipped command's help", () => { + assert.deepEqual(PACKED_SMOKE_COMMANDS, [ + "deploy track", + "deploy id", + "doctor track", + "doctor id", + "update track", + "update id", + "connect id track", + ]); +}); + test("a release lives under its version, with sums sha256sum checks", () => { assert.equal(tarballName("0.1.0"), "gateweave-0.1.0.tgz"); assert.deepEqual(releaseKeys("0.1.0"), {