mirror of
https://github.com/hanzoai/frames.git
synced 2026-09-24 00:08:03 +00:00
Forked from HyperFrames (Apache-2.0), full history preserved. Hosts are mapped explicitly and BEFORE the identifier rename, because hyperframes.heygen.com is not decoration: 175 of its occurrences are $schema identifiers that a validator dereferences. A blind rename would have left them naming a host that never serves them. The schema files are in this repo under docs/schema, so the mapped host is one we can actually serve -- that is the condition that makes the rewrite safe, and serving them is a deploy task, not an edit. docs/schema/hyperframes.json is renamed to frames.json to match the identifier it is now published under. api.heygen.com and the CLI auth against heygen.com are left UNRENAMED on purpose. They are a dependency on HeyGen's SaaS, not a name of ours to take, and the right move is to remove that integration rather than rebrand it. LICENSE and CREDITS.md are untouched; NOTICE records the lineage. Co-authored-by: Hanzo Dev <[email protected]>
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { spawnSync } from "node:child_process";
|
|
import { realpathSync } from "node:fs";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
export function hasCliCommand(helpText, command) {
|
|
const escaped = command.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
return new RegExp(`^\\s+${escaped}(?:\\s+|$)`, "m").test(String(helpText));
|
|
}
|
|
|
|
export function runCliPreflight({ command = "check", spawn = spawnSync } = {}) {
|
|
const result = spawn("npx", ["frames", "--help"], {
|
|
encoding: "utf8",
|
|
shell: process.platform === "win32",
|
|
});
|
|
const output = `${result.stdout ?? ""}\n${result.stderr ?? ""}`;
|
|
if (result.status !== 0) {
|
|
throw new Error(`unable to inspect Frames CLI capabilities\n${output.trim()}`);
|
|
}
|
|
if (!hasCliCommand(output, command)) {
|
|
throw new Error(
|
|
`the installed Frames CLI does not provide \`${command}\`, but the current pr-to-video skill requires it. Upgrade the CLI before starting frame work.`,
|
|
);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function main() {
|
|
try {
|
|
runCliPreflight();
|
|
console.log("✓ pr-to-video preflight: required CLI capabilities are available");
|
|
} catch (error) {
|
|
console.error(`✗ pr-to-video preflight: ${error.message}`);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// realpath both sides: on macOS /tmp → /private/tmp, and node resolves the main
|
|
// module's symlinks in import.meta.url while argv[1] keeps the invoked spelling —
|
|
// a raw compare silently skips main() when invoked through any symlinked path.
|
|
function isMainModule() {
|
|
if (!process.argv[1]) return false;
|
|
try {
|
|
return pathToFileURL(realpathSync(process.argv[1])).href === import.meta.url;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if (isMainModule()) main();
|