-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-docs.mjs
More file actions
77 lines (67 loc) · 2.22 KB
/
Copy pathcheck-docs.mjs
File metadata and controls
77 lines (67 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { readFileSync, existsSync } from 'node:fs';
import { resolve } from 'node:path';
import process from 'node:process';
const root = resolve(import.meta.dirname, '..');
const failures = [];
const read = (path) => readFileSync(resolve(root, path), 'utf8');
const required = [
'AGENTS.md',
'README.md',
'CONTRIBUTING.md',
'SECURITY.md',
'docs/CODEX_ALIGNMENT_PLAN.md',
'docs/quickstart.md',
'docs/security-model.md',
];
for (const path of required) {
if (!existsSync(resolve(root, path))) failures.push(`missing required document: ${path}`);
}
const currentDocs = [
'README.md',
'CONTRIBUTING.md',
'packages/core/README.md',
'docs/quickstart.md',
];
const staleCount = /(?:tests[- ]|测试[::]?\s*|测试\s+)[0-9]{2,}\s*(?:passing|passed|个测试通过)?/i;
for (const path of currentDocs) {
const body = read(path);
if (staleCount.test(body)) failures.push(`${path}: hard-codes a test count; link to CI instead`);
}
for (const path of currentDocs) {
if (/Electron Mac client|Electron \+ React|electron-builder/.test(read(path))) {
failures.push(`${path}: documents the retired Electron desktop stack`);
}
}
const historical = [
'MORNING_REPORT.md',
'docs/HANDOFF.md',
'docs/BEHAVIOR_PARITY.md',
'docs/DEVELOPMENT_PLAN.md',
];
for (const path of historical) {
const firstLines = read(path).split('\n').slice(0, 12).join('\n');
if (!firstLines.includes('历史快照')) {
failures.push(`${path}: legacy status document must be marked as 历史快照 near the top`);
}
}
const rootTsconfig = JSON.parse(read('tsconfig.json'));
const refs = new Set((rootTsconfig.references ?? []).map((entry) => entry.path));
for (const path of [
'./packages/core',
'./packages/shared-ui',
'./apps/cli',
'./apps/desktop',
'./apps/lsp',
'./apps/vscode',
]) {
if (!refs.has(path)) failures.push(`tsconfig.json: missing workspace reference ${path}`);
}
if (!read('CONTRIBUTING.md').includes('Node.js ≥ 22')) {
failures.push('CONTRIBUTING.md: Node requirement must match package.json (>=22)');
}
if (failures.length > 0) {
process.stderr.write(`${failures.map((failure) => `- ${failure}`).join('\n')}\n`);
process.exitCode = 1;
} else {
process.stdout.write('Documentation consistency checks passed.\n');
}