Skip to content

Commit 41df112

Browse files
committed
fix(docs): make link-check a cached task that depends on gen:docs
The docs link-check previously ran as a package.json script: vp run -w gen && node validate-links.mjs Script caching (cache.scripts) only caches stdout; it does not archive or restore files produced by a script. The generated example pages live under docs/content/examples/** (written by the dev-scripts gen:docs task), so on a cache-replay of the gen script those files were not restored, and validate-links raced ahead reading a stale/empty content/examples dir -> '13 errors / not-found' for every /examples link. Define docs#test as a Vite Task that dependsOn @blocknote/dev-scripts#gen:docs instead. Task output archiving restores docs/content/examples/** on a cache hit, and the task graph guarantees gen:docs fully completes before validation runs. Verified locally: deleting the generated dirs and re-running 'vp run test' restores the files on cache hit and reports '0 errored file, 0 errors'.
1 parent 8010e65 commit 41df112

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

docs/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"types:check": "fumadocs-mdx && next typegen && tsc --noEmit",
1313
"postinstall": "fumadocs-mdx",
1414
"lint": "vp lint",
15-
"init-db": "pnpx @better-auth/cli migrate",
16-
"test": "vp run -w gen && node validate-links.mjs"
15+
"init-db": "pnpx @better-auth/cli migrate"
1716
},
1817
"dependencies": {
1918
"@ai-sdk/groq": "^3.0.2",

docs/vite.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from "vite-plus";
2+
3+
export default defineConfig({
4+
run: {
5+
tasks: {
6+
// Validate that all `/examples/...` (and other) links referenced in the
7+
// docs resolve to a real page. The example pages under
8+
// `content/examples/**` are generated by the dev-scripts `gen:docs`
9+
// task, so we depend on it here. Declaring the dependency as a task
10+
// (instead of chaining `vp run gen && node validate-links.mjs` as a
11+
// package.json script) lets Vite Task's caching archive & restore the
12+
// generated files: on a cache hit the example pages are restored before
13+
// this task runs, and on a fresh run the dependency fully completes
14+
// before validation starts. This avoids a race where validate-links ran
15+
// before `gen:docs` finished writing `docs/content/examples/**`.
16+
test: {
17+
command: "node validate-links.mjs",
18+
dependsOn: ["@blocknote/dev-scripts#gen:docs"],
19+
},
20+
},
21+
},
22+
});

0 commit comments

Comments
 (0)