feat(packages): require declared feature surfaces (#240)

This commit is contained in:
Cato authored and GitHub committed 2026-10-26 11:17:36 +01:00
1 parent 912857993d
commit 88be04b2a5
3 files changed
+29 -1

No files matched your search

+9
View File
@@ -108,6 +108,15 @@ export function auditComposition(
findings.push(`${feature}: ${symbol} is not used in ${binding.file}`);
}
}
for (const surface of entry.surfaces ?? []) {
if (
!surface ||
surface.startsWith("/") ||
surface.split("/").includes("..") ||
!existsSync(resolve(dir, surface))
)
findings.push(`${feature}: required product surface is missing or unsafe: ${surface}`);
}
}
if (
!existsSync(resolve(dir, ".github/dependabot.yml")) ||
+15 -1
View File
@@ -1,6 +1,6 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from "node:fs";
import { mkdtempSync, writeFileSync, mkdirSync, rmSync, readFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { auditComposition } from "./package-composition-audit.mjs";
@@ -122,6 +122,20 @@ test("dependency-only adoption fails when the rendered binding disappears", () =
auditComposition(dir, baseline).some((x) => x.includes("not used")),
);
}));
test("required feature surfaces are checked against the product tree", () =>
fixture((dir) => {
const path = join(dir, "package-plan.json");
const plan = JSON.parse(readFileSync(path, "utf8"));
plan.blocks.shell.surfaces = ["src/app/roadmap/page.tsx", "src/app/changelog/page.tsx"];
writeFileSync(path, JSON.stringify(plan));
const findings = auditComposition(dir, baseline);
assert.equal(findings.filter((x) => x.includes("required product surface")).length, 2);
mkdirSync(join(dir, "src/app/roadmap"), { recursive: true });
mkdirSync(join(dir, "src/app/changelog"), { recursive: true });
writeFileSync(join(dir, "src/app/roadmap/page.tsx"), "export default function Roadmap() {}");
writeFileSync(join(dir, "src/app/changelog/page.tsx"), "export default function Changelog() {}");
assert.deepEqual(auditComposition(dir, baseline), []);
}));
test("a missing package plan fails before a product can claim a shared foundation", () =>
fixture((dir) => {
rmSync(join(dir, "package-plan.json"));
+5
View File
@@ -24,6 +24,11 @@
},
"publishing": {
"package": "bip-kit",
"surfaces": [
"app/[locale]/roadmap/page.tsx",
"app/[locale]/changelog/page.tsx",
"app/[locale]/blog/page.tsx"
],
"bindings": [
{
"file": "components/DevelopmentRecords.tsx",