feat(i18n): ④ l10n 漂移闸 + codegen 改纯 node 确定性输出
- gen_l10n_dart.mjs 去掉 dart format:其输出依赖包解析状态、跨环境不稳(首次 4 空格、 重跑 8 空格),会让漂移闸误报。改为确定性终态格式(list 单行 const [])。 analyze 不校验格式,不影响;gen 现零 dart 依赖、纯 node 确定。 - ci/check-codegen-drift.sh 增 l10n 段:重生成 strings_*.dart → git diff 非空即 fail (与 token 段同法,纯 node)。 - 验证:往返无损、重生成零 diff(闸稳定)、flutter analyze 0 issue、244 测试全绿。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A79VtQA1BwTuQN1ThpvYpo
This commit is contained in:
@@ -7,12 +7,14 @@
|
||||
// AppLangLabel / AppLangMisc 逻辑)。Dart 编译器强制 concrete⊆abstract 兜底漂移。
|
||||
//
|
||||
// 用法:node design/codegen/gen_l10n_dart.mjs
|
||||
// 生成后自动 `dart format`,保证 CI「重生成零 diff」闸稳定(漂移闸 = 重生成 + git diff)。
|
||||
// 输出为确定性终态格式,不跑 dart format(其结果依赖包解析状态、跨环境不稳,
|
||||
// 会让漂移闸误报)。漂移闸 = 纯 node 重生成 + git diff,无 dart 依赖。
|
||||
// analyze 不校验格式,故手控格式即可;若单独启用 `dart format --set-exit-if-changed`,
|
||||
// 需让本文件输出与之对齐(当前未启用)。
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import url from 'node:url';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..', '..');
|
||||
const SRC = path.join(ROOT, 'design/i18n/strings.json');
|
||||
@@ -72,12 +74,5 @@ for (const lang of LANGS) {
|
||||
fs.writeFileSync(out, genFile(lang));
|
||||
written.push(out);
|
||||
}
|
||||
|
||||
// dart format 定型,保证零 diff 闸稳定
|
||||
try {
|
||||
execFileSync('dart', ['format', ...written], { cwd: ROOT, stdio: 'inherit' });
|
||||
} catch (e) {
|
||||
console.warn('⚠ dart format 失败(dart 不在 PATH?),已生成未格式化文件:', e.message);
|
||||
}
|
||||
const g = Object.keys(getters).length, l = Object.keys(lists).length, me = Object.keys(methods).length;
|
||||
console.log(`✓ 生成 ${written.length} 份:getters=${g} lists=${l} methods=${me} × ${LANGS.length} 语`);
|
||||
|
||||
Reference in New Issue
Block a user