Make Camino examples and scaffolds complete Yarn and Nix packages
This commit is contained in:
@@ -5,6 +5,7 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { execFile as callback } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
import { componentEntries } from "../src/capability-language/component-nix.js";
|
||||
import { scaffoldRecipe } from "../src/capability-language/scaffold-recipes.js";
|
||||
import { planStructure, applyStructure } from "../src/capability-language/structural-plan.js";
|
||||
const execFile = promisify(callback);
|
||||
@@ -31,12 +32,23 @@ test("checked component scaffolding composes with execution handlers without rep
|
||||
id: "component:card",
|
||||
declaration: 'module Card id "component:card" implements View.render;',
|
||||
});
|
||||
assert.deepEqual(JSON.parse(await fs.readFile(path.join(root, "quixos.components.json"), "utf8")), {
|
||||
"component:card": { entry: "src/components/Card.tsx", export: "Card" },
|
||||
});
|
||||
assert.deepEqual(
|
||||
{ ...(await componentEntries(await fs.readFile(path.join(root, "components.nix"), "utf8"))) },
|
||||
{
|
||||
"component:card": { entry: "src/components/Card.tsx", export: "Card" },
|
||||
},
|
||||
);
|
||||
const card = path.join(root, "src/components/Card.tsx");
|
||||
await fs.appendFile(card, "\n// authored extension\n");
|
||||
const retained = await fs.readFile(card, "utf8");
|
||||
const flake = path.join(root, "flake.nix");
|
||||
await fs.appendFile(flake, "\n# retained authored toolchain configuration\n");
|
||||
const retainedFlake = await fs.readFile(flake, "utf8");
|
||||
const entriesFile = path.join(root, "components.nix");
|
||||
await fs.writeFile(
|
||||
entriesFile,
|
||||
(await fs.readFile(entriesFile, "utf8")).replace("{\n", "{\n # retained entry comment\n"),
|
||||
);
|
||||
await apply("function", {
|
||||
name: "echo",
|
||||
id: "echo",
|
||||
@@ -48,8 +60,10 @@ test("checked component scaffolding composes with execution handlers without rep
|
||||
declaration: 'module Details id "component:details" implements View.render;',
|
||||
});
|
||||
assert.equal(await fs.readFile(card, "utf8"), retained);
|
||||
assert.equal(await fs.readFile(flake, "utf8"), retainedFlake);
|
||||
assert.match(await fs.readFile(entriesFile, "utf8"), /retained entry comment/);
|
||||
assert.match(await fs.readFile(path.join(root, "src/server.ts"), "utf8"), /echo/);
|
||||
assert.match(await fs.readFile(path.join(root, "flake.nix"), "utf8"), /react \? null/);
|
||||
assert.match(await fs.readFile(path.join(root, "flake.nix"), "utf8"), /import \.\/package\.nix/);
|
||||
await assert.rejects(
|
||||
apply("component", {
|
||||
name: "Card",
|
||||
@@ -67,6 +81,17 @@ test("checked component scaffolding composes with execution handlers without rep
|
||||
}),
|
||||
/exactly one/,
|
||||
);
|
||||
const beforeUnsupported = await fs.readFile(packageFile, "utf8");
|
||||
await fs.writeFile(entriesFile, '{\n custom = builtins.abort "must not evaluate";\n}\n');
|
||||
await assert.rejects(
|
||||
apply("component", {
|
||||
name: "Unsupported",
|
||||
id: "component:unsupported",
|
||||
declaration: 'module Unsupported id "component:unsupported" implements View.render;',
|
||||
}),
|
||||
/literal-entry shape/,
|
||||
);
|
||||
assert.equal(await fs.readFile(packageFile, "utf8"), beforeUnsupported);
|
||||
});
|
||||
|
||||
test("controller scaffolding preserves existing registrations and rejects duplicate identities", async (context) => {
|
||||
|
||||
Reference in New Issue
Block a user