新建项目

This commit is contained in:
2026-07-29 10:50:33 +08:00
parent bfd3841cbd
commit 4f69b859a8
49 changed files with 5565 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
const assert = require("assert");
const fs = require("fs");
const path = require("path");
const pagesRoot = path.join(__dirname, "..", "pages");
const pageNames = fs.readdirSync(pagesRoot);
pageNames.forEach((pageName) => {
const pageRoot = path.join(pagesRoot, pageName);
const jsPath = path.join(pageRoot, `${pageName}.js`);
const wxmlPath = path.join(pageRoot, `${pageName}.wxml`);
if (!fs.existsSync(jsPath) || !fs.existsSync(wxmlPath)) return;
const js = fs.readFileSync(jsPath, "utf8");
const wxml = fs.readFileSync(wxmlPath, "utf8");
const handlers = [...wxml.matchAll(/(?:bind|catch)[a-z]+="([A-Za-z0-9_]+)"/g)]
.map((match) => match[1]);
handlers.forEach((handler) => {
assert.match(
js,
new RegExp(`\\n\\s{2}${handler}\\s*\\(`),
`${pageName}.wxml references missing handler ${handler}`
);
});
});
console.log("page contract tests passed");