Add forge data to main version info

This commit is contained in:
Jai A
2021-11-08 20:17:20 -07:00
parent e91f8f693b
commit 0990ac4fc1
3 changed files with 21 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "daedalus" name = "daedalus"
version = "0.1.4" version = "0.1.5"
authors = ["Jai A <jaiagr+gpg@pm.me>"] authors = ["Jai A <jaiagr+gpg@pm.me>"]
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"

View File

@@ -1,3 +1,4 @@
use crate::modded::{Processor, SidedDataEntry};
use crate::{download_file, Error}; use crate::{download_file, Error};
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -51,9 +52,11 @@ pub struct Version {
pub sha1: String, pub sha1: String,
/// Whether the version supports the latest player safety features /// Whether the version supports the latest player safety features
pub compliance_level: u32, pub compliance_level: u32,
#[serde(skip_serializing_if = "Option::is_none")]
/// (Modrinth Provided) The link to the assets index for this version /// (Modrinth Provided) The link to the assets index for this version
/// This is only available when using the Modrinth mirror /// This is only available when using the Modrinth mirror
pub assets_index_url: Option<String>, pub assets_index_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
/// (Modrinth Provided) The SHA1 hash of the assets index for this version /// (Modrinth Provided) The SHA1 hash of the assets index for this version
/// This is only available when using the Modrinth mirror /// This is only available when using the Modrinth mirror
pub assets_index_sha1: Option<String>, pub assets_index_sha1: Option<String>,
@@ -147,8 +150,10 @@ pub struct LibraryDownload {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
/// A list of files that should be downloaded for libraries /// A list of files that should be downloaded for libraries
pub struct LibraryDownloads { pub struct LibraryDownloads {
#[serde(skip_serializing_if = "Option::is_none")]
/// The primary library artifact /// The primary library artifact
pub artifact: Option<LibraryDownload>, pub artifact: Option<LibraryDownload>,
#[serde(skip_serializing_if = "Option::is_none")]
/// Conditional files that may be needed to be downloaded alongside the library /// Conditional files that may be needed to be downloaded alongside the library
/// The HashMap key specifies a classifier as additional information for downloading files /// The HashMap key specifies a classifier as additional information for downloading files
pub classifiers: Option<HashMap<String, LibraryDownload>>, pub classifiers: Option<HashMap<String, LibraryDownload>>,
@@ -315,6 +320,12 @@ pub struct VersionInfo {
#[serde(rename = "type")] #[serde(rename = "type")]
/// The type of version /// The type of version
pub type_: VersionType, pub type_: VersionType,
#[serde(skip_serializing_if = "Option::is_none")]
/// (Forge-only)
pub data: Option<HashMap<String, SidedDataEntry>>,
#[serde(skip_serializing_if = "Option::is_none")]
/// (Forge-only) The list of processors to run after downloading the files
pub processors: Option<Vec<Processor>>,
} }
/// Fetches detailed information about a version from the manifest /// Fetches detailed information about a version from the manifest

View File

@@ -31,10 +31,13 @@ pub struct PartialVersionInfo {
pub release_time: DateTime<Utc>, pub release_time: DateTime<Utc>,
/// The latest time a file in this version was updated /// The latest time a file in this version was updated
pub time: DateTime<Utc>, pub time: DateTime<Utc>,
#[serde(skip_serializing_if = "Option::is_none")]
/// The classpath to the main class to launch the game /// The classpath to the main class to launch the game
pub main_class: Option<String>, pub main_class: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
/// (Legacy) Arguments passed to the game /// (Legacy) Arguments passed to the game
pub minecraft_arguments: Option<String>, pub minecraft_arguments: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
/// Arguments passed to the game or JVM /// Arguments passed to the game or JVM
pub arguments: Option<HashMap<ArgumentType, Vec<Argument>>>, pub arguments: Option<HashMap<ArgumentType, Vec<Argument>>>,
/// Libraries that the version depends on /// Libraries that the version depends on
@@ -42,8 +45,10 @@ pub struct PartialVersionInfo {
#[serde(rename = "type")] #[serde(rename = "type")]
/// The type of version /// The type of version
pub type_: VersionType, pub type_: VersionType,
#[serde(skip_serializing_if = "Option::is_none")]
/// (Forge-only) /// (Forge-only)
pub data: Option<HashMap<String, SidedDataEntry>>, pub data: Option<HashMap<String, SidedDataEntry>>,
#[serde(skip_serializing_if = "Option::is_none")]
/// (Forge-only) The list of processors to run after downloading the files /// (Forge-only) The list of processors to run after downloading the files
pub processors: Option<Vec<Processor>>, pub processors: Option<Vec<Processor>>,
} }
@@ -57,8 +62,10 @@ pub struct Processor {
pub classpath: Vec<String>, pub classpath: Vec<String>,
/// Arguments for this processor. /// Arguments for this processor.
pub args: Vec<String>, pub args: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
/// Represents a map of outputs. Keys and values can be data values /// Represents a map of outputs. Keys and values can be data values
pub outputs: Option<HashMap<String, String>>, pub outputs: Option<HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
/// Which sides this processor shall be ran on. /// Which sides this processor shall be ran on.
/// Valid values: client, server, extract /// Valid values: client, server, extract
pub sides: Option<Vec<String>>, pub sides: Option<Vec<String>>,
@@ -120,6 +127,8 @@ pub fn merge_partial_version(partial: PartialVersionInfo, merge: VersionInfo) ->
release_time: partial.release_time, release_time: partial.release_time,
time: partial.time, time: partial.time,
type_: partial.type_, type_: partial.type_,
data: partial.data,
processors: partial.processors,
} }
} }