mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:00:07 +00:00
* fix(cli): reject extra positional arguments on every command * fix(cli): read the command name without assuming a resolved meta * fix(cli): join free-text words for catalog and tts, reject a bad repo root * test(cli): load the listed commands through static imports * fix(cli): keep a tts file path out of the word join and read the parsed json flag * fix(cli): apply the file exception only to a tts .txt path * fix(cli): keep usageLine private and test the json fallback for undeclared json * fix(cli): keep extra arguments and the repo root value out of telemetry * test(cli): type the skills update lookup * fix(cli): read json mode from the parsed flag, reject tts words with --text-file, restore add's hint * fix(cli): check tts words with --text-file before --list and test --json=false
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
/**
|
|
* Resolve the HyperFrames repo root. Used by `lambda deploy`/`destroy`
|
|
* to find `examples/aws-lambda/template.yaml` and the handler ZIP build
|
|
* script.
|
|
*
|
|
* Walks up from this file's location until it finds a directory that
|
|
* contains `packages/aws-lambda/`. Caching is unnecessary — this runs
|
|
* once per CLI invocation.
|
|
*/
|
|
|
|
import { existsSync } from "node:fs";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
export function repoRoot(): string {
|
|
const override = process.env.HYPERFRAMES_REPO_ROOT;
|
|
if (override) {
|
|
if (existsSync(resolve(override, "packages", "aws-lambda", "package.json"))) return override;
|
|
throw new Error(
|
|
"[hyperframes lambda] HYPERFRAMES_REPO_ROOT is not a hyperframes checkout " +
|
|
"(no packages/aws-lambda/package.json there). Point it at the repo root, or unset it.",
|
|
);
|
|
}
|
|
let dir = dirname(fileURLToPath(import.meta.url));
|
|
for (let depth = 0; depth < 12; depth++) {
|
|
if (existsSync(resolve(dir, "packages", "aws-lambda", "package.json"))) {
|
|
return dir;
|
|
}
|
|
const parent = dirname(dir);
|
|
if (parent === dir) break;
|
|
dir = parent;
|
|
}
|
|
throw new Error(
|
|
"[hyperframes lambda] could not find the repo root (no packages/aws-lambda/ above this CLI's source). " +
|
|
"Run `hyperframes lambda` from within a hyperframes checkout, or set HYPERFRAMES_REPO_ROOT explicitly.",
|
|
);
|
|
}
|