summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-07-09 11:25:58 -0400
committerDax Raad <[email protected]>2025-07-09 11:25:58 -0400
commit5c626e0a2fb787798363284ee6af8f6c68b41f58 (patch)
treea2f6dc87ee9a0844c3f9317f58055e8857d0ff1c
parent8e9e3832198b9a575bdb7bb9f23eb45cf73ed199 (diff)
downloadopencode-5c626e0a2fb787798363284ee6af8f6c68b41f58.tar.gz
opencode-5c626e0a2fb787798363284ee6af8f6c68b41f58.zip
ci: generate config schema as part of build
-rwxr-xr-xpackages/opencode/script/schema.ts4
-rw-r--r--packages/web/astro.config.mjs15
2 files changed, 18 insertions, 1 deletions
diff --git a/packages/opencode/script/schema.ts b/packages/opencode/script/schema.ts
index 4aa1d9823..008c168cb 100755
--- a/packages/opencode/script/schema.ts
+++ b/packages/opencode/script/schema.ts
@@ -4,6 +4,8 @@ import "zod-openapi/extend"
import { Config } from "../src/config/config"
import { zodToJsonSchema } from "zod-to-json-schema"
+const file = process.argv[2]
+
const result = zodToJsonSchema(Config.Info, {
/**
* We'll use the `default` values of the field as the only value in `examples`.
@@ -30,4 +32,4 @@ const result = zodToJsonSchema(Config.Info, {
return jsonSchema
},
})
-await Bun.write("config.schema.json", JSON.stringify(result, null, 2))
+await Bun.write(file, JSON.stringify(result, null, 2))
diff --git a/packages/web/astro.config.mjs b/packages/web/astro.config.mjs
index aea32caec..38a339c74 100644
--- a/packages/web/astro.config.mjs
+++ b/packages/web/astro.config.mjs
@@ -7,6 +7,7 @@ import theme from "toolbeam-docs-theme"
import config from "./config.mjs"
import { rehypeHeadingIds } from "@astrojs/markdown-remark"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
+import { spawnSync } from "child_process"
const github = "https://github.com/sst/opencode"
@@ -26,7 +27,9 @@ export default defineConfig({
markdown: {
rehypePlugins: [rehypeHeadingIds, [rehypeAutolinkHeadings, { behavior: "wrap" }]],
},
+ build: {},
integrations: [
+ configSchema(),
solidJs(),
starlight({
title: "opencode",
@@ -83,3 +86,15 @@ export default defineConfig({
"/discord": "https://discord.com/invite/opencode",
},
})
+
+function configSchema() {
+ return {
+ name: "configSchema",
+ hooks: {
+ "astro:build:done": async () => {
+ console.log("generating config schema")
+ spawnSync("../opencode/script/schema.ts", ["./dist/config.json"])
+ },
+ },
+ }
+}