Skip to content

Commit 7515469

Browse files
Update to Libium 1.6
1 parent f0ca1fb commit 7515469

File tree

7 files changed

+93
-80
lines changed

7 files changed

+93
-80
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog for Ferium
22

3+
## [3.19.0] - 02.04.2022
4+
5+
> WARNING!
6+
>
7+
> The config format has changed, your previous (pre-3.19) configs will not work!
8+
> Use [Frigate](https://github.com/theRookieCoder/frigate) to update your old config to the new format
9+
10+
- Updated to Libium 1.6
11+
- Improved the upgrading code in `main.rs`, taking advantage of the improved config format
12+
- Updated `remove.rs` to support the new libium version
13+
- Updated the test configs to the new format
14+
315
## [3.18.2] - 31.03.2022
416

517
- Improved readme

Cargo.lock

Lines changed: 28 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ferium"
3-
version = "3.18.2"
3+
version = "3.19.0"
44
edition = "2021"
55
authors = ["Ilesh Thiada (theRookieCoder) <[email protected]>", "Daniel Hauck (SolidTux)"]
66
description = "Ferium is a CLI program for managing Minecraft mods from Modrinth, CurseForge, and Github Releases"

src/main.rs

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use colored::{ColoredString, Colorize};
88
use ferinth::Ferinth;
99
use furse::Furse;
1010
use lazy_static::lazy_static;
11-
use libium::{add, config};
11+
use libium::{add, config, upgrade};
1212
use tokio::{
1313
fs::{create_dir_all, remove_dir_all},
1414
io::AsyncReadExt,
@@ -116,19 +116,20 @@ async fn actual_main() -> Result<()> {
116116
check_empty_profile(profile)?;
117117
for mod_ in &profile.mods {
118118
if verbose {
119-
match mod_ {
120-
config::structs::Mod::CurseForgeProject { project_id, .. } => {
119+
use config::structs::ModIdentifier;
120+
match &mod_.identifier {
121+
ModIdentifier::CurseForgeProject(project_id) => {
121122
subcommands::list::curseforge(&curseforge, *project_id).await
122123
},
123-
config::structs::Mod::ModrinthProject { project_id, .. } => {
124+
ModIdentifier::ModrinthProject(project_id) => {
124125
subcommands::list::modrinth(&modrinth, project_id).await
125126
},
126-
config::structs::Mod::GitHubRepository { full_name, .. } => {
127+
ModIdentifier::GitHubRepository(full_name) => {
127128
subcommands::list::github(&github, full_name).await
128129
},
129130
}?;
130131
} else {
131-
println!("{}", mod_.name());
132+
println!("{}", mod_.name);
132133
}
133134
}
134135
},
@@ -169,60 +170,44 @@ async fn actual_main() -> Result<()> {
169170
create_dir_all(&profile.output_dir).await?;
170171
let mut error = false;
171172
for mod_ in &profile.mods {
172-
use libium::config::structs::Mod;
173-
let result = match mod_ {
174-
Mod::CurseForgeProject { name, project_id } => (
175-
name,
176-
match libium::upgrade::curseforge(
177-
&curseforge,
178-
profile,
179-
*project_id,
180-
no_patch_check,
181-
)
182-
.await
173+
use libium::config::structs::ModIdentifier;
174+
let result = match &mod_.identifier {
175+
ModIdentifier::CurseForgeProject(project_id) => {
176+
match upgrade::curseforge(&curseforge, profile, *project_id, no_patch_check)
177+
.await
183178
{
184179
Ok(file) => Ok(file.file_name),
185180
Err(err) => Err(err),
186-
},
187-
),
188-
Mod::ModrinthProject { name, project_id } => (
189-
name,
190-
match libium::upgrade::modrinth(
191-
&modrinth,
192-
profile,
193-
project_id,
194-
no_patch_check,
195-
)
196-
.await
181+
}
182+
},
183+
ModIdentifier::ModrinthProject(project_id) => {
184+
match upgrade::modrinth(&modrinth, profile, project_id, no_patch_check)
185+
.await
197186
{
198187
Ok(version) => Ok(version.files[0].filename.clone()),
199188
Err(err) => Err(err),
200-
},
201-
),
202-
Mod::GitHubRepository { name, full_name } => (
203-
name,
204-
match libium::upgrade::github(
205-
&github.repos(&full_name.0, &full_name.1),
206-
profile,
207-
)
208-
.await
189+
}
190+
},
191+
ModIdentifier::GitHubRepository(full_name) => {
192+
match upgrade::github(&github.repos(&full_name.0, &full_name.1), profile)
193+
.await
209194
{
210195
Ok(asset) => Ok(asset.name),
211196
Err(err) => Err(err),
212-
},
213-
),
197+
}
198+
},
214199
};
215200
match result {
216-
(name, Ok(file_name)) => {
201+
Ok(file_name) => {
217202
println!(
218203
"{} {:40}{}",
219204
*TICK,
220-
name,
205+
mod_.name,
221206
format!("({})", file_name).dimmed()
222207
);
223208
},
224-
(name, Err(err)) => {
225-
eprintln!("{}", format!("× {:40}{}", name, err).red());
209+
Err(err) => {
210+
eprintln!("{}", format!("× {:40}{}", mod_.name, err).red());
226211
error = true;
227212
},
228213
}

src/subcommands/remove.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
use anyhow::{bail, Result};
22
use dialoguer::{theme::ColorfulTheme, MultiSelect};
3-
use libium::config::{self, structs::Mod};
3+
use libium::config;
44

55
/// Display a list of mods and repos in the profile to select from and remove selected ones
66
pub fn remove(
77
profile: &mut config::structs::Profile,
88
mod_names: Option<Vec<String>>,
99
) -> Result<()> {
10-
let names: Vec<&str> = profile.mods.iter().map(Mod::name).collect();
10+
let names = profile
11+
.mods
12+
.iter()
13+
.map(|mod_| &mod_.name)
14+
.collect::<Vec<_>>();
1115
let mut items_to_remove = Vec::new();
1216

1317
match mod_names {

tests/configs/one_profile_full.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
"mod_loader": "Fabric",
99
"mods": [
1010
{
11-
"ModrinthProject": {
12-
"name": "Starlight (Fabric)",
13-
"project_id": "H8CaAYZC"
11+
"name": "Starlight (Fabric)",
12+
"identifier": {
13+
"ModrinthProject": "H8CaAYZC"
1414
}
1515
},
1616
{
17-
"CurseForgeProject": {
18-
"name": "Terralith",
19-
"project_id": 513688
17+
"name": "Terralith",
18+
"identifier": {
19+
"CurseForgeProject": 513688
2020
}
2121
},
2222
{
23-
"GitHubRepository": {
24-
"name": "sodium-fabric",
25-
"full_name": [
23+
"name": "sodium-fabric",
24+
"identifier": {
25+
"GitHubRepository": [
2626
"CaffeineMC",
2727
"sodium-fabric"
2828
]

tests/configs/two_profiles_one_empty.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
"mod_loader": "Fabric",
99
"mods": [
1010
{
11-
"ModrinthProject": {
12-
"name": "Starlight (Fabric)",
13-
"project_id": "H8CaAYZC"
11+
"name": "Starlight (Fabric)",
12+
"identifier": {
13+
"ModrinthProject": "H8CaAYZC"
1414
}
1515
},
1616
{
17-
"CurseForgeProject": {
18-
"name": "Terralith",
19-
"project_id": 513688
17+
"name": "Terralith",
18+
"identifier": {
19+
"CurseForgeProject": 513688
2020
}
2121
},
2222
{
23-
"GitHubRepository": {
24-
"name": "sodium-fabric",
25-
"full_name": [
23+
"name": "sodium-fabric",
24+
"identifier": {
25+
"GitHubRepository": [
2626
"CaffeineMC",
2727
"sodium-fabric"
2828
]

0 commit comments

Comments
 (0)