c30613c8d4
Update scripts/docs to write directly into showcase/shell-docs/src/content/reference/ (consumed by /reference/[...slug]) instead of the legacy docs/content/docs tree. Adds repo-root cwd anchoring, mkdir -p on the destination, allSettled so a single missing source doesn't abort the run; generates 25 MDX pages (20 V1 + 5 SDK) and shell-docs build passes.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
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)`,
|
|
);
|
|
});
|