Skip to content

Commit

Permalink
plan
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Jun 21, 2024
1 parent 3e48389 commit ac465d6
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 24 deletions.
36 changes: 14 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ members = [
"crates/mcmeta",
"apps/wormhole",
"crates/commands",
"crates/plugins",
"crates/plugins", "crates/pack",
]
231 changes: 231 additions & 0 deletions apps/cli/CLI.md
Original file line number Diff line number Diff line change
@@ -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 = "<sha1>"
url = "<jar_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": "<sha1>"
}
}

...
],

"mods": [
{
"id": "sodium",
"source": "modrinth",
"version": "mc1.21-0.5.9",
"loaders": ["fabric", "quilt"],
"url": "<jar_url>",

"hash": {
"format": "sha1",
"value": "<sha1>"
}
},

{
"id": "embeddium",
"source": "modrinth",
"version": "1.0.0-beta.1+mc1.21",
"loaders": ["forge", "neoforge"],
"url": "<jar_url>",

"hash": {
"format": "sha1",
"value": "<sha1>"
}
}
]
}
```
10 changes: 10 additions & 0 deletions crates/pack/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
4 changes: 4 additions & 0 deletions crates/pack/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! # WHPack
//!
//! Wormhole's modpack management & creation module.
Empty file added crates/pack/src/models/index.rs
Empty file.
6 changes: 6 additions & 0 deletions crates/pack/src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -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.
Empty file added crates/pack/src/models/pack.rs
Empty file.
2 changes: 1 addition & 1 deletion external/ckandex
Submodule ckandex updated 1 files
+2 −2 ckandex/Cargo.toml

0 comments on commit ac465d6

Please sign in to comment.