From 21fd39b0c0347c77937ae2a6a026b751192fd9c5 Mon Sep 17 00:00:00 2001 From: Ilesh Thiada Date: Wed, 25 Sep 2024 22:31:23 +0530 Subject: [PATCH] Implement changes to libium --- .github/workflows/build.yml | 1 - CHANGELOG.md | 5 + Cargo.lock | 343 +++++++++++++++++++++-------- Cargo.toml | 8 +- justfile | 4 +- src/download.rs | 8 +- src/main.rs | 59 +---- src/subcommands/list.rs | 32 +-- src/subcommands/modpack/add.rs | 8 +- src/subcommands/modpack/upgrade.rs | 74 +++---- src/subcommands/upgrade.rs | 87 +++----- 11 files changed, 357 insertions(+), 272 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fa97db..8032dce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,6 @@ jobs: run: cargo clippy - name: Run tests - if: matrix.os == 'ubuntu-latest' run: cargo test --no-default-features - name: Build macOS Intel diff --git a/CHANGELOG.md b/CHANGELOG.md index 5136358..9575677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog for Ferium +## `v4.8.0` +### + + + ## `v4.7.1` ### 17.09.2024 diff --git a/Cargo.lock b/Cargo.lock index 598f4f0..07d2602 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,18 +124,22 @@ checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" [[package]] name = "ashpd" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd884d7c72877a94102c3715f3b1cd09ff4fac28221add3e57cfbe25c236d093" +checksum = "bfe7e0dd0ac5a401dc116ed9f9119cf9decc625600474cb41f0fc0a0050abc9a" dependencies = [ "enumflags2", "futures-channel", "futures-util", "rand", + "raw-window-handle", "serde", "serde_repr", "tokio", "url", + "wayland-backend", + "wayland-client", + "wayland-protocols", "zbus", ] @@ -249,9 +253,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", @@ -303,12 +307,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - [[package]] name = "block-buffer" version = "0.10.4" @@ -318,6 +316,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2", +] + [[package]] name = "blocking" version = "1.6.1" @@ -345,9 +352,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bzip2" @@ -372,9 +379,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.19" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" dependencies = [ "jobserver", "libc", @@ -420,9 +427,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -430,9 +437,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -442,18 +449,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.26" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" +checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -643,6 +650,21 @@ dependencies = [ "syn", ] +[[package]] +name = "dlib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" +dependencies = [ + "libloading", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + [[package]] name = "either" version = "1.13.0" @@ -743,7 +765,7 @@ dependencies = [ [[package]] name = "ferium" -version = "4.7.1" +version = "4.7.2" dependencies = [ "anyhow", "clap", @@ -1122,9 +1144,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1135,7 +1157,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -1222,9 +1243,9 @@ checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "iri-string" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0f755bd3806e06ad4f366f92639415d99a339a2c7ecf8c26ccea2097c11cb6" +checksum = "9c25163201be6ded9e686703e85532f8f852ea1f92ba625cb3c51f7fe6d07a4a" dependencies = [ "memchr", "serde", @@ -1315,15 +1336,14 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libium" version = "1.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f076800b80c9d1796f2b65cb1f51f6ae041fab0025be756502f78c07491ab85" +source = "git+https://github.com/gorilla-devs/libium?rev=bd79852#bd79852aca3a62eee7ac79542eec39b8e454cd7e" dependencies = [ "clap", "dialoguer", @@ -1332,7 +1352,6 @@ dependencies = [ "futures-util", "home", "octocrab", - "once_cell", "reqwest", "rfd", "serde", @@ -1344,6 +1363,16 @@ dependencies = [ "zip-extensions", ] +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets 0.52.6", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1372,15 +1401,6 @@ dependencies = [ "crc", ] -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - [[package]] name = "memchr" version = "2.7.4" @@ -1483,32 +1503,103 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] -name = "objc" -version = "0.2.7" +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" dependencies = [ - "malloc_buf", + "objc-sys", + "objc2-encode", ] [[package]] -name = "objc-foundation" -version = "0.1.1" +name = "objc2-app-kit" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "block", - "objc", - "objc_id", + "bitflags", + "block2", + "libc", + "objc2", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation", + "objc2-quartz-core", ] [[package]] -name = "objc_id" -version = "0.1.1" +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", +] + +[[package]] +name = "objc2-encode" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags", + "block2", + "dispatch", + "libc", + "objc2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags", + "block2", + "objc2", + "objc2-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "objc", + "bitflags", + "block2", + "objc2", + "objc2-foundation", + "objc2-metal", ] [[package]] @@ -1522,9 +1613,9 @@ dependencies = [ [[package]] name = "octocrab" -version = "0.39.0" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9305e4c99543ecd0f42bd659c9e9d6ca7115fe5e37d5c85a7277b1db0d4c4101" +checksum = "09386c28b984097d7a56ec23907bb76751ae6720ebdc4484fe2a705c95d5b77d" dependencies = [ "arc-swap", "async-trait", @@ -1658,9 +1749,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polling" @@ -1685,9 +1776,9 @@ checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" [[package]] name = "powerfmt" @@ -1722,6 +1813,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quick-xml" +version = "0.36.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" +dependencies = [ + "memchr", +] + [[package]] name = "quinn" version = "0.11.5" @@ -1890,18 +1990,17 @@ dependencies = [ [[package]] name = "rfd" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a73a7337fc24366edfca76ec521f51877b114e42dab584008209cca6719251" +checksum = "8af382a047821a08aa6bfc09ab0d80ff48d45d8726f7cd8e44891f7cb4a4278e" dependencies = [ "ashpd", - "block", - "dispatch", + "block2", "js-sys", "log", - "objc", - "objc-foundation", - "objc_id", + "objc2", + "objc2-app-kit", + "objc2-foundation", "pollster", "raw-window-handle", "urlencoding", @@ -2034,6 +2133,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "secrecy" version = "0.8.0" @@ -2058,9 +2163,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -2204,18 +2309,18 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snafu" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b835cb902660db3415a672d862905e791e54d306c6e8189168c7f3d9ae1c79d" +checksum = "223891c85e2a29c3fe8fb900c1fae5e69c2e42415e3177752e8718475efa5019" dependencies = [ "snafu-derive", ] [[package]] name = "snafu-derive" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d1e02fca405f6280643174a50c942219f0bbf4dbf7d480f1dd864d6f211ae5" +checksum = "03c3c6b7927ffe7ecaa769ee0e3994da3b8cafc8f444578982c83ecb161af917" dependencies = [ "heck", "proc-macro2", @@ -2313,18 +2418,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -2449,9 +2554,9 @@ checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", @@ -2576,18 +2681,18 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "untrusted" @@ -2707,6 +2812,66 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "wayland-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "056535ced7a150d45159d3a8dc30f91a2e2d588ca0b23f70e56033622b8016f6" +dependencies = [ + "cc", + "downcast-rs", + "rustix", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3f45d1222915ef1fd2057220c1d9d9624b7654443ea35c3877f7a52bd0a5a2d" +dependencies = [ + "bitflags", + "rustix", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b5755d77ae9040bb872a25026555ce4cb0ae75fd923e90d25fba07d81057de0" +dependencies = [ + "bitflags", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597f2001b2e5fc1121e3d5b9791d3e78f05ba6bfa4641053846248e3a13661c3" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efa8ac0d8e8ed3e3b5c9fc92c7881406a268e11555abe36493efabe649a29e09" +dependencies = [ + "dlib", + "log", + "pkg-config", +] + [[package]] name = "web-sys" version = "0.3.70" @@ -2719,9 +2884,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] @@ -2937,9 +3102,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "c52ac009d615e79296318c1bcce2d422aaca15ad08515e344feeda07df67a587" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 9cd5018..10b94d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ferium" -version = "4.7.1" +version = "4.7.2" repository = "https://github.com/gorilla-devs/ferium" description = "Fast CLI program for managing Minecraft mods and modpacks from Modrinth, CurseForge, and Github Releases" authors = [ @@ -54,12 +54,14 @@ serde_json = "1.0" dialoguer = "0.11" indicatif = "0.17" itertools = "0.13" -octocrab = "0.39" +octocrab = "0.40" fs_extra = "1.3" ferinth = "2.11" colored = "2.1" futures = "0.3" -libium = "1.30" +libium = { git = "https://github.com/gorilla-devs/libium", rev = "bd79852" } +# libium = { path = "../libium" } +# libium = "1.31" anyhow = "1.0" furse = "1.5" size = "0.4" diff --git a/justfile b/justfile index 6049587..df90460 100644 --- a/justfile +++ b/justfile @@ -6,8 +6,8 @@ install: cargo install --force --path . # Install ferium to cargo's binary folder, but with faster compilation (offline, debug, nightly, parallel frontend) -install-dev $RUSTFLAGS="-Z threads=8": - cargo +nightly install --offline --debug --force --path . +install-dev: + cargo install --offline --debug --force --path . # Delete test artefacts clean-test: diff --git a/src/download.rs b/src/download.rs index e76da48..71001c1 100644 --- a/src/download.rs +++ b/src/download.rs @@ -11,7 +11,7 @@ use fs_extra::{ use futures::{stream::FuturesUnordered, StreamExt as _}; use indicatif::ProgressBar; use itertools::Itertools; -use libium::upgrade::Downloadable; +use libium::upgrade::DownloadFile; use reqwest::Client; use size::Size; use std::{ @@ -30,10 +30,10 @@ use tokio::sync::Semaphore; /// - If the file is a `.part` file or if the move failed, the file will be deleted pub async fn clean( directory: &Path, - to_download: &mut Vec, + to_download: &mut Vec, to_install: &mut Vec<(OsString, PathBuf)>, ) -> Result<()> { - let dupes = find_dupes_by_key(to_download, Downloadable::filename); + let dupes = find_dupes_by_key(to_download, DownloadFile::filename); if !dupes.is_empty() { println!( "{}", @@ -100,7 +100,7 @@ pub fn read_overrides(directory: &Path) -> Result> { /// Download and install the files in `to_download` and `to_install` to `output_dir` pub async fn download( output_dir: PathBuf, - to_download: Vec, + to_download: Vec, to_install: Vec<(OsString, PathBuf)>, ) -> Result<()> { let progress_bar = Arc::new(Mutex::new( diff --git a/src/main.rs b/src/main.rs index 1a63f6f..05224dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,8 +24,6 @@ use clap::{CommandFactory, Parser}; use cli::{Ferium, ModpackSubCommands, ProfileSubCommands, SubCommands}; use colored::{ColoredString, Colorize}; use dialoguer::theme::ColorfulTheme; -use ferinth::Ferinth; -use furse::Furse; use indicatif::ProgressStyle; use itertools::Itertools; use libium::{ @@ -37,14 +35,13 @@ use libium::{ read_wrapper, }; use std::{ - env::{var, var_os}, + env::{set_var, var_os}, process::ExitCode, sync::LazyLock, }; const CROSS: &str = "×"; static TICK: LazyLock = LazyLock::new(|| "✓".green()); -static YELLOW_TICK: LazyLock = LazyLock::new(|| "✓".yellow()); /// Dialoguer theme static THEME: LazyLock = LazyLock::new(Default::default); @@ -137,23 +134,12 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { }; } - let mut github = octocrab::OctocrabBuilder::new(); if let Some(token) = cli_app.github_token { - github = github.personal_token(token); - } else if let Ok(token) = var("GITHUB_TOKEN") { - github = github.personal_token(token); + set_var("GITHUB_TOKEN", token); + } + if let Some(key) = cli_app.curseforge_api_key { + set_var("CURSEFORGE_API_KEY", key); } - let modrinth = Ferinth::new( - "ferium", - option_env!("CARGO_PKG_VERSION"), - Some("Discord: therookiecoder"), - None, - )?; - let curseforge = Furse::new(&cli_app.curseforge_api_key.unwrap_or_else(|| { - var("CURSEFORGE_API_KEY").unwrap_or(String::from( - "$2a$10$sI.yRk4h4R49XYF94IIijOrO4i3W3dAFZ4ssOlNE10GYrDhc2j8K.", - )) - })); let mut config_file = config::get_file( &cli_app @@ -180,14 +166,9 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { let spinner = indicatif::ProgressBar::new_spinner().with_message("Reading files"); spinner.enable_steady_tick(std::time::Duration::from_millis(100)); - let ids = libium::scan( - &modrinth, - &curseforge, - directory.as_ref().unwrap_or(&profile.output_dir), - || { - spinner.set_message("Querying servers"); - }, - ) + let ids = libium::scan(directory.as_ref().unwrap_or(&profile.output_dir), || { + spinner.set_message("Querying servers"); + }) .await?; spinner.set_message("Adding mods"); @@ -214,15 +195,7 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { } } - let (successes, failures) = libium::add( - libium::APIs::new(&modrinth, &curseforge, &github.build()?), - profile, - send_ids, - !force, - true, - true, - ) - .await?; + let (successes, failures) = libium::add(profile, send_ids, !force, true, true).await?; spinner.finish_and_clear(); did_add_fail = add::display_successes_failures(&successes, failures); @@ -240,7 +213,6 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { } let (successes, failures) = libium::add( - libium::APIs::new(&modrinth, &curseforge, &github.build()?), profile, identifiers .into_iter() @@ -259,7 +231,7 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { check_empty_profile(profile)?; if verbose { - subcommands::list::verbose(modrinth, curseforge, profile, markdown).await?; + subcommands::list::verbose(profile, markdown).await?; } else { println!( "{} {} on {} {}\n", @@ -302,7 +274,6 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { } => { if let Ok(project_id) = identifier.parse::() { subcommands::modpack::add::curseforge( - &curseforge, &mut config, project_id, output_dir, @@ -310,7 +281,6 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { ) .await?; } else if let Err(err) = subcommands::modpack::add::modrinth( - &modrinth, &mut config, &identifier, output_dir, @@ -355,12 +325,7 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { subcommands::modpack::switch(&mut config, modpack_name)?; } ModpackSubCommands::Upgrade => { - subcommands::modpack::upgrade( - &modrinth, - &curseforge, - get_active_modpack(&mut config)?, - ) - .await?; + subcommands::modpack::upgrade(get_active_modpack(&mut config)?).await?; } }; if default_flag { @@ -446,7 +411,7 @@ async fn actual_main(mut cli_app: Ferium) -> Result<()> { SubCommands::Upgrade => { let profile = get_active_profile(&mut config)?; check_empty_profile(profile)?; - subcommands::upgrade(modrinth, curseforge, github.build()?, profile).await?; + subcommands::upgrade(profile).await?; } }; diff --git a/src/subcommands/list.rs b/src/subcommands/list.rs index f347caf..914545d 100644 --- a/src/subcommands/list.rs +++ b/src/subcommands/list.rs @@ -3,18 +3,15 @@ use crate::TICK; use anyhow::{Context, Result}; use colored::Colorize; -use ferinth::{ - structures::{project::Project, user::TeamMember}, - Ferinth, -}; -use furse::{structures::mod_structs::Mod, Furse}; +use ferinth::structures::{project::Project, user::TeamMember}; +use furse::structures::mod_structs::Mod; use futures::{stream::FuturesUnordered, StreamExt as _}; use itertools::{izip, Itertools}; -use libium::config::structs::{ModIdentifier, Profile}; -use octocrab::{ - models::{repos::Release, Repository}, - OctocrabBuilder, +use libium::{ + config::structs::{ModIdentifier, Profile}, + CURSEFORGE_API, GITHUB_API, MODRINTH_API, }; +use octocrab::models::{repos::Release, Repository}; enum Metadata { CF(Mod), @@ -41,7 +38,7 @@ impl Metadata { } } -pub async fn verbose(md: Ferinth, cf: Furse, profile: &mut Profile, markdown: bool) -> Result<()> { +pub async fn verbose(profile: &mut Profile, markdown: bool) -> Result<()> { if !markdown { eprint!("Querying metadata... "); } @@ -56,13 +53,8 @@ pub async fn verbose(md: Ferinth, cf: Furse, profile: &mut Profile, markdown: bo ModIdentifier::GitHubRepository((owner, repo)) => { tasks.push(async { Ok::<_, anyhow::Error>(( - OctocrabBuilder::new() - .build()? - .repos(&owner, &repo) - .get() - .await?, - OctocrabBuilder::new() - .build()? + GITHUB_API.repos(&owner, &repo).get().await?, + GITHUB_API .repos(owner, repo) .releases() .list() @@ -74,10 +66,10 @@ pub async fn verbose(md: Ferinth, cf: Furse, profile: &mut Profile, markdown: bo } } - let mr_projects = md + let mr_projects = MODRINTH_API .get_multiple_projects(&mr_ids.iter().map(|s| &**s).collect::>()) .await?; - let mr_teams_members = md + let mr_teams_members = MODRINTH_API .list_multiple_teams_members( &mr_projects .iter() @@ -89,7 +81,7 @@ pub async fn verbose(md: Ferinth, cf: Furse, profile: &mut Profile, markdown: bo let cf_projects = if cf_ids.is_empty() { Vec::new() } else { - cf.get_mods(cf_ids).await? + CURSEFORGE_API.get_mods(cf_ids).await? }; let mut metadata = Vec::new(); diff --git a/src/subcommands/modpack/add.rs b/src/subcommands/modpack/add.rs index 2ee5725..26c6805 100644 --- a/src/subcommands/modpack/add.rs +++ b/src/subcommands/modpack/add.rs @@ -3,8 +3,6 @@ use crate::{THEME, TICK}; use anyhow::{anyhow, Result}; use colored::Colorize; use dialoguer::Confirm; -use ferinth::Ferinth; -use furse::Furse; use itertools::Itertools; use libium::{ config::structs::{Config, Modpack, ModpackIdentifier}, @@ -15,14 +13,13 @@ use libium::{ use std::path::PathBuf; pub async fn curseforge( - curseforge: &Furse, config: &mut Config, project_id: i32, output_dir: Option, install_overrides: Option, ) -> Result<()> { eprint!("Checking modpack... "); - let project = add::curseforge(curseforge, config, project_id).await?; + let project = add::curseforge(config, project_id).await?; println!("{} ({})", *TICK, project.name); println!("Where should the modpack be installed to?"); let output_dir = match output_dir { @@ -62,14 +59,13 @@ pub async fn curseforge( } pub async fn modrinth( - modrinth: &Ferinth, config: &mut Config, project_id: &str, output_dir: Option, install_overrides: Option, ) -> Result<()> { eprint!("Checking modpack... "); - let project = add::modrinth(modrinth, config, project_id).await?; + let project = add::modrinth(config, project_id).await?; println!("{} ({})", *TICK, project.title); println!("Where should the modpack be installed to?"); let output_dir = match output_dir { diff --git a/src/subcommands/modpack/upgrade.rs b/src/subcommands/modpack/upgrade.rs index 0392ccf..cffa8f6 100644 --- a/src/subcommands/modpack/upgrade.rs +++ b/src/subcommands/modpack/upgrade.rs @@ -4,8 +4,6 @@ use crate::{ }; use anyhow::{Context, Result}; use colored::Colorize; -use ferinth::Ferinth; -use furse::Furse; use futures::{stream::FuturesUnordered, StreamExt as _}; use indicatif::ProgressBar; use itertools::Itertools; @@ -14,11 +12,8 @@ use libium::{ modpack::{ curseforge::structs::Manifest, modrinth::structs::Metadata, read_file_from_zip, zip_extract, }, - upgrade::{ - modpack_downloadable::{download_curseforge_modpack, download_modrinth_modpack}, - DistributionDeniedError, Downloadable, - }, - HOME, + upgrade::{DistributionDeniedError, DownloadFile}, + CURSEFORGE_API, HOME, }; use std::{ fs::File, @@ -27,43 +22,45 @@ use std::{ time::Duration, }; -pub async fn upgrade(modrinth: &Ferinth, curseforge: &Furse, modpack: &'_ Modpack) -> Result<()> { - let mut to_download: Vec = Vec::new(); +pub async fn upgrade(modpack: &'_ Modpack) -> Result<()> { + let mut to_download: Vec = Vec::new(); let mut to_install = Vec::new(); let install_msg; + + let progress_bar = ProgressBar::new(0).with_style(STYLE_BYTE.clone()); + let modpack_filepath = modpack + .identifier + .download_file( + |total| { + progress_bar.println("Downloading Modpack".bold().to_string()); + progress_bar.enable_steady_tick(Duration::from_millis(100)); + progress_bar.set_length(total as u64); + }, + |additional| { + progress_bar.inc(additional as u64); + }, + ) + .await?; + let modpack_file = File::open(&modpack_filepath)?; + progress_bar.finish_and_clear(); + match &modpack.identifier { - ModpackIdentifier::CurseForgeModpack(project_id) => { - let progress_bar = ProgressBar::new(0).with_style(STYLE_BYTE.clone()); - let modpack_filepath = download_curseforge_modpack( - &curseforge.clone(), - *project_id, - |total| { - progress_bar.println("Downloading Modpack".bold().to_string()); - progress_bar.enable_steady_tick(Duration::from_millis(100)); - progress_bar.set_length(total as u64); - }, - |additional| { - progress_bar.inc(additional as u64); - }, - ) - .await?; - let modpack_file = File::open(&modpack_filepath)?; + ModpackIdentifier::CurseForgeModpack(_) => { let manifest: Manifest = serde_json::from_str( &read_file_from_zip(BufReader::new(modpack_file), "manifest.json")? .context("Does not contain manifest")?, )?; - progress_bar.finish_and_clear(); eprint!("\n{}", "Determining files to download... ".bold()); let file_ids = manifest.files.iter().map(|file| file.file_id).collect(); - let files = curseforge.get_files(file_ids).await?; + let files = CURSEFORGE_API.get_files(file_ids).await?; println!("{} Fetched {} mods", &*TICK, files.len()); let mut tasks = FuturesUnordered::new(); let mut msg_shown = false; for file in files { - match TryInto::::try_into(file) { + match TryInto::::try_into(file) { Ok(mut downloadable) => { downloadable.output = PathBuf::from( if Path::new(&downloadable.filename()) @@ -83,9 +80,8 @@ pub async fn upgrade(modrinth: &Ferinth, curseforge: &Furse, modpack: &'_ Modpac println!("\n{}", "The following mod(s) have denied 3rd parties such as Ferium from downloading it".red().bold()); } msg_shown = true; - let curseforge = curseforge.clone(); tasks.push(async move { - let project = curseforge.get_mod(mod_id).await?; + let project = CURSEFORGE_API.get_mod(mod_id).await?; eprintln!( "- {} \r {}", @@ -125,27 +121,11 @@ pub async fn upgrade(modrinth: &Ferinth, curseforge: &Furse, modpack: &'_ Modpac to_install = read_overrides(&tmp_dir.join(manifest.overrides))?; } } - ModpackIdentifier::ModrinthModpack(project_id) => { - let progress_bar = ProgressBar::new(0).with_style(STYLE_BYTE.clone()); - let modpack_filepath = download_modrinth_modpack( - &modrinth.clone(), - project_id, - |total| { - println!("{}", "Downloading Modpack".bold()); - progress_bar.enable_steady_tick(Duration::from_millis(100)); - progress_bar.set_length(total as u64); - }, - |additional| { - progress_bar.inc(additional as u64); - }, - ) - .await?; - let modpack_file = File::open(&modpack_filepath)?; + ModpackIdentifier::ModrinthModpack(_) => { let metadata: Metadata = serde_json::from_str( &read_file_from_zip(BufReader::new(modpack_file), "modrinth.index.json")? .context("Does not contain metadata file")?, )?; - progress_bar.finish_and_clear(); for file in metadata.files { to_download.push(file.into()); diff --git a/src/subcommands/upgrade.rs b/src/subcommands/upgrade.rs index 54203bb..a34ccce 100644 --- a/src/subcommands/upgrade.rs +++ b/src/subcommands/upgrade.rs @@ -3,23 +3,20 @@ use crate::{ download::{clean, download}, - CROSS, STYLE_NO, TICK, YELLOW_TICK, + CROSS, STYLE_NO, TICK, }; use anyhow::{anyhow, bail, Result}; use colored::Colorize; -use ferinth::Ferinth; -use furse::Furse; use futures::{stream::FuturesUnordered, StreamExt}; use indicatif::ProgressBar; use libium::{ config::structs::{ModLoader, Profile}, upgrade::{ - mod_downloadable::{self, get_latest_compatible_downloadable}, - Downloadable, + check, + mod_downloadable::{self}, + DownloadFile, }, - APIs, }; -use octocrab::Octocrab; use std::{ fs::read_dir, sync::{Arc, Mutex}, @@ -31,12 +28,7 @@ use tokio::sync::Semaphore; /// /// If an error occurs with a resolving task, instead of failing immediately, /// resolution will continue and the error return flag is set to true. -pub async fn get_platform_downloadables( - modrinth: Ferinth, - curseforge: Furse, - github: Octocrab, - profile: &Profile, -) -> Result<(Vec, bool)> { +pub async fn get_platform_downloadables(profile: &Profile) -> Result<(Vec, bool)> { let to_download = Arc::new(Mutex::new(Vec::new())); let progress_bar = Arc::new(Mutex::new( ProgressBar::new(profile.mods.len() as u64).with_style(STYLE_NO.clone()), @@ -60,37 +52,40 @@ pub async fn get_platform_downloadables( let permit = Arc::clone(&semaphore).acquire_owned().await?; let to_download = Arc::clone(&to_download); let progress_bar = Arc::clone(&progress_bar); - let apis = APIs::new(&modrinth, &curseforge, &github); tasks.push(async move { let _permit = permit; - let result = get_latest_compatible_downloadable( - apis, - &mod_, - &profile.game_version, - profile.mod_loader, - ) - .await; + let result = mod_.identifier.fetch_download_files().await; let progress_bar = progress_bar.lock().expect("Mutex poisoned"); progress_bar.inc(1); match result { - Ok((downloadable, qf_flag)) => { - progress_bar.println(format!( - "{} {:pad_len$} {}", - if qf_flag { - YELLOW_TICK.clone() - } else { - TICK.clone() - }, - mod_.name, - downloadable.filename().dimmed() - )); - { + Ok(download_files) => { + if let Some(download_file) = check::select_latest( + download_files, + profile.get_version(mod_.check_game_version), + profile.get_loader(mod_.check_mod_loader), + ) { + progress_bar.println(format!( + "{} {:pad_len$} {}", + TICK.clone(), + mod_.name, + download_file.filename().dimmed() + )); to_download .lock() .expect("Mutex poisoned") - .push(downloadable); - Ok((false, qf_flag)) + .push(download_file); + Ok(true) + } else { + progress_bar.println(format!( + "{}", + format!( + "{CROSS} {:pad_len$} No compatible file was found", + mod_.name + ) + .red() + )); + Ok(false) } } Err(err) => { @@ -106,29 +101,21 @@ pub async fn get_platform_downloadables( "{}", format!("{CROSS} {:pad_len$} {err}", mod_.name).red() )); - Ok((true, false)) + Ok(false) } } }); } let mut error = false; - let mut qf_flag = false; while let Some(res) = tasks.next().await { let res = res?; - error |= res.0; - qf_flag |= res.1; + error |= !res; } Arc::try_unwrap(progress_bar) .map_err(|_| anyhow!("Failed to run threads to completion"))? .into_inner()? .finish_and_clear(); - if qf_flag { - println!( - "{}", - "Fabric mod using Quilt backwards compatibility".yellow() - ); - } Ok(( Arc::try_unwrap(to_download) .map_err(|_| anyhow!("Failed to run threads to completion"))? @@ -137,14 +124,8 @@ pub async fn get_platform_downloadables( )) } -pub async fn upgrade( - modrinth: Ferinth, - curseforge: Furse, - github: Octocrab, - profile: &Profile, -) -> Result<()> { - let (mut to_download, error) = - get_platform_downloadables(modrinth, curseforge, github, profile).await?; +pub async fn upgrade(profile: &Profile) -> Result<()> { + let (mut to_download, error) = get_platform_downloadables(profile).await?; let mut to_install = Vec::new(); if profile.output_dir.join("user").exists() && profile.mod_loader != ModLoader::Quilt { for file in read_dir(profile.output_dir.join("user"))? {