Skip to content

Commit 4eaca6f

Browse files
committed
improve: pr test workflow + chore: cleanup docs.json
1 parent 9670c39 commit 4eaca6f

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

sdk-reference-generator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "module",
55
"scripts": {
66
"generate": "tsx src/cli.ts",
7+
"rebuild-docs-json": "tsx src/rebuild-docs-json.ts",
78
"test": "vitest run",
89
"test:watch": "vitest"
910
},
@@ -26,4 +27,3 @@
2627
"vitest": "^2.1.8"
2728
}
2829
}
29-
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env node
2+
3+
import path from "path";
4+
import { fileURLToPath } from "url";
5+
import { buildNavigation, mergeNavigation } from "./navigation.js";
6+
import { verifyGeneratedDocs } from "./lib/verify.js";
7+
import { log } from "./lib/log.js";
8+
9+
const __filename = fileURLToPath(import.meta.url);
10+
const __dirname = path.dirname(__filename);
11+
12+
const SCRIPT_DIR = path.resolve(__dirname, "..");
13+
const DOCS_DIR = path.resolve(SCRIPT_DIR, "..");
14+
15+
async function main(): Promise<void> {
16+
log.header("Rebuild docs.json from local SDK references");
17+
18+
log.section("Building navigation");
19+
const navigation = await buildNavigation(DOCS_DIR);
20+
21+
if (navigation.length === 0) {
22+
log.warn("No SDK references found locally");
23+
process.exit(1);
24+
}
25+
26+
log.blank();
27+
log.section("Merging into docs.json");
28+
await mergeNavigation(navigation, DOCS_DIR);
29+
30+
log.blank();
31+
log.section("Verifying documentation");
32+
const verification = await verifyGeneratedDocs(DOCS_DIR);
33+
34+
if (verification.warnings.length > 0) {
35+
log.warn("Warnings detected:");
36+
for (const warning of verification.warnings) {
37+
log.data(`- ${warning}`, 1);
38+
}
39+
}
40+
41+
if (!verification.valid) {
42+
log.blank();
43+
log.error("Verification failed:");
44+
for (const error of verification.errors) {
45+
log.data(`- ${error}`, 1);
46+
}
47+
if (!verification.docsJsonValid) {
48+
log.error("docs.json validation failed");
49+
}
50+
process.exit(1);
51+
}
52+
53+
log.blank();
54+
log.success("docs.json rebuilt successfully");
55+
log.stats(
56+
[
57+
{ label: "Total SDKs", value: verification.stats.totalSDKs },
58+
{ label: "Total versions", value: verification.stats.totalVersions },
59+
{ label: "Total MDX files", value: verification.stats.totalMdxFiles },
60+
],
61+
0
62+
);
63+
}
64+
65+
main().catch((error) => {
66+
log.error(`Fatal error: ${error.message}`);
67+
process.exit(1);
68+
});

0 commit comments

Comments
 (0)