From 7c19af307e4d89949450f829118c3c93c0374072 Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Wed, 23 Sep 2026 11:44:37 +0200 Subject: [PATCH] fix(build): reuse committed docs snapshot when docs/ is outside context Script resolved paths from repo root; inside the frontend Docker build (context = app/frontend) it scanned /docs and died on ENOENT, breaking the compose smoke job. Resolve from the frontend dir and fall back to the committed snapshot when the docs tree is absent. Authored By: TDvorak Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../scripts/generate-docs-snapshot.mjs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/frontend/scripts/generate-docs-snapshot.mjs b/app/frontend/scripts/generate-docs-snapshot.mjs index 6534cee..766fa4c 100644 --- a/app/frontend/scripts/generate-docs-snapshot.mjs +++ b/app/frontend/scripts/generate-docs-snapshot.mjs @@ -1,13 +1,26 @@ // Bundles the repository docs/ tree into a generated TS module so the docs // browser renders instantly and offline. The GitHub sync layer refreshes it // at runtime when network is available. -import { readdirSync, readFileSync, statSync, writeFileSync, mkdirSync } from 'node:fs'; +import { existsSync, readdirSync, readFileSync, statSync, writeFileSync, mkdirSync } from 'node:fs'; import { join, relative } from 'node:path'; import { fileURLToPath } from 'node:url'; -const root = join(fileURLToPath(new URL('.', import.meta.url)), '..', '..', '..'); +const frontendRoot = join(fileURLToPath(new URL('.', import.meta.url)), '..'); +const root = join(frontendRoot, '..', '..'); const docsDir = join(root, 'docs'); -const outFile = join(root, 'app/frontend/src/generated/docs-snapshot.ts'); +const outFile = join(frontendRoot, 'src/generated/docs-snapshot.ts'); + +// The published frontend image builds with only app/frontend as its Docker +// context, so the repo docs tree is absent there — reuse the committed +// snapshot instead of failing on ENOENT. +if (!existsSync(docsDir)) { + if (!existsSync(outFile)) { + console.error('docs snapshot: docs/ missing and no committed snapshot to reuse'); + process.exit(1); + } + console.warn('docs snapshot: docs/ not found, reusing committed snapshot'); + process.exit(0); +} // Directories that are internal working notes rather than user documentation. const SKIP_DIRS = new Set(['archive', 'design', 'superpowers']);