update_schemas.rs

 1use std::{path::Path, process::Command};
 2
 3use dap_adapters::{GoDebugAdapter, JsDebugAdapter, PythonDebugAdapter, UpdateSchemasDapDelegate};
 4use tempfile::TempDir;
 5
 6fn main() -> anyhow::Result<()> {
 7    let temp_dir = TempDir::new()?;
 8    let output_dir = Path::new("crates/dap_adapters/schemas");
 9    let delegate = UpdateSchemasDapDelegate::new();
10
11    let schema = JsDebugAdapter::get_schema(&temp_dir, delegate.clone())?;
12    std::fs::write(
13        &output_dir
14            .join(JsDebugAdapter::ADAPTER_NAME)
15            .with_extension("json"),
16        serde_json::to_string(&schema)?,
17    )?;
18
19    let schema = PythonDebugAdapter::get_schema(&temp_dir, delegate.clone())?;
20    std::fs::write(
21        &output_dir
22            .join(PythonDebugAdapter::ADAPTER_NAME)
23            .with_extension("json"),
24        serde_json::to_string(&schema)?,
25    )?;
26
27    let schema = GoDebugAdapter::get_schema(&temp_dir, delegate.clone())?;
28    std::fs::write(
29        &output_dir
30            .join(GoDebugAdapter::ADAPTER_NAME)
31            .with_extension("json"),
32        serde_json::to_string(&schema)?,
33    )?;
34
35    Command::new("npx")
36        .arg("prettier")
37        .arg("--write")
38        .arg(output_dir.join("*"))
39        .status()?;
40    Ok(())
41}