Skip to content

Commit

Permalink
feat(bundler): add publisher field, closes #5273 (#5283)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
  • Loading branch information
amrbashir and lucasfernog committed Sep 28, 2022
1 parent 54c337e commit 628285c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .changes/publisher-field.md
@@ -0,0 +1,8 @@
---
"tauri-utils": "minor"
"tauri-bundler": "minor"
"cli.rs": "minor"
---

Add `tauri.conf.json > bundle > publisher` field to specify the app publisher.

6 changes: 6 additions & 0 deletions core/tauri-utils/src/config.rs
Expand Up @@ -549,6 +549,9 @@ pub struct BundleConfig {
/// This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-),
/// and periods (.).
pub identifier: String,
/// The application's publisher. Defaults to the second element in the identifier string.
/// Currently maps to the Manufacturer property of the Windows Installer.
pub publisher: Option<String>,
/// The app's icons
#[serde(default)]
pub icon: Vec<String>,
Expand Down Expand Up @@ -3128,6 +3131,7 @@ mod build {
impl ToTokens for BundleConfig {
fn to_tokens(&self, tokens: &mut TokenStream) {
let identifier = str_lit(&self.identifier);
let publisher = quote!(None);
let icon = vec_lit(&self.icon, str_lit);
let active = self.active;
let targets = quote!(Default::default());
Expand All @@ -3147,6 +3151,7 @@ mod build {
BundleConfig,
active,
identifier,
publisher,
icon,
targets,
resources,
Expand Down Expand Up @@ -3560,6 +3565,7 @@ mod test {
active: false,
targets: Default::default(),
identifier: String::from(""),
publisher: None,
icon: Vec::new(),
resources: None,
copyright: None,
Expand Down
8 changes: 8 additions & 0 deletions tooling/bundler/src/bundle/settings.rs
Expand Up @@ -295,6 +295,9 @@ impl Default for WindowsSettings {
pub struct BundleSettings {
/// the app's identifier.
pub identifier: Option<String>,
/// The app's publisher. Defaults to the second element in the identifier string.
/// Currently maps to the Manufacturer property of the Windows Installer.
pub publisher: Option<String>,
/// the app's icon list.
pub icon: Option<Vec<String>>,
/// the app's resources to bundle.
Expand Down Expand Up @@ -610,6 +613,11 @@ impl Settings {
self.bundle_settings.identifier.as_deref().unwrap_or("")
}

/// Returns the bundle's identifier
pub fn publisher(&self) -> Option<&str> {
self.bundle_settings.publisher.as_deref()
}

/// Returns an iterator over the icon files to be used for this bundle.
pub fn icon_files(&self) -> ResourcePaths<'_> {
match self.bundle_settings.icon {
Expand Down
4 changes: 3 additions & 1 deletion tooling/bundler/src/bundle/windows/msi/wix.rs
Expand Up @@ -594,7 +594,9 @@ pub fn build_wix_app_installer(
data.insert("product_name", to_json(settings.product_name()));
data.insert("version", to_json(settings.version_string()));
let bundle_id = settings.bundle_identifier();
let manufacturer = bundle_id.split('.').nth(1).unwrap_or(bundle_id);
let manufacturer = settings
.publisher()
.unwrap_or_else(|| bundle_id.split('.').nth(1).unwrap_or(bundle_id));
data.insert("bundle_id", to_json(bundle_id));
data.insert("manufacturer", to_json(manufacturer));
let upgrade_code = Uuid::new_v5(
Expand Down
7 changes: 7 additions & 0 deletions tooling/cli/schema.json
Expand Up @@ -934,6 +934,13 @@
"description": "The application identifier in reverse domain name notation (e.g. `com.tauri.example`). This string must be unique across applications since it is used in system configurations like the bundle ID and path to the webview data directory. This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-), and periods (.).",
"type": "string"
},
"publisher": {
"description": "The application's publisher. Defaults to the second element in the identifier string. Currently maps to the Manufacturer property of the Windows Installer.",
"type": [
"string",
"null"
]
},
"icon": {
"description": "The app's icons",
"default": [],
Expand Down
1 change: 1 addition & 0 deletions tooling/cli/src/interface/rust.rs
Expand Up @@ -765,6 +765,7 @@ fn tauri_config_to_bundle_settings(

Ok(BundleSettings {
identifier: Some(config.identifier),
publisher: config.publisher,
icon: Some(config.icon),
resources: if resources.is_empty() {
None
Expand Down

0 comments on commit 628285c

Please sign in to comment.