feat: add dependency manager and setup wizard

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-21 10:50:24 -04:00
parent fcdb1a72d6
commit e76254912a
6 changed files with 463 additions and 2 deletions

View File

@@ -1 +1,53 @@
// Dependency check and install commands — implemented in Task 2
use serde::Serialize;
use std::io::{BufRead, BufReader};
use std::process::{Command, Stdio};
use tauri::ipc::Channel;
use crate::models::DependencyStatus;
use crate::services::dependency_manager;
#[tauri::command]
pub fn check_dependencies() -> Vec<DependencyStatus> {
dependency_manager::get_all_dependency_statuses()
}
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase", tag = "event", content = "data")]
pub enum InstallEvent {
Output { line: String },
Finished { success: bool },
}
#[tauri::command]
pub async fn install_dependency(
name: String,
on_event: Channel<InstallEvent>,
) -> Result<(), String> {
let args = dependency_manager::get_install_args(&name)?;
let (cmd, cmd_args) = args.split_first().ok_or("Empty install command")?;
let mut child = Command::new(cmd)
.args(cmd_args)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.map_err(|e| format!("Failed to start install: {e}"))?;
if let Some(stdout) = child.stdout.take() {
let reader = BufReader::new(stdout);
for line in reader.lines().map_while(Result::ok) {
let _ = on_event.send(InstallEvent::Output { line });
}
}
let status = child.wait().map_err(|e| format!("Install failed: {e}"))?;
let _ = on_event.send(InstallEvent::Finished {
success: status.success(),
});
if status.success() {
Ok(())
} else {
Err("Install command exited with non-zero status".to_string())
}
}