-
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod models; | |
pub mod app; | ||
pub mod tools; | ||
pub mod utils; | ||
pub mod sources; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
mod addon; | ||
Check failure on line 1 in src/api/models/addon/mod.rs GitHub Actions / clippymodule has the same name as its containing module
|
||
mod addon_source; | ||
mod addon_type; | ||
|
||
pub use addon::*; | ||
pub use addon_source::*; | ||
pub use addon_type::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub struct Lockfile { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
mod modpack_source; | ||
mod step; | ||
mod env; | ||
mod source; | ||
|
||
pub mod addon; | ||
pub mod packwiz; | ||
pub mod mrpack; | ||
pub mod unsup; | ||
pub mod network; | ||
pub mod server; | ||
pub mod lockfile; | ||
|
||
pub use modpack_source::*; | ||
pub use step::*; | ||
pub use addon::*; | ||
pub use env::*; | ||
pub use source::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
pub const MRPACK_INDEX_FILE: &str = "modrinth.index.json"; | ||
Check warning on line 1 in src/api/models/mrpack/mod.rs GitHub Actions / clippyconstant `MRPACK_INDEX_FILE` is never used
|
||
|
||
mod mrpack_index; | ||
mod mrpack_file; | ||
|
||
use anyhow::Result; | ||
pub use mrpack_index::*; | ||
pub use mrpack_file::*; | ||
|
||
use crate::api::{app::App, utils::accessor::Accessor}; | ||
|
||
use super::Addon; | ||
|
||
pub async fn resolve_mrpack_addons( | ||
Check warning on line 14 in src/api/models/mrpack/mod.rs GitHub Actions / clippyfunction `resolve_mrpack_addons` is never used
|
||
app: &App, | ||
Check warning on line 15 in src/api/models/mrpack/mod.rs GitHub Actions / clippyunused variable: `app`
|
||
accessor: Accessor, | ||
Check warning on line 16 in src/api/models/mrpack/mod.rs GitHub Actions / clippyunused variable: `accessor`
|
||
) -> Result<Vec<Addon>> { | ||
|
||
|
||
todo!() | ||
} | ||
Check warning on line 21 in src/api/models/mrpack/mod.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
|
||
impl MRPackFile { | ||
pub async fn into_addon(&self) -> Result<Addon> { | ||
Check failure on line 24 in src/api/models/mrpack/mod.rs GitHub Actions / clippymethods called `into_*` usually take `self` by value
Check warning on line 24 in src/api/models/mrpack/mod.rs GitHub Actions / clippymethod `into_addon` is never used
|
||
todo!() | ||
} | ||
Check warning on line 26 in src/api/models/mrpack/mod.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::collections::HashMap; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct MRPackFile { | ||
path: String, | ||
hashes: HashMap<String, String>, | ||
env: Option<Env>, | ||
file_size: u64, | ||
downloads: Vec<String>, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
pub struct Env { | ||
pub client: EnvSupport, | ||
pub server: EnvSupport, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum EnvSupport { | ||
Required, | ||
Optional, | ||
Unsupported, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::collections::HashMap; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::MRPackFile; | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct MRPackIndex { | ||
pub game: String, | ||
pub name: String, | ||
pub version_id: String, | ||
pub summary: Option<String>, | ||
pub files: Vec<MRPackFile>, | ||
pub dependencies: HashMap<String, String>, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::collections::HashMap; | ||
|
||
use anyhow::Result; | ||
|
||
use super::{app::App, models::{CacheStrategy, Step}, utils::url::get_filename_from_url}; | ||
|
||
pub mod vanilla; | ||
|
||
pub async fn resolve_steps_for_url( | ||
Check warning on line 9 in src/api/sources/mod.rs GitHub Actions / clippyfunction `resolve_steps_for_url` is never used
|
||
app: &App, | ||
url: impl Into<String>, | ||
filename: Option<String>, | ||
) -> Result<Vec<Step>> { | ||
let url: String = url.into(); | ||
|
||
let filename = filename.unwrap_or_else(|| { | ||
get_filename_from_url(&url) | ||
}); | ||
|
||
Ok(vec![ | ||
Step::CacheCheck(CacheStrategy::Indexed { | ||
namespace: "url".into(), | ||
path: None, | ||
key: url.clone(), | ||
}), | ||
Step::Download { | ||
url: url.into(), | ||
Check failure on line 27 in src/api/sources/mod.rs GitHub Actions / clippyuseless conversion to the same type: `std::string::String`
|
||
filename, | ||
size: None, | ||
hashes: HashMap::new(), | ||
} | ||
]) | ||
} | ||
Check warning on line 33 in src/api/sources/mod.rs GitHub Actions / clippyunused `async` for function with no await statements
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use crate::api::app::App; | ||
|
||
pub struct VanillaAPI<'a>(pub &'a App); | ||
Check warning on line 3 in src/api/sources/vanilla/mod.rs GitHub Actions / clippystruct `VanillaAPI` is never constructed
|
||
|
||
impl<'a> VanillaAPI<'a> { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
use std::path::PathBuf; | ||
use std::{ffi::OsString, fs::DirEntry, io::{Read, Seek}, path::PathBuf}; | ||
Check warning on line 1 in src/api/utils/accessor.rs GitHub Actions / clippyunused imports: `Read`, `ffi::OsString`, `fs::DirEntry`
|
||
|
||
use anyhow::{anyhow, Result}; | ||
use serde::de::DeserializeOwned; | ||
use zip::ZipArchive; | ||
|
||
use crate::api::app::App; | ||
|
||
pub trait ReadSeek: std::io::Read + Seek {} | ||
|
||
pub enum Accessor { | ||
Local(PathBuf), | ||
Remote(reqwest::Url), | ||
Zip(ZipArchive<Box<dyn ReadSeek>>), | ||
} | ||
|
||
impl Accessor { | ||
|
||
pub async fn dir(&self) -> Result<Vec<String>> { | ||
Check warning on line 18 in src/api/utils/accessor.rs GitHub Actions / clippymethods `dir` and `json` are never used
|
||
match self { | ||
Accessor::Zip(zip) => Ok(zip.file_names().map(ToOwned::to_owned).collect()), | ||
Accessor::Local(path) => Ok(path.read_dir()? | ||
.filter_map(|r| r.ok()) | ||
Check warning on line 22 in src/api/utils/accessor.rs GitHub Actions / clippyredundant closure
|
||
.map(|n| n.file_name().to_string_lossy().into_owned()) | ||
.collect()), | ||
Accessor::Remote(_) => Err(anyhow!("cannot dir() Accessor::Remote")), | ||
} | ||
} | ||
Check warning on line 27 in src/api/utils/accessor.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
|
||
pub async fn json<T: DeserializeOwned>(&mut self, app: &App, path: &str) -> Result<T> { | ||
match self { | ||
Accessor::Local(base) => Ok(serde_json::from_reader(std::fs::File::open(base.join(path))?)?), | ||
Accessor::Zip(zip) => Ok(serde_json::from_reader(zip.by_name(path)?)?), | ||
Accessor::Remote(url) => Ok(app.http_get_json(url.join(path)?).await?), | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod hashing; | ||
pub mod accessor; | ||
pub mod serde; | ||
pub mod url; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub fn get_filename_from_url(url: &str) -> String { | ||
Check warning on line 1 in src/api/utils/url.rs GitHub Actions / clippyfunction `get_filename_from_url` is never used
|
||
let url_clean = url.split(&['?', '#'][..]).next().unwrap(); | ||
url_clean.split('/').last().unwrap().to_string() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod init; | ||
pub mod build; |