From ac465d63eb20e829485513b266c06a05ba19bde9 Mon Sep 17 00:00:00 2001 From: Jacob Sapoznikow Date: Fri, 21 Jun 2024 14:06:32 +0000 Subject: [PATCH] plan --- Cargo.lock | 36 ++--- Cargo.toml | 2 +- apps/cli/CLI.md | 231 ++++++++++++++++++++++++++++++++ crates/pack/Cargo.toml | 10 ++ crates/pack/src/lib.rs | 4 + crates/pack/src/models/index.rs | 0 crates/pack/src/models/mod.rs | 6 + crates/pack/src/models/pack.rs | 0 external/ckandex | 2 +- 9 files changed, 267 insertions(+), 24 deletions(-) create mode 100644 apps/cli/CLI.md create mode 100644 crates/pack/Cargo.toml create mode 100644 crates/pack/src/lib.rs create mode 100644 crates/pack/src/models/index.rs create mode 100644 crates/pack/src/models/mod.rs create mode 100644 crates/pack/src/models/pack.rs diff --git a/Cargo.lock b/Cargo.lock index 8a48b3e..0d07aad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2850,22 +2850,6 @@ dependencies = [ "tokio-native-tls", ] -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes 1.6.0", - "http-body-util", - "hyper 1.3.1", - "hyper-util", - "native-tls", - "tokio 1.37.0", - "tokio-native-tls", - "tower-service", -] - [[package]] name = "hyper-util" version = "0.1.3" @@ -4095,6 +4079,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.28.1+1.1.1w" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf7e82ffd6d3d6e6524216a0bfd85509f68b5b28354e8e7800057e44cefa9b4" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.85" @@ -4103,6 +4096,7 @@ checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] @@ -4159,6 +4153,10 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "pack" +version = "2.0.0" + [[package]] name = "pango" version = "0.15.10" @@ -5007,22 +5005,18 @@ dependencies = [ "async-compression", "base64 0.22.1", "bytes 1.6.0", - "encoding_rs", "futures-core", "futures-util", - "h2 0.4.4", "http 1.1.0", "http-body 1.0.0", "http-body-util", "hyper 1.3.1", "hyper-rustls", - "hyper-tls 0.6.0", "hyper-util", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite 0.2.13", @@ -5033,9 +5027,7 @@ dependencies = [ "serde_json", "serde_urlencoded 0.7.1", "sync_wrapper 0.1.2", - "system-configuration", "tokio 1.37.0", - "tokio-native-tls", "tokio-rustls", "tokio-util 0.7.11", "tower-service", diff --git a/Cargo.toml b/Cargo.toml index 2dba72d..14c0348 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -147,5 +147,5 @@ members = [ "crates/mcmeta", "apps/wormhole", "crates/commands", - "crates/plugins", + "crates/plugins", "crates/pack", ] diff --git a/apps/cli/CLI.md b/apps/cli/CLI.md new file mode 100644 index 0000000..19a1890 --- /dev/null +++ b/apps/cli/CLI.md @@ -0,0 +1,231 @@ +# Modpacks + +## Pack Info (pack.toml) + +```toml +[meta] +name = "My Modpack" +version = "0.1.0" # Adheres to SemVer +authors = ["Me!"] + +[versions] +minecraft = "1.21.x" # SemVer range + +[[export]] +side = "client" +format = "modrinth" + +[[export]] +side = "client" +format = "curseforge" + +[[export]] +side = "server" +format = "zip" + +[[export]] +side = "server" +format = "tar+gz" + +[[export]] +side = "both" +format = "wormhole" + +[[loaders]] +id = "fabric" +version = "0.15.11" + +[[loaders]] +id = "quilt" +version = "0.26.1-beta.1" + +[[loaders]] +id = "forge" +version = "51.0.16" + +[[loaders]] +id = "neoforge" +version = "21.0.21-beta" +``` + +## Version Handling Example + +```rs +/* +[dependencies] +anyhow = "1.0.86" +semver = "1.0.23" +lenient_semver = "0.4.2" +*/ + +use anyhow::Result; +use semver::VersionReq; + +fn main() -> Result<()> { + let v = VersionReq::parse("1.21.x")?; + let n = lenient_semver::parse("1.21")?; + let n2 = lenient_semver::parse("1.20.1")?; + let n3 = lenient_semver::parse("1.21.1")?; + let n4 = lenient_semver::parse("1.22")?; + + println!("{} in {}: {}", n, v, v.matches(&n)); + println!("{} in {}: {}", n2, v, v.matches(&n2)); + println!("{} in {}: {}", n3, v, v.matches(&n3)); + println!("{} in {}: {}", n4, v, v.matches(&n4)); + + Ok(()) +} +``` + +## Commands + +- `wh pack init`: Initialize a modpack project (interactively or non-interactively) +- `wh pack add [slug|id|url] (--file [file_id] --source [source])`: Add a mod +- `wh pack export (--format [format] --side [side])`: Export the pack +- `wh pack refresh`: Refresh the index lock +- `wh pack list`: List all mods in a modpack +- `wh pack update (--all)`: Update mods + +## Mod Metadata (mods/[mod_id].toml) + +```toml +# mods/sodium.toml +[mod] +id = "sodium" +source = "modrinth" +version = "mc1.21-0.5.9" +side = "client" +loaders = ["fabric", "quilt"] + +[file] +hash-format = "sha1" +hash = "" +url = "" +``` + +## Index File (index.lock) + +```rs +// Binary Serialized +// THIS IS PSEUDOCODE! NOT AN ACTUAL MACRO! + +define_binary_format! { + gzip = true, + + input = array({ + path: str, + hash: [char; 40], + }), + + body = { + // Header + ascii("INDX"); + NUL; + literal(1 => u8); + NUL; + + // Body + ascii("DATA"); + NUL + + array({ + ascii(F); + NUL; + input(path => str + '\0'); // Yes there are two null characters after the string. + NUL; + input(hash => [char; 40]); // sha-1 is always 40 chars long + NUL; + }); + + // End + EOF; + } +} +``` + +## Wormhole Pack Format + +### manifest.json + +```json +{ + "$schema": "TODO", + "version": 1, + + "pack": { + "name": "My Modpack", + "version": "0.1.0", + + "authors": [ + "Me!" + ] + }, + + "management": { + "game_id": "mc", // Wormhole Plugin ID + "game_version": "1.21.x", // Optional for anything but Minecraft + + "mod_loaders": [ + { + "id": "fabric", + "version": "0.15.11" + }, + + { + "id": "quilt", + "version": "0.26.1-beta.1" + }, + + { + "id": "forge", + "version": "51.0.16" + }, + + { + "id": "neoforge", + "version": "21.0.21-beta" + } + ] + }, + + "files": [ + { + "path": "options.txt", + "hash": { + "format": "sha1", + "value": "" + } + } + + ... + ], + + "mods": [ + { + "id": "sodium", + "source": "modrinth", + "version": "mc1.21-0.5.9", + "loaders": ["fabric", "quilt"], + "url": "", + + "hash": { + "format": "sha1", + "value": "" + } + }, + + { + "id": "embeddium", + "source": "modrinth", + "version": "1.0.0-beta.1+mc1.21", + "loaders": ["forge", "neoforge"], + "url": "", + + "hash": { + "format": "sha1", + "value": "" + } + } + ] +} +``` diff --git a/crates/pack/Cargo.toml b/crates/pack/Cargo.toml new file mode 100644 index 0000000..d4be898 --- /dev/null +++ b/crates/pack/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "pack" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true +homepage.workspace = true +authors.workspace = true + +[dependencies] diff --git a/crates/pack/src/lib.rs b/crates/pack/src/lib.rs new file mode 100644 index 0000000..53bf209 --- /dev/null +++ b/crates/pack/src/lib.rs @@ -0,0 +1,4 @@ +//! # WHPack +//! +//! Wormhole's modpack management & creation module. + diff --git a/crates/pack/src/models/index.rs b/crates/pack/src/models/index.rs new file mode 100644 index 0000000..e69de29 diff --git a/crates/pack/src/models/mod.rs b/crates/pack/src/models/mod.rs new file mode 100644 index 0000000..37621a9 --- /dev/null +++ b/crates/pack/src/models/mod.rs @@ -0,0 +1,6 @@ +//! # Models +//! +//! WHPack follows the pack-config-index system introduced by Packwiz. +//! The pack.toml file will contain general information about the pack, +//! the index.lock file will contain a cached list of every file in the pack, +//! and the .whignore file will contain a gitignore-style list of files to ignore. \ No newline at end of file diff --git a/crates/pack/src/models/pack.rs b/crates/pack/src/models/pack.rs new file mode 100644 index 0000000..e69de29 diff --git a/external/ckandex b/external/ckandex index 675af20..9f17405 160000 --- a/external/ckandex +++ b/external/ckandex @@ -1 +1 @@ -Subproject commit 675af20d078cc8914a026343a26424a546706a58 +Subproject commit 9f174058a2b10c5de8a1596e32c4ce8ac5fd5e31