forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen.ts
More file actions
33 lines (31 loc) · 1.17 KB
/
Copy pathgen.ts
File metadata and controls
33 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import path from "path";
import { REFERENCE_DOCS } from "./lib/files";
import { ReferenceDoc } from "./lib/reference-doc";
// Resolve all source/destination paths relative to the repo root so the
// pipeline behaves the same regardless of where it's invoked from.
const repoRoot = path.resolve(__dirname, "..", "..");
process.chdir(repoRoot);
// allSettled so one missing source (e.g. an SDK file that was renamed
// upstream) doesn't abort the entire pipeline — we still want every other
// reference page to land in shell-docs.
Promise.allSettled(
REFERENCE_DOCS.map(async (referenceDoc) => {
const doc = new ReferenceDoc(referenceDoc);
await doc.generate();
}),
).then((results) => {
const failures = results
.map((r, i) => ({ r, i }))
.filter(({ r }) => r.status === "rejected");
for (const { r, i } of failures) {
const reason = (r as PromiseRejectedResult).reason;
console.error(
`[gen] Failed: ${REFERENCE_DOCS[i].destinationPath}: ${
reason instanceof Error ? reason.message : String(reason)
}`,
);
}
console.log(
`All reference docs processed (${results.length - failures.length}/${results.length} succeeded)`,
);
});