feat: 分离模板演示数据并校验预览资源

This commit is contained in:
que01 committed 2026-10-16 17:55:52 +08:00
1 parent 6edde5a8d6
commit b60174885e
31 files changed
+1785 -69

No files matched your search

+17 -4
View File
@@ -1,5 +1,6 @@
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";
@@ -9,8 +10,20 @@ 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" });
assert.match(output, /Conformance passed: acheng-campus-food@1\.0\.0/);
assert.match(output, /Conformance passed: atelier-solopreneur@1\.1\.0/);
assert.match(output, /Conformance passed: linjing-editorial@1\.0\.0/);
assert.match(output, /Template conformance passed: 3 package\(s\)\./);
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).`));
});