import fs from "node:fs"; import path from "node:path"; import { REPO_ROOT } from "./deployed"; /** * The user manual is the coverage yardstick for this suite: every chapter has * objectives and `checks`, but no selectors, so it is used for grouping and * acceptance wording, not executed as a script. */ export interface ChapterInfo { id: string; number: number; title: string; part: string; workspace: string; checks: string[]; } interface ManualChapter { id: string; number: number; title: string; workspace: string; checks?: string[] } interface ManualPart { id: string; title: string; chapterIds: string[] } interface Manual { chapters: ManualChapter[]; parts: ManualPart[] } const MANUAL_PATH = path.join(REPO_ROOT, "user-manual/WEB_Blender_Web_Manual_20261113/manual.json"); function load(): ChapterInfo[] { if (!fs.existsSync(MANUAL_PATH)) throw new Error(`user manual not found: ${MANUAL_PATH}`); const manual = JSON.parse(fs.readFileSync(MANUAL_PATH, "utf8")) as Manual; const partOf = new Map(); for (const part of manual.parts) for (const id of part.chapterIds) partOf.set(id, part.title); return manual.chapters.map((chapter) => ({ id: chapter.id, number: chapter.number, title: chapter.title, part: partOf.get(chapter.id) ?? "", workspace: chapter.workspace, checks: chapter.checks ?? [], })); } export const CHAPTERS: ChapterInfo[] = load(); export function chapter(id: string): ChapterInfo { const found = CHAPTERS.find((item) => item.id === id); if (!found) throw new Error(`manual chapter not found: ${id}`); return found; }