Sfoglia il codice sorgente

feat(bundler): add `publisher` field, closes #5273 (#5283)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Amr Bashir 2 anni fa
parent
commit
628285c1cf

+ 8 - 0
.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 - 0
core/tauri-utils/src/config.rs

@@ -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>,
@@ -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());
@@ -3147,6 +3151,7 @@ mod build {
         BundleConfig,
         active,
         identifier,
+        publisher,
         icon,
         targets,
         resources,
@@ -3560,6 +3565,7 @@ mod test {
         active: false,
         targets: Default::default(),
         identifier: String::from(""),
+        publisher: None,
         icon: Vec::new(),
         resources: None,
         copyright: None,

+ 8 - 0
tooling/bundler/src/bundle/settings.rs

@@ -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.
@@ -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 {

+ 3 - 1
tooling/bundler/src/bundle/windows/msi/wix.rs

@@ -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(

+ 7 - 0
tooling/cli/schema.json

@@ -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": [],

+ 1 - 0
tooling/cli/src/interface/rust.rs

@@ -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