-
-
Notifications
You must be signed in to change notification settings - Fork 776
CLI dev: load bundled plugins from ROOT/plugins #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
68d6803
8f0062f
e34301c
a2f12ae
be26cc4
9c09e32
23e9cbb
072b486
e64404d
b9b9018
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ use crate::error::Result; | |
| use crate::models_ext::QueryManagerExt; | ||
| use log::{error, info, warn}; | ||
| use serde::Serialize; | ||
| use std::path::PathBuf; | ||
| use std::sync::Arc; | ||
| use std::sync::atomic::{AtomicBool, Ordering}; | ||
| use std::time::{Duration, Instant}; | ||
|
|
@@ -239,10 +240,15 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| Builder::new("yaak-plugins") | ||
| .setup(|app_handle, _| { | ||
| // Resolve paths for plugin manager | ||
| let vendored_plugin_dir = app_handle | ||
| let bundled_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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
By assigning Useful? React with 👍 / 👎. |
||
| } else { | ||
| bundled_plugin_dir | ||
| }; | ||
|
|
||
| let installed_plugin_dir = app_handle | ||
| .path() | ||
|
|
@@ -266,7 +272,6 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| .expect("failed to resolve plugin runtime") | ||
| .join("index.cjs"); | ||
|
|
||
| let dev_mode = is_dev(); | ||
| let query_manager = | ||
| app_handle.state::<yaak_models::query_manager::QueryManager>().inner().clone(); | ||
|
|
||
|
|
@@ -280,7 +285,6 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| plugin_runtime_main, | ||
| &query_manager, | ||
| &PluginContext::new_empty(), | ||
| dev_mode, | ||
| ) | ||
| .await | ||
| .expect("Failed to initialize plugins"); | ||
|
|
@@ -322,3 +326,11 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| }) | ||
| .build() | ||
| } | ||
|
|
||
| fn resolve_workspace_plugins_dir() -> Option<PathBuf> { | ||
| PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
| .join("../..") | ||
| .join("plugins") | ||
| .canonicalize() | ||
| .ok() | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In debug builds this now resolves bundled plugins from
current_dir()/plugins, so any plugin-enabled CLI command run inside an unrelated repo that happens to contain apluginsfolder will load those directories as bundled plugins;PluginManager::newthen auto-registers bundled dirs asenabled: trueand boots them. This makes plugin execution depend on shell CWD instead of the Yaak workspace and can execute unintended code when developers run the debug CLI outside this repo.Useful? React with 👍 / 👎.