fix(cli): make clean source checkouts start reliably

This commit is contained in:
morluto
2026-07-15 14:44:04 +00:00
parent 70e1a0f532
commit 6ba97656ca
5 changed files with 88 additions and 10 deletions
+29
View File
@@ -61,4 +61,33 @@ describe("executable dispatcher", () => {
args: ["--mcp", "extra"],
});
});
it("explains how to restore a missing compiled runtime", async () => {
fixtureRoot = await mkdtemp(join(tmpdir(), "rea-dispatcher-"));
const scripts = join(fixtureRoot, "scripts");
await mkdir(scripts);
await Promise.all([
copyFile("scripts/rea.mjs", join(scripts, "rea.mjs")),
writeFile(
join(fixtureRoot, "package.json"),
JSON.stringify({ type: "module", version: "1.0.0" }),
),
]);
for (const args of [["mcp"], ["--help"]]) {
const execution = execFileAsync(process.execPath, [
join(scripts, "rea.mjs"),
...args,
]);
await expect(execution).rejects.toMatchObject({
code: 1,
stderr: expect.stringContaining(
"REA's compiled runtime is missing. Run `npm ci` in",
),
});
await expect(execution).rejects.toMatchObject({
stderr: expect.not.stringContaining("ERR_MODULE_NOT_FOUND"),
});
}
});
});
+12 -1
View File
@@ -8,7 +8,15 @@ import { PRODUCT_IDENTITY } from "../src/identity.js";
describe("package identity", () => {
it("keeps the manifest, executable, and floating MCP command aligned", async () => {
const packageJson = z
.object({ name: z.string(), bin: z.record(z.string(), z.string()) })
.object({
name: z.string(),
bin: z.record(z.string(), z.string()),
scripts: z.object({
start: z.string(),
prepare: z.string(),
prepack: z.string().optional(),
}),
})
.parse(
JSON.parse(
await readFile(
@@ -20,5 +28,8 @@ describe("package identity", () => {
expect(packageJson.name).toBe(PRODUCT_IDENTITY.packageName);
expect(Object.keys(packageJson.bin)).toEqual([PRODUCT_IDENTITY.cliBinary]);
expect(PRODUCT_IDENTITY.mcpCommand).toBe(`npx -y ${packageJson.name} mcp`);
expect(packageJson.scripts.start).toBe("node scripts/rea.mjs mcp");
expect(packageJson.scripts.prepare).toBe("npm run build && husky");
expect(packageJson.scripts.prepack).toBeUndefined();
});
});