MCPcopy Create free account
hub / github.com/esengine/esengine / build_plugin

Function build_plugin

packages/editor-app/src-tauri/src/commands/plugin.rs:22–141  ·  view source on GitHub ↗
(plugin_folder: String, app: AppHandle)

Source from the content-addressed store, hash-verified

20/// Build a plugin from source
21#[tauri::command]
22pub async fn build_plugin(plugin_folder: String, app: AppHandle) -> Result<String, String> {
23 let plugin_path = Path::new(&plugin_folder);
24 if !plugin_path.exists() {
25 return Err(format!("Plugin folder does not exist: {}", plugin_folder));
26 }
27
28 let package_json_path = plugin_path.join("package.json");
29 if !package_json_path.exists() {
30 return Err("package.json not found in plugin folder".to_string());
31 }
32
33 let build_cache_dir = plugin_path.join(".build-cache");
34 if !build_cache_dir.exists() {
35 fs::create_dir_all(&build_cache_dir)
36 .map_err(|e| format!("Failed to create .build-cache directory: {}", e))?;
37 }
38
39 let pnpm_command = if cfg!(target_os = "windows") {
40 "pnpm.cmd"
41 } else {
42 "pnpm"
43 };
44
45 // Step 1: Install dependencies
46 app.emit(
47 "plugin-build-progress",
48 BuildProgress {
49 step: "install".to_string(),
50 output: None,
51 },
52 )
53 .ok();
54
55 let install_output = Command::new(&pnpm_command)
56 .args(["install"])
57 .current_dir(&plugin_folder)
58 .output()
59 .map_err(|e| format!("Failed to run pnpm install: {}", e))?;
60
61 if !install_output.status.success() {
62 return Err(format!(
63 "pnpm install failed: {}",
64 String::from_utf8_lossy(&install_output.stderr)
65 ));
66 }
67
68 // Step 2: Build
69 app.emit(
70 "plugin-build-progress",
71 BuildProgress {
72 step: "build".to_string(),
73 output: None,
74 },
75 )
76 .ok();
77
78 let build_output = Command::new(&pnpm_command)
79 .args(["run", "build"])

Callers

nothing calls this directly

Calls 7

createFunction · 0.85
readFunction · 0.85
add_directory_to_zipFunction · 0.85
existsMethod · 0.65
joinMethod · 0.45
emitMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected