refactor(build-docs): integrate with original build-docs script

This commit is contained in:
Elian Doran
2025-11-01 20:37:03 +02:00
parent ecf12a4063
commit 6e06d7169f
6 changed files with 40 additions and 32 deletions

View File

@@ -10,19 +10,21 @@ interface BuildInfo {
const buildInfos: BuildInfo[] = [
{
specPath: join(__dirname, "../../server/src/assets/api-openapi.yaml"),
// Paths are relative to Git root.
specPath: "apps/server/src/assets/api-openapi.yaml",
outDir: "api/internal"
},
{
specPath: join(__dirname, "../../server/src/assets/etapi.openapi.yaml"),
specPath: "apps/server/src/assets/etapi.openapi.yaml",
outDir: "api/etapi"
}
];
export default function buildSwagger({ baseDir }: BuildContext) {
export default function buildSwagger({ baseDir, gitRootDir }: BuildContext) {
for (const { specPath, outDir } of buildInfos) {
const absSpecPath = join(gitRootDir, specPath);
const targetDir = join(baseDir, outDir);
mkdirSync(outDir, { recursive: true });
execSync(`pnpm redocly build-docs ${specPath} -o ${targetDir}/index.html`, { stdio: "inherit" });
execSync(`pnpm redocly build-docs ${absSpecPath} -o ${targetDir}/index.html`, { stdio: "inherit" });
}
}