feat: 收口多品牌与模板构建基础

This commit is contained in:
que01 committed 2026-09-25 02:55:46 +08:00
1 parent 0425a1c672
commit 77224ea51f
317 files changed
+11290 -1158

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const { execFileSync } = require("node:child_process");
const root = path.resolve(__dirname, "..");
const buildConfig = JSON.parse(
fs.readFileSync(path.join(root, "config/template-build.json"), "utf8"),
);
const compiler = path.join(root, "packages/template-compiler/src/cli.mjs");
const failures = [];
for (const entry of buildConfig.templates) {
const packagePath = path.join(root, "packages/template-" + entry.packageKey);
const manifestPath = path.join(packagePath, "template.json");
if (!fs.existsSync(manifestPath)) {
failures.push(`${entry.packageKey}: template.json is missing`);
continue;
}
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
if (manifest.version !== entry.version)
failures.push(
`${entry.packageKey}: build version ${entry.version} != manifest ${manifest.version}`,
);
if (manifest.runtimeContract !== buildConfig.runtimeContract)
failures.push(`${entry.packageKey}: runtime contract mismatch`);
const output = fs.mkdtempSync(path.join(os.tmpdir(), "personal-brand-release-"));
try {
execFileSync(process.execPath, [compiler, "--template", entry.packageKey, "--out", output], {
cwd: root,
stdio: "ignore",
});
const runtime = JSON.parse(fs.readFileSync(path.join(output, "template.runtime.json"), "utf8"));
if (runtime.packageKey !== entry.packageKey || runtime.version !== entry.version)
failures.push(`${entry.packageKey}: generated runtime snapshot mismatch`);
} catch (error) {
failures.push(`${entry.packageKey}: compiler failed (${error.message})`);
} finally {
fs.rmSync(output, { recursive: true, force: true });
}
}
if (failures.length) {
console.error(failures.join("\n"));
process.exit(1);
}
console.log(`Template release validation passed: ${buildConfig.templates.length} packages.`);