mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-01-04 22:36:25 +00:00
18 lines
553 B
TypeScript
18 lines
553 B
TypeScript
import { mkdir, rm, writeFile } from 'node:fs/promises'
|
|
import { zodToJsonSchema } from 'zod-to-json-schema'
|
|
import { ConfigSchema } from '../src/config/schema/config'
|
|
|
|
const OUTPUT = './schema'
|
|
|
|
await rm(OUTPUT, { recursive: true, force: true })
|
|
await mkdir(OUTPUT, { recursive: true })
|
|
|
|
const Schemas = {
|
|
config: ConfigSchema,
|
|
}
|
|
|
|
for (const [name, schema] of Object.entries(Schemas)) {
|
|
const jsonSchema = zodToJsonSchema(schema, 'mySchema')
|
|
await writeFile(`${OUTPUT}/${name}.json`, JSON.stringify(jsonSchema, null, 2), { encoding: 'utf-8' })
|
|
}
|