-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat(bundler): add dmg settings, closes #4669 #7964
Conversation
@Andreybest this is looking amazing! I wanted to push a cleanup but I don't have access to your fork :D mostly fixing clippy warnings and using diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs
index 185dd7bc7..10286331b 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<Position>,
/// 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<Option<String>, D::Error>
diff --git a/tooling/bundler/src/bundle/macos/dmg.rs b/tooling/bundler/src/bundle/macos/dmg.rs
index c5273f755..73cf62b7f 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 c13d0bbdc..3885e6571 100644
--- a/tooling/cli/src/interface/rust.rs
+++ b/tooling/cli/src/interface/rust.rs
@@ -1175,13 +1175,10 @@ fn tauri_config_to_bundle_settings(
},
dmg: DmgSettings {
background: config.dmg.background,
- window_position: match config.dmg.window_position {
- Some(window_position) => Some(Position {
+ window_position: config.dmg.window_position.map(|window_position| Position {
x: window_position.x,
y: window_position.y,
}),
- None => None,
- },
window_size: Size {
width: config.dmg.window_size.width,
height: config.dmg.window_size.height, |
Is it worth mentioning in the docs that macOS seems to want the image to be 72dpi? I accidentally save a PNG out as 96dpi from Inkscape and it did not fill the window correctly. |
Yes we should document that. Issue: create-dmg/create-dmg#20 (comment) |
@lucasfernog : It would be great to see this change in a Tauri release. Is it worth recreating the MR to apply those fixes? |
Yeah I'll see if I can merge this one as is then open a separate PR with the fixes. |
@lucasfernog : How do I request backporting this to |
Yep, if possible cherry picking would be the way to go here. (The branch diverged quite a lot though so it may have to be a more manual process) |
Cherry pick PR is here #8334 |
Hey @lucasfernog! So sorry for not responding to your comment. For some reason I totally forgot about this PR... |
Added new "dmg" param to tauri.conf.json. It provides more settings to "create-dmg" cli and allows to customise DMG files with:
DMG view before:
DMG view after:
New part of tauri.conf.json looks like this:
Resolves #4669
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information
Small note. I've never used commit signing, but saw that it's required after creating PR (after first commit). So I have only 1 out of 2 commit signed, I hope it's not a big deal 🙂