iter(g30): check 链并入 demo 构建并校验产物锚点
This commit is contained in:
@@ -763,6 +763,18 @@ function checkIterations() {
|
||||
return issues;
|
||||
}
|
||||
|
||||
/*** 演示产物校验:打包后的 demo.html 必须含每个区块锚点,证明演示代码真的编进了产物(防「只改源码、产物过期」) ***/
|
||||
function checkDemoBundle(anchors) {
|
||||
const issues = [];
|
||||
const file = path.join(ROOT, 'apps', 'demo', 'dist', 'demo.html');
|
||||
if (!fs.existsSync(file)) return issues; // 卫语句:产物未构建时不判定(check 链已保证有 demo 步骤)
|
||||
const html = fs.readFileSync(file, 'utf8');
|
||||
for (const a of anchors) {
|
||||
if (!html.includes(a)) issues.push(`demo 产物缺少区块锚点 ${a},请重跑 npm run demo`);
|
||||
}
|
||||
return issues;
|
||||
}
|
||||
|
||||
/*** 清单一致性校验:组件文档块的 id / props 说明 / demo 锚点必须与代码和演示产物对齐 ***/
|
||||
function cmdVerify() {
|
||||
const issues = [];
|
||||
@@ -771,6 +783,7 @@ function cmdVerify() {
|
||||
const demoSource = fs.existsSync(demoPath) ? fs.readFileSync(demoPath, 'utf8') : '';
|
||||
const anchors = new Set(demoSource.match(/sec-[a-z0-9-]+/g) ?? []); // 已定义的区块锚点
|
||||
const tokenVars = new Set(loadTokenList().map((t) => t.cssVar)); // 令牌白名单:tokens.json 拍平结果
|
||||
if (demoSource) issues.push(...checkDemoBundle(anchors)); // 产物与源码同步校验
|
||||
if (!demoSource) console.log('verify: 未找到 apps/demo/main.ts,跳过 demo 锚点校验');
|
||||
|
||||
for (const pkg of pkgs) {
|
||||
|
||||
Reference in New Issue
Block a user