From 9cb9aa7978f231f7da238b33d6ab33fdd2d2c842 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 26 Jan 2024 23:46:51 +0100 Subject: [PATCH] fix(cli): add MaybeWorkspace to license field (#8672) * Add MaybeWorkspace to license field * Fix last changes * Fix formatting * Add change .MD file --- .changes/cli-license-field-workspace.md | 6 ++++++ tooling/cli/src/interface/rust.rs | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changes/cli-license-field-workspace.md diff --git a/.changes/cli-license-field-workspace.md b/.changes/cli-license-field-workspace.md new file mode 100644 index 000000000..faf0bd004 --- /dev/null +++ b/.changes/cli-license-field-workspace.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:bug +"@tauri-apps/cli": patch:bug +--- + +Allow license field in Cargo.toml to be `{ workspace = true }` diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index ad31a979a..16b83a947 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/tooling/cli/src/interface/rust.rs @@ -612,6 +612,7 @@ struct WorkspacePackageSettings { description: Option, homepage: Option, version: Option, + license: Option, } #[derive(Clone, Debug, Deserialize)] @@ -635,7 +636,7 @@ pub struct CargoPackageSettings { /// the package's authors. pub authors: Option>>, /// the package's license. - pub license: Option, + pub license: Option>, /// the default binary to run. pub default_run: Option, } @@ -930,7 +931,16 @@ impl RustAppSettings { }) .unwrap() }), - license: cargo_package_settings.license.clone(), + license: cargo_package_settings.license.clone().map(|license| { + license + .resolve("license", || { + ws_package_settings + .as_ref() + .and_then(|v| v.license.clone()) + .ok_or_else(|| anyhow::anyhow!("Couldn't inherit value for `license` from workspace")) + }) + .unwrap() + }), default_run: cargo_package_settings.default_run.clone(), };