fix(ST-1359): docs-index generator hardenen + dode INDEX-link weg (#204)
* fix(ST-1359): docs-index generator indexeert alleen git-tracked bestanden scripts/generate-docs-index.mjs walkte de docs/-map op schijf en indexeerde elk .md-bestand — ook ongetrackte scratch-bestanden. Daardoor kon een tijdelijk review-bestand van een Claude-worktree-sessie een link in de gegenereerde INDEX.md krijgen die dood achterbleef nadat de worktree was opgeruimd. Vervangen door een `git ls-files -z docs`-listing: alleen getrackte (en gestagede) .md-bestanden komen nog in de index. EXCLUDE_PATTERNS en de archived-filter blijven ongewijzigd erbovenop werken; git ls-files is recursief en werkt correct binnen git-worktrees. Verificatie: npm run lint groen; regressietest met een ongetrackt docs/-bestand bevestigt dat het niet meer in INDEX.md belandt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(ST-1359): regenereer INDEX.md — verwijder dode reviews-link npm run docs:check-links faalde op een dode link naar docs/reviews/onderzoek-wat-er-gedaan-quirky-mist-review.md — een review-bestand dat nooit in git is gecommit. INDEX.md is geregenereerd met de geharde generator uit de vorige commit; de stale regel valt daardoor vanzelf weg (1 regel verwijderd, verder geen wijzigingen). Verificatie: npm run docs → docs:check-links ✓ All doc links valid (119 files checked). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ff22196714
commit
b6bad83319
2 changed files with 18 additions and 16 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
// Generate docs/INDEX.md from the front-matter and headings of every
|
||||
// .md file under docs/. Pure Node 20 — no external dependencies.
|
||||
// git-tracked .md file under docs/. No external npm dependencies — shells
|
||||
// out to `git ls-files` so untracked scratch files never pollute the index.
|
||||
//
|
||||
// Usage: `npm run docs:index` (or `node scripts/generate-docs-index.mjs`).
|
||||
//
|
||||
|
|
@ -8,9 +9,10 @@
|
|||
// output (apart from the generation date in the header), so the script
|
||||
// is safe to run repeatedly and in pre-commit hooks.
|
||||
|
||||
import { readdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import { readFile, writeFile } from 'node:fs/promises';
|
||||
import { join, relative, basename, sep } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
const SCRIPT_DIR = fileURLToPath(new URL('.', import.meta.url));
|
||||
const REPO_ROOT = join(SCRIPT_DIR, '..');
|
||||
|
|
@ -28,18 +30,19 @@ const EXCLUDE_PATTERNS = [
|
|||
/^docs\/old\//,
|
||||
];
|
||||
|
||||
async function walk(dir) {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
const files = [];
|
||||
for (const e of entries) {
|
||||
const full = join(dir, e.name);
|
||||
if (e.isDirectory()) {
|
||||
files.push(...(await walk(full)));
|
||||
} else if (e.isFile() && e.name.endsWith('.md')) {
|
||||
files.push(full);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
// List git-tracked (and staged) .md files under docs/ via `git ls-files`
|
||||
// rather than walking the filesystem — this keeps untracked scratch files
|
||||
// out of the index. Paths return repo-root-relative and forward-slashed,
|
||||
// and the call works correctly inside git worktrees.
|
||||
function trackedDocsFiles() {
|
||||
const out = execFileSync('git', ['ls-files', '-z', 'docs'], {
|
||||
cwd: REPO_ROOT,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
return out
|
||||
.split('\0')
|
||||
.filter((p) => p.endsWith('.md'))
|
||||
.map((p) => join(REPO_ROOT, p));
|
||||
}
|
||||
|
||||
// Minimal YAML front-matter parser. Front-matter in this repo is restricted
|
||||
|
|
@ -113,7 +116,7 @@ function escapePipe(s) {
|
|||
}
|
||||
|
||||
async function main() {
|
||||
const files = await walk(DOCS_DIR);
|
||||
const files = trackedDocsFiles();
|
||||
const docs = [];
|
||||
|
||||
for (const full of files) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue