Skip to content

Commit af67ef5

Browse files
authored
feat(validate): Add validation to installer (#171)
2 parents 517c360 + 773e6f4 commit af67ef5

File tree

15 files changed

+166
-122
lines changed

15 files changed

+166
-122
lines changed

.envrc-sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
set -a
22
use nix
3-
mkdir -p $TMPDIR
3+
[[ -f "${TMPDIR}" ]] && mkdir -p "${TMPDIR}"

.github/workflows/main.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,16 @@ jobs:
5252
with:
5353
name: mod_installer-${{ matrix.target }}${{ matrix.suffix }}
5454
path: ./target/release/mod_installer${{ matrix.suffix }}
55+
build-nix:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v4
59+
- uses: cachix/install-nix-action@v31
60+
with:
61+
nix_path: nixpkgs=channel:nixos-25.05
62+
- run: nix build -f default.nix
5563
release:
56-
needs: [build, pre-commit]
64+
needs: [build, build-nix, pre-commit]
5765
runs-on: ubuntu-latest
5866
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
5967
outputs:

Cargo.lock

Lines changed: 26 additions & 29 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 = "mod_installer"
3-
version = "10.2.0"
3+
version = "11.0.0"
44
edition = "2021"
55
authors = [ "dark0dave" ]
66
documentation = "https://raw.githubusercontent.com/dark0dave/mod_installer/main/README.md"

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,13 @@ See the `example_config.toml` for defaults parser uses. Here we provide a brief
372372

373373
Name|Category|Description|Example
374374
----|----|:----|----
375-
| in_progress_words | A list of words | Checks if weidu is currently running | ["installing", "creating",]
376-
| useful_status_words | A list of words | Provides feedback on the weidu process | ["copied", "copying",]
377-
| choice_words | A list of words | Words which check if weidu wants user input | ["choice", "choose",]
378-
| choice_phrase | A list of phrases | Phrases which check if weidu wants user input | ["do you want", "would you like",]
379-
| completed_with_warnings | A single phrase | Standard phrase wiedu uses if it finishes with warning | "installed with warnings"
380-
| failed_with_error | A single phrase | Standard phrase wiedu uses if it finishes with an error | "not installed due to errors"
381-
| finished | A single phrase | Standard phrase wiedu uses if it finishes successfully | "successfully installed"
382-
| eet_finished | A single phrase | A special exemption for EET for EET Core install | "process ended"
375+
| in_progress_words | A list of words | Checks if weidu is currently running | ["installing", "creating", ...]
376+
| useful_status_words | A list of words | Provides feedback on the weidu process | ["copied", "copying", ...]
377+
| choice_words | A list of words | Words which check if weidu wants user input | ["choice", "choose", ...]
378+
| choice_phrase | A list of phrases | Phrases which check if weidu wants user input | ["do you want", "would you like", ...]
379+
| completed_with_warnings | A list of phrases | Phrases which wiedu uses if it finishes with warning | ["installed with warnings", ...]
380+
| failed_with_error | A list of phrases | Phrases which wiedu uses if it finishes with an error | ["not installed due to errors", ...]
381+
| finished | A list of phrases | Phrases which wiedu uses if it finishes successfully | ["successfully installed","process ended", ...]
383382

384383
Note: **All words/phrases are compared in lowercase ascii.**
385384

default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{ pkgs ? import <nixpkgs> { } }:
22
pkgs.rustPlatform.buildRustPackage rec {
33
pname = "mod_installer";
4-
version = "10.2.0";
4+
version = "11.0.0";
55
cargoLock.lockFile = ./Cargo.lock;
66
src = pkgs.lib.cleanSource ./.;
77
buildInputs = with pkgs; [

example_config.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ choice_phrase = [
2323
"do you want",
2424
"would you like",
2525
]
26-
completed_with_warnings = "installed with warnings"
27-
failed_with_error = "not installed due to errors"
28-
finished = "successfully installed"
29-
eet_finished = "process ended"
26+
completed_with_warnings = [
27+
"installed with warnings",
28+
]
29+
failed_with_error = [
30+
"not installed due to errors",
31+
"installation aborted",
32+
]
33+
finished = [
34+
"successfully installed",
35+
"process ended",
36+
]

src/component.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ impl TryFrom<String> for Component {
4040
let install_path = parts
4141
.nth(1)
4242
.ok_or(format!(
43-
"Could not get full name of mod, from provided string: {}",
44-
line
43+
"Could not get full name of mod, from provided string: {line}"
4544
))?
4645
.to_string();
4746

@@ -51,8 +50,7 @@ impl TryFrom<String> for Component {
5150
.split('\\')
5251
.next()
5352
.ok_or(format!(
54-
"Could not split {} into mod into name and component",
55-
line
53+
"Could not split {line} into mod into name and component"
5654
))?
5755
.to_ascii_lowercase();
5856
(windows_path.to_string(), name)
@@ -61,42 +59,34 @@ impl TryFrom<String> for Component {
6159
.split('/')
6260
.next()
6361
.ok_or(format!(
64-
"Could not split {} into mod into name and component",
65-
line
62+
"Could not split {line} into mod into name and component"
6663
))?
6764
.to_ascii_lowercase();
6865
(linux_path.to_string(), name)
6966
} else {
70-
return Err(format!(
71-
"Could not find tp2 file name, from provided string: {}",
72-
line
73-
)
74-
.into());
67+
return Err(
68+
format!("Could not find tp2 file name, from provided string: {line}").into(),
69+
);
7570
};
7671

7772
let mut tail = parts
7873
.next()
7974
.ok_or(format!(
80-
"Could not find lang and component, from provided string {}",
81-
line
75+
"Could not find lang and component, from provided string {line}"
8276
))?
8377
.split("//");
8478

8579
let mut lang_and_component = tail.next().unwrap_or_default().split(' ');
8680

8781
let lang = lang_and_component
8882
.nth(1)
89-
.ok_or(format!(
90-
"Could not find lang, from provided string: {}",
91-
line
92-
))?
83+
.ok_or(format!("Could not find lang, from provided string: {line}"))?
9384
.replace('#', "");
9485

9586
let component = lang_and_component
9687
.next()
9788
.ok_or(format!(
98-
"Could not find component, from provided string {}",
99-
line
89+
"Could not find component, from provided string {line}"
10090
))?
10191
.replace('#', "");
10292

src/config/args.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn parse_weidu_log_mode(arg: &str) -> Result<String, String> {
234234
"autolog" => output.push(format!("--{arg}")),
235235
"logapp" => output.push(format!("--{arg}")),
236236
"log-extern" => output.push(format!("--{arg}")),
237-
_ => return Err(format!("{}, Provided {}", WEIDU_LOG_MODE_ERROR, arg)),
237+
_ => return Err(format!("{WEIDU_LOG_MODE_ERROR}, Provided {arg}")),
238238
};
239239
}
240240
Ok(output.join(" "))
@@ -310,7 +310,7 @@ mod tests {
310310
),
311311
];
312312
for (test, expected) in tests {
313-
println!("{:#?}", test);
313+
println!("{test:#?}");
314314
let result = parse_weidu_log_mode(test);
315315
assert_eq!(
316316
result, expected,

0 commit comments

Comments
 (0)