feat: 补齐模板编译扩展性门禁与演练模板

- 新增第二行业演练模板 drill-consultant,验证新增行业无需修改编译器和运行���
- 补充 override 冲突与显式覆盖测试,产物校验覆盖 wxss
- 修复 --template-dir 模板被误判引用其他模板组件的问题
- 修复运行时排除规则误删 TDesign 深层 src 目录,增加 miniprogram_npm 完整性回归
- 模板目录校验统一复用 template-contract,新增 template:check 并接入 pnpm check
- tabBar 配色归属模板包,清理编译器过期排除项和旧 fixture
- ADR 0015 明确对 0005/0008/0009 的替换范围

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
que01andClaude Opus 5.5 committed 2026-09-27 06:55:56 +08:00
1 parent e2e2340bfe
commit a97cc860cf
31 files changed
+418 -158

No files matched your search

+34 -39
View File
@@ -1,11 +1,11 @@
const fs = require("node:fs");
const path = require("node:path");
const { pathToFileURL } = require("node:url");
const root = path.resolve(__dirname, "..");
require(path.join(root, "scripts/generate-template-catalog.cjs"));
const workspacePackageRoot = path.join(root, "packages");
const requiredPages = ["home", "offerings", "detail", "inquiry", "success", "records", "profile"];
const errors = [];
const contractEntry = path.join(workspacePackageRoot, "template-contract/src/index.ts");
const workspaceTemplates = fs
.readdirSync(workspacePackageRoot, { withFileTypes: true })
.filter(
@@ -15,44 +15,39 @@ const workspaceTemplates = fs
fs.existsSync(path.join(workspacePackageRoot, entry.name, "template.json")),
);
for (const entry of workspaceTemplates) {
const packageDir = path.join(workspacePackageRoot, entry.name);
const manifestPath = path.join(packageDir, "template.json");
let manifest;
try {
manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
} catch (error) {
errors.push(`${entry.name}: invalid template.json (${error.message})`);
continue;
}
if (![entry.name, entry.name.replace(/^template-/, "")].includes(manifest.packageKey))
errors.push(`${entry.name}: packageKey must match directory name or template key`);
if (!manifest.version) errors.push(`${entry.name}: version is required`);
if (manifest.runtimeContract !== "1.0") errors.push(`${entry.name}: unsupported runtimeContract`);
if (!manifest.displayName) errors.push(`${entry.name}: displayName is required`);
if (!Array.isArray(manifest.navigation) || !manifest.navigation.length)
errors.push(`${entry.name}: navigation is required`);
if (!Array.isArray(manifest.dataSlots) || !manifest.dataSlots.length)
errors.push(`${entry.name}: dataSlots is required`);
if (!Array.isArray(manifest.assetSlots))
errors.push(`${entry.name}: assetSlots must be an array`);
if (!manifest.admin || !Array.isArray(manifest.admin.sections) || !manifest.admin.sections.length)
errors.push(`${entry.name}: admin.sections is required`);
if (!Array.isArray(manifest.pages) || !manifest.pages.length)
errors.push(`${entry.name}: pages is required`);
for (const page of requiredPages)
if (typeof manifest.entrypoints?.[page] !== "string")
errors.push(`${entry.name}: entrypoints.${page} is required`);
for (const item of manifest.navigation || []) {
for (const asset of [item.iconPath, item.selectedIconPath]) {
if (asset && !fs.existsSync(path.join(packageDir, "miniapp", asset)))
errors.push(`${entry.name}: navigation asset is missing: ${asset}`);
async function main() {
// manifest 规则只在 template-contract 中维护;这里只补充依赖文件系统的检查。
const { validateTemplatePackageManifest } = await import(pathToFileURL(contractEntry).href);
const errors = [];
for (const entry of workspaceTemplates) {
const packageDir = path.join(workspacePackageRoot, entry.name);
let manifest;
try {
manifest = JSON.parse(fs.readFileSync(path.join(packageDir, "template.json"), "utf8"));
} catch (error) {
errors.push(`${entry.name}: invalid template.json (${error.message})`);
continue;
}
for (const error of validateTemplatePackageManifest(manifest))
errors.push(`${entry.name}: ${error}`);
if (![entry.name, entry.name.replace(/^template-/, "")].includes(manifest.packageKey))
errors.push(`${entry.name}: packageKey must match directory name or template key`);
for (const page of manifest.pages || []) {
if (!fs.existsSync(path.join(packageDir, "miniapp", page + ".js")))
errors.push(`${entry.name}: declared page is missing: ${page}`);
}
for (const item of manifest.navigation || []) {
for (const asset of [item.iconPath, item.selectedIconPath]) {
if (asset && !fs.existsSync(path.join(packageDir, "miniapp", asset)))
errors.push(`${entry.name}: navigation asset is missing: ${asset}`);
}
}
}
if (errors.length) {
console.error(errors.join("\n"));
process.exit(1);
}
console.log(`Workspace template packages validated: ${workspaceTemplates.length}`);
}
if (errors.length) {
console.error(errors.join("\n"));
process.exit(1);
}
console.log(`Workspace template packages validated: ${workspaceTemplates.length}`);
main();