mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-06 18:40:40 +00:00
initial 2 commit
This commit is contained in:
17
scripts/generateSchema.ts
Normal file
17
scripts/generateSchema.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
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' })
|
||||
}
|
Reference in New Issue
Block a user