From fbff6388ad6e3fcc450f262125823bdc3861ed6a Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 18 Sep 2024 17:00:27 +0300 Subject: [PATCH] refactor(bundler): group and organize template file structure (#11046) This PR groups files in a predictable mannar, so instead of ``` windows/ |_ templates |_ main.wxs |_ installer.nsi |_ nsis.rs |_ msi.rs ``` we group them next to each other ``` windows/ |_ msi |_ main.wxs |_ mod.rs |_ nsis |_ installer.nsi |_ mod.rs ``` --- .../linux/{templates => appimage}/appimage | 0 .../linux/{appimage.rs => appimage/mod.rs} | 2 +- .../{templates => freedesktop}/main.desktop | 0 .../{freedesktop.rs => freedesktop/mod.rs} | 2 +- .../macos/{templates => }/dmg/bundle_dmg | 0 .../dmg/eula-resources-template.xml | 0 .../src/bundle/macos/{dmg.rs => dmg/mod.rs} | 9 ++-- .../{templates => }/dmg/template.applescript | 0 crates/tauri-bundler/src/bundle/settings.rs | 6 +-- .../tauri-bundler/src/bundle/windows/msi.rs | 47 ------------------- .../{templates => msi}/install-task.ps1 | 0 .../windows/{templates => msi}/main.wxs | 0 .../src/bundle/windows/msi/{wix.rs => mod.rs} | 45 ++++++++++++++++-- .../{templates => msi}/uninstall-task.ps1 | 0 .../{templates => msi}/update-task.xml | 0 .../{templates => nsis}/FileAssociation.nsh | 0 .../windows/{templates => nsis}/installer.nsi | 0 .../languages}/Arabic.nsh | 0 .../languages}/Bulgarian.nsh | 0 .../languages}/Dutch.nsh | 0 .../languages}/English.nsh | 0 .../languages}/French.nsh | 0 .../languages}/German.nsh | 0 .../languages}/Japanese.nsh | 0 .../languages}/Korean.nsh | 0 .../languages}/Persian.nsh | 0 .../languages}/PortugueseBR.nsh | 0 .../languages}/Russian.nsh | 0 .../languages}/SimpChinese.nsh | 0 .../languages}/Spanish.nsh | 0 .../languages}/SpanishInternational.nsh | 0 .../languages}/Swedish.nsh | 0 .../languages}/TradChinese.nsh | 0 .../languages}/Turkish.nsh | 0 .../bundle/windows/{nsis.rs => nsis/mod.rs} | 43 ++++++++--------- .../windows/{templates => nsis}/utils.nsh | 0 crates/tauri-cli/config.schema.json | 2 +- .../schemas/config.schema.json | 2 +- crates/tauri-utils/src/config.rs | 2 +- 39 files changed, 72 insertions(+), 88 deletions(-) rename crates/tauri-bundler/src/bundle/linux/{templates => appimage}/appimage (100%) rename crates/tauri-bundler/src/bundle/linux/{appimage.rs => appimage/mod.rs} (97%) rename crates/tauri-bundler/src/bundle/linux/{templates => freedesktop}/main.desktop (100%) rename crates/tauri-bundler/src/bundle/linux/{freedesktop.rs => freedesktop/mod.rs} (99%) rename crates/tauri-bundler/src/bundle/macos/{templates => }/dmg/bundle_dmg (100%) rename crates/tauri-bundler/src/bundle/macos/{templates => }/dmg/eula-resources-template.xml (100%) rename crates/tauri-bundler/src/bundle/macos/{dmg.rs => dmg/mod.rs} (96%) rename crates/tauri-bundler/src/bundle/macos/{templates => }/dmg/template.applescript (100%) delete mode 100644 crates/tauri-bundler/src/bundle/windows/msi.rs rename crates/tauri-bundler/src/bundle/windows/{templates => msi}/install-task.ps1 (100%) rename crates/tauri-bundler/src/bundle/windows/{templates => msi}/main.wxs (100%) rename crates/tauri-bundler/src/bundle/windows/msi/{wix.rs => mod.rs} (96%) rename crates/tauri-bundler/src/bundle/windows/{templates => msi}/uninstall-task.ps1 (100%) rename crates/tauri-bundler/src/bundle/windows/{templates => msi}/update-task.xml (100%) rename crates/tauri-bundler/src/bundle/windows/{templates => nsis}/FileAssociation.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates => nsis}/installer.nsi (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Arabic.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Bulgarian.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Dutch.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/English.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/French.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/German.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Japanese.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Korean.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Persian.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/PortugueseBR.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Russian.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/SimpChinese.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Spanish.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/SpanishInternational.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Swedish.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/TradChinese.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{templates/nsis-languages => nsis/languages}/Turkish.nsh (100%) rename crates/tauri-bundler/src/bundle/windows/{nsis.rs => nsis/mod.rs} (93%) rename crates/tauri-bundler/src/bundle/windows/{templates => nsis}/utils.nsh (100%) diff --git a/crates/tauri-bundler/src/bundle/linux/templates/appimage b/crates/tauri-bundler/src/bundle/linux/appimage/appimage similarity index 100% rename from crates/tauri-bundler/src/bundle/linux/templates/appimage rename to crates/tauri-bundler/src/bundle/linux/appimage/appimage diff --git a/crates/tauri-bundler/src/bundle/linux/appimage.rs b/crates/tauri-bundler/src/bundle/linux/appimage/mod.rs similarity index 97% rename from crates/tauri-bundler/src/bundle/linux/appimage.rs rename to crates/tauri-bundler/src/bundle/linux/appimage/mod.rs index 167fcd4030c..6897cec688d 100644 --- a/crates/tauri-bundler/src/bundle/linux/appimage.rs +++ b/crates/tauri-bundler/src/bundle/linux/appimage/mod.rs @@ -86,7 +86,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result> { let mut handlebars = Handlebars::new(); handlebars.register_escape_fn(handlebars::no_escape); handlebars - .register_template_string("appimage", include_str!("templates/appimage")) + .register_template_string("appimage", include_str!("./appimage")) .expect("Failed to register template for handlebars"); let temp = handlebars.render("appimage", &sh_map)?; diff --git a/crates/tauri-bundler/src/bundle/linux/templates/main.desktop b/crates/tauri-bundler/src/bundle/linux/freedesktop/main.desktop similarity index 100% rename from crates/tauri-bundler/src/bundle/linux/templates/main.desktop rename to crates/tauri-bundler/src/bundle/linux/freedesktop/main.desktop diff --git a/crates/tauri-bundler/src/bundle/linux/freedesktop.rs b/crates/tauri-bundler/src/bundle/linux/freedesktop/mod.rs similarity index 99% rename from crates/tauri-bundler/src/bundle/linux/freedesktop.rs rename to crates/tauri-bundler/src/bundle/linux/freedesktop/mod.rs index 5f369a7c2fd..e3a47a35555 100644 --- a/crates/tauri-bundler/src/bundle/linux/freedesktop.rs +++ b/crates/tauri-bundler/src/bundle/linux/freedesktop/mod.rs @@ -114,7 +114,7 @@ pub fn generate_desktop_file( .with_context(|| "Failed to setup custom handlebar template")?; } else { handlebars - .register_template_string("main.desktop", include_str!("./templates/main.desktop")) + .register_template_string("main.desktop", include_str!("./main.desktop")) .with_context(|| "Failed to setup default handlebar template")?; } diff --git a/crates/tauri-bundler/src/bundle/macos/templates/dmg/bundle_dmg b/crates/tauri-bundler/src/bundle/macos/dmg/bundle_dmg similarity index 100% rename from crates/tauri-bundler/src/bundle/macos/templates/dmg/bundle_dmg rename to crates/tauri-bundler/src/bundle/macos/dmg/bundle_dmg diff --git a/crates/tauri-bundler/src/bundle/macos/templates/dmg/eula-resources-template.xml b/crates/tauri-bundler/src/bundle/macos/dmg/eula-resources-template.xml similarity index 100% rename from crates/tauri-bundler/src/bundle/macos/templates/dmg/eula-resources-template.xml rename to crates/tauri-bundler/src/bundle/macos/dmg/eula-resources-template.xml diff --git a/crates/tauri-bundler/src/bundle/macos/dmg.rs b/crates/tauri-bundler/src/bundle/macos/dmg/mod.rs similarity index 96% rename from crates/tauri-bundler/src/bundle/macos/dmg.rs rename to crates/tauri-bundler/src/bundle/macos/dmg/mod.rs index 6e2c0b087a9..c93432a65a5 100644 --- a/crates/tauri-bundler/src/bundle/macos/dmg.rs +++ b/crates/tauri-bundler/src/bundle/macos/dmg/mod.rs @@ -72,17 +72,14 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result< log::info!(action = "Bundling"; "{} ({})", dmg_name, dmg_path.display()); // write the scripts - write( - &bundle_script_path, - include_str!("templates/dmg/bundle_dmg"), - )?; + write(&bundle_script_path, include_str!("./bundle_dmg"))?; write( support_directory_path.join("template.applescript"), - include_str!("templates/dmg/template.applescript"), + include_str!("./template.applescript"), )?; write( support_directory_path.join("eula-resources-template.xml"), - include_str!("templates/dmg/eula-resources-template.xml"), + include_str!("./eula-resources-template.xml"), )?; // chmod script for execution diff --git a/crates/tauri-bundler/src/bundle/macos/templates/dmg/template.applescript b/crates/tauri-bundler/src/bundle/macos/dmg/template.applescript similarity index 100% rename from crates/tauri-bundler/src/bundle/macos/templates/dmg/template.applescript rename to crates/tauri-bundler/src/bundle/macos/dmg/template.applescript diff --git a/crates/tauri-bundler/src/bundle/settings.rs b/crates/tauri-bundler/src/bundle/settings.rs index 616c5f0fc65..fe738f79d81 100644 --- a/crates/tauri-bundler/src/bundle/settings.rs +++ b/crates/tauri-bundler/src/bundle/settings.rs @@ -185,7 +185,7 @@ pub struct DebianSettings { /// /// Default file contents: /// ```text - #[doc = include_str!("./linux/templates/main.desktop")] + #[doc = include_str!("./linux/freedesktop/main.desktop")] /// ``` pub desktop_template: Option, /// Define the section in Debian Control file. See : @@ -243,7 +243,7 @@ pub struct RpmSettings { /// /// Default file contents: /// ```text - #[doc = include_str!("./linux/templates/main.desktop")] + #[doc = include_str!("./linux/freedesktop/main.desktop")] /// ``` pub desktop_template: Option, /// Path to script that will be executed before the package is unpacked. See @@ -410,7 +410,7 @@ pub struct NsisSettings { /// An key-value pair where the key is the language and the /// value is the path to a custom `.nsi` file that holds the translated text for tauri's custom messages. /// - /// See for an example `.nsi` file. + /// See for an example `.nsi` file. /// /// **Note**: the key must be a valid NSIS language and it must be added to [`NsisConfig`]languages array, pub custom_language_files: Option>, diff --git a/crates/tauri-bundler/src/bundle/windows/msi.rs b/crates/tauri-bundler/src/bundle/windows/msi.rs deleted file mode 100644 index f0860fc054e..00000000000 --- a/crates/tauri-bundler/src/bundle/windows/msi.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2016-2019 Cargo-Bundle developers -// Copyright 2019-2024 Tauri Programme within The Commons Conservancy -// SPDX-License-Identifier: Apache-2.0 -// SPDX-License-Identifier: MIT - -mod wix; - -use crate::Settings; - -use std::{self, path::PathBuf}; - -const WIX_REQUIRED_FILES: &[&str] = &[ - "candle.exe", - "candle.exe.config", - "darice.cub", - "light.exe", - "light.exe.config", - "wconsole.dll", - "winterop.dll", - "wix.dll", - "WixUIExtension.dll", - "WixUtilExtension.dll", -]; - -/// Runs all of the commands to build the MSI installer. -/// Returns a vector of PathBuf that shows where the MSI was created. -pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result> { - let tauri_tools_path = settings - .local_tools_directory() - .map(|d| d.join(".tauri")) - .unwrap_or_else(|| dirs::cache_dir().unwrap().join("tauri")); - - let wix_path = tauri_tools_path.join("WixTools314"); - - if !wix_path.exists() { - wix::get_and_extract_wix(&wix_path)?; - } else if WIX_REQUIRED_FILES - .iter() - .any(|p| !wix_path.join(p).exists()) - { - log::warn!("WixTools directory is missing some files. Recreating it."); - std::fs::remove_dir_all(&wix_path)?; - wix::get_and_extract_wix(&wix_path)?; - } - - wix::build_wix_app_installer(settings, &wix_path, updater) -} diff --git a/crates/tauri-bundler/src/bundle/windows/templates/install-task.ps1 b/crates/tauri-bundler/src/bundle/windows/msi/install-task.ps1 similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/install-task.ps1 rename to crates/tauri-bundler/src/bundle/windows/msi/install-task.ps1 diff --git a/crates/tauri-bundler/src/bundle/windows/templates/main.wxs b/crates/tauri-bundler/src/bundle/windows/msi/main.wxs similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/main.wxs rename to crates/tauri-bundler/src/bundle/windows/msi/main.wxs diff --git a/crates/tauri-bundler/src/bundle/windows/msi/wix.rs b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs similarity index 96% rename from crates/tauri-bundler/src/bundle/windows/msi/wix.rs rename to crates/tauri-bundler/src/bundle/windows/msi/mod.rs index db053e28d99..9858ac25c50 100644 --- a/crates/tauri-bundler/src/bundle/windows/msi/wix.rs +++ b/crates/tauri-bundler/src/bundle/windows/msi/mod.rs @@ -34,6 +34,43 @@ pub const WIX_URL: &str = "https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip"; pub const WIX_SHA256: &str = "6ac824e1642d6f7277d0ed7ea09411a508f6116ba6fae0aa5f2c7daa2ff43d31"; +const WIX_REQUIRED_FILES: &[&str] = &[ + "candle.exe", + "candle.exe.config", + "darice.cub", + "light.exe", + "light.exe.config", + "wconsole.dll", + "winterop.dll", + "wix.dll", + "WixUIExtension.dll", + "WixUtilExtension.dll", +]; + +/// Runs all of the commands to build the MSI installer. +/// Returns a vector of PathBuf that shows where the MSI was created. +pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result> { + let tauri_tools_path = settings + .local_tools_directory() + .map(|d| d.join(".tauri")) + .unwrap_or_else(|| dirs::cache_dir().unwrap().join("tauri")); + + let wix_path = tauri_tools_path.join("WixTools314"); + + if !wix_path.exists() { + get_and_extract_wix(&wix_path)?; + } else if WIX_REQUIRED_FILES + .iter() + .any(|p| !wix_path.join(p).exists()) + { + log::warn!("WixTools directory is missing some files. Recreating it."); + std::fs::remove_dir_all(&wix_path)?; + get_and_extract_wix(&wix_path)?; + } + + build_wix_app_installer(settings, &wix_path, updater) +} + // For Cross Platform Compilation. // const VC_REDIST_X86_URL: &str = @@ -630,7 +667,7 @@ pub fn build_wix_app_installer( .expect("Failed to setup custom handlebar template"); } else { handlebars - .register_template_string("main.wxs", include_str!("../templates/main.wxs")) + .register_template_string("main.wxs", include_str!("./main.wxs")) .map_err(|e| e.to_string()) .expect("Failed to setup handlebar template"); } @@ -649,7 +686,7 @@ pub fn build_wix_app_installer( // Create the update task XML let mut skip_uac_task = Handlebars::new(); - let xml = include_str!("../templates/update-task.xml"); + let xml = include_str!("./update-task.xml"); skip_uac_task .register_template_string("update.xml", xml) .map_err(|e| e.to_string()) @@ -661,7 +698,7 @@ pub fn build_wix_app_installer( // Create the Powershell script to install the task let mut skip_uac_task_installer = Handlebars::new(); skip_uac_task_installer.register_escape_fn(handlebars::no_escape); - let xml = include_str!("../templates/install-task.ps1"); + let xml = include_str!("./install-task.ps1"); skip_uac_task_installer .register_template_string("install-task.ps1", xml) .map_err(|e| e.to_string()) @@ -673,7 +710,7 @@ pub fn build_wix_app_installer( // Create the Powershell script to uninstall the task let mut skip_uac_task_uninstaller = Handlebars::new(); skip_uac_task_uninstaller.register_escape_fn(handlebars::no_escape); - let xml = include_str!("../templates/uninstall-task.ps1"); + let xml = include_str!("./uninstall-task.ps1"); skip_uac_task_uninstaller .register_template_string("uninstall-task.ps1", xml) .map_err(|e| e.to_string()) diff --git a/crates/tauri-bundler/src/bundle/windows/templates/uninstall-task.ps1 b/crates/tauri-bundler/src/bundle/windows/msi/uninstall-task.ps1 similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/uninstall-task.ps1 rename to crates/tauri-bundler/src/bundle/windows/msi/uninstall-task.ps1 diff --git a/crates/tauri-bundler/src/bundle/windows/templates/update-task.xml b/crates/tauri-bundler/src/bundle/windows/msi/update-task.xml similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/update-task.xml rename to crates/tauri-bundler/src/bundle/windows/msi/update-task.xml diff --git a/crates/tauri-bundler/src/bundle/windows/templates/FileAssociation.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/FileAssociation.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/FileAssociation.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/FileAssociation.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/installer.nsi b/crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/installer.nsi rename to crates/tauri-bundler/src/bundle/windows/nsis/installer.nsi diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Arabic.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Arabic.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Arabic.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Arabic.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Bulgarian.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Bulgarian.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Bulgarian.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Bulgarian.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Dutch.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Dutch.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Dutch.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Dutch.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/English.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/English.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/English.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/English.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/French.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/French.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/French.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/French.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/German.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/German.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/German.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/German.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Japanese.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Japanese.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Japanese.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Japanese.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Korean.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Korean.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Korean.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Korean.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Persian.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Persian.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Persian.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Persian.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/PortugueseBR.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/PortugueseBR.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/PortugueseBR.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/PortugueseBR.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Russian.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Russian.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Russian.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Russian.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/SimpChinese.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/SimpChinese.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/SimpChinese.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/SimpChinese.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Spanish.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Spanish.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Spanish.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Spanish.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/SpanishInternational.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/SpanishInternational.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/SpanishInternational.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/SpanishInternational.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Swedish.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Swedish.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Swedish.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Swedish.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/TradChinese.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/TradChinese.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/TradChinese.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/TradChinese.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Turkish.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/languages/Turkish.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/nsis-languages/Turkish.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/languages/Turkish.nsh diff --git a/crates/tauri-bundler/src/bundle/windows/nsis.rs b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs similarity index 93% rename from crates/tauri-bundler/src/bundle/windows/nsis.rs rename to crates/tauri-bundler/src/bundle/windows/nsis/mod.rs index 37ab9a3e66d..cffaa06dc27 100644 --- a/crates/tauri-bundler/src/bundle/windows/nsis.rs +++ b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs @@ -480,19 +480,16 @@ fn build_nsis_app_installer( .expect("Failed to setup custom handlebar template"); } else { handlebars - .register_template_string("installer.nsi", include_str!("./templates/installer.nsi")) + .register_template_string("installer.nsi", include_str!("./installer.nsi")) .map_err(|e| e.to_string()) .expect("Failed to setup handlebar template"); } write_utf8_with_bom( output_path.join("FileAssociation.nsh"), - include_bytes!("./templates/FileAssociation.nsh"), - )?; - write_utf8_with_bom( - output_path.join("utils.nsh"), - include_bytes!("./templates/utils.nsh"), + include_bytes!("./FileAssociation.nsh"), )?; + write_utf8_with_bom(output_path.join("utils.nsh"), include_bytes!("./utils.nsh"))?; let installer_nsi_path = output_path.join("installer.nsi"); write_utf8_with_bom( @@ -681,23 +678,23 @@ fn generate_estimated_size( fn get_lang_data(lang: &str) -> Option<(String, &[u8])> { let path = format!("{lang}.nsh"); let content: &[u8] = match lang.to_lowercase().as_str() { - "arabic" => include_bytes!("./templates/nsis-languages/Arabic.nsh"), - "bulgarian" => include_bytes!("./templates/nsis-languages/Bulgarian.nsh"), - "dutch" => include_bytes!("./templates/nsis-languages/Dutch.nsh"), - "english" => include_bytes!("./templates/nsis-languages/English.nsh"), - "german" => include_bytes!("./templates/nsis-languages/German.nsh"), - "japanese" => include_bytes!("./templates/nsis-languages/Japanese.nsh"), - "korean" => include_bytes!("./templates/nsis-languages/Korean.nsh"), - "portuguesebr" => include_bytes!("./templates/nsis-languages/PortugueseBR.nsh"), - "russian" => include_bytes!("./templates/nsis-languages/Russian.nsh"), - "tradchinese" => include_bytes!("./templates/nsis-languages/TradChinese.nsh"), - "simpchinese" => include_bytes!("./templates/nsis-languages/SimpChinese.nsh"), - "french" => include_bytes!("./templates/nsis-languages/French.nsh"), - "spanish" => include_bytes!("./templates/nsis-languages/Spanish.nsh"), - "spanishinternational" => include_bytes!("./templates/nsis-languages/SpanishInternational.nsh"), - "persian" => include_bytes!("./templates/nsis-languages/Persian.nsh"), - "turkish" => include_bytes!("./templates/nsis-languages/Turkish.nsh"), - "swedish" => include_bytes!("./templates/nsis-languages/Swedish.nsh"), + "arabic" => include_bytes!("./languages/Arabic.nsh"), + "bulgarian" => include_bytes!("./languages/Bulgarian.nsh"), + "dutch" => include_bytes!("./languages/Dutch.nsh"), + "english" => include_bytes!("./languages/English.nsh"), + "german" => include_bytes!("./languages/German.nsh"), + "japanese" => include_bytes!("./languages/Japanese.nsh"), + "korean" => include_bytes!("./languages/Korean.nsh"), + "portuguesebr" => include_bytes!("./languages/PortugueseBR.nsh"), + "russian" => include_bytes!("./languages/Russian.nsh"), + "tradchinese" => include_bytes!("./languages/TradChinese.nsh"), + "simpchinese" => include_bytes!("./languages/SimpChinese.nsh"), + "french" => include_bytes!("./languages/French.nsh"), + "spanish" => include_bytes!("./languages/Spanish.nsh"), + "spanishinternational" => include_bytes!("./languages/SpanishInternational.nsh"), + "persian" => include_bytes!("./languages/Persian.nsh"), + "turkish" => include_bytes!("./languages/Turkish.nsh"), + "swedish" => include_bytes!("./languages/Swedish.nsh"), _ => return None, }; Some((path, content)) diff --git a/crates/tauri-bundler/src/bundle/windows/templates/utils.nsh b/crates/tauri-bundler/src/bundle/windows/nsis/utils.nsh similarity index 100% rename from crates/tauri-bundler/src/bundle/windows/templates/utils.nsh rename to crates/tauri-bundler/src/bundle/windows/nsis/utils.nsh diff --git a/crates/tauri-cli/config.schema.json b/crates/tauri-cli/config.schema.json index 0b0bd96c2a1..0210dbd5442 100644 --- a/crates/tauri-cli/config.schema.json +++ b/crates/tauri-cli/config.schema.json @@ -2340,7 +2340,7 @@ } }, "customLanguageFiles": { - "description": "A key-value pair where the key is the language and the\n value is the path to a custom `.nsh` file that holds the translated text for tauri's custom messages.\n\n See for an example `.nsh` file.\n\n **Note**: the key must be a valid NSIS language and it must be added to [`NsisConfig`] languages array,", + "description": "A key-value pair where the key is the language and the\n value is the path to a custom `.nsh` file that holds the translated text for tauri's custom messages.\n\n See for an example `.nsh` file.\n\n **Note**: the key must be a valid NSIS language and it must be added to [`NsisConfig`] languages array,", "type": [ "object", "null" diff --git a/crates/tauri-schema-generator/schemas/config.schema.json b/crates/tauri-schema-generator/schemas/config.schema.json index 0b0bd96c2a1..0210dbd5442 100644 --- a/crates/tauri-schema-generator/schemas/config.schema.json +++ b/crates/tauri-schema-generator/schemas/config.schema.json @@ -2340,7 +2340,7 @@ } }, "customLanguageFiles": { - "description": "A key-value pair where the key is the language and the\n value is the path to a custom `.nsh` file that holds the translated text for tauri's custom messages.\n\n See for an example `.nsh` file.\n\n **Note**: the key must be a valid NSIS language and it must be added to [`NsisConfig`] languages array,", + "description": "A key-value pair where the key is the language and the\n value is the path to a custom `.nsh` file that holds the translated text for tauri's custom messages.\n\n See for an example `.nsh` file.\n\n **Note**: the key must be a valid NSIS language and it must be added to [`NsisConfig`] languages array,", "type": [ "object", "null" diff --git a/crates/tauri-utils/src/config.rs b/crates/tauri-utils/src/config.rs index 51bab4a5c1a..6c57caac474 100644 --- a/crates/tauri-utils/src/config.rs +++ b/crates/tauri-utils/src/config.rs @@ -783,7 +783,7 @@ pub struct NsisConfig { /// A key-value pair where the key is the language and the /// value is the path to a custom `.nsh` file that holds the translated text for tauri's custom messages. /// - /// See for an example `.nsh` file. + /// See for an example `.nsh` file. /// /// **Note**: the key must be a valid NSIS language and it must be added to [`NsisConfig`] languages array, pub custom_language_files: Option>,