Skip to content
This repository has been archived by the owner on Jan 11, 2025. It is now read-only.

Add Curseforge Support #21

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
target/
**/samples/
**/.env
**/node_modules
**/node_modules

**/*.so
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
"lldb.showDisassembly": "never",
"lldb.dereferencePointers": true,
"lldb.consoleMode": "commands",
"rust-analyzer.cargo.features": "all",
"rust-analyzer.rustfmt.extraArgs": [
"--config",
"tab_spaces=2"
],
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
},
}
19 changes: 19 additions & 0 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
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["denji", "hangar", "mar", "modparser", "modrinth", "mparse"]
members = [ "curseforge","denji", "hangar", "mar", "modparser", "modrinth", "mparse"]

[workspace.dependencies]
log = "0.4.21"
Expand Down
20 changes: 20 additions & 0 deletions curseforge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "curseforge"
version = "0.1.0"
edition = "2021"

[dependencies]
thiserror.workspace = true
anyhow.workspace = true
serde.workspace = true
reqwest.workspace = true
log.workspace = true

[dev-dependencies]
dotenv.workspace = true
anyhow.workspace = true
tokio.workspace = true


[lints]
workspace = true
11 changes: 11 additions & 0 deletions curseforge/examples/dep-resolve.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use anyhow::Context;
use dotenv::dotenv;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenv().context("while loading dotenv")?;

dbg!(std::env::vars());

Ok(())
}
14 changes: 14 additions & 0 deletions curseforge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
54 changes: 27 additions & 27 deletions denji/examples/install-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,34 @@ const CHANNEL_TIMEOUT: Duration = Duration::from_secs(90);

#[tokio::main]
async fn main() -> Result<()> {
env_logger::init();

let root_dir = TempDir::new("test.denji.serverInstall")?.into_path();
let server_installer =
MinecraftServer::new(ServerSoftware::Forge, "1.20.4-49.1.4", "1.20.4", root_dir);
let (tx, rx) = channel();
let server_build = spawn(async move { server_installer.build_server(tx).await });

info!(
"started installer (timeout: {})",
format_duration(CHANNEL_TIMEOUT)
);

loop {
match rx.recv_timeout(CHANNEL_TIMEOUT) {
Ok(line) => info!("{}", line),
Err(e) => {
warn!("{}. closing installer", e);
break;
}
}
env_logger::init();

let root_dir = TempDir::new("test.denji.serverInstall")?.into_path();
let server_installer =
MinecraftServer::new(ServerSoftware::Forge, "1.20.4-49.1.4", "1.20.4", root_dir);
let (tx, rx) = channel();
let server_build = spawn(async move { server_installer.build_server(tx).await });

info!(
"started installer (timeout: {})",
format_duration(CHANNEL_TIMEOUT)
);

loop {
match rx.recv_timeout(CHANNEL_TIMEOUT) {
Ok(line) => info!("{}", line),
Err(e) => {
warn!("{}. closing installer", e);
break;
}
}
}

server_build
.await
.context("while trying to finish installer")?
.context("while trying to install server")?;
server_build
.await
.context("while trying to finish installer")?
.context("while trying to install server")?;

info!("you may test the channel and close this program when finished");
Result::Ok(())
info!("you may test the channel and close this program when finished");
Result::Ok(())
}
Loading
Loading