import assert from "node:assert/strict"; import { execFileSync } from "node:child_process"; import { readFileSync, readdirSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import test from "node:test"; const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const script = path.join(root, "scripts/template-conformance.cjs"); test("template:conformance automatically discovers all template packages", () => { const output = execFileSync(process.execPath, [script], { cwd: root, encoding: "utf8" }); const manifests = readdirSync(path.join(root, "packages")) .filter((name) => name.startsWith("template-")) .flatMap((name) => { try { return [ JSON.parse(readFileSync(path.join(root, "packages", name, "template.json"), "utf8")), ]; } catch (error) { if (error.code === "ENOENT") return []; throw error; } }); assert.ok(manifests.length > 0); for (const manifest of manifests) assert.ok(output.includes(`Conformance passed: ${manifest.packageKey}@${manifest.version} (`)); assert.ok(output.includes(`Template conformance passed: ${manifests.length} package(s).`)); });