diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index 7c46537eaf10..34744989ae27 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -304,8 +304,6 @@ pub struct Size { pub height: u32, } - - /// Configuration for Apple Disk Image (.dmg) bundles. /// /// See more: https://tauri.app/v1/api/config#dmgconfig @@ -319,20 +317,14 @@ pub struct DmgConfig { /// Position of volume window on screen. pub window_position: Option, /// Size of volume window. - #[serde( - default = "window_size", - alias = "window-size" - )] + #[serde(default = "dmg_window_size", alias = "window-size")] pub window_size: Size, /// Position of app file on window. - #[serde( - default = "app_position", - alias = "app-position" - )] + #[serde(default = "dmg_app_position", alias = "app-position")] pub app_position: Position, /// Position of application folder on window. #[serde( - default = "application_folder_position", + default = "dmg_application_folder_position", alias = "application-folder-position" )] pub application_folder_position: Position, @@ -343,32 +335,26 @@ impl Default for DmgConfig { Self { background: None, window_position: None, - window_size: window_size(), - app_position: app_position(), - application_folder_position: application_folder_position(), + window_size: dmg_window_size(), + app_position: dmg_app_position(), + application_folder_position: dmg_application_folder_position(), } } } -fn window_size() -> Size { +fn dmg_window_size() -> Size { Size { width: 660, height: 400, } } -fn app_position() -> Position { - Position { - x: 180, - y: 170, - } +fn dmg_app_position() -> Position { + Position { x: 180, y: 170 } } -fn application_folder_position() -> Position { - Position { - x: 480, - y: 170, - } +fn dmg_application_folder_position() -> Position { + Position { x: 480, y: 170 } } fn de_minimum_system_version<'de, D>(deserializer: D) -> Result, D::Error> diff --git a/tooling/bundler/src/bundle.rs b/tooling/bundler/src/bundle.rs index afc865a763d7..ae26b0d7d8fa 100644 --- a/tooling/bundler/src/bundle.rs +++ b/tooling/bundler/src/bundle.rs @@ -20,8 +20,8 @@ use tauri_utils::display_path; pub use self::{ category::AppCategory, settings::{ - BundleBinary, BundleSettings, DebianSettings, DmgSettings, MacOsSettings, PackageSettings, PackageType, - Settings, SettingsBuilder, UpdaterSettings, Position, Size + BundleBinary, BundleSettings, DebianSettings, DmgSettings, MacOsSettings, PackageSettings, + PackageType, Position, Settings, SettingsBuilder, Size, UpdaterSettings, }, }; #[cfg(target_os = "macos")] diff --git a/tooling/bundler/src/bundle/macos/dmg.rs b/tooling/bundler/src/bundle/macos/dmg.rs index cc0b768a3f94..94214e5a7d18 100644 --- a/tooling/bundler/src/bundle/macos/dmg.rs +++ b/tooling/bundler/src/bundle/macos/dmg.rs @@ -109,7 +109,9 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result< let window_size_width = window_size.width.to_string(); let window_size_height = window_size.height.to_string(); - let mut args = vec![ + let mut bundle_dmg_cmd = Command::new(&bundle_script_path); + + bundle_dmg_cmd.args([ "--volname", product_name, "--icon", @@ -124,71 +126,60 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result< &window_size_height, "--hide-extension", &bundle_file_name, - ]; + ]); - let window_position = dmg_settings.window_position.as_ref().map(|position| { - (position.x.to_string(), position.y.to_string()) - }); + let window_position = dmg_settings + .window_position + .as_ref() + .map(|position| (position.x.to_string(), position.y.to_string())); if let Some(window_position) = &window_position { - args.push("--window-pos"); - args.push(&window_position.0); - args.push(&window_position.1); + bundle_dmg_cmd.arg("--window-pos"); + bundle_dmg_cmd.arg(&window_position.0); + bundle_dmg_cmd.arg(&window_position.1); } - let background_path_string = if let Some(background_path) = &dmg_settings.background { - Some( - env::current_dir()? - .join(background_path) - .to_string_lossy() - .to_string(), - ) + let background_path = if let Some(background_path) = &dmg_settings.background { + Some(env::current_dir()?.join(background_path)) } else { None }; - if let Some(background_path_string) = &background_path_string { - args.push("--background"); - args.push(background_path_string); + if let Some(background_path) = &background_path { + bundle_dmg_cmd.arg("--background"); + bundle_dmg_cmd.arg(background_path); } - let icns_icon_path = - create_icns_file(&output_path, settings)?.map(|path| path.to_string_lossy().to_string()); + let icns_icon_path = create_icns_file(&output_path, settings)?; if let Some(icon) = &icns_icon_path { - args.push("--volicon"); - args.push(icon); + bundle_dmg_cmd.arg("--volicon"); + bundle_dmg_cmd.arg(icon); } - let license_path_string = if let Some(license_path) = &settings.macos().license { - Some( - env::current_dir()? - .join(license_path) - .to_string_lossy() - .to_string(), - ) + let license_path = if let Some(license_path) = &settings.macos().license { + Some(env::current_dir()?.join(license_path)) } else { None }; - if let Some(license_path) = &license_path_string { - args.push("--eula"); - args.push(license_path); + if let Some(license_path) = &license_path { + bundle_dmg_cmd.arg("--eula"); + bundle_dmg_cmd.arg(license_path); } // Issue #592 - Building MacOS dmg files on CI // https://github.com/tauri-apps/tauri/issues/592 if let Some(value) = env::var_os("CI") { if value == "true" { - args.push("--skip-jenkins"); + bundle_dmg_cmd.arg("--skip-jenkins"); } } info!(action = "Running"; "bundle_dmg.sh"); // execute the bundle script - Command::new(&bundle_script_path) + bundle_dmg_cmd .current_dir(bundle_dir.clone()) - .args(args) .args(vec![dmg_name.as_str(), bundle_file_name.as_str()]) .output_ok() .context("error running bundle_dmg.sh")?; diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index 319ced86d7e0..3ba6b016681f 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/tooling/cli/src/interface/rust.rs @@ -22,8 +22,8 @@ use notify::RecursiveMode; use notify_debouncer_mini::new_debouncer; use serde::Deserialize; use tauri_bundler::{ - AppCategory, BundleBinary, BundleSettings, DebianSettings, DmgSettings, MacOsSettings, PackageSettings, - UpdaterSettings, WindowsSettings, Position, Size + AppCategory, BundleBinary, BundleSettings, DebianSettings, DmgSettings, MacOsSettings, + PackageSettings, Position, Size, UpdaterSettings, WindowsSettings, }; use tauri_utils::config::parse::is_configuration_file; @@ -1179,16 +1179,13 @@ fn tauri_config_to_bundle_settings( }, dmg: DmgSettings { background: config.dmg.background, - window_position: match config.dmg.window_position { - Some(window_position) => Some(Position { - x: window_position.x, - y: window_position.y, - }), - None => None, - }, + window_position: config.dmg.window_position.map(|window_position| Position { + x: window_position.x, + y: window_position.y, + }), window_size: Size { - width: config.dmg.window_size.width, - height: config.dmg.window_size.height, + width: config.dmg.window_size.width, + height: config.dmg.window_size.height, }, app_position: Position { x: config.dmg.app_position.x,