diff --git a/src/core/package_manager/installer.rs b/src/core/package_manager/installer.rs index f11efb7ff..36e43480e 100644 --- a/src/core/package_manager/installer.rs +++ b/src/core/package_manager/installer.rs @@ -20,6 +20,8 @@ impl PackageManager { let os_type = detect_os(); let base_path = if mode == InstallMode::Container { PathBuf::from("/opt/gbo") + } else if let Ok(custom_path) = std::env::var("BOTSERVER_STACK_PATH") { + PathBuf::from(custom_path) } else { std::env::current_dir()?.join("botserver-stack") }; @@ -36,6 +38,26 @@ impl PackageManager { Ok(pm) } + /// Create a PackageManager with a custom base path (for testing) + pub fn with_base_path( + mode: InstallMode, + tenant: Option, + base_path: PathBuf, + ) -> Result { + let os_type = detect_os(); + let tenant = tenant.unwrap_or_else(|| "default".to_string()); + + let mut pm = PackageManager { + mode, + os_type, + base_path, + tenant, + components: HashMap::new(), + }; + pm.register_components(); + Ok(pm) + } + fn register_components(&mut self) { self.register_tables(); self.register_cache(); diff --git a/src/main.rs b/src/main.rs index da1414694..e8692648f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -386,6 +386,14 @@ async fn main() -> std::io::Result<()> { None }; + // Set custom stack path if provided (for testing) + if let Some(idx) = args.iter().position(|a| a == "--stack-path") { + if let Some(path) = args.get(idx + 1) { + std::env::set_var("BOTSERVER_STACK_PATH", path); + info!("Using custom stack path: {}", path); + } + } + // Bootstrap trace!("Starting bootstrap process..."); let progress_tx_clone = progress_tx.clone();