🔥 chore: 清理 Legacy 冻结校验工具链及相关残留配置

- 删除 `scripts/verify-legacy-frozen.js` 及 `scripts/legacy-freeze.json`,移除 legacy 文件冻结校验能力
- 删除 `package.json` 中 `verify:legacy` 和 `verify:legacy:update` 两个 npm scripts
- 删除 `build-static.js` 中移除 legacy HTML 文件的构建时清理逻辑
- 移除 `server.js` 中已废弃的 `/simyo-static` 路由及其兼容静态路径
- 更新 CLAUDE.md、scripts/CLAUDE.md 及两个业务模块架构文档,将"Legacy 架构"表述统一改为"原生 ES6 模块"
This commit is contained in:
Abner
2026-05-25 20:34:53 +08:00
parent 5768c0a075
commit defcea2160
9 changed files with 11 additions and 138 deletions

View File

@@ -9,6 +9,7 @@
| 时间 | 变更内容 |
|------|----------|
| 2026-05-25 | 清理 Legacy 残留措辞:删除 verify-legacy-frozen 工具链、修复 server.js 死路由 simyo-static、统一架构表述为"原生 ES6 模块" |
| 2026-05-18 | 文档清理与路径重构:移除未使用的新模块化版本,修复文档错链,精简重复文档 |
| 2026-05-03 22:11:20 | 增量扫描更新:重新扫描全仓,更新模块索引与覆盖率报告 |
| 2026-04-28 19:11:10 | 增量扫描更新:重新扫描全仓,更新模块索引与覆盖率报告 |
@@ -44,7 +45,7 @@ eSIM-Tools 是一个 JAMstack 架构的 Web 应用,为已有 Giffgaff 和 Simy
2. **Serverless 优先**: 所有后端逻辑通过 Netlify Functions 实现
3. **BFF 模式**: Edge Functions 作为 Backend-For-Frontend 代理层,注入 ACCESS_KEY 并转发请求
4. **中间件统一**: 通过 `withAuth` 中间件统一处理鉴权、CORS、验证
5. **Legacy 架构**: 前端采用 Legacy 模块化架构 (HTML + ES6 模块),通过 ES6 import 按需加载
5. **原生 ES6 模块**: 前端采用浏览器原生 ES6 模块化设计 (HTML + `<script type="module">` + `import/export`),业务页面不经 Webpack 打包,按需加载,由 Netlify 静态托管直接派发
### 部署流程
@@ -61,8 +62,8 @@ eSIM-Tools 是一个 JAMstack 架构的 Web 应用,为已有 Giffgaff 和 Simy
```mermaid
graph TD
A["eSIM-Tools (根)"] --> B["src/giffgaff (Legacy)"];
A --> C["src/simyo (Legacy)"];
A["eSIM-Tools (根)"] --> B["src/giffgaff"];
A --> C["src/simyo"];
A --> D["src/js/modules (通用工具)"];
A --> E["netlify/functions"];
A --> F["netlify/edge-functions"];
@@ -101,8 +102,8 @@ graph TD
F --> F1["bff-proxy.js"];
F --> F2["markdown-negotiation.js"];
click B "./src/giffgaff/MODULE_ARCHITECTURE.md" "查看 Giffgaff Legacy 架构文档"
click C "./src/simyo/MODULE_ARCHITECTURE.md" "查看 Simyo Legacy 架构文档"
click B "./src/giffgaff/MODULE_ARCHITECTURE.md" "查看 Giffgaff 模块架构文档"
click C "./src/simyo/MODULE_ARCHITECTURE.md" "查看 Simyo 模块架构文档"
click D "./src/js/modules/CLAUDE.md" "查看通用工具模块文档"
click E "./netlify/functions/CLAUDE.md" "查看 Functions 模块文档"
click F "./netlify/edge-functions/CLAUDE.md" "查看 Edge Functions 模块文档"
@@ -116,8 +117,8 @@ graph TD
| 模块 | 路径 | 职责 | 语言 |
|------|------|------|------|
| **Giffgaff Legacy** | `src/giffgaff/` | Giffgaff eSIM 管理流程 (OAuth/MFA/GraphQL) | JavaScript |
| **Simyo Legacy** | `src/simyo/` | Simyo eSIM 管理流程 (登录/设备更换/激活) | JavaScript |
| **Giffgaff 前端** | `src/giffgaff/` | Giffgaff eSIM 管理流程 (OAuth/MFA/GraphQL) | JavaScript (ES6 Module) |
| **Simyo 前端** | `src/simyo/` | Simyo eSIM 管理流程 (登录/设备更换/激活) | JavaScript (ES6 Module) |
| **通用工具** | `src/js/modules/` | 可复用前端工具模块 (日志/存储/安全/性能/i18n) | JavaScript |
| **Netlify Functions** | `netlify/functions/` | Serverless 后端逻辑 (11 个函数) | JavaScript (Node.js) |
| **Edge Functions** | `netlify/edge-functions/` | BFF 代理层 (密钥注入 + 请求转发 + 内容协商) | JavaScript (Deno) |

View File

@@ -17,8 +17,6 @@
"dev": "nodemon server.js",
"build": "npm run build:static",
"build:static": "node scripts/build-static.js",
"verify:legacy": "node scripts/verify-legacy-frozen.js",
"verify:legacy:update": "node scripts/verify-legacy-frozen.js --update",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",

View File

@@ -12,8 +12,7 @@
| 脚本 | 命令 | 职责 |
|------|------|------|
| `build-static.js` | `npm run build` | Webpack 打包与资源优化 |
| `verify-legacy-frozen.js` | `npm run verify:legacy` | 验证 legacy 文件未被修改 |
| `build-static.js` | `npm run build` | 静态资源复制与 dist 构建 |
| `transpile-dist-js.js` | - | dist/ JS 文件转译 |
| `inject-sentry-config.js` | - | Sentry 配置注入 |

View File

@@ -91,18 +91,6 @@ async function copyDirectory(source, destination) {
}
}
// 删除 Legacy HTML 文件(已废弃,统一使用 Modular 版本)
const legacyHtmlFiles = [
path.join(distDir, 'src', 'giffgaff', 'giffgaff_complete_esim.html'),
path.join(distDir, 'src', 'simyo', 'simyo_complete_esim.html')
];
for (const f of legacyHtmlFiles) {
if (fs.existsSync(f)) {
await fs.promises.unlink(f);
BuildLogger.log(`🗑️ 已删除 Legacy 文件: ${path.relative(projectRoot, f)}`);
}
}
BuildLogger.log('🧩 转译 dist/src 下的 JSbrowserslist 目标)...');
await transpileDistJs();

View File

@@ -1,4 +0,0 @@
{
"algorithm": "sha256",
"files": {}
}

View File

@@ -1,107 +0,0 @@
#!/usr/bin/env node
/**
* Legacy 页面冻结校验
*
* 校验 legacy-freeze.json 中声明的冻结文件是否被修改。
*
* 用法:
* - 校验默认node scripts/verify-legacy-frozen.js
* - 更新基线: node scripts/verify-legacy-frozen.js --update
*/
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const projectRoot = path.join(__dirname, '..');
const baselinePath = path.join(__dirname, 'legacy-freeze.json');
function sha256(content) {
return crypto.createHash('sha256').update(content).digest('hex');
}
function readJson(filePath) {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
}
function writeJson(filePath, value) {
fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, 'utf8');
}
function resolveProjectPath(relPath) {
return path.join(projectRoot, relPath);
}
function computeFileHash(relPath) {
const fullPath = resolveProjectPath(relPath);
if (!fs.existsSync(fullPath)) {
throw new Error(`missing file: ${relPath}`);
}
const content = fs.readFileSync(fullPath, 'utf8');
return sha256(content);
}
function main() {
const shouldUpdate = process.argv.includes('--update');
if (!fs.existsSync(baselinePath)) {
console.error(`[Legacy Freeze] ✗ 基线文件不存在: ${path.relative(projectRoot, baselinePath)}`);
process.exitCode = 1;
return;
}
const baseline = readJson(baselinePath);
const algorithm = baseline.algorithm || 'sha256';
if (algorithm !== 'sha256') {
console.error(`[Legacy Freeze] ✗ 不支持的 hash 算法: ${algorithm}`);
process.exitCode = 1;
return;
}
const fileMap = baseline.files || {};
const fileEntries = Object.entries(fileMap);
if (fileEntries.length === 0) {
console.log('[Legacy Freeze] ✓ 无 legacy 冻结文件,跳过校验');
return;
}
if (shouldUpdate) {
const next = { algorithm: 'sha256', files: {} };
for (const [relPath] of fileEntries) {
next.files[relPath] = computeFileHash(relPath);
}
writeJson(baselinePath, next);
console.log(`[Legacy Freeze] ✓ 已更新基线: ${path.relative(projectRoot, baselinePath)}`);
return;
}
let hasMismatch = false;
for (const [relPath, expected] of fileEntries) {
let actual;
try {
actual = computeFileHash(relPath);
} catch (err) {
console.error(`[Legacy Freeze] ✗ 缺失文件: ${relPath} (${err.message})`);
hasMismatch = true;
continue;
}
if (actual !== expected) {
console.error(`[Legacy Freeze] ✗ 文件已变更(冻结保护触发): ${relPath}`);
console.error(` expected: ${expected}`);
console.error(` actual: ${actual}`);
hasMismatch = true;
} else {
console.log(`[Legacy Freeze] ✓ OK: ${relPath}`);
}
}
if (hasMismatch) {
console.error('[Legacy Freeze] 解决方式如需有意更新旧页面请运行node scripts/verify-legacy-frozen.js --update');
process.exitCode = 1;
}
}
main();

View File

@@ -218,11 +218,9 @@ app.use('/api/simyo/*', (req, res) => {
const htmlRoutes = [
{ url: '/giffgaff', file: 'src/giffgaff/giffgaff_modular.html' },
{ url: '/simyo', file: 'src/simyo/simyo_modular.html' },
{ url: '/simyo-static', file: 'src/simyo/simyo_static.html' },
// 兼容静态路径访问(与 Netlify 重写保持一致)
{ url: '/src/giffgaff/giffgaff_modular.html', file: 'src/giffgaff/giffgaff_modular.html' },
{ url: '/src/simyo/simyo_modular.html', file: 'src/simyo/simyo_modular.html' },
{ url: '/src/simyo/simyo_static.html', file: 'src/simyo/simyo_static.html' },
{ url: '/', file: 'index.html' }
];

View File

@@ -1,6 +1,6 @@
# Giffgaff eSIM 工具 - 模块架构说明
> **注意**: 本文档描述的是 `src/giffgaff/` 下的 Legacy 模块架构。新的模块化架构位于 `src/js/modules/giffgaff/`,详见 `src/js/modules/giffgaff/CLAUDE.md`
> 本项目采用浏览器原生 ES6 模块HTML + `<script type="module">` + `import/export`)作为唯一前端架构。业务页面不经 Webpack 打包,由 Netlify 静态托管直接派发。本文档即描述当前生产架构
## 🏗️ 架构概览

View File

@@ -1,6 +1,6 @@
# Simyo eSIM 工具 - 模块架构说明
> **注意**: 本文档描述的是 `src/simyo/` 下的 Legacy 模块架构。
> 本项目采用浏览器原生 ES6 模块HTML + `<script type="module">` + `import/export`)作为唯一前端架构。业务页面不经 Webpack 打包,由 Netlify 静态托管直接派发。本文档即描述当前生产架构。
## 🏗️ 架构概览