feat: 分离模板演示数据并校验预览资源
This commit is contained in:
1 parent
6edde5a8d6
commit
b60174885e
31 files changed
+1785
-69
No files matched your search
@@ -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).`));
|
||||
});
|
||||
@@ -1,17 +1,24 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
||||
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync } 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-pack.cjs");
|
||||
const templatePackages = [
|
||||
["acheng-campus-food", "1.0.0"],
|
||||
["atelier-solopreneur", "1.1.0"],
|
||||
["linjing-editorial", "1.0.0"],
|
||||
];
|
||||
const templatePackages = readdirSync(path.join(root, "packages"))
|
||||
.filter(
|
||||
(name) =>
|
||||
name.startsWith("template-") &&
|
||||
existsSync(path.join(root, "packages", name, "template.json")),
|
||||
)
|
||||
.map((name) => {
|
||||
const manifest = JSON.parse(
|
||||
readFileSync(path.join(root, "packages", name, "template.json"), "utf8"),
|
||||
);
|
||||
return [manifest.packageKey, manifest.version];
|
||||
});
|
||||
|
||||
for (const [packageKey, version] of templatePackages) {
|
||||
test(`${packageKey} produces a stable package directory and archive`, () => {
|
||||
|
||||
Reference in new issue
Block a user