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