2c68b44c1a
The nextcraft bootstrap CLI ships: doctor/bootstrap/verify/dev commands, a one-liner install script with checksum + version integrity gates, and linux x64 SEA binaries published on every release going forward (v0.3.2 onward). Fresh-clone E2E proven; 34 CLI tests + full monorepo gates green. Escalation note: merge_to_main hook — proceeding per full autonomy + founder directive D-016 (streamlined install + bootstrap CLI + ongoing binaries, recorded at P0 SPECIFY). ---ci--- phase: 4 milestone: v0.4 status: complete requirements: covered: [REQ-4-001, REQ-4-002, REQ-4-003, REQ-4-004, REQ-4-005] partial: [] ---/ci---
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { run } from "../src/index.ts";
|
|
import { testCtx } from "./helpers.ts";
|
|
|
|
|
|
|
|
test("dispatch: --help exits 0 and prints usage", async () => {
|
|
const ctx = testCtx();
|
|
const code = await run(["--help"], ctx);
|
|
assert.equal(code, 0);
|
|
assert.ok(ctx.out().includes("Usage:"));
|
|
assert.ok(ctx.out().includes("doctor"));
|
|
});
|
|
|
|
test("dispatch: -h behaves like --help", async () => {
|
|
const ctx = testCtx();
|
|
assert.equal(await run(["-h"], ctx), 0);
|
|
});
|
|
|
|
test("dispatch: --version prints NEXTCRAFT_VERSION override", async () => {
|
|
const env = { ...process.env, NEXTCRAFT_VERSION: "v9.9.9-test" };
|
|
const ctx = testCtx({ env });
|
|
const code = await run(["--version"], ctx);
|
|
assert.equal(code, 0);
|
|
assert.ok(ctx.out().includes("v9.9.9-test"));
|
|
});
|
|
|
|
test("dispatch: no command exits 2 with usage on stderr", async () => {
|
|
const ctx = testCtx();
|
|
assert.equal(await run([], ctx), 2);
|
|
assert.ok(ctx.err().includes("Usage:") || ctx.out().includes("Usage:") || ctx.err().includes("nextcraft"));
|
|
});
|
|
|
|
test("dispatch: unknown command exits 2", async () => {
|
|
const ctx = testCtx();
|
|
const code = await run(["frobnicate"], ctx);
|
|
assert.equal(code, 2);
|
|
assert.ok(ctx.err().includes("unknown command: frobnicate"));
|
|
});
|
|
|
|
test("dispatch: unknown flag exits 2", async () => {
|
|
const ctx = testCtx();
|
|
assert.equal(await run(["doctor", "--bogus"], ctx), 2);
|
|
});
|
|
|
|
test("dispatch: doctor routes to the doctor command", async () => {
|
|
const ctx = testCtx({
|
|
spawn: async (cmd, args) => {
|
|
if (cmd === "which") return { code: 0, signal: null, timedOut: false, stdout: "", stderr: "" };
|
|
if (cmd === "pnpm" && args[0] === "--version") return r("10.0.0\n");
|
|
if (cmd === "python3" && args[0] === "--version") return r("Python 3.11.2\n");
|
|
if (cmd === "git" && args[0] === "--version") return r("git version 2.39.2\n");
|
|
return { code: 0, signal: null, timedOut: false, stdout: "", stderr: "" };
|
|
},
|
|
});
|
|
const code = await run(["doctor"], ctx);
|
|
assert.equal(code, 0);
|
|
assert.ok(ctx.out().includes("All checks passed"));
|
|
});
|
|
|
|
const r = (stdout: string) => ({ code: 0, signal: null, timedOut: false, stdout, stderr: "" }); |