Commit 71458166
| SHA | 71458166108ab805e8924f851953489f0c00d989 |
|---|---|
| Author | Mohamed Bassem <me at mbassem dot com> |
| Author Date | 2025-07-06 23:01 +0000 |
| Committer | Mohamed Bassem <me at mbassem dot com> |
| Commit Date | 2025-07-06 23:01 +0000 |
| Parent(s) | 0eeefd686f2d (diff) |
| Tree | a1da0708db17 |
build: Add an open-api husky check
| File | + | - | Graph | |
|---|---|---|---|---|
| M | .husky/pre-commit | +1 | -0 |
|
| M | packages/open-api/index.ts | +17 | -1 |
|
| M | packages/open-api/package.json | +1 | -0 |
|
3 file(s) changed, 19 insertions(+), 1 deletions(-)
.husky/pre-commit
diff --git a/.husky/pre-commit b/.husky/pre-commit index 5a448e3b..eb3cb0a2 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,3 +2,4 @@ pnpm typecheck pnpm format --check pnpm lint pnpm exec sherif +pnpm run --filter @karakeep/open-api check
packages/open-api/index.ts
diff --git a/packages/open-api/index.ts b/packages/open-api/index.ts index 06fbc913..057a823f 100644 --- a/packages/open-api/index.ts +++ b/packages/open-api/index.ts @@ -1,4 +1,5 @@ import * as fs from "fs"; +import * as process from "process"; import { OpenApiGeneratorV3, OpenAPIRegistry, @@ -54,4 +55,19 @@ function writeDocumentation() { }); } -writeDocumentation(); +function checkDocumentation() { + const docs = getOpenApiDocumentation(); + const fileContent = JSON.stringify(docs, null, 2); + const oldContent = fs.readFileSync(`./karakeep-openapi-spec.json`, { + encoding: "utf-8", + }); + if (oldContent !== fileContent) { + process.exit(1); + } +} + +if (process.argv[2] === "check") { + checkDocumentation(); +} else { + writeDocumentation(); +}
packages/open-api/package.json
diff --git a/packages/open-api/package.json b/packages/open-api/package.json index d88543a9..a2a20ef7 100644 --- a/packages/open-api/package.json +++ b/packages/open-api/package.json @@ -16,6 +16,7 @@ }, "scripts": { "typecheck": "tsc --noEmit", + "check": "tsx index.ts check", "generate": "tsx index.ts", "format": "prettier . --ignore-path ../../.prettierignore", "format:fix": "prettier . --write --ignore-path ../../.prettierignore",