Skip to content

Commit

Permalink
Merge pull request #5 from Ryex/generate-mojang
Browse files Browse the repository at this point in the history
Refactor: Split out storage so that is is mostly generic.
  • Loading branch information
cozyGalvinism committed Oct 1, 2023
2 parents 9dd5582 + 1240a92 commit c3aa0a9
Show file tree
Hide file tree
Showing 8 changed files with 1,273 additions and 663 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ meta
# dev envierment
/.helix
/.vscode

# let this be self generated
mcmeta/static/forge/forge-legacyinfo.json
10 changes: 9 additions & 1 deletion libmcmeta/src/models/forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct ForgeVersionClassifier {
pub stash: Option<String>,
}

#[derive(Deserialize, Serialize, Clone, Debug, Validate)]
pub enum ForgeVersionClassifierExtensions {
Txt,
Zip,
Expand Down Expand Up @@ -692,7 +693,7 @@ pub struct ForgeOptional {
}

#[derive(Deserialize, Serialize, Clone, Debug, Validate, Merge, Default)]
pub struct ForgeInstallerProfile {
pub struct ForgeInstallerProfileV1 {
pub install: ForgeInstallerProfileInstallSection,
#[serde(rename = "versionInfo")]
pub version_info: ForgeVersionFile,
Expand Down Expand Up @@ -778,6 +779,13 @@ pub struct ForgeInstallerProfileV2 {
server_jar_path: Option<String>,
}

#[derive(Deserialize, Serialize, Clone, Debug, Validate)]
#[serde(untagged)]
pub enum ForgeInstallerProfile {
V1(Box<ForgeInstallerProfileV1>),
V2(Box<ForgeInstallerProfileV2>),
}

#[derive(Deserialize, Serialize, Clone, Debug, Validate, Merge, Default)]
pub struct InstallerInfo {
pub sha1hash: Option<String>,
Expand Down
8 changes: 4 additions & 4 deletions mcmeta/src/app_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use serde::Deserialize;

#[derive(Deserialize, Debug)]
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum StorageFormat {
Json {
Expand All @@ -11,7 +11,7 @@ pub enum StorageFormat {
Database,
}

#[derive(Deserialize, Debug)]
#[derive(Deserialize, Debug, Clone)]
pub struct MetadataConfig {
pub max_parallel_fetch_connections: usize,
pub static_directory: String,
Expand Down Expand Up @@ -46,9 +46,9 @@ impl ServerConfig {
.set_default("debug_log.path", "./logs")?
.set_default("debug_log.prefix", "mcmeta.log")?
.set_default("debug_log.level", "debug")?
// optionaly oad config from a file. this is optional though
// optionally add config from a file. this is optional though
.add_source(config::File::from(std::path::Path::new(path)).required(false))
// envierment overrides file
// environment overrides file
.add_source(config::Environment::with_prefix("mcmeta").separator("__"))
.build()?;

Expand Down
2 changes: 1 addition & 1 deletion mcmeta/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async fn main() -> Result<()> {

config
.storage_format
.initialize_metadata(&config.metadata)
.update_upstream_metadata(&config.metadata)
.await?;

let raw_mojang_routes = Router::new()
Expand Down

0 comments on commit c3aa0a9

Please sign in to comment.