16 lines
473 B
TypeScript
16 lines
473 B
TypeScript
import { createConfigJsonSchema } from "../src/server/config/schema/export";
|
|
|
|
const schemaPath = "config.schema.json";
|
|
const schema = `${JSON.stringify(createConfigJsonSchema(), null, 2)}\n`;
|
|
|
|
if (process.argv.includes("--check")) {
|
|
const existing = await Bun.file(schemaPath)
|
|
.text()
|
|
.catch(() => null);
|
|
if (existing !== schema) {
|
|
throw new Error(`${schemaPath} 未同步,请运行 bun run schema`);
|
|
}
|
|
} else {
|
|
await Bun.write(schemaPath, schema);
|
|
}
|