Selaa lähdekoodia

fix(bundler): sort package types before bundling, closes #7349 (#7360)

fix(bundler): sort package types before bundling, closes #7349
Amr Bashir 2 vuotta sitten
vanhempi
sitoutus
46df2c9b91

+ 5 - 0
.changes/bundler-bundle-order.md

@@ -0,0 +1,5 @@
+---
+'tauri-bundler': 'patch:bug'
+---
+
+Fix bundler skipping updater artifacts if `updater` target shows before other updater-enabled targets in the list, see [#7349](https://github.com/tauri-apps/tauri/issues/7349).

+ 3 - 1
tooling/bundler/src/bundle.rs

@@ -43,11 +43,13 @@ pub struct Bundle {
 /// Bundles the project.
 /// Returns the list of paths where the bundles can be found.
 pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
-  let package_types = settings.package_types()?;
+  let mut package_types = settings.package_types()?;
   if package_types.is_empty() {
     return Ok(Vec::new());
   }
 
+  package_types.sort_by_key(|a| a.priority());
+
   let mut bundles: Vec<Bundle> = Vec::new();
 
   let target_os = settings

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

@@ -93,6 +93,26 @@ impl PackageType {
   pub fn all() -> &'static [PackageType] {
     ALL_PACKAGE_TYPES
   }
+
+  /// Gets a number representing priority which used to sort package types
+  /// in an order that guarantees that if a certain package type
+  /// depends on another (like Dmg depending on MacOsBundle), the dependency
+  /// will be built first
+  ///
+  /// The lower the number, the higher the priority
+  pub fn priority(&self) -> u32 {
+    match self {
+      PackageType::MacOsBundle => 0,
+      PackageType::IosBundle => 0,
+      PackageType::WindowsMsi => 0,
+      PackageType::Nsis => 0,
+      PackageType::Deb => 0,
+      PackageType::Rpm => 0,
+      PackageType::AppImage => 0,
+      PackageType::Dmg => 1,
+      PackageType::Updater => 2,
+    }
+  }
 }
 
 const ALL_PACKAGE_TYPES: &[PackageType] = &[

+ 1 - 1
tooling/cli/src/build.rs

@@ -324,7 +324,7 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
               "The updater secret key from `TAURI_PRIVATE_KEY` does not match the public key defined in `tauri.conf.json > tauri > updater > pubkey`."
             ));
           }
-          signed_paths.append(&mut vec![signature_path]);
+          signed_paths.push(signature_path);
         }
       }