Files
frames/scripts/check-workspace-contracts.mjs
zooqueenandHanzo Dev 70b41673a3 frames: rebrand the fork to Hanzo Frames
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]>
2026-07-28 23:42:24 -07:00

63 lines
2.0 KiB
JavaScript

#!/usr/bin/env node
import { existsSync, readFileSync, readdirSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
const ROOT = join(import.meta.dirname, "..");
export const REQUIRED_WORKSPACE_SCRIPTS = ["build", "typecheck", "test"];
function hasExecutableScript(pkg, script) {
return typeof pkg.scripts?.[script] === "string" && pkg.scripts[script].trim().length > 0;
}
function hasSpecificReason(reason) {
return typeof reason === "string" ? reason.trim().length >= 20 : false;
}
function hasDocumentedOptOut(pkg, script) {
const optOut = pkg.framesWorkspaceContract?.[script];
return optOut?.optOut === true && hasSpecificReason(optOut.reason);
}
export function listWorkspaceContractIssues(workspace, pkg) {
return REQUIRED_WORKSPACE_SCRIPTS.flatMap((script) => {
if (hasExecutableScript(pkg, script) || hasDocumentedOptOut(pkg, script)) return [];
return [
`${workspace}: missing executable \`${script}\` script or ` +
`framesWorkspaceContract.${script} opt-out with a specific reason`,
];
});
}
export function listWorkspacePackages(root = ROOT) {
const packagesDir = join(root, "packages");
return readdirSync(packagesDir)
.sort()
.filter((name) => existsSync(join(packagesDir, name, "package.json")))
.map((name) => {
const workspace = `packages/${name}`;
const pkg = JSON.parse(readFileSync(join(root, workspace, "package.json"), "utf8"));
return { workspace, pkg };
});
}
export function checkWorkspaceContracts(root = ROOT) {
return listWorkspacePackages(root).flatMap(({ workspace, pkg }) =>
listWorkspaceContractIssues(workspace, pkg),
);
}
function main() {
const issues = checkWorkspaceContracts();
if (issues.length > 0) {
console.error("Workspace contract violations:");
issues.forEach((issue) => console.error(`- ${issue}`));
process.exitCode = 1;
return;
}
console.log("Workspace contracts verified: build, typecheck, and test are explicit.");
}
if (process.argv[1] === fileURLToPath(import.meta.url)) main();