mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:00:07 +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>
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import module from "node:module";
|
|
import { runtimeVersionError, runtimeVersionJson } from "../dist/runtimeVersion.js";
|
|
|
|
// The plugin launcher starts npx outside the project so npm cannot pick the CLI from it,
|
|
// and names the project here. Nested CLI runs keep the working folder their caller gives them.
|
|
const projectDir = process.env.HYPERFRAMES_PLUGIN_CWD;
|
|
delete process.env.HYPERFRAMES_PLUGIN_CWD;
|
|
if (projectDir) {
|
|
process.chdir(projectDir);
|
|
// npm's shell resets PWD to the folder npx started in; commands read the project name from it.
|
|
process.env.PWD = projectDir;
|
|
}
|
|
|
|
const error = runtimeVersionError(process.versions.node);
|
|
if (error) {
|
|
console.error(error);
|
|
const json = runtimeVersionJson(error, process.argv.slice(2));
|
|
if (json) console.log(json);
|
|
process.exitCode = 1;
|
|
} else {
|
|
// Reuses V8 bytecode across runs (os.tmpdir()/node-compile-cache); Node 22.0 has no such API.
|
|
module.enableCompileCache?.();
|
|
if (process.env.HYPERFRAMES_HANG_REPORT) (await import("../dist/hangReport.js")).watchForHang();
|
|
const warm = process.argv[2] === "check" ? await import("../dist/warmCheckClient.js") : undefined;
|
|
if (warm?.warmCheckEligible()) process.once("exit", () => warm.startNextWarmCheck());
|
|
if (!(warm?.warmCheckEligible() && (await warm.runWarmCheck()))) await import("../dist/cli.js");
|
|
}
|