-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use anyhow::{Context, Result}; | ||
|
||
pub const APP_USER_AGENT: &str = concat!( | ||
env!("CARGO_PKG_NAME"), | ||
"/", | ||
env!("CARGO_PKG_VERSION"), | ||
" - ", | ||
env!("CARGO_PKG_REPOSITORY"), | ||
); | ||
|
||
pub struct App { | ||
http_client: reqwest::Client, | ||
} | ||
|
||
impl App { | ||
pub fn new() -> Result<Self> { | ||
Check warning on line 16 in src/api/app/mod.rs GitHub Actions / clippyassociated function `new` is never used
|
||
let http_client = reqwest::Client::builder() | ||
.user_agent(APP_USER_AGENT) | ||
.build() | ||
.context("Initializing http_client")?; | ||
|
||
Ok(Self { | ||
http_client, | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod models; | ||
pub mod app; | ||
pub mod tools; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use anyhow::Result; | ||
|
||
use crate::app::AddonType; | ||
|
||
use super::{Environment, Step}; | ||
|
||
pub enum AddonTarget { | ||
Plugin, | ||
Mod, | ||
} | ||
|
||
pub struct Addon { | ||
pub environment: Option<Environment>, | ||
pub addon_type: AddonType, | ||
} | ||
|
||
impl Addon { | ||
async fn resolve_steps(&self) -> Result<Vec<Step>> { | ||
Check warning on line 18 in src/api/models/addon.rs GitHub Actions / clippymethod `resolve_steps` is never used
|
||
Ok(vec![]) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use anyhow::Result; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::{ModpackSource, Addon}; | ||
|
||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub enum AddonSource { | ||
File { | ||
path: String, | ||
}, | ||
|
||
Folder { | ||
path: String, | ||
}, | ||
|
||
Modpack { | ||
modpack: ModpackSource, | ||
}, | ||
} | ||
|
||
impl AddonSource { | ||
async fn resolve(&self) -> Result<Vec<Addon>> { | ||
Check warning on line 23 in src/api/models/addon_source.rs GitHub Actions / clippymethod `resolve` is never used
|
||
Ok(vec![]) | ||
} | ||
Check warning on line 25 in src/api/models/addon_source.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub enum AddonType { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash, Default)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum Environment { | ||
#[default] | ||
Both, | ||
Server, | ||
Client, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash, Default)] | ||
#[serde(rename_all = "lowercase")] | ||
#[non_exhaustive] | ||
pub enum HashFormat { | ||
Sha256, | ||
Sha512, | ||
Sha1, | ||
Md5, | ||
#[serde(rename = "murmur2")] | ||
#[default] | ||
Curseforge, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
mod server; | ||
mod addon_source; | ||
mod modpack_source; | ||
mod step; | ||
mod addon; | ||
mod env; | ||
mod packwiz; | ||
mod mrpack; | ||
mod hash; | ||
|
||
pub use server::*; | ||
pub use addon_source::*; | ||
pub use modpack_source::*; | ||
pub use step::*; | ||
pub use addon::*; | ||
pub use env::*; | ||
pub use packwiz::*; | ||
pub use mrpack::*; | ||
pub use hash::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub enum ModpackSource { | ||
Local { | ||
modpack_type: ModpackType, | ||
path: String, | ||
}, | ||
|
||
Remote { | ||
modpack_type: ModpackType, | ||
url: String, | ||
}, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] | ||
pub enum ModpackType { | ||
Packwiz, | ||
MRPack, | ||
Unsup, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod packwiz_mod; | ||
mod packwiz_pack; | ||
|
||
pub use packwiz_pack::*; | ||
Check warning on line 4 in src/api/models/packwiz/mod.rs GitHub Actions / clippyunused import: `packwiz_pack::*`
|
||
pub use packwiz_mod::*; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::api::models::{Environment, HashFormat}; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, Default)] | ||
#[serde(default)] | ||
pub struct PackwizMod { | ||
pub name: String, | ||
pub filename: String, | ||
pub download: PackwizModDownload, | ||
pub option: PackwizModOption, | ||
pub side: Environment, | ||
pub update: Option<PackwizModUpdate>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, Default)] | ||
pub struct PackwizModOption { | ||
pub optional: bool, | ||
pub default: bool, | ||
pub description: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, Default)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct PackwizModDownload { | ||
pub url: Option<String>, | ||
pub hash: String, | ||
pub hash_format: HashFormat, | ||
#[serde(default)] | ||
pub mode: PackwizDownloadMode, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, Default)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum PackwizDownloadMode { | ||
#[default] | ||
#[serde(alias = "")] | ||
Url, | ||
#[serde(rename = "metadata:curseforge")] | ||
Curseforge, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum PackwizModUpdate { | ||
#[serde(rename_all = "kebab-case")] | ||
Modrinth { | ||
mod_id: String, | ||
version: String, | ||
}, | ||
#[serde(rename_all = "kebab-case")] | ||
Curseforge { | ||
file_id: u64, | ||
project_id: u64, | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::collections::HashMap; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::api::models::HashFormat; | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct PackwizPack { | ||
pub name: String, | ||
pub author: Option<String>, | ||
pub version: Option<String>, | ||
pub description: Option<String>, | ||
pub pack_format: String, | ||
pub index: PackwizPackFile, | ||
pub versions: HashMap<String, String>, | ||
} | ||
|
||
pub static PACK_TOML: &str = "pack.toml"; | ||
Check warning on line 19 in src/api/models/packwiz/packwiz_pack.rs GitHub Actions / clippystatic `PACK_TOML` is never used
|
||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct PackwizPackIndex { | ||
pub hash_format: HashFormat, | ||
pub files: Vec<PackwizPackFile>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct PackwizPackFile { | ||
pub file: String, | ||
pub hash: String, | ||
pub hash_format: Option<String>, | ||
|
||
pub alias: Option<String>, | ||
#[serde(default)] | ||
pub metafile: bool, | ||
#[serde(default)] | ||
pub preserve: bool, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use serde::{Serialize, Deserialize}; | ||
|
||
use super::AddonSource; | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] | ||
#[serde(default)] | ||
pub struct Server { | ||
name: String, | ||
port: Option<i32>, | ||
|
||
sources: Vec<AddonSource>, | ||
} | ||
|
||
impl Default for Server { | ||
fn default() -> Self { | ||
Self { | ||
name: String::from("server"), | ||
port: None, | ||
|
||
sources: vec![], | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::collections::HashMap; | ||
|
||
use anyhow::Result; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::HashFormat; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
#[serde(tag = "type")] | ||
pub enum Step { | ||
CacheCheck(CacheStrategy), | ||
Download { | ||
url: String, | ||
filename: String, | ||
size: Option<i32>, | ||
hashes: HashMap<HashFormat, String>, | ||
}, | ||
Execute, | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default)] | ||
#[serde(tag = "type")] | ||
pub enum CacheStrategy { | ||
File { | ||
namespace: String, | ||
path: String, | ||
}, | ||
Indexed { | ||
index_path: String, | ||
key: String, | ||
value: String, | ||
}, | ||
#[default] | ||
None, | ||
} | ||
|
||
pub enum StepResult { | ||
// continue into running next step | ||
Continue, | ||
// skip next steps for this addon | ||
// example: addon is already downloaded / cache hit | ||
Skip, | ||
} | ||
|
||
impl Step { | ||
async fn run(&self) -> Result<StepResult> { | ||
Check warning on line 46 in src/api/models/step.rs GitHub Actions / clippymethod `run` is never used
|
||
Ok(StepResult::Continue) | ||
} | ||
Check warning on line 48 in src/api/models/step.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod java; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ use anyhow::Result; | |
use app::BaseApp; | ||
use clap::Parser; | ||
|
||
mod api; | ||
mod app; | ||
mod commands; | ||
mod core; | ||
|