Install plugins from Yaak plugin registry (#230)

This commit is contained in:
Gregory Schier
2025-06-23 08:55:38 -07:00
committed by GitHub
parent b5620fcdf3
commit cb7c44cc65
27 changed files with 421 additions and 218 deletions

View File

@@ -1,9 +1,9 @@
use crate::api::search_plugins;
use crate::api::{
PluginSearchResponse, PluginUpdatesResponse, check_plugin_updates, search_plugins,
};
use crate::error::Result;
use crate::install::download_and_install;
use serde::{Deserialize, Serialize};
use tauri::{AppHandle, Runtime, WebviewWindow, command};
use ts_rs::TS;
#[command]
pub(crate) async fn search<R: Runtime>(
@@ -16,30 +16,14 @@ pub(crate) async fn search<R: Runtime>(
#[command]
pub(crate) async fn install<R: Runtime>(
window: WebviewWindow<R>,
plugin: PluginVersion,
) -> Result<String> {
download_and_install(&window, &plugin).await
name: &str,
version: Option<String>,
) -> Result<()> {
download_and_install(&window, name, version).await?;
Ok(())
}
#[derive(Debug, Clone, Serialize, Deserialize, TS, PartialEq)]
#[serde(rename_all = "camelCase")]
#[ts(export, export_to = "gen_search.ts")]
pub struct PluginSearchResponse {
pub results: Vec<PluginVersion>,
}
#[derive(Debug, Clone, Serialize, Deserialize, TS, PartialEq)]
#[serde(rename_all = "camelCase")]
#[ts(export, export_to = "gen_search.ts")]
pub struct PluginVersion {
pub id: String,
pub version: String,
pub description: Option<String>,
pub name: String,
pub display_name: String,
pub homepage_url: Option<String>,
pub repository_url: Option<String>,
pub checksum: String,
pub readme: Option<String>,
pub yanked: bool,
#[command]
pub(crate) async fn updates<R: Runtime>(app_handle: AppHandle<R>) -> Result<PluginUpdatesResponse> {
check_plugin_updates(&app_handle).await
}