mirror of
https://github.com/zadam/trilium.git
synced 2026-03-09 18:03:42 +01:00
This enhances the `build-docs` utility to allow running it via pnpm and packaging it as a Nix application. Changes include: - Added `build` and `cli` scripts to `apps/build-docs/package.json`. - Implemented a standalone CLI wrapper for documentation generation. - Added a `trilium-build-docs` package to the Nix flake for use in other projects. - Integrated `apps/build-docs` into the Nix workspace and build pipeline. These changes make the documentation build process more portable and easier to integrate into CI/CD pipelines outside of the main repository.
37 lines
972 B
TypeScript
37 lines
972 B
TypeScript
import { execSync } from "child_process";
|
|
import { mkdirSync } from "fs";
|
|
import { join } from "path";
|
|
|
|
import BuildContext from "./context";
|
|
|
|
interface BuildInfo {
|
|
specPath: string;
|
|
outDir: string;
|
|
}
|
|
|
|
const DIR_PREFIX = "rest-api";
|
|
|
|
const buildInfos: BuildInfo[] = [
|
|
{
|
|
// Paths are relative to Git root.
|
|
specPath: "apps/server/internal.openapi.yaml",
|
|
outDir: `${DIR_PREFIX}/internal`
|
|
},
|
|
{
|
|
specPath: "apps/server/etapi.openapi.yaml",
|
|
outDir: `${DIR_PREFIX}/etapi`
|
|
}
|
|
];
|
|
|
|
export default function buildSwagger({ baseDir, gitRootDir }: BuildContext) {
|
|
for (const { specPath, outDir } of buildInfos) {
|
|
const absSpecPath = join(gitRootDir, specPath);
|
|
const targetDir = join(baseDir, outDir);
|
|
mkdirSync(targetDir, { recursive: true });
|
|
execSync(
|
|
`pnpm redocly build-docs ${absSpecPath} -o ${targetDir}/index.html`,
|
|
{ stdio: "inherit" }
|
|
);
|
|
}
|
|
}
|