import { createDefaultCheckerRegistry } from "../src/server/checker/runner";
import { createProbeConfigJsonSchema } from "../src/server/checker/schema/export";

const schemaPath = "probe-config.schema.json";
const schema = `${JSON.stringify(createProbeConfigJsonSchema(createDefaultCheckerRegistry()), 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);
}
