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) {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"docs": {
|
||||
"intro": "工程层工具包(private,不发布)。所有 Agent 与人都通过它读取组件库:清单驱动索引、文档、MCP 三件套,外加 style / verify 两道门禁。",
|
||||
"steps": [
|
||||
"装好依赖后先跑 npm run check 确认基线全绿(build → style → typecheck → smoke → index → verify)",
|
||||
"装好依赖后先跑 npm run check 确认基线全绿(build → demo → style → typecheck → smoke → index → verify)",
|
||||
"查组件:ua list 看全量,ua info <包名> 看单包 api 与约定",
|
||||
"查令牌:ua tokens 打印全部 --ua-* 变量(颜色带暗色值),--json 输出结构化数组;写样式前先查,禁止硬编码",
|
||||
"改完清单跑 npm run docs:同时刷新人类文档站与 llms-full.txt(Agent 首选喂料)",
|
||||
|
||||
Reference in New Issue
Block a user