【本次核心 · S6-P21】 - 族层数据:families.json + 44 份契约注入 family/familyRole/familyParams; data.json / data.js / site/details 同步。13 族 / 44 成员 / 35 独立 → 概念组件 79→48。 - 79 个 slug 全保留、集合逐一不变(铁律 5 对外承诺未破);frameworks 仍 395 文件、薄壳仍 79。 - 归族判据为契约中可核对字段(semanticTypeCandidates 重叠 / anatomy 为同一骨架子集 / 变体维度同构 / doNotInvent 显式从属声明),每族 mergeBasis 写明依据,不按名字猜。 - 实现层合并(导航族端到端切片):tools/gen-family-impl.mjs 从 5 端模板生成 TopMenu / SideMenu / MixedNavigation 共 15 文件,参数 direction=top|side|mixed; 三份 CSS md5 完全相同 = 一份样式表服务三个组件。 - 新增 tools/gen-families.mjs、tools/gen-family-impl.mjs、tools/verify-families.mjs、 tools/lib/family-model.mjs、tools/lib/family-impl/nav-menu/*.tpl。 【同时清掉此前已完成但未提交的批次】 生成物(data.json / data.js / site/sources / site/components 薄壳 / sitemap.xml / tests 报告) 跨阶段交织,无法拆成互相自洽的多个提交,故按既有批量风格合并提交: - Package:三端可 import(S5-P18)+ 发布到私有 npm 源 - Docs site:导航语言改下拉(S5-P19)、详情页代码块默认展开、中英切换完整性 - Security:生产部署链审计修复(2026-09-19)+ 线上部署 - Theme modes 日间/夜间/自动;S1-P4 data.js 瘦身;S2-P5 暗色;S2-P6 跨端一致性; S2-P7 行为断言;S2-P9 FAQ;S3-P8 RTL;S3-P9 契约缺口解释层;S4-P12 发布流程 - 补入 tools/pack-deploy.mjs、run-site-smoke.mjs、verify-*.mjs,.dockerignore、 安全审计修复与待决策项.md 【验收】 - node tools/verify-families.mjs → OK: 族层端到端一致(13 族 / 44 成员 / 79 组件不变 / 395 文件不变) - node tools/verify-cross-platform.mjs → 79/79 identical(HEAD 基线 high 44) - node tools/run-regression.mjs → 100%(79/79 页,1017/1017 断言,N/A 34),连跑 8 次一致,0 超时 - 逐页实测:topmenu / sidemenu / mixednavigation 各 13/13,帧内 direction 参数正确,0 JS 错误 - 零运行时依赖 OK;build-site.ps1 ASCII-only OK 【未纳入】site/components/<slug>/ 平台薄壳 316 个 —— 历史从未跟踪且属构建产物,保持现状。
64 lines
3.2 KiB
JavaScript
64 lines
3.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* verify-site-routing.mjs — 校验组件端入口、SPA 路由契约和 sitemap 覆盖。
|
|
* 只使用 Node 内置模块,不启动服务、不修改文件。
|
|
*/
|
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
|
|
const ROOT = process.cwd();
|
|
const SITE = join(ROOT, 'site');
|
|
const COMPONENTS = join(SITE, 'components');
|
|
const app = readFileSync(join(SITE, 'app.js'), 'utf8');
|
|
const data = JSON.parse(readFileSync(join(SITE, 'data.json'), 'utf8'));
|
|
const sitemap = readFileSync(join(ROOT, 'sitemap.xml'), 'utf8');
|
|
const platforms = ['h5', 'react', 'vue2', 'vue3'];
|
|
const failures = [];
|
|
const check = (ok, message) => { if (!ok) failures.push(message); };
|
|
|
|
const components = data.components || [];
|
|
check(components.length === 79, `expected 79 components, got ${components.length}`);
|
|
check(app.includes("(?:\\/([a-z0-9-]+))?"), 'SPA platform route parser is missing');
|
|
check(app.includes("PLATFORM_KINDS = { h5: 'html', react: 'jsx', vue2: 'vue2', vue3: 'vue3' }"), 'platform kind map is missing');
|
|
check(app.includes("a.href = componentPageHref(c, platform)"), 'other-platform links do not use component pages');
|
|
|
|
let shellCount = 0;
|
|
for (const component of components) {
|
|
const slug = component.slug;
|
|
const legacy = join(COMPONENTS, `${slug}.html`);
|
|
check(existsSync(legacy), `missing legacy shell: ${slug}.html`);
|
|
if (existsSync(legacy)) {
|
|
const legacyText = readFileSync(legacy, 'utf8');
|
|
check(!legacyText.includes('aurora-admin/"site/components'), `legacy canonical is malformed: ${slug}`);
|
|
}
|
|
for (const platform of platforms) {
|
|
const shell = join(COMPONENTS, slug, `${platform}.html`);
|
|
shellCount += 1;
|
|
check(existsSync(shell), `missing platform shell: ${slug}/${platform}.html`);
|
|
if (!existsSync(shell)) continue;
|
|
const text = readFileSync(shell, 'utf8');
|
|
check(text.includes(`#/component/${slug}/${platform}`), `wrong route target: ${slug}/${platform}`);
|
|
check(text.includes(`/site/components/${slug}/${platform}.html`), `wrong canonical: ${slug}/${platform}`);
|
|
check(!text.includes('aurora-admin/"site/components'), `malformed canonical: ${slug}/${platform}`);
|
|
}
|
|
}
|
|
|
|
const urlCount = (sitemap.match(/<url><loc>/g) || []).length;
|
|
check(urlCount === 1 + components.length * (1 + platforms.length), `sitemap URL count is ${urlCount}, expected ${1 + components.length * (1 + platforms.length)}`);
|
|
check(sitemap.includes('<loc>https://YOUR-ACCOUNT.github.io/aurora-admin/site/index.html</loc>'), 'site index is missing from sitemap');
|
|
|
|
const dirs = readdirSync(COMPONENTS).filter((name) => {
|
|
const path = join(COMPONENTS, name);
|
|
return existsSync(path) && statSync(path).isDirectory();
|
|
});
|
|
check(dirs.length === components.length, `platform shell directories are ${dirs.length}, expected ${components.length}`);
|
|
check(shellCount === components.length * platforms.length, `platform shell count is ${shellCount}`);
|
|
|
|
if (failures.length) {
|
|
console.error(`[routing] FAIL (${failures.length})`);
|
|
failures.forEach((failure) => console.error(`- ${failure}`));
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`[routing] OK: ${components.length} components / ${shellCount} platform shells / ${urlCount} sitemap URLs`);
|