MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / main

Function main

tools/gen-bindings/src/main.rs:46–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44}
45
46fn main() -> Result<()> {
47 let args = Cli::parse();
48
49 let workspace_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
50 .parent()
51 .unwrap()
52 .parent()
53 .unwrap();
54
55 // 1) Build prerequisite
56 run_inherit("cargo", &["build"], Some(workspace_dir))?;
57
58 // 2) Ensure output directory exists
59 if !Path::new(&args.out_dir).exists() {
60 fs::create_dir_all(&args.out_dir).context("create output directory")?;
61 }
62
63 // 3) Generate TS client from project
64 run_inherit(
65 workspace_dir
66 .join("target/debug/spacetimedb-cli")
67 .with_extension(std::env::consts::EXE_EXTENSION),
68 &[
69 "generate",
70 "-y",
71 "--lang",
72 "typescript",
73 "--out-dir",
74 &args.out_dir,
75 "--module-path",
76 &args.module_path,
77 ],
78 None,
79 )?;
80
81 if let Some(other_replacement) = &args.replacement {
82 let index_replacement = if let Some(index_replacement) = &args.index_replacement {
83 index_replacement
84 } else {
85 other_replacement
86 };
87
88 // 5) Replace "spacetimedb" references
89 let opts = ReplaceOptions {
90 dry_run: false,
91 only_exts: Some(vec![
92 "ts".into(),
93 "tsx".into(),
94 "js".into(),
95 "jsx".into(),
96 "mts".into(),
97 "cts".into(),
98 "json".into(),
99 "d.ts".into(),
100 ]),
101 follow_symlinks: false,
102 include_hidden: false,
103 ignore_globs: vec!["**/node_modules/**".into(), "**/dist/**".into(), "**/target/**".into()],

Callers

nothing calls this directly

Calls 7

parseFunction · 0.85
replace_in_treeFunction · 0.85
joinMethod · 0.80
run_inheritFunction · 0.70
newFunction · 0.50
OkFunction · 0.50
unwrapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…