mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-22 01:53:27 +00:00
21 lines
720 B
TypeScript
21 lines
720 B
TypeScript
import { OpenApi } from "effect/unstable/httpapi"
|
|
import { format } from "prettier"
|
|
import { fileURLToPath } from "url"
|
|
import { ClientApi } from "../src/client.js"
|
|
import { stabilizeOpenApi } from "./openapi-stabilize.js"
|
|
|
|
const document = await format(JSON.stringify(stabilizeOpenApi(OpenApi.fromApi(ClientApi)), null, 2), {
|
|
parser: "json",
|
|
printWidth: 120,
|
|
})
|
|
const target = fileURLToPath(new URL("../openapi.json", import.meta.url))
|
|
|
|
if (process.argv.includes("--check")) {
|
|
if ((await Bun.file(target).text()) !== document) {
|
|
console.error("Generated OpenAPI document is stale. Run `bun run generate` from packages/protocol.")
|
|
process.exit(1)
|
|
}
|
|
process.exit(0)
|
|
}
|
|
|
|
await Bun.write(target, document)
|