瀏覽代碼

feat(bundler): expose `{{long_description}}` to custom templates (#9494)

* feat(bundler): expose `{{long_description}}` to custom templates

closes #9437

* fix linux
Amr Bashir 1 年之前
父節點
當前提交
05088b0679

+ 6 - 0
.changes/bundler-long_description.md

@@ -0,0 +1,6 @@
+---
+"tauri-bundler": "patch:feat"
+---
+
+Expose `{{long_description}}` variable for custom templates.
+

+ 4 - 2
tooling/bundler/src/bundle/linux/freedesktop.rs

@@ -93,7 +93,7 @@ pub fn copy_icon_files(settings: &Settings, data_dir: &Path) -> crate::Result<Ve
 /// path in the package.
 pub fn generate_desktop_file(
   settings: &Settings,
-  template_settings: &Option<PathBuf>,
+  custom_template_path: &Option<PathBuf>,
   data_dir: &Path,
 ) -> crate::Result<(PathBuf, PathBuf)> {
   let bin_name = settings.main_binary_name();
@@ -105,7 +105,7 @@ pub fn generate_desktop_file(
 
   let mut handlebars = Handlebars::new();
   handlebars.register_escape_fn(handlebars::no_escape);
-  if let Some(template) = template_settings {
+  if let Some(template) = custom_template_path {
     handlebars
       .register_template_string("main.desktop", read_to_string(template)?)
       .with_context(|| "Failed to setup custom handlebar template")?;
@@ -123,6 +123,7 @@ pub fn generate_desktop_file(
     icon: &'a str,
     name: &'a str,
     mime_type: Option<String>,
+    long_description: String,
   }
 
   let mut mime_type: Vec<String> = Vec::new();
@@ -162,6 +163,7 @@ pub fn generate_desktop_file(
       icon: bin_name,
       name: settings.product_name(),
       mime_type,
+      long_description: settings.long_description().unwrap_or_default().to_string(),
     },
     file,
   )?;

+ 4 - 0
tooling/bundler/src/bundle/windows/msi/wix.rs

@@ -518,6 +518,10 @@ pub fn build_wix_app_installer(
 
   data.insert("product_name", to_json(settings.product_name()));
   data.insert("version", to_json(app_version));
+  data.insert(
+    "long_description",
+    to_json(settings.long_description().unwrap_or_default()),
+  );
   let bundle_id = settings.bundle_identifier();
   let manufacturer = settings
     .publisher()

+ 4 - 0
tooling/bundler/src/bundle/windows/nsis.rs

@@ -210,6 +210,10 @@ fn build_nsis_app_installer(
   data.insert("manufacturer", to_json(manufacturer));
   data.insert("product_name", to_json(settings.product_name()));
   data.insert("short_description", to_json(settings.short_description()));
+  data.insert(
+    "long_description",
+    to_json(settings.long_description().unwrap_or_default()),
+  );
   data.insert("copyright", to_json(settings.copyright_string()));
 
   // Code signing is currently only supported on Windows hosts