feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -3,6 +3,8 @@ const path = require("node:path");
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const requestSource = fs.readFileSync(path.join(root, "utils/request.js"), "utf8");
|
||||
const configSource = fs.readFileSync(path.join(root, "utils/config.js"), "utf8");
|
||||
const moduleRegistrySource = fs.readFileSync(path.join(root, "utils/module-registry.js"), "utf8");
|
||||
const runtimeRequestSource = fs.readFileSync(path.join(root, "utils/request.js"), "utf8");
|
||||
if (
|
||||
!requestSource.includes('path.startsWith("/public/")') ||
|
||||
!requestSource.includes("brandSlug") ||
|
||||
@@ -11,7 +13,37 @@ if (
|
||||
console.error("miniapp: public requests must carry the configured brand slug");
|
||||
process.exit(1);
|
||||
}
|
||||
const fixtureFiles = ["linjing-door.json", "minimal-neutral.json", "doors-industry.json"];
|
||||
if (!moduleRegistrySource.includes("Object.values(manifest?.pages || {})")) {
|
||||
console.error("miniapp: visual page renderers must resolve from the manifest");
|
||||
process.exit(1);
|
||||
}
|
||||
if (
|
||||
!runtimeRequestSource.includes('path.startsWith("/customer/session/wechat")') ||
|
||||
!runtimeRequestSource.includes('"customerToken:" + config.brandSlug')
|
||||
) {
|
||||
console.error("miniapp: customer sessions must be brand-scoped");
|
||||
process.exit(1);
|
||||
}
|
||||
const productionRoots = ["components/modules", "components/templates", "pages"];
|
||||
const productionSources = [];
|
||||
function collectSources(directory) {
|
||||
const current = path.join(root, directory);
|
||||
for (const item of fs.readdirSync(current, { withFileTypes: true })) {
|
||||
const itemPath = path.join(current, item.name);
|
||||
if (item.isDirectory()) collectSources(path.relative(root, itemPath));
|
||||
else if (itemPath.endsWith(".js") || itemPath.endsWith(".wxml"))
|
||||
productionSources.push({ file: itemPath, content: fs.readFileSync(itemPath, "utf8") });
|
||||
}
|
||||
}
|
||||
productionRoots.forEach(collectSources);
|
||||
for (const term of ["林境门", "亲自主理量房", "拒绝流水线拼装", "linjingInquiryRecords"]) {
|
||||
const leak = productionSources.find(({ content }) => content.includes(term));
|
||||
if (leak) {
|
||||
console.error(`miniapp: static business term ${term} leaked into ${leak.file}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
const fixtureFiles = ["linjing-door.json", "doors-industry.json"];
|
||||
const fixtures = fixtureFiles.map((file) =>
|
||||
JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", file), "utf8")),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user