use camino::{Utf8Path, Utf8PathBuf};
use miette::{Context, IntoDiagnostic, Result};
use nextest_runner::config::core::nextest_config_schema;
use std::fs;
fn main() -> Result<()> {
let schema_path = schema_path();
let schema_dir = schema_path
.parent()
.expect("schema path always has a parent directory");
fs::create_dir_all(schema_dir)
.into_diagnostic()
.wrap_err_with(|| format!("failed to create schema directory {schema_dir}"))?;
let mut schema_json = serde_json::to_vec_pretty(&nextest_config_schema())
.into_diagnostic()
.wrap_err("failed to serialize nextest config schema")?;
schema_json.push(b'\n');
fs::write(&schema_path, schema_json)
.into_diagnostic()
.wrap_err_with(|| format!("failed to write schema to {schema_path}"))?;
println!("{schema_path}");
Ok(())
}
fn schema_path() -> Utf8PathBuf {
Utf8Path::new(env!("CARGO_MANIFEST_DIR")).join("jsonschemas/repo-config.json")
}