From 45476f38a72e4a48dcb17619b8b34dbc1f2c0868 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Thu, 23 Jul 2026 14:53:32 +0800 Subject: [PATCH] fix: fetch-sources passes file path to parseFrontmatter (expects raw text) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Regression introduced in PR #100 (the architecture refactor). When I extracted the YAML-front-matter parser to src/lib/frontmatter.mjs, I kept its interface as `parseFrontmatter(rawText)` — but in fetch-sources.mjs I called it as `parseFrontmatter(filePath)`. The regex matched nothing, every product's `docs_repo` came back undefined, every product hit the `continue`, and `vendor/` stayed empty. CI then built with no vendor checkout, so the `softwareDocs` and `manpages` collections were empty, ~970 internal doc/manpage links went missing, and lychee reported 8 broken internal links (the README and installation hrefs that had nothing to point at). The live site deployed from this broken build. Fix: readFileSync(join(softwareDir, file), 'utf8') before calling parseFrontmatter, matching what asciidoc.ts already does through its adocLoader. Verified locally: - parseFrontmatter(readFileSync('src/content/software/rnp.md', 'utf8')) returns docs_repo + docs_ref correctly - rm -rf vendor && npm run fetch-sources clones all 3 products - npm run build: no empty-collection warnings - npm run check:links: "OK — all internal href/src targets exist" --- scripts/fetch-sources.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/fetch-sources.mjs b/scripts/fetch-sources.mjs index 5e45f87..99d20eb 100644 --- a/scripts/fetch-sources.mjs +++ b/scripts/fetch-sources.mjs @@ -12,7 +12,7 @@ * Existing vendor clones are reused (delete vendor/ to force a refresh). * Network failures are warnings, not errors — docs pages degrade gracefully. */ -import { existsSync, mkdirSync, readdirSync } from 'node:fs'; +import { existsSync, mkdirSync, readdirSync, readFileSync } from 'node:fs'; import { execFileSync } from 'node:child_process'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -35,7 +35,7 @@ function run(args, cwd) { let failures = 0; for (const file of readdirSync(softwareDir).filter((f) => f.endsWith('.md'))) { - const fm = parseFrontmatter(join(softwareDir, file)).frontMatter; + const fm = parseFrontmatter(readFileSync(join(softwareDir, file), 'utf8')).frontMatter; if (!fm.docs_repo) continue; const name = file.replace(/\.md$/, '');