mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
feat: add cli command to export configs as json schema
This commit is contained in:
parent
b0a9cf1bcd
commit
b83f388096
4 changed files with 42 additions and 5 deletions
24
backend/src/exportSchemas.ts
Normal file
24
backend/src/exportSchemas.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { z } from "zod";
|
||||
import { guildPlugins } from "./plugins/availablePlugins";
|
||||
import zodToJsonSchema from "zod-to-json-schema";
|
||||
import { zZeppelinGuildConfig } from "./types";
|
||||
|
||||
const pluginSchemaMap = guildPlugins.reduce((map, plugin) => {
|
||||
if (! plugin.info) {
|
||||
return map;
|
||||
}
|
||||
map[plugin.name] = plugin.info.configSchema;
|
||||
return map;
|
||||
}, {});
|
||||
|
||||
const fullSchema = zZeppelinGuildConfig
|
||||
.omit({ plugins: true })
|
||||
.merge(z.strictObject({
|
||||
plugins: z.strictObject(pluginSchemaMap).partial(),
|
||||
}));
|
||||
|
||||
const jsonSchema = zodToJsonSchema(fullSchema);
|
||||
|
||||
console.log(JSON.stringify(jsonSchema, null, 2));
|
||||
|
||||
process.exit(0);
|
Loading…
Add table
Add a link
Reference in a new issue