You've already forked AstralRinth
Daedalus Rewrite + Code Cleanup (#16)
* [wip] rewrite daedalus, vanilla, fabric, and quilt * finish forge + neo * fix docker * fix neoforge 1.21+ * update concurrency limit * finish * remove mac garb
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use crate::{download_file, Error};
|
||||
|
||||
use crate::minecraft::{
|
||||
Argument, ArgumentType, Library, VersionInfo, VersionType,
|
||||
};
|
||||
@@ -7,9 +5,6 @@ use chrono::{DateTime, TimeZone, Utc};
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(feature = "bincode")]
|
||||
use bincode::{Decode, Encode};
|
||||
|
||||
/// The latest version of the format the fabric model structs deserialize to
|
||||
pub const CURRENT_FABRIC_FORMAT_VERSION: usize = 0;
|
||||
/// The latest version of the format the fabric model structs deserialize to
|
||||
@@ -23,7 +18,6 @@ pub const CURRENT_NEOFORGE_FORMAT_VERSION: usize = 0;
|
||||
pub const DUMMY_REPLACE_STRING: &str = "${modrinth.gameVersion}";
|
||||
|
||||
/// A data variable entry that depends on the side of the installation
|
||||
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SidedDataEntry {
|
||||
/// The value on the client
|
||||
@@ -43,7 +37,6 @@ where
|
||||
.map_err(serde::de::Error::custom)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
/// A partial version returned by fabric meta
|
||||
@@ -53,11 +46,9 @@ pub struct PartialVersionInfo {
|
||||
/// The version ID this partial version inherits from
|
||||
pub inherits_from: String,
|
||||
/// The time that the version was released
|
||||
#[cfg_attr(feature = "bincode", bincode(with_serde))]
|
||||
#[serde(deserialize_with = "deserialize_date")]
|
||||
pub release_time: DateTime<Utc>,
|
||||
/// The latest time a file in this version was updated
|
||||
#[cfg_attr(feature = "bincode", bincode(with_serde))]
|
||||
#[serde(deserialize_with = "deserialize_date")]
|
||||
pub time: DateTime<Utc>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@@ -83,7 +74,6 @@ pub struct PartialVersionInfo {
|
||||
}
|
||||
|
||||
/// A processor to be ran after downloading the files
|
||||
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Processor {
|
||||
/// Maven coordinates for the JAR library of this processor.
|
||||
@@ -101,13 +91,6 @@ pub struct Processor {
|
||||
pub sides: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
/// Fetches the version manifest of a game version's URL
|
||||
pub async fn fetch_partial_version(
|
||||
url: &str,
|
||||
) -> Result<PartialVersionInfo, Error> {
|
||||
Ok(serde_json::from_slice(&download_file(url, None).await?)?)
|
||||
}
|
||||
|
||||
/// Merges a partial version into a complete one
|
||||
pub fn merge_partial_version(
|
||||
partial: PartialVersionInfo,
|
||||
@@ -154,15 +137,10 @@ pub fn merge_partial_version(
|
||||
.libraries
|
||||
.into_iter()
|
||||
.chain(merge.libraries)
|
||||
.map(|x| Library {
|
||||
downloads: x.downloads,
|
||||
extract: x.extract,
|
||||
name: x.name.replace(DUMMY_REPLACE_STRING, &merge_id),
|
||||
url: x.url,
|
||||
natives: x.natives,
|
||||
rules: x.rules,
|
||||
checksums: x.checksums,
|
||||
include_in_classpath: x.include_in_classpath,
|
||||
.map(|mut x| {
|
||||
x.name = x.name.replace(DUMMY_REPLACE_STRING, &merge_id);
|
||||
|
||||
x
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
main_class: if let Some(main_class) = partial.main_class {
|
||||
@@ -180,7 +158,6 @@ pub fn merge_partial_version(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
/// A manifest containing information about a mod loader's versions
|
||||
@@ -189,7 +166,6 @@ pub struct Manifest {
|
||||
pub game_versions: Vec<Version>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
/// A game version of Minecraft
|
||||
pub struct Version {
|
||||
@@ -201,7 +177,6 @@ pub struct Version {
|
||||
pub loaders: Vec<LoaderVersion>,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "bincode", derive(Encode, Decode))]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
/// A version of a Minecraft mod loader
|
||||
pub struct LoaderVersion {
|
||||
@@ -212,8 +187,3 @@ pub struct LoaderVersion {
|
||||
/// Whether the loader is stable or not
|
||||
pub stable: bool,
|
||||
}
|
||||
|
||||
/// Fetches the manifest of a mod loader
|
||||
pub async fn fetch_manifest(url: &str) -> Result<Manifest, Error> {
|
||||
Ok(serde_json::from_slice(&download_file(url, None).await?)?)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user