Skip to content

Commit bd765cc

Browse files
chore(release): verify generated docs
1 parent 4447e1f commit bd765cc

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"test:ci": "jest --ci --runInBand",
7979
"test:watch": "jest --watch",
8080
"test:coverage": "jest --coverage",
81+
"check:docs": "node scripts/check-docs.mjs",
8182
"check:package": "node scripts/check-package.mjs",
8283
"prepare": "husky install",
8384
"prepublishOnly": "npm run build"

‎scripts/check-docs.mjs‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { spawnSync } from 'node:child_process';
2+
import { dirname, resolve } from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
6+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
7+
8+
const build = spawnSync(npm, ['run', 'build:playground'], {
9+
cwd: root,
10+
stdio: 'inherit',
11+
});
12+
13+
if (build.status !== 0) {
14+
process.exit(build.status ?? 1);
15+
}
16+
17+
const status = spawnSync(
18+
'git',
19+
['status', '--porcelain=v1', '--untracked-files=all', '--', 'docs'],
20+
{ cwd: root, encoding: 'utf8' },
21+
);
22+
23+
if (status.status !== 0) {
24+
process.stderr.write(status.stderr || 'Unable to inspect generated docs.\n');
25+
process.exit(status.status ?? 1);
26+
}
27+
28+
if (status.stdout.trim()) {
29+
console.error('\nGenerated docs are out of date:');
30+
console.error(status.stdout.trimEnd());
31+
console.error('\nReview and commit the regenerated docs before releasing.');
32+
process.exit(1);
33+
}
34+
35+
console.log('Verified that generated docs match the committed playground sources.');

0 commit comments

Comments
 (0)