mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-04 05:07:28 +01:00
feat(packages): require declared feature surfaces (#240)
This commit is contained in:
3 files changed
+29
-1
No files matched your search
@@ -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")) ||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user