From 87c2f64f134756578f6cf9e12fd085b9bb03c5c7 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Fri, 13 Sep 2024 03:30:47 -0500 Subject: [PATCH] Fix dx bundle command and resources panic (#2951) --- packages/cli/src/cli/bundle.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/cli/bundle.rs b/packages/cli/src/cli/bundle.rs index f82843edc..c0470290d 100644 --- a/packages/cli/src/cli/bundle.rs +++ b/packages/cli/src/cli/bundle.rs @@ -13,8 +13,9 @@ use super::*; #[derive(Clone, Debug, Parser)] #[clap(name = "bundle")] pub struct Bundle { + /// The package types to bundle #[clap(long)] - pub package: Option>, + pub packages: Option>, /// The arguments for the dioxus build #[clap(flatten)] pub build_arguments: Build, @@ -28,7 +29,7 @@ impl Deref for Bundle { } } -#[derive(Clone, Debug)] +#[derive(Clone, Copy, Debug)] pub enum PackageType { MacOsBundle, IosBundle, @@ -162,6 +163,15 @@ impl Bundle { } } + // Drain any resources set in the config into the resources map. Tauri bundle doesn't let you set both resources and resources_map https://github.com/DioxusLabs/dioxus/issues/2941 + for resource_path in bundle_settings.resources.take().into_iter().flatten() { + if let Some(resources) = &mut bundle_settings.resources_map { + resources.insert(resource_path, "".to_string()); + } else { + bundle_settings.resources_map = Some([(resource_path, "".to_string())].into()); + } + } + let mut settings = SettingsBuilder::new() .project_out_directory(dioxus_crate.out_dir()) .package_settings(PackageSettings { @@ -174,13 +184,8 @@ impl Bundle { }) .binaries(binaries) .bundle_settings(bundle_settings); - if let Some(packages) = &self.package { - settings = settings.package_types( - packages - .iter() - .map(|p| p.parse::().unwrap().into()) - .collect(), - ); + if let Some(packages) = &self.packages { + settings = settings.package_types(packages.iter().map(|p| (*p).into()).collect()); } if let Some(target) = &self.target_args.target {