mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* fix(cli): render --json gives each missing tool, a held slot and an old Node its own code Every failed `render --json` answered with `error.code: "runtime_error"`, so a script could only tell a missing FFmpeg from a busy render slot by matching the human message. A CliRuntimeError now carries a code, as CliUsageError does, and the envelope reports it: chrome_not_found, ffmpeg_not_found, ffprobe_not_found, render_locked. A Node older than 22 prints the envelope too (node_version_unsupported) when the run asked for --json. Other failures keep runtime_error. Refs #7408 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * test(cli): give the bin entry test's runtimeVersion stub the new JSON export bin/hyperframes.mjs now imports runtimeVersionJson, so the stub dist file binEntry.test.ts writes must export it too, or the bin fails to load. --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { runtimeVersionError, runtimeVersionJson } from "./runtimeVersion.js";
|
|
|
|
describe("runtimeVersionError", () => {
|
|
it("rejects Node 20 before the bundled CLI is imported", () => {
|
|
expect(runtimeVersionError("20.11.1")).toBe(
|
|
"HyperFrames requires Node.js >= 22 (current: 20.11.1). Switch Node versions and retry.",
|
|
);
|
|
});
|
|
|
|
it("accepts supported Node releases", () => {
|
|
expect(runtimeVersionError("22.0.0")).toBeNull();
|
|
expect(runtimeVersionError("24.14.0")).toBeNull();
|
|
});
|
|
|
|
it("rejects malformed versions safely", () => {
|
|
expect(runtimeVersionError("unknown")).toContain("requires Node.js >= 22");
|
|
});
|
|
});
|
|
|
|
describe("runtimeVersionJson", () => {
|
|
const message = "HyperFrames requires Node.js >= 22 (current: 20.11.1).";
|
|
|
|
it("answers a --json run with the failure envelope", () => {
|
|
expect(JSON.parse(runtimeVersionJson(message, ["render", ".", "--json"]) ?? "")).toEqual({
|
|
ok: false,
|
|
error: { code: "node_version_unsupported", message },
|
|
});
|
|
});
|
|
|
|
it("stays out of a run that did not ask for JSON", () => {
|
|
expect(runtimeVersionJson(message, ["render", "."])).toBeNull();
|
|
});
|
|
});
|