mirror of
https://github.com/Hmbown/DeepSeek-TUI.git
synced 2026-09-03 06:50:13 +08:00
web(i18n): one-way ceiling on isZh branching (#5805)
The isZh migration was losing ground (12 -> 31 files over 90 days at filing; 28 today outside web/lib/i18n). Count the files that still branch on isZh outside the migration home and fail web CI if the number grows. Migrating branches lowers the count; then ratchet the CEILING. Signed-off-by: CodeWhale Bot <bot@codewhale.net> Co-authored-by: CodeWhale Bot <bot@codewhale.net>
This commit is contained in:
38
web/lib/i18n/iszh-ceiling.test.ts
Normal file
38
web/lib/i18n/iszh-ceiling.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readdirSync, readFileSync, statSync } from "node:fs";
|
||||
import { join, relative } from "node:path";
|
||||
|
||||
const ROOT = process.cwd();
|
||||
const MIGRATION_HOME = join("lib", "i18n");
|
||||
// One-way ceiling (#5519): the isZh migration converges or holds, never
|
||||
// regresses. To lower the number: migrate branches into lib/i18n, then set
|
||||
// CEILING to the new count reported by this test.
|
||||
const CEILING = 28;
|
||||
|
||||
function walk(dir: string, out: string[] = []): string[] {
|
||||
for (const entry of readdirSync(dir)) {
|
||||
if (entry === "node_modules" || entry === ".next" || entry === ".git") continue;
|
||||
const full = join(dir, entry);
|
||||
if (statSync(full).isDirectory()) walk(full, out);
|
||||
else if (/\.[jt]sx?$/.test(entry)) out.push(full);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
describe("isZh one-way ceiling (#5519)", () => {
|
||||
it(`keeps isZh branching outside ${MIGRATION_HOME} at <= ${CEILING} files`, () => {
|
||||
const offenders = walk(ROOT)
|
||||
.map((file) => relative(ROOT, file))
|
||||
.filter(
|
||||
(file) =>
|
||||
!file.startsWith(MIGRATION_HOME) &&
|
||||
!/\.test\.[jt]sx?$/.test(file) &&
|
||||
readFileSync(join(ROOT, file), "utf8").includes("isZh"),
|
||||
)
|
||||
.sort();
|
||||
expect(
|
||||
offenders.length,
|
||||
`isZh branching outside ${MIGRATION_HOME} (migrate, then lower the CEILING):\n${offenders.join("\n")}`,
|
||||
).toBeLessThanOrEqual(CEILING);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user