mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-02-23 10:16:40 -05:00
Compare commits
3 Commits
yaak-cli-0
...
yaak-cli-0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
443e1b8262 | ||
|
|
c6b7cb2e32 | ||
|
|
4aef826a80 |
40
.github/workflows/release-cli-npm.yml
vendored
40
.github/workflows/release-cli-npm.yml
vendored
@@ -27,12 +27,17 @@ jobs:
|
||||
with:
|
||||
node-version: lts/*
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build plugin assets
|
||||
env:
|
||||
SKIP_WASM_BUILD: "1"
|
||||
run: |
|
||||
npm run build-plugins
|
||||
npm run build
|
||||
npm run vendor:vendor-plugins
|
||||
|
||||
- name: Upload vendored assets
|
||||
@@ -104,6 +109,39 @@ jobs:
|
||||
name: vendored-assets
|
||||
path: crates-tauri/yaak-app/vendored
|
||||
|
||||
- name: Set CLI build version
|
||||
shell: bash
|
||||
env:
|
||||
WORKFLOW_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
VERSION="$WORKFLOW_VERSION"
|
||||
else
|
||||
VERSION="${GITHUB_REF_NAME#yaak-cli-}"
|
||||
fi
|
||||
VERSION="${VERSION#v}"
|
||||
echo "Building yaak version: $VERSION"
|
||||
python - "$VERSION" <<'PY'
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
|
||||
version = sys.argv[1]
|
||||
manifest = pathlib.Path("crates-cli/yaak-cli/Cargo.toml")
|
||||
contents = manifest.read_text()
|
||||
updated, replacements = re.subn(
|
||||
r'(?m)^version = ".*"$',
|
||||
f'version = "{version}"',
|
||||
contents,
|
||||
count=1,
|
||||
)
|
||||
if replacements != 1:
|
||||
raise SystemExit("Failed to update yaak-cli version in Cargo.toml")
|
||||
manifest.write_text(updated)
|
||||
print(f"Updated {manifest} to version {version}")
|
||||
PY
|
||||
|
||||
- name: Build yaak
|
||||
run: cargo build --locked --release -p yaak-cli --bin yaak --target ${{ matrix.target }}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ use yaak_crypto::manager::EncryptionManager;
|
||||
use yaak_models::blob_manager::BlobManager;
|
||||
use yaak_models::db_context::DbContext;
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_plugins::bootstrap;
|
||||
use yaak_plugins::events::PluginContext;
|
||||
use yaak_plugins::manager::PluginManager;
|
||||
|
||||
@@ -52,7 +51,7 @@ impl CliContext {
|
||||
.expect("Failed to prepare embedded plugin runtime")
|
||||
});
|
||||
|
||||
match bootstrap::create_and_initialize_manager(
|
||||
match PluginManager::new(
|
||||
vendored_plugin_dir,
|
||||
installed_plugin_dir,
|
||||
node_bin_path,
|
||||
@@ -63,7 +62,7 @@ impl CliContext {
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(plugin_manager) => Some(plugin_manager),
|
||||
Ok(plugin_manager) => Some(Arc::new(plugin_manager)),
|
||||
Err(err) => {
|
||||
eprintln!("Warning: Failed to initialize plugins: {err}");
|
||||
None
|
||||
|
||||
@@ -27,7 +27,6 @@ use yaak_plugins::api::{
|
||||
PluginNameVersion, PluginSearchResponse, PluginUpdatesResponse, check_plugin_updates,
|
||||
search_plugins,
|
||||
};
|
||||
use yaak_plugins::bootstrap;
|
||||
use yaak_plugins::events::PluginContext;
|
||||
use yaak_plugins::install::{delete_and_uninstall, download_and_install};
|
||||
use yaak_plugins::manager::PluginManager;
|
||||
@@ -274,7 +273,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
// Create plugin manager asynchronously
|
||||
let app_handle_clone = app_handle.clone();
|
||||
tauri::async_runtime::block_on(async move {
|
||||
let manager = bootstrap::create_and_initialize_manager(
|
||||
let manager = PluginManager::new(
|
||||
vendored_plugin_dir,
|
||||
installed_plugin_dir,
|
||||
node_bin_path,
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
use crate::error::{Error, Result};
|
||||
use crate::events::PluginContext;
|
||||
use crate::manager::PluginManager;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use yaak_models::models::Plugin;
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_models::util::UpdateSource;
|
||||
|
||||
/// Create a plugin manager and initialize all registered plugins.
|
||||
///
|
||||
/// This performs:
|
||||
/// 1. Plugin runtime startup (`PluginManager::new`)
|
||||
/// 2. Bundled plugin registration in DB (if missing)
|
||||
/// 3. Plugin initialization from DB
|
||||
pub async fn create_and_initialize_manager(
|
||||
vendored_plugin_dir: PathBuf,
|
||||
installed_plugin_dir: PathBuf,
|
||||
node_bin_path: PathBuf,
|
||||
plugin_runtime_main: PathBuf,
|
||||
query_manager: &QueryManager,
|
||||
plugin_context: &PluginContext,
|
||||
dev_mode: bool,
|
||||
) -> Result<Arc<PluginManager>> {
|
||||
let plugin_manager = Arc::new(
|
||||
PluginManager::new(
|
||||
vendored_plugin_dir,
|
||||
installed_plugin_dir,
|
||||
node_bin_path,
|
||||
plugin_runtime_main,
|
||||
dev_mode,
|
||||
)
|
||||
.await,
|
||||
);
|
||||
|
||||
let bundled_dirs = plugin_manager.list_bundled_plugin_dirs().await?;
|
||||
let db = query_manager.connect();
|
||||
for dir in bundled_dirs {
|
||||
if db.get_plugin_by_directory(&dir).is_none() {
|
||||
db.upsert_plugin(
|
||||
&Plugin {
|
||||
directory: dir,
|
||||
enabled: true,
|
||||
url: None,
|
||||
..Default::default()
|
||||
},
|
||||
&UpdateSource::Background,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
let plugins = db.list_plugins()?;
|
||||
drop(db);
|
||||
|
||||
let init_errors = plugin_manager.initialize_all_plugins(plugins, plugin_context).await;
|
||||
if !init_errors.is_empty() {
|
||||
let joined = init_errors
|
||||
.into_iter()
|
||||
.map(|(dir, err)| format!("{dir}: {err}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join("; ");
|
||||
return Err(Error::PluginErr(format!("Failed to initialize plugin(s): {joined}")));
|
||||
}
|
||||
|
||||
Ok(plugin_manager)
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
//! by yaak-app's plugins_ext module.
|
||||
|
||||
pub mod api;
|
||||
pub mod bootstrap;
|
||||
mod checksum;
|
||||
pub mod error;
|
||||
pub mod events;
|
||||
|
||||
@@ -34,7 +34,8 @@ use tokio::sync::mpsc::error::TrySendError;
|
||||
use tokio::sync::{Mutex, mpsc, oneshot};
|
||||
use tokio::time::{Instant, timeout};
|
||||
use yaak_models::models::Plugin;
|
||||
use yaak_models::util::generate_id;
|
||||
use yaak_models::query_manager::QueryManager;
|
||||
use yaak_models::util::{UpdateSource, generate_id};
|
||||
use yaak_templates::error::Error::RenderError;
|
||||
use yaak_templates::error::Result as TemplateResult;
|
||||
|
||||
@@ -61,14 +62,18 @@ impl PluginManager {
|
||||
/// * `installed_plugin_dir` - Path to installed plugins directory
|
||||
/// * `node_bin_path` - Path to the yaaknode binary
|
||||
/// * `plugin_runtime_main` - Path to the plugin runtime index.cjs
|
||||
/// * `query_manager` - Query manager for bundled plugin registration and loading
|
||||
/// * `plugin_context` - Context to use while initializing plugins
|
||||
/// * `dev_mode` - Whether the app is in dev mode (affects plugin loading)
|
||||
pub async fn new(
|
||||
vendored_plugin_dir: PathBuf,
|
||||
installed_plugin_dir: PathBuf,
|
||||
node_bin_path: PathBuf,
|
||||
plugin_runtime_main: PathBuf,
|
||||
query_manager: &QueryManager,
|
||||
plugin_context: &PluginContext,
|
||||
dev_mode: bool,
|
||||
) -> PluginManager {
|
||||
) -> Result<PluginManager> {
|
||||
let (events_tx, mut events_rx) = mpsc::channel(2048);
|
||||
let (kill_server_tx, kill_server_rx) = tokio::sync::watch::channel(false);
|
||||
let (killed_tx, killed_rx) = oneshot::channel();
|
||||
@@ -151,12 +156,40 @@ impl PluginManager {
|
||||
&kill_server_rx,
|
||||
killed_tx,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
.await?;
|
||||
info!("Waiting for plugins to initialize");
|
||||
init_plugins_task.await.unwrap();
|
||||
init_plugins_task.await.map_err(|e| PluginErr(e.to_string()))?;
|
||||
|
||||
plugin_manager
|
||||
let bundled_dirs = plugin_manager.list_bundled_plugin_dirs().await?;
|
||||
let db = query_manager.connect();
|
||||
for dir in bundled_dirs {
|
||||
if db.get_plugin_by_directory(&dir).is_none() {
|
||||
db.upsert_plugin(
|
||||
&Plugin {
|
||||
directory: dir,
|
||||
enabled: true,
|
||||
url: None,
|
||||
..Default::default()
|
||||
},
|
||||
&UpdateSource::Background,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
let plugins = db.list_plugins()?;
|
||||
drop(db);
|
||||
|
||||
let init_errors = plugin_manager.initialize_all_plugins(plugins, plugin_context).await;
|
||||
if !init_errors.is_empty() {
|
||||
let joined = init_errors
|
||||
.into_iter()
|
||||
.map(|(dir, err)| format!("{dir}: {err}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join("; ");
|
||||
return Err(PluginErr(format!("Failed to initialize plugin(s): {joined}")));
|
||||
}
|
||||
|
||||
Ok(plugin_manager)
|
||||
}
|
||||
|
||||
/// Get the vendored plugin directory path (resolves dev mode path if applicable)
|
||||
|
||||
@@ -70,7 +70,6 @@
|
||||
"app-dev": "node scripts/run-dev.mjs",
|
||||
"migration": "node scripts/create-migration.cjs",
|
||||
"build": "npm run --workspaces --if-present build",
|
||||
"build-plugins": "npm run --workspaces --if-present build",
|
||||
"test": "npm run --workspaces --if-present test",
|
||||
"icons": "run-p icons:*",
|
||||
"icons:dev": "tauri icon crates-tauri/yaak-app/icons/icon-dev.png --output crates-tauri/yaak-app/icons/dev",
|
||||
|
||||
Reference in New Issue
Block a user