diff --git a/crates-cli/yaak-cli/src/context.rs b/crates-cli/yaak-cli/src/context.rs index a0175b84..fabe9b04 100644 --- a/crates-cli/yaak-cli/src/context.rs +++ b/crates-cli/yaak-cli/src/context.rs @@ -39,13 +39,13 @@ impl CliContext { let plugin_manager = if with_plugins { let embedded_vendored_plugin_dir = data_dir.join("vendored-plugins"); - let vendored_plugin_dir = + let bundled_plugin_dir = resolve_bundled_plugin_dir_for_cli(&embedded_vendored_plugin_dir); let installed_plugin_dir = data_dir.join("installed-plugins"); let node_bin_path = PathBuf::from("node"); - if vendored_plugin_dir == embedded_vendored_plugin_dir { - prepare_embedded_vendored_plugins(&vendored_plugin_dir) + if bundled_plugin_dir == embedded_vendored_plugin_dir { + prepare_embedded_vendored_plugins(&embedded_vendored_plugin_dir) .expect("Failed to prepare bundled plugins"); } @@ -56,7 +56,8 @@ impl CliContext { }); match PluginManager::new( - vendored_plugin_dir, + bundled_plugin_dir, + embedded_vendored_plugin_dir, installed_plugin_dir, node_bin_path, plugin_runtime_main, diff --git a/crates-tauri/yaak-app/src/plugins_ext.rs b/crates-tauri/yaak-app/src/plugins_ext.rs index 29b95b67..7bcf822b 100644 --- a/crates-tauri/yaak-app/src/plugins_ext.rs +++ b/crates-tauri/yaak-app/src/plugins_ext.rs @@ -240,14 +240,14 @@ pub fn init() -> TauriPlugin { Builder::new("yaak-plugins") .setup(|app_handle, _| { // Resolve paths for plugin manager - let bundled_plugin_dir = app_handle + let vendored_plugin_dir = app_handle .path() .resolve("vendored/plugins", BaseDirectory::Resource) .expect("failed to resolve plugin directory resource"); - let vendored_plugin_dir = if is_dev() { - resolve_workspace_plugins_dir().unwrap_or(bundled_plugin_dir) + let bundled_plugin_dir = if is_dev() { + resolve_workspace_plugins_dir().unwrap_or_else(|| vendored_plugin_dir.clone()) } else { - bundled_plugin_dir + vendored_plugin_dir.clone() }; let installed_plugin_dir = app_handle @@ -279,6 +279,7 @@ pub fn init() -> TauriPlugin { let app_handle_clone = app_handle.clone(); tauri::async_runtime::block_on(async move { let manager = PluginManager::new( + bundled_plugin_dir, vendored_plugin_dir, installed_plugin_dir, node_bin_path, diff --git a/crates/yaak-plugins/src/manager.rs b/crates/yaak-plugins/src/manager.rs index 7dc939ea..f7e6f2ab 100644 --- a/crates/yaak-plugins/src/manager.rs +++ b/crates/yaak-plugins/src/manager.rs @@ -45,6 +45,7 @@ pub struct PluginManager { kill_tx: tokio::sync::watch::Sender, killed_rx: Arc>>>, ws_service: Arc, + bundled_plugin_dir: PathBuf, vendored_plugin_dir: PathBuf, pub(crate) installed_plugin_dir: PathBuf, } @@ -56,6 +57,7 @@ impl PluginManager { /// Create a new PluginManager with the given paths. /// /// # Arguments + /// * `bundled_plugin_dir` - Directory to scan for bundled plugins /// * `vendored_plugin_dir` - Path to vendored plugins directory /// * `installed_plugin_dir` - Path to installed plugins directory /// * `node_bin_path` - Path to the yaaknode binary @@ -63,6 +65,7 @@ impl PluginManager { /// * `query_manager` - Query manager for bundled plugin registration and loading /// * `plugin_context` - Context to use while initializing plugins pub async fn new( + bundled_plugin_dir: PathBuf, vendored_plugin_dir: PathBuf, installed_plugin_dir: PathBuf, node_bin_path: PathBuf, @@ -85,6 +88,7 @@ impl PluginManager { ws_service: Arc::new(ws_service.clone()), kill_tx: kill_server_tx, killed_rx: Arc::new(Mutex::new(Some(killed_rx))), + bundled_plugin_dir, vendored_plugin_dir, installed_plugin_dir, }; @@ -190,8 +194,8 @@ impl PluginManager { /// Read plugin directories from disk and return their paths. /// This is useful for discovering bundled plugins. pub async fn list_bundled_plugin_dirs(&self) -> Result> { - info!("Loading bundled plugins from {:?}", self.vendored_plugin_dir); - read_plugins_dir(&self.vendored_plugin_dir).await + info!("Loading bundled plugins from {:?}", self.bundled_plugin_dir); + read_plugins_dir(&self.bundled_plugin_dir).await } pub async fn uninstall(&self, plugin_context: &PluginContext, dir: &str) -> Result<()> {