Skip to content

Commit

Permalink
Modify mod config & parse mod dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jadelily18 committed Oct 26, 2023
1 parent 9b4352f commit 8538e34
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 11 deletions.
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ async fn main() -> Result<(), anyhow::Error> {
))
};

println!("jar path: {:?}", &jar_path);
if file_name.ends_with("-sources.jar") {
possible_sources_jars.push(jar_path)
} else if file_name.ends_with(".jar") {
Expand Down Expand Up @@ -476,8 +475,14 @@ async fn main() -> Result<(), anyhow::Error> {
&*loader_file_string
)?;

println!("Mod Version: {}", parsed_loader_file["version"]);
println!("Mod ID: {}", parsed_loader_file["id"]);
// println!("Mod Version: {}", parsed_loader_file["version"]);
// println!("Mod ID: {}", parsed_loader_file["id"]);

for dependency in config_file.modrinth.dependencies {
println!("Project ID: {:?}", &dependency.project_id);
println!("Version ID: {:?}", &dependency.version_id);
println!("Dependency Type: {:?}", &dependency.dependency_type)
}

clean_up(&tmp_info.dir_path)?

Expand Down
1 change: 0 additions & 1 deletion src/models/meta.rs

This file was deleted.

4 changes: 3 additions & 1 deletion src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use serde::{Deserialize, Serialize};

pub mod github;
pub mod meta;
pub mod modrinth;
pub mod project_type;
pub mod util;
Expand All @@ -13,6 +12,9 @@ pub struct GithubConfig {
pub repo_name: String
}

// Eventually should be moved to models::project_type::modpack::config
// unnecessary for now, but should be moved before project types other than modpacks
// and mods are implemented.
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ModrinthConfig {
pub project_id: String,
Expand Down
5 changes: 1 addition & 4 deletions src/models/modrinth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ pub struct GalleryObject {
}

#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum DependencyType {
#[serde(rename = "required")]
REQUIRED,
#[serde(rename = "optional")]
OPTIONAL,
#[serde(rename = "incompatible")]
INCOMPATIBLE,
#[serde(rename = "embedded")]
EMBEDDED
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
use serde::{Serialize, Deserialize};
use crate::models::{DiscordConfig, GithubConfig, ModrinthConfig};
use crate::models::modrinth::Loader;
use crate::models::{
DiscordConfig,
GithubConfig,
modrinth::Loader,
project_type::mc_mod::config::modrinth::ModrinthConfig
};

mod modrinth;

#[derive(Debug, Serialize, Deserialize)]
pub struct ModConfig {
Expand Down
19 changes: 19 additions & 0 deletions src/models/project_type/mc_mod/config/modrinth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use serde::{Serialize, Deserialize};
use crate::models::modrinth::DependencyType;


#[derive(Debug, Serialize, Deserialize)]
pub struct ModrinthConfig {
pub project_id: String,
pub staging: Option<bool>,
#[serde(rename = "dependency")]
pub dependencies: Vec<ModrinthDependency>
}

#[derive(Debug, Serialize, Deserialize)]
pub struct ModrinthDependency {
pub version_id: Option<String>,
pub project_id: Option<String>,
pub dependency_type: DependencyType
}

13 changes: 13 additions & 0 deletions test_projects/mod/peony_mod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,27 @@ config_format_version = 1
version_name_format = "[%mc_version%] %project_name% v%project_version% - %loader%"
loaders = ["fabric", "quilt"]


[modrinth]
project_id = "2jZzXrpV"
staging = true

[[modrinth.dependency]]
version_id = "aegpoin"
project_id = "2jZzXrpV"
dependency_type = "optional"

[[modrinth.dependency]]
version_id = "aegpoin"
project_id = "2jZzXrpV"
dependency_type = "required"


[github]
repo_owner = "LilydevMC"
repo_name = "mrpack-dist-test"


[discord]
github_emoji_id = "<:github_light:1000525612911444118>"
modrinth_emoji_id = "<:modrinth:1000522854766497813>"
Expand Down

0 comments on commit 8538e34

Please sign in to comment.