Files
hyperframes/packages/cli/src/runtimeVersion.ts
T
wonjangandClaude Fable 5.2 47d007e5b0 fix(cli): render --json gives each missing tool, a held slot and an old Node its own code (#7842)
* 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>
2026-11-16 18:16:11 +00:00

13 lines
604 B
TypeScript

const MINIMUM_NODE_MAJOR = 22;
export function runtimeVersionError(version: string): string | null {
const major = Number.parseInt(version.split(".", 1)[0] ?? "", 10);
if (Number.isFinite(major) && major >= MINIMUM_NODE_MAJOR) return null;
return `HyperFrames requires Node.js >= ${MINIMUM_NODE_MAJOR} (current: ${version}). Switch Node versions and retry.`;
}
export function runtimeVersionJson(message: string, argv: readonly string[]): string | null {
if (!argv.includes("--json")) return null;
return JSON.stringify({ ok: false, error: { code: "node_version_unsupported", message } });
}