Move parser, tokenize, and area-aliases under cli/parse; runner and read-only under cli/run; printer under cli/output; help plus the docs/naming contract tests under cli/help. types.ts and helpers.ts stay at the cli root. Update imports, the app-root depth calculation, test fixtures, and the CLI doc generator path. No behavior change.
29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
#!/usr/bin/env bun
|
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { HELP_REGISTRY } from "../src/cli/help/help.ts";
|
|
|
|
export const cliDocPath = resolve(import.meta.dirname, "../skills/seal-use/references/cli.md");
|
|
const begin = "<!-- BEGIN GENERATED CLI COMMANDS -->";
|
|
const end = "<!-- END GENERATED CLI COMMANDS -->";
|
|
|
|
export function renderCliCommandBlock() {
|
|
const usages = ["seal-use version", ...HELP_REGISTRY.flatMap((area) => area.commands.flatMap((command) => command.usage))];
|
|
return [begin, "", "```bash", ...usages, "```", "", end].join("\n");
|
|
}
|
|
|
|
export function updateCliDoc(markdown) {
|
|
if (markdown.split(begin).length !== 2 || markdown.split(end).length !== 2 || markdown.indexOf(end) < markdown.indexOf(begin)) {
|
|
throw new Error("CLI documentation must contain exactly one ordered generated command block.");
|
|
}
|
|
const start = markdown.indexOf(begin);
|
|
const finish = markdown.indexOf(end) + end.length;
|
|
return markdown.slice(0, start) + renderCliCommandBlock() + markdown.slice(finish);
|
|
}
|
|
|
|
if (import.meta.main) {
|
|
const before = readFileSync(cliDocPath, "utf8");
|
|
const after = updateCliDoc(before);
|
|
if (before !== after) writeFileSync(cliDocPath, after, "utf8");
|
|
}
|