Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Unable to add files to dmg interface #11916

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/tauri-bundler/src/bundle/macos/dmg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<
&bundle_file_name,
]);

for item in &dmg_settings.files {
let _arg = format!("{} {:?} {} {}", item.name, item.path, item.x, item.y);
bundle_dmg_cmd.arg("--add-file");
bundle_dmg_cmd.arg(&item.name);

if item.path.is_absolute() {
bundle_dmg_cmd.arg(&item.path);
} else {
bundle_dmg_cmd.arg(env::current_dir()?.join(&item.path));
}

bundle_dmg_cmd.arg(&item.x.to_string());
bundle_dmg_cmd.arg(&item.y.to_string());
}

let window_position = dmg_settings
.window_position
.as_ref()
Expand Down
3 changes: 3 additions & 0 deletions crates/tauri-bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::{
collections::HashMap,
path::{Path, PathBuf},
};
use tauri_utils::config::DmgFile;

/// The type of the package we're bundling.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -304,6 +305,8 @@ pub struct DmgSettings {
pub app_position: Position,
/// Position of application folder on window.
pub application_folder_position: Position,
/// Need to add files to the dmg collection
pub files: Vec<DmgFile>,
}

/// The macOS bundle settings.
Expand Down
43 changes: 43 additions & 0 deletions crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"x": 480,
"y": 170
},
"files": [],
"windowSize": {
"height": 400,
"width": 660
Expand Down Expand Up @@ -1994,6 +1995,7 @@
"x": 480,
"y": 170
},
"files": [],
"windowSize": {
"height": 400,
"width": 660
Expand Down Expand Up @@ -3263,6 +3265,7 @@
"x": 480,
"y": 170
},
"files": [],
"windowSize": {
"height": 400,
"width": 660
Expand Down Expand Up @@ -3334,6 +3337,14 @@
"$ref": "#/definitions/Position"
}
]
},
"files": {
"description": "Need to add files to the dmg collection",
"default": [],
"type": "array",
"items": {
"$ref": "#/definitions/DmgFile"
}
}
},
"additionalProperties": false
Expand Down Expand Up @@ -3384,6 +3395,38 @@
},
"additionalProperties": false
},
"DmgFile": {
"type": "object",
"required": [
"name",
"path",
"x",
"y"
],
"properties": {
"path": {
"description": "The path to the file.",
"type": "string"
},
"name": {
"description": "The name of the file.",
"type": "string"
},
"x": {
"description": "The x-coordinate associated with the file.",
"type": "integer",
"format": "uint32",
"minimum": 0.0
},
"y": {
"description": "The y-coordinate associated with the file.",
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
},
"additionalProperties": false
},
"IosConfig": {
"description": "General configuration for the iOS target.",
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,7 @@ fn tauri_config_to_bundle_settings(
x: config.macos.dmg.application_folder_position.x,
y: config.macos.dmg.application_folder_position.y,
},
files: config.macos.dmg.files,
},
macos: MacOsSettings {
frameworks: config.macos.frameworks,
Expand Down
43 changes: 43 additions & 0 deletions crates/tauri-schema-generator/schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"x": 480,
"y": 170
},
"files": [],
"windowSize": {
"height": 400,
"width": 660
Expand Down Expand Up @@ -1994,6 +1995,7 @@
"x": 480,
"y": 170
},
"files": [],
"windowSize": {
"height": 400,
"width": 660
Expand Down Expand Up @@ -3263,6 +3265,7 @@
"x": 480,
"y": 170
},
"files": [],
"windowSize": {
"height": 400,
"width": 660
Expand Down Expand Up @@ -3334,6 +3337,14 @@
"$ref": "#/definitions/Position"
}
]
},
"files": {
"description": "Need to add files to the dmg collection",
"default": [],
"type": "array",
"items": {
"$ref": "#/definitions/DmgFile"
}
}
},
"additionalProperties": false
Expand Down Expand Up @@ -3384,6 +3395,38 @@
},
"additionalProperties": false
},
"DmgFile": {
"type": "object",
"required": [
"name",
"path",
"x",
"y"
],
"properties": {
"path": {
"description": "The path to the file.",
"type": "string"
},
"name": {
"description": "The name of the file.",
"type": "string"
},
"x": {
"description": "The x-coordinate associated with the file.",
"type": "integer",
"format": "uint32",
"minimum": 0.0
},
"y": {
"description": "The y-coordinate associated with the file.",
"type": "integer",
"format": "uint32",
"minimum": 0.0
}
},
"additionalProperties": false
},
"IosConfig": {
"description": "General configuration for the iOS target.",
"type": "object",
Expand Down
26 changes: 26 additions & 0 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,27 @@ pub struct DmgConfig {
alias = "application-folder-position"
)]
pub application_folder_position: Position,
/// Need to add files to the dmg collection
#[serde(default = "files_default", alias = "files")]
pub files: Vec<DmgFile>,
}

#[derive(Default, Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct DmgFile {
#[serde(alias = "path")]
/// The path to the file.
pub path: PathBuf,
#[serde(alias = "name")]
/// The name of the file.
pub name: String,
#[serde(alias = "x")]
/// The x-coordinate associated with the file.
pub x: u32,
#[serde(alias = "y")]
/// The y-coordinate associated with the file.
pub y: u32,
}

impl Default for DmgConfig {
Expand All @@ -556,6 +577,7 @@ impl Default for DmgConfig {
window_size: dmg_window_size(),
app_position: dmg_app_position(),
application_folder_position: dmg_application_folder_position(),
files: files_default(),
}
}
}
Expand All @@ -575,6 +597,10 @@ fn dmg_application_folder_position() -> Position {
Position { x: 480, y: 170 }
}

fn files_default() -> Vec<DmgFile> {
Vec::new()
}

fn de_macos_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
where
D: Deserializer<'de>,
Expand Down
2 changes: 1 addition & 1 deletion crates/tauri/scripts/bundle.global.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions examples/api/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@
}
},
"bundle": {
"macOS": {
"dmg": {
"files": [
{
"x": 200,
"y": 200,
"name": "111",
"path": "./info.plist"
}
]

}
},
"active": true,
"icon": [
"../../.icons/32x32.png",
Expand Down
14 changes: 13 additions & 1 deletion examples/helloworld/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
"../.icons/[email protected]",
"../.icons/icon.icns",
"../.icons/icon.ico"
]
],
"macOS": {
"dmg": {
"files": [
{
"name": "aa.md",
"path": "./README.md",
"x": 200,
"y": 200
}
]
}
}
}
}
Loading