From 110d1b336f836b2a24c09a752eb714a4c2dd523e Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Wed, 10 Apr 2024 07:55:25 -0300 Subject: [PATCH 1/5] fix(packager): exit with error if config not found --- .changes/error-out-if-no-config.md | 5 +++++ Cargo.lock | 4 ++-- crates/packager/src/cli/mod.rs | 3 +-- crates/packager/src/error.rs | 3 +++ 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .changes/error-out-if-no-config.md diff --git a/.changes/error-out-if-no-config.md b/.changes/error-out-if-no-config.md new file mode 100644 index 00000000..eacac4f7 --- /dev/null +++ b/.changes/error-out-if-no-config.md @@ -0,0 +1,5 @@ +--- +"cargo-packager": patch +--- + +Error out if we cannot find a configuration file. diff --git a/Cargo.lock b/Cargo.lock index 01f83774..b59bc92f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -978,7 +978,7 @@ dependencies = [ [[package]] name = "cargo-packager" -version = "0.6.1" +version = "0.7.0" dependencies = [ "ar", "base64 0.21.7", @@ -1035,7 +1035,7 @@ dependencies = [ [[package]] name = "cargo-packager-resource-resolver" -version = "0.1.0" +version = "0.1.1" dependencies = [ "cargo-packager-utils", "heck 0.4.1", diff --git a/crates/packager/src/cli/mod.rs b/crates/packager/src/cli/mod.rs index 2a925a1c..b612eb7e 100644 --- a/crates/packager/src/cli/mod.rs +++ b/crates/packager/src/cli/mod.rs @@ -135,8 +135,7 @@ fn run_cli(cli: Cli) -> Result<()> { }; if configs.is_empty() { - tracing::debug!("Couldn't detect a valid configuration file or all configurations are disabled! Nothing to do here."); - return Ok(()); + return Err(crate::Error::NoConfig); } let cli_out_dir = cli.out_dir.as_ref().map(dunce::canonicalize).transpose()?; diff --git a/crates/packager/src/error.rs b/crates/packager/src/error.rs index b1557e49..a73d6440 100644 --- a/crates/packager/src/error.rs +++ b/crates/packager/src/error.rs @@ -32,6 +32,9 @@ pub enum Error { /// Target triple environment error #[error("Unable to determine target-environment")] Environment, + /// No config file found. + #[error("Couldn't detect a valid configuration file or all configurations are disabled.")] + NoConfig, /// I/O errors. #[error(transparent)] Io(#[from] std::io::Error), From f52c738722b1320ca3b8765a0c2d65951d84cead Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Wed, 10 Apr 2024 09:18:38 -0300 Subject: [PATCH 2/5] lint --- crates/packager/src/package/app/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/packager/src/package/app/mod.rs b/crates/packager/src/package/app/mod.rs index 4d0f4ea0..74546d5a 100644 --- a/crates/packager/src/package/app/mod.rs +++ b/crates/packager/src/package/app/mod.rs @@ -158,7 +158,7 @@ pub(crate) fn package(ctx: &Context) -> crate::Result> { .clone() .ok_or_else(|| crate::Error::MissingNotarizeAuthVars) }) - .unwrap_or_else(|| codesign::notarize_auth()) + .unwrap_or_else(codesign::notarize_auth) { Ok(auth) => { tracing::debug!("Notarizing {}", app_bundle_path.display()); From e54bacb1e623941f8aa0608292993d9bfce5eb02 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Wed, 10 Apr 2024 09:20:03 -0300 Subject: [PATCH 3/5] lint --- examples/slint/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/slint/src/main.rs b/examples/slint/src/main.rs index 747e82e7..25923690 100644 --- a/examples/slint/src/main.rs +++ b/examples/slint/src/main.rs @@ -1,4 +1,5 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release +#![allow(dead_code)] slint::include_modules!(); From 5e9e873e9a98544a4e29f5fdb2955e63a30afa7f Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 15 Apr 2024 07:10:01 +0200 Subject: [PATCH 4/5] error out with a new Error variant --- Cargo.lock | 4 ++-- crates/packager/src/cli/mod.rs | 3 ++- crates/packager/src/error.rs | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b59bc92f..a97b4de8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Cargo. +r# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 @@ -978,7 +978,7 @@ dependencies = [ [[package]] name = "cargo-packager" -version = "0.7.0" +rversion = "0.7.0" dependencies = [ "ar", "base64 0.21.7", diff --git a/crates/packager/src/cli/mod.rs b/crates/packager/src/cli/mod.rs index b612eb7e..e11b2849 100644 --- a/crates/packager/src/cli/mod.rs +++ b/crates/packager/src/cli/mod.rs @@ -135,7 +135,8 @@ fn run_cli(cli: Cli) -> Result<()> { }; if configs.is_empty() { - return Err(crate::Error::NoConfig); + tracing::error!("Couldn't detect a valid configuration file or all configurations are disabled! Nothing to do here."); + std::process::exit(1); } let cli_out_dir = cli.out_dir.as_ref().map(dunce::canonicalize).transpose()?; diff --git a/crates/packager/src/error.rs b/crates/packager/src/error.rs index a73d6440..b1557e49 100644 --- a/crates/packager/src/error.rs +++ b/crates/packager/src/error.rs @@ -32,9 +32,6 @@ pub enum Error { /// Target triple environment error #[error("Unable to determine target-environment")] Environment, - /// No config file found. - #[error("Couldn't detect a valid configuration file or all configurations are disabled.")] - NoConfig, /// I/O errors. #[error(transparent)] Io(#[from] std::io::Error), From 3205f89fd531d7f53e17fd05910cd24ee36eb824 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 15 Apr 2024 07:13:15 +0200 Subject: [PATCH 5/5] Update Cargo.lock --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a97b4de8..b59bc92f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,4 +1,4 @@ -r# This file is automatically @generated by Cargo. +# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 @@ -978,7 +978,7 @@ dependencies = [ [[package]] name = "cargo-packager" -rversion = "0.7.0" +version = "0.7.0" dependencies = [ "ar", "base64 0.21.7",