Files
raea/engine/cli/tools/pack.ts
shane d873402ac5 raea goal is the loop, raea make the asset tools (#269)
One loop, raea goal: every rule in TypeScript, held at edit, render, publish and done (goal check, tasks, judge, seen, gates, next); the brief's contract is goal: (one goal or a list, a workflow inline), and its plan is plan:. raea make is making a finished asset: character, clothes, motion, solid, wear, splat, physics, bake, sounds, component, the kit pipeline and shots. Instruments (check, judge, ask, world, scene faults, light check) stay top-level. With it: the montage pack (MK48-MK51), JavaScriptCore fixes raea goal needs (CommonJS named exports, reserved words too, dynamic import of file URLs, process.exit from a promise, stdin for -), raea-cli-goal and raea-cli-refused split out of raea-cli, and skills at raea-skills 105aede.
2026-11-29 18:43:09 -08:00

27 lines
1.6 KiB
TypeScript

// bun tools/pack.ts: the parts `raea make component add` copies in (every folder of examples/parts, a set each: brand, reel ...) and
// the project template as strings in src/registry.gen.ts, so `raea make component add` and `raea init` work inside the shell (raea's
// V8 reads only the project folder, not this package). Run after changing either; `bun test` fails when the generated
// file is stale. A set's tests (*.test.ts) stay behind: they check the example, not a project.
import { readdirSync, readFileSync, writeFileSync } from "fs";
import { join } from "path";
const here = join(import.meta.dir, "..");
const PARTS = "../../examples/parts";
const read = (dir: string) =>
Object.fromEntries(
readdirSync(join(here, dir), { withFileTypes: true })
.filter((e) => e.isFile() && !e.name.startsWith(".") && !e.name.includes(".gen.") && !e.name.includes(".test."))
.map((e) => e.name)
.sort()
.map((f) => [f, readFileSync(join(here, dir, f), "utf8")]),
);
export function generated(): string {
const sets = readdirSync(join(here, PARTS), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
const registry = Object.fromEntries(sets.map((s) => [s, read(`${PARTS}/${s}`)]));
const template = read("template");
return `// generated by tools/pack.ts from examples/parts/ and template/: don't edit, run \`bun tools/pack.ts\`\nexport const REGISTRY: Record<string, Record<string, string>> = ${JSON.stringify(registry, null, 2)};\nexport const TEMPLATE: Record<string, string> = ${JSON.stringify(template, null, 2)};\n`;
}
if (import.meta.main) writeFileSync(join(here, "src/registry.gen.ts"), generated());