feat: Implement backend commands for plugin data management and enhance frontend synchronization with updated plugin interfaces

This commit is contained in:
Rbanh committed 2025-03-30 19:31:00 -04:00
1 parent 78f22f65f4
commit 83be780243
35 files changed
+5261 -2208

No files matched your search

+40 -1
View File
@@ -1,4 +1,43 @@
pub mod hangar;
pub mod spigotmc;
pub mod modrinth;
pub mod github;
use std::path::Path;
use crate::models::repository::RepositoryPlugin;
use crate::models::server::ServerType;
use async_trait::async_trait;
/// Common interface for all repository crawlers
#[async_trait]
pub trait Repository {
/// Get the name of the repository
fn get_repository_name(&self) -> String;
/// Search for plugins in the repository
async fn search(&self, query: &str) -> Result<Vec<RepositoryPlugin>, String>;
/// Get plugin details from the repository
async fn get_plugin_details(&self, plugin_id: &str) -> Result<RepositoryPlugin, String>;
/// Get plugin details with server type consideration
async fn get_plugin_details_with_server_type(&self, plugin_id: &str, server_type: Option<&ServerType>) -> Result<RepositoryPlugin, String> {
// Default implementation just calls the regular get_plugin_details
self.get_plugin_details(plugin_id).await
}
/// Download a plugin from the repository
async fn download_plugin(&self, plugin_id: &str, version: &str, destination: &Path) -> Result<String, String>;
/// Download a plugin with server type consideration
async fn download_plugin_with_server_type(&self, plugin_id: &str, version: &str, destination: &Path, server_type: Option<&ServerType>) -> Result<String, String> {
// Default implementation calls the regular download_plugin
self.download_plugin(plugin_id, version, destination).await
}
}
// Re-export the crawler implementations
pub use hangar::HangarCrawler;
pub use hangar::HangarCrawler;
pub use spigotmc::SpigotMCCrawler;
pub use modrinth::ModrinthCrawler;
pub use github::GitHubCrawler;