浏览代码

export lazy current config

Evan Almloff 1 年之前
父节点
当前提交
06be18a591

+ 4 - 77
packages/cli-config/Cargo.toml

@@ -9,90 +9,17 @@ license = "MIT OR Apache-2.0"
 keywords = ["react", "gui", "cli", "dioxus", "wasm"]
 
 [dependencies]
-# cli core
 clap = { version = "4.2", features = ["derive"] }
-thiserror = { workspace = true }
-wasm-bindgen-cli-support = "0.2"
-colored = "2.0.0"
-
-# features
-log = "0.4.14"
-fern = { version = "0.6.0", features = ["colored"] }
 serde = { version = "1.0.136", features = ["derive"] }
 serde_json = "1.0.79"
 toml = "0.5.8"
-fs_extra = "1.2.0"
 cargo_toml = "0.16.0"
-futures = "0.3.21"
-notify = { version = "5.0.0-pre.16", features = ["serde"] }
-html_parser  = { workspace = true }
-cargo_metadata = "0.15.0"
-tokio = { version = "1.16.1", features = ["fs", "sync", "rt", "macros"] }
-atty = "0.2.14"
-chrono = "0.4.19"
-anyhow = "1.0.53"
-hyper = "0.14.17"
-hyper-rustls = "0.23.2"
-indicatif = "0.17.5"
-subprocess = "0.2.9"
-
-axum = { version = "0.5.1", features = ["ws", "headers"] }
-axum-server = { version = "0.5.1", features = ["tls-rustls"] }
-tower-http = { version = "0.2.2", features = ["full"] }
-headers = "0.3.7"
-
-walkdir = "2"
-
-# tools download
-dirs = "4.0.0"
-reqwest = { version = "0.11", features = [
-    "rustls-tls",
-    "stream",
-    "trust-dns",
-    "blocking",
-] }
-flate2 = "1.0.22"
-tar = "0.4.38"
-zip = "0.6.2"
-tower = "0.4.12"
-syn = { version = "2.0", features = ["full", "extra-traits"] }
-lazy_static = "1.4.0"
-
-# plugin packages
-mlua = { version = "0.8.1", features = [
-    "lua54",
-    "vendored",
-    "async",
-    "send",
-    "macros",
-], optional = true }
-ctrlc = "3.2.3"
-open = "4.1.0"
-cargo-generate = "0.18"
-toml_edit = "0.19.11"
 
 # bundling
-tauri-bundler = { version = "=1.3.0", features = ["native-tls-vendored"] }
-tauri-utils = "=1.4.*"
-
-dioxus-autofmt = { workspace = true }
-dioxus-check = { workspace = true }
-rsx-rosetta = { workspace = true }
-dioxus-rsx = { workspace = true }
-dioxus-html = { workspace = true, features = ["hot-reload-context"] }
-dioxus-core = { workspace = true, features = ["serialize"] }
-dioxus-hot-reload = { workspace = true }
-interprocess-docfix = { version = "1.2.2" }
+tauri-bundler = { version = "=1.3.0", features = ["native-tls-vendored"], optional = true  }
+tauri-utils = { version = "=1.4.*", optional = true }
+once_cell = "1.18.0"
 
 [features]
 default = []
-plugin = ["mlua"]
-
-[dev-dependencies]
-tempfile = "3.3"
-
-[package.metadata.binstall]
-pkg-url = "{ repo }/releases/download/v{ version }/dx-{ target }{ archive-suffix }"
-
-[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
-pkg-fmt = "zip"
+cli = ["tauri-bundler", "tauri-utils"]

+ 258 - 0
packages/cli-config/src/bundle.rs

@@ -0,0 +1,258 @@
+use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
+use std::path::PathBuf;
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct BundleConfig {
+    pub identifier: Option<String>,
+    pub publisher: Option<String>,
+    pub icon: Option<Vec<String>>,
+    pub resources: Option<Vec<String>>,
+    pub copyright: Option<String>,
+    pub category: Option<String>,
+    pub short_description: Option<String>,
+    pub long_description: Option<String>,
+    pub external_bin: Option<Vec<String>>,
+    pub deb: Option<DebianSettings>,
+    pub macos: Option<MacOsSettings>,
+    pub windows: Option<WindowsSettings>,
+}
+
+#[cfg(feature = "cli")]
+impl From<BundleConfig> for tauri_bundler::BundleSettings {
+    fn from(val: BundleConfig) -> Self {
+        tauri_bundler::BundleSettings {
+            identifier: val.identifier,
+            publisher: val.publisher,
+            icon: val.icon,
+            resources: val.resources,
+            copyright: val.copyright,
+            category: val.category.and_then(|c| c.parse().ok()),
+            short_description: val.short_description,
+            long_description: val.long_description,
+            external_bin: val.external_bin,
+            deb: val.deb.map(Into::into).unwrap_or_default(),
+            macos: val.macos.map(Into::into).unwrap_or_default(),
+            windows: val.windows.map(Into::into).unwrap_or_default(),
+            ..Default::default()
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct DebianSettings {
+    pub depends: Option<Vec<String>>,
+    pub files: HashMap<PathBuf, PathBuf>,
+    pub nsis: Option<NsisSettings>,
+}
+
+#[cfg(feature = "cli")]
+impl From<DebianSettings> for tauri_bundler::DebianSettings {
+    fn from(val: DebianSettings) -> Self {
+        tauri_bundler::DebianSettings {
+            depends: val.depends,
+            files: val.files,
+            desktop_template: None,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct WixSettings {
+    pub language: Vec<(String, Option<PathBuf>)>,
+    pub template: Option<PathBuf>,
+    pub fragment_paths: Vec<PathBuf>,
+    pub component_group_refs: Vec<String>,
+    pub component_refs: Vec<String>,
+    pub feature_group_refs: Vec<String>,
+    pub feature_refs: Vec<String>,
+    pub merge_refs: Vec<String>,
+    pub skip_webview_install: bool,
+    pub license: Option<PathBuf>,
+    pub enable_elevated_update_task: bool,
+    pub banner_path: Option<PathBuf>,
+    pub dialog_image_path: Option<PathBuf>,
+    pub fips_compliant: bool,
+}
+
+#[cfg(feature = "cli")]
+impl From<WixSettings> for tauri_bundler::WixSettings {
+    fn from(val: WixSettings) -> Self {
+        tauri_bundler::WixSettings {
+            language: tauri_bundler::bundle::WixLanguage({
+                let mut languages: Vec<_> = val
+                    .language
+                    .iter()
+                    .map(|l| {
+                        (
+                            l.0.clone(),
+                            tauri_bundler::bundle::WixLanguageConfig {
+                                locale_path: l.1.clone(),
+                            },
+                        )
+                    })
+                    .collect();
+                if languages.is_empty() {
+                    languages.push(("en-US".into(), Default::default()));
+                }
+                languages
+            }),
+            template: val.template,
+            fragment_paths: val.fragment_paths,
+            component_group_refs: val.component_group_refs,
+            component_refs: val.component_refs,
+            feature_group_refs: val.feature_group_refs,
+            feature_refs: val.feature_refs,
+            merge_refs: val.merge_refs,
+            skip_webview_install: val.skip_webview_install,
+            license: val.license,
+            enable_elevated_update_task: val.enable_elevated_update_task,
+            banner_path: val.banner_path,
+            dialog_image_path: val.dialog_image_path,
+            fips_compliant: val.fips_compliant,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+pub struct MacOsSettings {
+    pub frameworks: Option<Vec<String>>,
+    pub minimum_system_version: Option<String>,
+    pub license: Option<String>,
+    pub exception_domain: Option<String>,
+    pub signing_identity: Option<String>,
+    pub provider_short_name: Option<String>,
+    pub entitlements: Option<String>,
+    pub info_plist_path: Option<PathBuf>,
+}
+
+#[cfg(feature = "cli")]
+impl From<MacOsSettings> for tauri_bundler::MacOsSettings {
+    fn from(val: MacOsSettings) -> Self {
+        tauri_bundler::MacOsSettings {
+            frameworks: val.frameworks,
+            minimum_system_version: val.minimum_system_version,
+            license: val.license,
+            exception_domain: val.exception_domain,
+            signing_identity: val.signing_identity,
+            provider_short_name: val.provider_short_name,
+            entitlements: val.entitlements,
+            info_plist_path: val.info_plist_path,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct WindowsSettings {
+    pub digest_algorithm: Option<String>,
+    pub certificate_thumbprint: Option<String>,
+    pub timestamp_url: Option<String>,
+    pub tsp: bool,
+    pub wix: Option<WixSettings>,
+    pub icon_path: Option<PathBuf>,
+    pub webview_install_mode: WebviewInstallMode,
+    pub webview_fixed_runtime_path: Option<PathBuf>,
+    pub allow_downgrades: bool,
+    pub nsis: Option<NsisSettings>,
+}
+
+#[cfg(feature = "cli")]
+impl From<WindowsSettings> for tauri_bundler::WindowsSettings {
+    fn from(val: WindowsSettings) -> Self {
+        tauri_bundler::WindowsSettings {
+            digest_algorithm: val.digest_algorithm,
+            certificate_thumbprint: val.certificate_thumbprint,
+            timestamp_url: val.timestamp_url,
+            tsp: val.tsp,
+            wix: val.wix.map(Into::into),
+            icon_path: val.icon_path.unwrap_or("icons/icon.ico".into()),
+            webview_install_mode: val.webview_install_mode.into(),
+            webview_fixed_runtime_path: val.webview_fixed_runtime_path,
+            allow_downgrades: val.allow_downgrades,
+            nsis: val.nsis.map(Into::into),
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct NsisSettings {
+    pub template: Option<PathBuf>,
+    pub license: Option<PathBuf>,
+    pub header_image: Option<PathBuf>,
+    pub sidebar_image: Option<PathBuf>,
+    pub installer_icon: Option<PathBuf>,
+    pub install_mode: NSISInstallerMode,
+    pub languages: Option<Vec<String>>,
+    pub custom_language_files: Option<HashMap<String, PathBuf>>,
+    pub display_language_selector: bool,
+}
+
+#[cfg(feature = "cli")]
+impl From<NsisSettings> for tauri_bundler::NsisSettings {
+    fn from(val: NsisSettings) -> Self {
+        tauri_bundler::NsisSettings {
+            license: val.license,
+            header_image: val.header_image,
+            sidebar_image: val.sidebar_image,
+            installer_icon: val.installer_icon,
+            install_mode: val.install_mode.into(),
+            languages: val.languages,
+            display_language_selector: val.display_language_selector,
+            custom_language_files: None,
+            template: None,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum NSISInstallerMode {
+    CurrentUser,
+    PerMachine,
+    Both,
+}
+
+#[cfg(feature = "cli")]
+impl From<NSISInstallerMode> for tauri_utils::config::NSISInstallerMode {
+    fn from(val: NSISInstallerMode) -> Self {
+        match val {
+            NSISInstallerMode::CurrentUser => tauri_utils::config::NSISInstallerMode::CurrentUser,
+            NSISInstallerMode::PerMachine => tauri_utils::config::NSISInstallerMode::PerMachine,
+            NSISInstallerMode::Both => tauri_utils::config::NSISInstallerMode::Both,
+        }
+    }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum WebviewInstallMode {
+    Skip,
+    DownloadBootstrapper { silent: bool },
+    EmbedBootstrapper { silent: bool },
+    OfflineInstaller { silent: bool },
+    FixedRuntime { path: PathBuf },
+}
+
+impl WebviewInstallMode {
+    fn into(self) -> tauri_utils::config::WebviewInstallMode {
+        match self {
+            Self::Skip => tauri_utils::config::WebviewInstallMode::Skip,
+            Self::DownloadBootstrapper { silent } => {
+                tauri_utils::config::WebviewInstallMode::DownloadBootstrapper { silent }
+            }
+            Self::EmbedBootstrapper { silent } => {
+                tauri_utils::config::WebviewInstallMode::EmbedBootstrapper { silent }
+            }
+            Self::OfflineInstaller { silent } => {
+                tauri_utils::config::WebviewInstallMode::OfflineInstaller { silent }
+            }
+            Self::FixedRuntime { path } => {
+                tauri_utils::config::WebviewInstallMode::FixedRuntime { path }
+            }
+        }
+    }
+}
+
+impl Default for WebviewInstallMode {
+    fn default() -> Self {
+        Self::OfflineInstaller { silent: false }
+    }
+}

+ 128 - 330
packages/cli-config/src/config.rs

@@ -1,13 +1,14 @@
+use crate::BundleConfig;
+use crate::CargoError;
+use crate::{crate_root, Metadata};
 use clap::ValueEnum;
+use core::fmt::{Display, Formatter};
 use serde::{Deserialize, Serialize};
 use std::{
     collections::HashMap,
-    fmt::{Display, Formatter},
     path::{Path, PathBuf},
 };
 
-use crate::CargoError;
-
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Serialize, Deserialize, Debug)]
 pub enum Platform {
     #[clap(name = "web")]
@@ -49,6 +50,51 @@ impl std::fmt::Display for LoadDioxusConfigError {
 
 impl std::error::Error for LoadDioxusConfigError {}
 
+#[derive(Debug)]
+pub enum CrateConfigError {
+    Cargo(CargoError),
+    Io(std::io::Error),
+    Toml(toml::de::Error),
+    LoadDioxusConfig(LoadDioxusConfigError),
+}
+
+impl From<CargoError> for CrateConfigError {
+    fn from(err: CargoError) -> Self {
+        Self::Cargo(err)
+    }
+}
+
+impl From<std::io::Error> for CrateConfigError {
+    fn from(err: std::io::Error) -> Self {
+        Self::Io(err)
+    }
+}
+
+impl From<toml::de::Error> for CrateConfigError {
+    fn from(err: toml::de::Error) -> Self {
+        Self::Toml(err)
+    }
+}
+
+impl From<LoadDioxusConfigError> for CrateConfigError {
+    fn from(err: LoadDioxusConfigError) -> Self {
+        Self::LoadDioxusConfig(err)
+    }
+}
+
+impl Display for CrateConfigError {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        match self {
+            Self::Cargo(err) => write!(f, "{}", err),
+            Self::Io(err) => write!(f, "{}", err),
+            Self::Toml(err) => write!(f, "{}", err),
+            Self::LoadDioxusConfig(err) => write!(f, "{}", err),
+        }
+    }
+}
+
+impl std::error::Error for CrateConfigError {}
+
 impl DioxusConfig {
     /// Load the dioxus config from a path
     pub fn load(bin: Option<PathBuf>) -> Result<Option<DioxusConfig>, CrateConfigError> {
@@ -117,33 +163,33 @@ fn acquire_dioxus_toml(dir: &Path) -> Option<PathBuf> {
 
 impl Default for DioxusConfig {
     fn default() -> Self {
-        let name = "name";
+        let name = default_name();
         Self {
             application: ApplicationConfig {
-                name: name.into(),
-                default_platform: Platform::Web,
-                out_dir: Some(PathBuf::from("dist")),
-                asset_dir: Some(PathBuf::from("public")),
+                name: name.clone(),
+                default_platform: default_platform(),
+                out_dir: out_dir_default(),
+                asset_dir: asset_dir_default(),
 
-                tools: None,
+                tools: Default::default(),
 
                 sub_package: None,
             },
             web: WebConfig {
                 app: WebAppConfig {
-                    title: Some("dioxus | ⛺".into()),
+                    title: default_title(),
                     base_path: None,
                 },
-                proxy: Some(vec![]),
+                proxy: vec![],
                 watcher: WebWatcherConfig {
-                    watch_path: Some(vec![PathBuf::from("src"), PathBuf::from("examples")]),
-                    reload_html: Some(false),
-                    index_on_404: Some(true),
+                    watch_path: watch_path_default(),
+                    reload_html: false,
+                    index_on_404: true,
                 },
                 resource: WebResourceConfig {
                     dev: WebDevResourceConfig {
-                        style: Some(vec![]),
-                        script: Some(vec![]),
+                        style: vec![],
+                        script: vec![],
                     },
                     style: Some(vec![]),
                     script: Some(vec![]),
@@ -157,7 +203,7 @@ impl Default for DioxusConfig {
             },
             bundle: BundleConfig {
                 identifier: Some(format!("io.github.{name}")),
-                publisher: Some(name.into()),
+                publisher: Some(name),
                 ..Default::default()
             },
             plugin: toml::Value::Table(toml::map::Map::new()),
@@ -167,20 +213,44 @@ impl Default for DioxusConfig {
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct ApplicationConfig {
+    #[serde(default = "default_name")]
     pub name: String,
+    #[serde(default = "default_platform")]
     pub default_platform: Platform,
-    pub out_dir: Option<PathBuf>,
-    pub asset_dir: Option<PathBuf>,
+    #[serde(default = "out_dir_default")]
+    pub out_dir: PathBuf,
+    #[serde(default = "asset_dir_default")]
+    pub asset_dir: PathBuf,
 
-    pub tools: Option<HashMap<String, toml::Value>>,
+    #[serde(default)]
+    pub tools: HashMap<String, toml::Value>,
 
+    #[serde(default)]
     pub sub_package: Option<String>,
 }
 
+fn default_name() -> String {
+    "name".into()
+}
+
+fn default_platform() -> Platform {
+    Platform::Web
+}
+
+fn asset_dir_default() -> PathBuf {
+    PathBuf::from("public")
+}
+
+fn out_dir_default() -> PathBuf {
+    PathBuf::from("dist")
+}
+
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct WebConfig {
+    #[serde(default)]
     pub app: WebAppConfig,
-    pub proxy: Option<Vec<WebProxyConfig>>,
+    #[serde(default)]
+    pub proxy: Vec<WebProxyConfig>,
     pub watcher: WebWatcherConfig,
     pub resource: WebResourceConfig,
     #[serde(default)]
@@ -189,10 +259,24 @@ pub struct WebConfig {
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct WebAppConfig {
-    pub title: Option<String>,
+    #[serde(default = "default_title")]
+    pub title: String,
     pub base_path: Option<String>,
 }
 
+impl Default for WebAppConfig {
+    fn default() -> Self {
+        Self {
+            title: default_title(),
+            base_path: None,
+        }
+    }
+}
+
+fn default_title() -> String {
+    "dioxus | ⛺".into()
+}
+
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct WebProxyConfig {
     pub backend: String,
@@ -200,9 +284,16 @@ pub struct WebProxyConfig {
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct WebWatcherConfig {
-    pub watch_path: Option<Vec<PathBuf>>,
-    pub reload_html: Option<bool>,
-    pub index_on_404: Option<bool>,
+    #[serde(default = "watch_path_default")]
+    pub watch_path: Vec<PathBuf>,
+    #[serde(default)]
+    pub reload_html: bool,
+    #[serde(default = "true_bool")]
+    pub index_on_404: bool,
+}
+
+fn watch_path_default() -> Vec<PathBuf> {
+    vec![PathBuf::from("src"), PathBuf::from("examples")]
 }
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -214,8 +305,10 @@ pub struct WebResourceConfig {
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct WebDevResourceConfig {
-    pub style: Option<Vec<PathBuf>>,
-    pub script: Option<Vec<PathBuf>>,
+    #[serde(default)]
+    pub style: Vec<PathBuf>,
+    #[serde(default)]
+    pub script: Vec<PathBuf>,
 }
 
 #[derive(Debug, Default, Clone, Serialize, Deserialize)]
@@ -226,7 +319,7 @@ pub struct WebHttpsConfig {
     pub cert_path: Option<String>,
 }
 
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
 pub struct CrateConfig {
     pub out_dir: PathBuf,
     pub crate_dir: PathBuf,
@@ -244,52 +337,7 @@ pub struct CrateConfig {
     pub features: Option<Vec<String>>,
 }
 
-#[derive(Debug)]
-pub enum CrateConfigError {
-    Cargo(CargoError),
-    Io(std::io::Error),
-    Toml(toml::de::Error),
-    LoadDioxusConfig(LoadDioxusConfigError),
-}
-
-impl From<CargoError> for CrateConfigError {
-    fn from(err: CargoError) -> Self {
-        Self::Cargo(err)
-    }
-}
-
-impl From<std::io::Error> for CrateConfigError {
-    fn from(err: std::io::Error) -> Self {
-        Self::Io(err)
-    }
-}
-
-impl From<toml::de::Error> for CrateConfigError {
-    fn from(err: toml::de::Error) -> Self {
-        Self::Toml(err)
-    }
-}
-
-impl From<LoadDioxusConfigError> for CrateConfigError {
-    fn from(err: LoadDioxusConfigError) -> Self {
-        Self::LoadDioxusConfig(err)
-    }
-}
-
-impl Display for CrateConfigError {
-    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
-        match self {
-            Self::Cargo(err) => write!(f, "{}", err),
-            Self::Io(err) => write!(f, "{}", err),
-            Self::Toml(err) => write!(f, "{}", err),
-            Self::LoadDioxusConfig(err) => write!(f, "{}", err),
-        }
-    }
-}
-
-impl std::error::Error for CrateConfigError {}
-
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
 pub enum ExecutableType {
     Binary(String),
     Lib(String),
@@ -300,7 +348,7 @@ impl CrateConfig {
     pub fn new(bin: Option<PathBuf>) -> Result<Self, CrateConfigError> {
         let dioxus_config = DioxusConfig::load(bin.clone())?.unwrap_or_default();
 
-        let crate_root = crate::cargo::crate_root()?;
+        let crate_root = crate_root()?;
 
         let crate_dir = if let Some(package) = &dioxus_config.application.sub_package {
             crate_root.join(package)
@@ -310,21 +358,15 @@ impl CrateConfig {
             crate_root
         };
 
-        let meta = crate::cargo::Metadata::get()?;
+        let meta = Metadata::get()?;
         let workspace_dir = meta.workspace_root;
         let target_dir = meta.target_directory;
 
-        let out_dir = match dioxus_config.application.out_dir {
-            Some(ref v) => crate_dir.join(v),
-            None => crate_dir.join("dist"),
-        };
+        let out_dir = crate_dir.join(&dioxus_config.application.out_dir);
 
         let cargo_def = &crate_dir.join("Cargo.toml");
 
-        let asset_dir = match dioxus_config.application.asset_dir {
-            Some(ref v) => crate_dir.join(v),
-            None => crate_dir.join("public"),
-        };
+        let asset_dir = crate_dir.join(&dioxus_config.application.asset_dir);
 
         let manifest = cargo_toml::Manifest::from_path(cargo_def).unwrap();
 
@@ -409,250 +451,6 @@ impl CrateConfig {
     }
 }
 
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct BundleConfig {
-    pub identifier: Option<String>,
-    pub publisher: Option<String>,
-    pub icon: Option<Vec<String>>,
-    pub resources: Option<Vec<String>>,
-    pub copyright: Option<String>,
-    pub category: Option<String>,
-    pub short_description: Option<String>,
-    pub long_description: Option<String>,
-    pub external_bin: Option<Vec<String>>,
-    pub deb: Option<DebianSettings>,
-    pub macos: Option<MacOsSettings>,
-    pub windows: Option<WindowsSettings>,
-}
-
-impl From<BundleConfig> for tauri_bundler::BundleSettings {
-    fn from(val: BundleConfig) -> Self {
-        tauri_bundler::BundleSettings {
-            identifier: val.identifier,
-            publisher: val.publisher,
-            icon: val.icon,
-            resources: val.resources,
-            copyright: val.copyright,
-            category: val.category.and_then(|c| c.parse().ok()),
-            short_description: val.short_description,
-            long_description: val.long_description,
-            external_bin: val.external_bin,
-            deb: val.deb.map(Into::into).unwrap_or_default(),
-            macos: val.macos.map(Into::into).unwrap_or_default(),
-            windows: val.windows.map(Into::into).unwrap_or_default(),
-            ..Default::default()
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct DebianSettings {
-    pub depends: Option<Vec<String>>,
-    pub files: HashMap<PathBuf, PathBuf>,
-    pub nsis: Option<NsisSettings>,
-}
-
-impl From<DebianSettings> for tauri_bundler::DebianSettings {
-    fn from(val: DebianSettings) -> Self {
-        tauri_bundler::DebianSettings {
-            depends: val.depends,
-            files: val.files,
-            desktop_template: None,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct WixSettings {
-    pub language: Vec<(String, Option<PathBuf>)>,
-    pub template: Option<PathBuf>,
-    pub fragment_paths: Vec<PathBuf>,
-    pub component_group_refs: Vec<String>,
-    pub component_refs: Vec<String>,
-    pub feature_group_refs: Vec<String>,
-    pub feature_refs: Vec<String>,
-    pub merge_refs: Vec<String>,
-    pub skip_webview_install: bool,
-    pub license: Option<PathBuf>,
-    pub enable_elevated_update_task: bool,
-    pub banner_path: Option<PathBuf>,
-    pub dialog_image_path: Option<PathBuf>,
-    pub fips_compliant: bool,
-}
-
-impl From<WixSettings> for tauri_bundler::WixSettings {
-    fn from(val: WixSettings) -> Self {
-        tauri_bundler::WixSettings {
-            language: tauri_bundler::bundle::WixLanguage({
-                let mut languages: Vec<_> = val
-                    .language
-                    .iter()
-                    .map(|l| {
-                        (
-                            l.0.clone(),
-                            tauri_bundler::bundle::WixLanguageConfig {
-                                locale_path: l.1.clone(),
-                            },
-                        )
-                    })
-                    .collect();
-                if languages.is_empty() {
-                    languages.push(("en-US".into(), Default::default()));
-                }
-                languages
-            }),
-            template: val.template,
-            fragment_paths: val.fragment_paths,
-            component_group_refs: val.component_group_refs,
-            component_refs: val.component_refs,
-            feature_group_refs: val.feature_group_refs,
-            feature_refs: val.feature_refs,
-            merge_refs: val.merge_refs,
-            skip_webview_install: val.skip_webview_install,
-            license: val.license,
-            enable_elevated_update_task: val.enable_elevated_update_task,
-            banner_path: val.banner_path,
-            dialog_image_path: val.dialog_image_path,
-            fips_compliant: val.fips_compliant,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct MacOsSettings {
-    pub frameworks: Option<Vec<String>>,
-    pub minimum_system_version: Option<String>,
-    pub license: Option<String>,
-    pub exception_domain: Option<String>,
-    pub signing_identity: Option<String>,
-    pub provider_short_name: Option<String>,
-    pub entitlements: Option<String>,
-    pub info_plist_path: Option<PathBuf>,
-}
-
-impl From<MacOsSettings> for tauri_bundler::MacOsSettings {
-    fn from(val: MacOsSettings) -> Self {
-        tauri_bundler::MacOsSettings {
-            frameworks: val.frameworks,
-            minimum_system_version: val.minimum_system_version,
-            license: val.license,
-            exception_domain: val.exception_domain,
-            signing_identity: val.signing_identity,
-            provider_short_name: val.provider_short_name,
-            entitlements: val.entitlements,
-            info_plist_path: val.info_plist_path,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WindowsSettings {
-    pub digest_algorithm: Option<String>,
-    pub certificate_thumbprint: Option<String>,
-    pub timestamp_url: Option<String>,
-    pub tsp: bool,
-    pub wix: Option<WixSettings>,
-    pub icon_path: Option<PathBuf>,
-    pub webview_install_mode: WebviewInstallMode,
-    pub webview_fixed_runtime_path: Option<PathBuf>,
-    pub allow_downgrades: bool,
-    pub nsis: Option<NsisSettings>,
-}
-
-impl From<WindowsSettings> for tauri_bundler::WindowsSettings {
-    fn from(val: WindowsSettings) -> Self {
-        tauri_bundler::WindowsSettings {
-            digest_algorithm: val.digest_algorithm,
-            certificate_thumbprint: val.certificate_thumbprint,
-            timestamp_url: val.timestamp_url,
-            tsp: val.tsp,
-            wix: val.wix.map(Into::into),
-            icon_path: val.icon_path.unwrap_or("icons/icon.ico".into()),
-            webview_install_mode: val.webview_install_mode.into(),
-            webview_fixed_runtime_path: val.webview_fixed_runtime_path,
-            allow_downgrades: val.allow_downgrades,
-            nsis: val.nsis.map(Into::into),
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct NsisSettings {
-    pub template: Option<PathBuf>,
-    pub license: Option<PathBuf>,
-    pub header_image: Option<PathBuf>,
-    pub sidebar_image: Option<PathBuf>,
-    pub installer_icon: Option<PathBuf>,
-    pub install_mode: NSISInstallerMode,
-    pub languages: Option<Vec<String>>,
-    pub custom_language_files: Option<HashMap<String, PathBuf>>,
-    pub display_language_selector: bool,
-}
-
-impl From<NsisSettings> for tauri_bundler::NsisSettings {
-    fn from(val: NsisSettings) -> Self {
-        tauri_bundler::NsisSettings {
-            license: val.license,
-            header_image: val.header_image,
-            sidebar_image: val.sidebar_image,
-            installer_icon: val.installer_icon,
-            install_mode: val.install_mode.into(),
-            languages: val.languages,
-            display_language_selector: val.display_language_selector,
-            custom_language_files: None,
-            template: None,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub enum NSISInstallerMode {
-    CurrentUser,
-    PerMachine,
-    Both,
-}
-
-impl From<NSISInstallerMode> for tauri_utils::config::NSISInstallerMode {
-    fn from(val: NSISInstallerMode) -> Self {
-        match val {
-            NSISInstallerMode::CurrentUser => tauri_utils::config::NSISInstallerMode::CurrentUser,
-            NSISInstallerMode::PerMachine => tauri_utils::config::NSISInstallerMode::PerMachine,
-            NSISInstallerMode::Both => tauri_utils::config::NSISInstallerMode::Both,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub enum WebviewInstallMode {
-    Skip,
-    DownloadBootstrapper { silent: bool },
-    EmbedBootstrapper { silent: bool },
-    OfflineInstaller { silent: bool },
-    FixedRuntime { path: PathBuf },
-}
-
-impl WebviewInstallMode {
-    fn into(self) -> tauri_utils::config::WebviewInstallMode {
-        match self {
-            Self::Skip => tauri_utils::config::WebviewInstallMode::Skip,
-            Self::DownloadBootstrapper { silent } => {
-                tauri_utils::config::WebviewInstallMode::DownloadBootstrapper { silent }
-            }
-            Self::EmbedBootstrapper { silent } => {
-                tauri_utils::config::WebviewInstallMode::EmbedBootstrapper { silent }
-            }
-            Self::OfflineInstaller { silent } => {
-                tauri_utils::config::WebviewInstallMode::OfflineInstaller { silent }
-            }
-            Self::FixedRuntime { path } => {
-                tauri_utils::config::WebviewInstallMode::FixedRuntime { path }
-            }
-        }
-    }
-}
-
-impl Default for WebviewInstallMode {
-    fn default() -> Self {
-        Self::OfflineInstaller { silent: false }
-    }
+fn true_bool() -> bool {
+    true
 }

+ 45 - 1
packages/cli-config/src/lib.rs

@@ -4,6 +4,50 @@
 
 mod config;
 pub use config::*;
-
+mod bundle;
+pub use bundle::*;
 mod cargo;
 pub use cargo::*;
+
+#[doc(hidden)]
+pub mod __private {
+    use crate::CrateConfig;
+
+    pub const CONFIG_ENV: &str = "DIOXUS_CONFIG";
+
+    pub fn save_config(config: &CrateConfig) -> CrateConfigDropGuard {
+        std::env::set_var(CONFIG_ENV, serde_json::to_string(config).unwrap());
+        CrateConfigDropGuard
+    }
+
+    /// A guard that removes the config from the environment when dropped.
+    pub struct CrateConfigDropGuard;
+
+    impl Drop for CrateConfigDropGuard {
+        fn drop(&mut self) {
+            std::env::remove_var(CONFIG_ENV);
+        }
+    }
+}
+
+/// An error that occurs when the dioxus CLI was not used to build the application.
+#[derive(Debug)]
+pub struct DioxusCLINotUsed;
+
+impl std::fmt::Display for DioxusCLINotUsed {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        f.write_str("dioxus CLI was not used to build the application")
+    }
+}
+
+impl std::error::Error for DioxusCLINotUsed {}
+
+/// The current crate's configuration.
+pub static CURRENT_CONFIG: once_cell::sync::Lazy<
+    Result<crate::config::CrateConfig, DioxusCLINotUsed>,
+> = once_cell::sync::Lazy::new(|| {
+    std::env::var(crate::__private::CONFIG_ENV)
+        .ok()
+        .and_then(|config| serde_json::from_str(&config).ok())
+        .ok_or(DioxusCLINotUsed)
+});

+ 1 - 1
packages/cli/Cargo.toml

@@ -14,7 +14,7 @@ clap = { version = "4.2", features = ["derive"] }
 thiserror = { workspace = true }
 wasm-bindgen-cli-support = "0.2"
 colored = "2.0.0"
-dioxus-cli-config = { workspace = true }
+dioxus-cli-config = { workspace = true, features = ["cli"] }
 
 # features
 log = "0.4.14"

+ 14 - 9
packages/cli/src/builder.rs

@@ -1,11 +1,12 @@
 use crate::{
-    config::{CrateConfig, ExecutableType},
     error::{Error, Result},
     tools::Tool,
-    DioxusConfig,
 };
 use cargo_metadata::{diagnostic::Diagnostic, Message};
 use dioxus_cli_config::crate_root;
+use dioxus_cli_config::CrateConfig;
+use dioxus_cli_config::DioxusConfig;
+use dioxus_cli_config::ExecutableType;
 use indicatif::{ProgressBar, ProgressStyle};
 use serde::Serialize;
 use std::{
@@ -89,6 +90,8 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
         ExecutableType::Example(name) => cmd.arg("--example").arg(name),
     };
 
+    let _ = dioxus_cli_config::__private::save_config(config);
+
     let warning_messages = prettier_build(cmd)?;
 
     // [2] Establish the output directory structure
@@ -276,11 +279,13 @@ pub fn build_desktop(config: &CrateConfig, _is_serve: bool) -> Result<BuildResul
     }
 
     let cmd = match &config.executable {
-        crate::ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
-        crate::ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
-        crate::ExecutableType::Example(name) => cmd.arg("--example").arg(name),
+        ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
+        ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
+        ExecutableType::Example(name) => cmd.arg("--example").arg(name),
     };
 
+    let _ = dioxus_cli_config::__private::save_config(config);
+
     let warning_messages = prettier_build(cmd)?;
 
     let release_type = match config.release {
@@ -290,11 +295,11 @@ pub fn build_desktop(config: &CrateConfig, _is_serve: bool) -> Result<BuildResul
 
     let file_name: String;
     let mut res_path = match &config.executable {
-        crate::ExecutableType::Binary(name) | crate::ExecutableType::Lib(name) => {
+        ExecutableType::Binary(name) | ExecutableType::Lib(name) => {
             file_name = name.clone();
             config.target_dir.join(release_type).join(name)
         }
-        crate::ExecutableType::Example(name) => {
+        ExecutableType::Example(name) => {
             file_name = name.clone();
             config
                 .target_dir
@@ -444,8 +449,8 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String {
     let mut script_list = resources.script.unwrap_or_default();
 
     if serve {
-        let mut dev_style = resouces.dev.style.clone();
-        let mut dev_script = resouces.dev.script.clone();
+        let mut dev_style = resources.dev.style.clone();
+        let mut dev_script = resources.dev.script.clone();
         style_list.append(&mut dev_style);
         script_list.append(&mut dev_script);
     }

+ 1 - 1
packages/cli/src/cli/autoformat.rs

@@ -88,7 +88,7 @@ impl Autoformat {
 ///
 /// Doesn't do mod-descending, so it will still try to format unreachable files. TODO.
 async fn autoformat_project(check: bool) -> Result<()> {
-    let crate_config = crate::CrateConfig::new(None)?;
+    let crate_config = dioxus_cli_config::CrateConfig::new(None)?;
 
     let mut files_to_format = vec![];
     collect_rs_files(&crate_config.crate_dir, &mut files_to_format);

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

@@ -14,7 +14,7 @@ pub struct Build {
 
 impl Build {
     pub fn build(self, bin: Option<PathBuf>) -> Result<()> {
-        let mut crate_config = crate::CrateConfig::new(bin)?;
+        let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
 
         // change the release state.
         crate_config.with_release(self.build.release);

+ 5 - 4
packages/cli/src/cli/bundle.rs

@@ -1,4 +1,5 @@
 use core::panic;
+use dioxus_cli_config::ExecutableType;
 use std::{fs::create_dir_all, str::FromStr};
 
 use tauri_bundler::{BundleSettings, PackageSettings, SettingsBuilder};
@@ -62,7 +63,7 @@ impl From<PackageType> for tauri_bundler::PackageType {
 
 impl Bundle {
     pub fn bundle(self, bin: Option<PathBuf>) -> Result<()> {
-        let mut crate_config = crate::CrateConfig::new(bin)?;
+        let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
 
         // change the release state.
         crate_config.with_release(self.build.release);
@@ -83,9 +84,9 @@ impl Bundle {
         let package = crate_config.manifest.package.unwrap();
 
         let mut name: PathBuf = match &crate_config.executable {
-            crate::ExecutableType::Binary(name)
-            | crate::ExecutableType::Lib(name)
-            | crate::ExecutableType::Example(name) => name,
+            ExecutableType::Binary(name)
+            | ExecutableType::Lib(name)
+            | ExecutableType::Example(name) => name,
         }
         .into();
         if cfg!(windows) {

+ 1 - 1
packages/cli/src/cli/check.rs

@@ -47,7 +47,7 @@ async fn check_file_and_report(path: PathBuf) -> Result<()> {
 ///
 /// Doesn't do mod-descending, so it will still try to check unreachable files. TODO.
 async fn check_project_and_report() -> Result<()> {
-    let crate_config = crate::CrateConfig::new(None)?;
+    let crate_config = dioxus_cli_config::CrateConfig::new(None)?;
 
     let mut files_to_check = vec![];
     collect_rs_files(&crate_config.crate_dir, &mut files_to_check);

+ 1 - 1
packages/cli/src/cli/clean.rs

@@ -7,7 +7,7 @@ pub struct Clean {}
 
 impl Clean {
     pub fn clean(self, bin: Option<PathBuf>) -> Result<()> {
-        let crate_config = crate::CrateConfig::new(bin)?;
+        let crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
 
         let output = Command::new("cargo")
             .arg("clean")

+ 4 - 1
packages/cli/src/cli/config.rs

@@ -50,7 +50,10 @@ impl Config {
                 log::info!("🚩 Init config file completed.");
             }
             Config::FormatPrint {} => {
-                println!("{:#?}", crate::CrateConfig::new(None)?.dioxus_config);
+                println!(
+                    "{:#?}",
+                    dioxus_cli_config::CrateConfig::new(None)?.dioxus_config
+                );
             }
             Config::CustomHtml {} => {
                 let html_path = crate_root.join("index.html");

+ 2 - 1
packages/cli/src/cli/mod.rs

@@ -15,9 +15,10 @@ use crate::{
     cfg::{ConfigOptsBuild, ConfigOptsServe},
     custom_error,
     error::Result,
-    gen_page, server, CrateConfig, Error,
+    gen_page, server, Error,
 };
 use clap::{Parser, Subcommand};
+use dioxus_cli_config::CrateConfig;
 use html_parser::Dom;
 use serde::Deserialize;
 use std::{

+ 1 - 1
packages/cli/src/cli/serve.rs

@@ -13,7 +13,7 @@ pub struct Serve {
 
 impl Serve {
     pub async fn serve(self, bin: Option<PathBuf>) -> Result<()> {
-        let mut crate_config = crate::CrateConfig::new(bin)?;
+        let mut crate_config = dioxus_cli_config::CrateConfig::new(bin)?;
 
         // change the relase state.
         crate_config.with_hot_reload(self.serve.hot_reload);

+ 0 - 628
packages/cli/src/config.rs

@@ -1,628 +0,0 @@
-use crate::error::Result;
-use dioxus_cli_config::{crate_root, Metadata, Platform};
-use serde::{Deserialize, Serialize};
-use std::{
-    collections::HashMap,
-    path::{Path, PathBuf},
-};
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct DioxusConfig {
-    pub application: ApplicationConfig,
-
-    pub web: WebConfig,
-
-    #[serde(default)]
-    pub bundle: BundleConfig,
-
-    #[serde(default = "default_plugin")]
-    pub plugin: toml::Value,
-}
-
-fn default_plugin() -> toml::Value {
-    toml::Value::Boolean(true)
-}
-
-impl DioxusConfig {
-    pub fn load(bin: Option<PathBuf>) -> crate::error::Result<Option<DioxusConfig>> {
-        let crate_dir = crate_root();
-
-        let crate_dir = match crate_dir {
-            Ok(dir) => {
-                if let Some(bin) = bin {
-                    dir.join(bin)
-                } else {
-                    dir
-                }
-            }
-            Err(_) => return Ok(None),
-        };
-        let crate_dir = crate_dir.as_path();
-
-        let Some(dioxus_conf_file) = acquire_dioxus_toml(crate_dir) else {
-            return Ok(None);
-        };
-
-        let dioxus_conf_file = dioxus_conf_file.as_path();
-        let cfg = toml::from_str::<DioxusConfig>(&std::fs::read_to_string(dioxus_conf_file)?)
-            .map_err(|err| {
-                let error_location = dioxus_conf_file
-                    .strip_prefix(crate_dir)
-                    .unwrap_or(dioxus_conf_file)
-                    .display();
-                crate::Error::Unique(format!("{error_location} {err}"))
-            })
-            .map(Some);
-        match cfg {
-            Ok(Some(mut cfg)) => {
-                let name = cfg.application.name.clone();
-                if cfg.bundle.identifier.is_none() {
-                    cfg.bundle.identifier = Some(format!("io.github.{name}"));
-                }
-                if cfg.bundle.publisher.is_none() {
-                    cfg.bundle.publisher = Some(name);
-                }
-                Ok(Some(cfg))
-            }
-            cfg => cfg,
-        }
-    }
-}
-
-fn acquire_dioxus_toml(dir: &Path) -> Option<PathBuf> {
-    // prefer uppercase
-    let uppercase_conf = dir.join("Dioxus.toml");
-    if uppercase_conf.is_file() {
-        return Some(uppercase_conf);
-    }
-
-    // lowercase is fine too
-    let lowercase_conf = dir.join("dioxus.toml");
-    if lowercase_conf.is_file() {
-        return Some(lowercase_conf);
-    }
-
-    None
-}
-
-impl Default for DioxusConfig {
-    fn default() -> Self {
-        let name = default_name();
-        Self {
-            application: ApplicationConfig {
-                name: name.clone(),
-                default_platform: default_platform(),
-                out_dir: out_dir_default(),
-                asset_dir: asset_dir_default(),
-
-                tools: Default::default(),
-
-                sub_package: None,
-            },
-            web: WebConfig {
-                app: WebAppConfig {
-                    title: default_title(),
-                    base_path: None,
-                },
-                proxy: vec![],
-                watcher: WebWatcherConfig {
-                    watch_path: watch_path_default(),
-                    reload_html: false,
-                    index_on_404: true,
-                },
-                resource: WebResourceConfig {
-                    dev: WebDevResourceConfig {
-                        style: vec![],
-                        script: vec![],
-                    },
-                    style: Some(vec![]),
-                    script: Some(vec![]),
-                },
-                https: WebHttpsConfig {
-                    enabled: None,
-                    mkcert: None,
-                    key_path: None,
-                    cert_path: None,
-                },
-            },
-            bundle: BundleConfig {
-                identifier: Some(format!("io.github.{name}")),
-                publisher: Some(name),
-                ..Default::default()
-            },
-            plugin: toml::Value::Table(toml::map::Map::new()),
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct ApplicationConfig {
-    #[serde(default = "default_name")]
-    pub name: String,
-    #[serde(default = "default_platform")]
-    pub default_platform: Platform,
-    #[serde(default = "out_dir_default")]
-    pub out_dir: PathBuf,
-    #[serde(default = "asset_dir_default")]
-    pub asset_dir: PathBuf,
-
-    #[serde(default)]
-    pub tools: HashMap<String, toml::Value>,
-
-    #[serde(default)]
-    pub sub_package: Option<String>,
-}
-
-fn default_name() -> String {
-    "name".into()
-}
-
-fn default_platform() -> Platform {
-    Platform::Web
-}
-
-fn asset_dir_default() -> PathBuf {
-    PathBuf::from("public")
-}
-
-fn out_dir_default() -> PathBuf {
-    PathBuf::from("dist")
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebConfig {
-    #[serde(default)]
-    pub app: WebAppConfig,
-    #[serde(default)]
-    pub proxy: Vec<WebProxyConfig>,
-    pub watcher: WebWatcherConfig,
-    pub resource: WebResourceConfig,
-    #[serde(default)]
-    pub https: WebHttpsConfig,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebAppConfig {
-    #[serde(default = "default_title")]
-    pub title: String,
-    pub base_path: Option<String>,
-}
-
-impl Default for WebAppConfig {
-    fn default() -> Self {
-        Self {
-            title: default_title(),
-            base_path: None,
-        }
-    }
-}
-
-fn default_title() -> String {
-    "dioxus | ⛺".into()
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebProxyConfig {
-    pub backend: String,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebWatcherConfig {
-    #[serde(default = "watch_path_default")]
-    pub watch_path: Vec<PathBuf>,
-    #[serde(default)]
-    pub reload_html: bool,
-    #[serde(default = "true_bool")]
-    pub index_on_404: bool,
-}
-
-fn watch_path_default() -> Vec<PathBuf> {
-    vec![PathBuf::from("src"), PathBuf::from("examples")]
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebResourceConfig {
-    pub dev: WebDevResourceConfig,
-    pub style: Option<Vec<PathBuf>>,
-    pub script: Option<Vec<PathBuf>>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WebDevResourceConfig {
-    #[serde(default)]
-    pub style: Vec<PathBuf>,
-    #[serde(default)]
-    pub script: Vec<PathBuf>,
-}
-
-#[derive(Debug, Default, Clone, Serialize, Deserialize)]
-pub struct WebHttpsConfig {
-    pub enabled: Option<bool>,
-    pub mkcert: Option<bool>,
-    pub key_path: Option<String>,
-    pub cert_path: Option<String>,
-}
-
-#[derive(Debug, Clone)]
-pub struct CrateConfig {
-    pub out_dir: PathBuf,
-    pub crate_dir: PathBuf,
-    pub workspace_dir: PathBuf,
-    pub target_dir: PathBuf,
-    pub asset_dir: PathBuf,
-    pub manifest: cargo_toml::Manifest<cargo_toml::Value>,
-    pub executable: ExecutableType,
-    pub dioxus_config: DioxusConfig,
-    pub release: bool,
-    pub hot_reload: bool,
-    pub cross_origin_policy: bool,
-    pub verbose: bool,
-    pub custom_profile: Option<String>,
-    pub features: Option<Vec<String>>,
-}
-
-#[derive(Debug, Clone)]
-pub enum ExecutableType {
-    Binary(String),
-    Lib(String),
-    Example(String),
-}
-
-impl CrateConfig {
-    pub fn new(bin: Option<PathBuf>) -> Result<Self> {
-        let dioxus_config = DioxusConfig::load(bin.clone())?.unwrap_or_default();
-
-        let crate_root = crate_root()?;
-
-        let crate_dir = if let Some(package) = &dioxus_config.application.sub_package {
-            crate_root.join(package)
-        } else if let Some(bin) = bin {
-            crate_root.join(bin)
-        } else {
-            crate_root
-        };
-
-        let meta = Metadata::get()?;
-        let workspace_dir = meta.workspace_root;
-        let target_dir = meta.target_directory;
-
-        let out_dir = crate_dir.join(&dioxus_config.application.out_dir);
-
-        let cargo_def = &crate_dir.join("Cargo.toml");
-
-        let asset_dir = crate_dir.join(&dioxus_config.application.asset_dir);
-
-        let manifest = cargo_toml::Manifest::from_path(cargo_def).unwrap();
-
-        let mut output_filename = String::from("dioxus_app");
-        if let Some(package) = &manifest.package.as_ref() {
-            output_filename = match &package.default_run {
-                Some(default_run_target) => default_run_target.to_owned(),
-                None => manifest
-                    .bin
-                    .iter()
-                    .find(|b| b.name == manifest.package.as_ref().map(|pkg| pkg.name.clone()))
-                    .or(manifest
-                        .bin
-                        .iter()
-                        .find(|b| b.path == Some("src/main.rs".to_owned())))
-                    .or(manifest.bin.first())
-                    .or(manifest.lib.as_ref())
-                    .and_then(|prod| prod.name.clone())
-                    .unwrap_or(String::from("dioxus_app")),
-            };
-        }
-
-        let executable = ExecutableType::Binary(output_filename);
-
-        let release = false;
-        let hot_reload = false;
-        let verbose = false;
-        let custom_profile = None;
-        let features = None;
-
-        Ok(Self {
-            out_dir,
-            crate_dir,
-            workspace_dir,
-            target_dir,
-            asset_dir,
-            manifest,
-            executable,
-            release,
-            dioxus_config,
-            hot_reload,
-            cross_origin_policy: false,
-            custom_profile,
-            features,
-            verbose,
-        })
-    }
-
-    pub fn as_example(&mut self, example_name: String) -> &mut Self {
-        self.executable = ExecutableType::Example(example_name);
-        self
-    }
-
-    pub fn with_release(&mut self, release: bool) -> &mut Self {
-        self.release = release;
-        self
-    }
-
-    pub fn with_hot_reload(&mut self, hot_reload: bool) -> &mut Self {
-        self.hot_reload = hot_reload;
-        self
-    }
-
-    pub fn with_cross_origin_policy(&mut self, cross_origin_policy: bool) -> &mut Self {
-        self.cross_origin_policy = cross_origin_policy;
-        self
-    }
-
-    pub fn with_verbose(&mut self, verbose: bool) -> &mut Self {
-        self.verbose = verbose;
-        self
-    }
-
-    pub fn set_profile(&mut self, profile: String) -> &mut Self {
-        self.custom_profile = Some(profile);
-        self
-    }
-
-    pub fn set_features(&mut self, features: Vec<String>) -> &mut Self {
-        self.features = Some(features);
-        self
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct BundleConfig {
-    pub identifier: Option<String>,
-    pub publisher: Option<String>,
-    pub icon: Option<Vec<String>>,
-    pub resources: Option<Vec<String>>,
-    pub copyright: Option<String>,
-    pub category: Option<String>,
-    pub short_description: Option<String>,
-    pub long_description: Option<String>,
-    pub external_bin: Option<Vec<String>>,
-    pub deb: Option<DebianSettings>,
-    pub macos: Option<MacOsSettings>,
-    pub windows: Option<WindowsSettings>,
-}
-
-impl From<BundleConfig> for tauri_bundler::BundleSettings {
-    fn from(val: BundleConfig) -> Self {
-        tauri_bundler::BundleSettings {
-            identifier: val.identifier,
-            publisher: val.publisher,
-            icon: val.icon,
-            resources: val.resources,
-            copyright: val.copyright,
-            category: val.category.and_then(|c| c.parse().ok()),
-            short_description: val.short_description,
-            long_description: val.long_description,
-            external_bin: val.external_bin,
-            deb: val.deb.map(Into::into).unwrap_or_default(),
-            macos: val.macos.map(Into::into).unwrap_or_default(),
-            windows: val.windows.map(Into::into).unwrap_or_default(),
-            ..Default::default()
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct DebianSettings {
-    pub depends: Option<Vec<String>>,
-    pub files: HashMap<PathBuf, PathBuf>,
-    pub nsis: Option<NsisSettings>,
-}
-
-impl From<DebianSettings> for tauri_bundler::DebianSettings {
-    fn from(val: DebianSettings) -> Self {
-        tauri_bundler::DebianSettings {
-            depends: val.depends,
-            files: val.files,
-            desktop_template: None,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct WixSettings {
-    pub language: Vec<(String, Option<PathBuf>)>,
-    pub template: Option<PathBuf>,
-    pub fragment_paths: Vec<PathBuf>,
-    pub component_group_refs: Vec<String>,
-    pub component_refs: Vec<String>,
-    pub feature_group_refs: Vec<String>,
-    pub feature_refs: Vec<String>,
-    pub merge_refs: Vec<String>,
-    pub skip_webview_install: bool,
-    pub license: Option<PathBuf>,
-    pub enable_elevated_update_task: bool,
-    pub banner_path: Option<PathBuf>,
-    pub dialog_image_path: Option<PathBuf>,
-    pub fips_compliant: bool,
-}
-
-impl From<WixSettings> for tauri_bundler::WixSettings {
-    fn from(val: WixSettings) -> Self {
-        tauri_bundler::WixSettings {
-            language: tauri_bundler::bundle::WixLanguage({
-                let mut languages: Vec<_> = val
-                    .language
-                    .iter()
-                    .map(|l| {
-                        (
-                            l.0.clone(),
-                            tauri_bundler::bundle::WixLanguageConfig {
-                                locale_path: l.1.clone(),
-                            },
-                        )
-                    })
-                    .collect();
-                if languages.is_empty() {
-                    languages.push(("en-US".into(), Default::default()));
-                }
-                languages
-            }),
-            template: val.template,
-            fragment_paths: val.fragment_paths,
-            component_group_refs: val.component_group_refs,
-            component_refs: val.component_refs,
-            feature_group_refs: val.feature_group_refs,
-            feature_refs: val.feature_refs,
-            merge_refs: val.merge_refs,
-            skip_webview_install: val.skip_webview_install,
-            license: val.license,
-            enable_elevated_update_task: val.enable_elevated_update_task,
-            banner_path: val.banner_path,
-            dialog_image_path: val.dialog_image_path,
-            fips_compliant: val.fips_compliant,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-pub struct MacOsSettings {
-    pub frameworks: Option<Vec<String>>,
-    pub minimum_system_version: Option<String>,
-    pub license: Option<String>,
-    pub exception_domain: Option<String>,
-    pub signing_identity: Option<String>,
-    pub provider_short_name: Option<String>,
-    pub entitlements: Option<String>,
-    pub info_plist_path: Option<PathBuf>,
-}
-
-impl From<MacOsSettings> for tauri_bundler::MacOsSettings {
-    fn from(val: MacOsSettings) -> Self {
-        tauri_bundler::MacOsSettings {
-            frameworks: val.frameworks,
-            minimum_system_version: val.minimum_system_version,
-            license: val.license,
-            exception_domain: val.exception_domain,
-            signing_identity: val.signing_identity,
-            provider_short_name: val.provider_short_name,
-            entitlements: val.entitlements,
-            info_plist_path: val.info_plist_path,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct WindowsSettings {
-    pub digest_algorithm: Option<String>,
-    pub certificate_thumbprint: Option<String>,
-    pub timestamp_url: Option<String>,
-    pub tsp: bool,
-    pub wix: Option<WixSettings>,
-    pub icon_path: Option<PathBuf>,
-    pub webview_install_mode: WebviewInstallMode,
-    pub webview_fixed_runtime_path: Option<PathBuf>,
-    pub allow_downgrades: bool,
-    pub nsis: Option<NsisSettings>,
-}
-
-impl From<WindowsSettings> for tauri_bundler::WindowsSettings {
-    fn from(val: WindowsSettings) -> Self {
-        tauri_bundler::WindowsSettings {
-            digest_algorithm: val.digest_algorithm,
-            certificate_thumbprint: val.certificate_thumbprint,
-            timestamp_url: val.timestamp_url,
-            tsp: val.tsp,
-            wix: val.wix.map(Into::into),
-            icon_path: val.icon_path.unwrap_or("icons/icon.ico".into()),
-            webview_install_mode: val.webview_install_mode.into(),
-            webview_fixed_runtime_path: val.webview_fixed_runtime_path,
-            allow_downgrades: val.allow_downgrades,
-            nsis: val.nsis.map(Into::into),
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct NsisSettings {
-    pub template: Option<PathBuf>,
-    pub license: Option<PathBuf>,
-    pub header_image: Option<PathBuf>,
-    pub sidebar_image: Option<PathBuf>,
-    pub installer_icon: Option<PathBuf>,
-    pub install_mode: NSISInstallerMode,
-    pub languages: Option<Vec<String>>,
-    pub custom_language_files: Option<HashMap<String, PathBuf>>,
-    pub display_language_selector: bool,
-}
-
-impl From<NsisSettings> for tauri_bundler::NsisSettings {
-    fn from(val: NsisSettings) -> Self {
-        tauri_bundler::NsisSettings {
-            license: val.license,
-            header_image: val.header_image,
-            sidebar_image: val.sidebar_image,
-            installer_icon: val.installer_icon,
-            install_mode: val.install_mode.into(),
-            languages: val.languages,
-            display_language_selector: val.display_language_selector,
-            custom_language_files: None,
-            template: None,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub enum NSISInstallerMode {
-    CurrentUser,
-    PerMachine,
-    Both,
-}
-
-impl From<NSISInstallerMode> for tauri_utils::config::NSISInstallerMode {
-    fn from(val: NSISInstallerMode) -> Self {
-        match val {
-            NSISInstallerMode::CurrentUser => tauri_utils::config::NSISInstallerMode::CurrentUser,
-            NSISInstallerMode::PerMachine => tauri_utils::config::NSISInstallerMode::PerMachine,
-            NSISInstallerMode::Both => tauri_utils::config::NSISInstallerMode::Both,
-        }
-    }
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub enum WebviewInstallMode {
-    Skip,
-    DownloadBootstrapper { silent: bool },
-    EmbedBootstrapper { silent: bool },
-    OfflineInstaller { silent: bool },
-    FixedRuntime { path: PathBuf },
-}
-
-impl WebviewInstallMode {
-    fn into(self) -> tauri_utils::config::WebviewInstallMode {
-        match self {
-            Self::Skip => tauri_utils::config::WebviewInstallMode::Skip,
-            Self::DownloadBootstrapper { silent } => {
-                tauri_utils::config::WebviewInstallMode::DownloadBootstrapper { silent }
-            }
-            Self::EmbedBootstrapper { silent } => {
-                tauri_utils::config::WebviewInstallMode::EmbedBootstrapper { silent }
-            }
-            Self::OfflineInstaller { silent } => {
-                tauri_utils::config::WebviewInstallMode::OfflineInstaller { silent }
-            }
-            Self::FixedRuntime { path } => {
-                tauri_utils::config::WebviewInstallMode::FixedRuntime { path }
-            }
-        }
-    }
-}
-
-impl Default for WebviewInstallMode {
-    fn default() -> Self {
-        Self::OfflineInstaller { silent: false }
-    }
-}
-
-fn true_bool() -> bool {
-    true
-}

+ 6 - 0
packages/cli/src/error.rs

@@ -81,6 +81,12 @@ impl From<dioxus_cli_config::CargoError> for Error {
     }
 }
 
+impl From<dioxus_cli_config::CrateConfigError> for Error {
+    fn from(e: dioxus_cli_config::CrateConfigError) -> Self {
+        Self::RuntimeError(e.to_string())
+    }
+}
+
 #[macro_export]
 macro_rules! custom_error {
     ($msg:literal $(,)?) => {

+ 0 - 3
packages/cli/src/lib.rs

@@ -13,9 +13,6 @@ pub use builder::*;
 pub mod cli;
 pub use cli::*;
 
-pub mod config;
-pub use config::*;
-
 pub mod error;
 pub use error::*;
 

+ 6 - 4
packages/cli/src/server/desktop/mod.rs

@@ -3,8 +3,10 @@ use crate::{
         output::{print_console_info, PrettierOptions},
         setup_file_watcher,
     },
-    BuildResult, CrateConfig, Result,
+    BuildResult, Result,
 };
+use dioxus_cli_config::CrateConfig;
+use dioxus_cli_config::ExecutableType;
 
 use dioxus_hot_reload::HotReloadMsg;
 use dioxus_html::HtmlCtx;
@@ -215,9 +217,9 @@ pub fn start_desktop(config: &CrateConfig) -> Result<(Child, BuildResult)> {
     let result = crate::builder::build_desktop(config, true)?;
 
     match &config.executable {
-        crate::ExecutableType::Binary(name)
-        | crate::ExecutableType::Lib(name)
-        | crate::ExecutableType::Example(name) => {
+        ExecutableType::Binary(name)
+        | ExecutableType::Lib(name)
+        | ExecutableType::Example(name) => {
             let mut file = config.out_dir.join(name);
             if cfg!(windows) {
                 file.set_extension("exe");

+ 2 - 1
packages/cli/src/server/mod.rs

@@ -1,4 +1,5 @@
-use crate::{BuildResult, CrateConfig, Result};
+use crate::{BuildResult, Result};
+use dioxus_cli_config::CrateConfig;
 
 use cargo_metadata::diagnostic::Diagnostic;
 use dioxus_core::Template;

+ 1 - 1
packages/cli/src/server/output.rs

@@ -1,7 +1,7 @@
 use crate::server::Diagnostic;
-use crate::CrateConfig;
 use colored::Colorize;
 use dioxus_cli_config::crate_root;
+use dioxus_cli_config::CrateConfig;
 use std::path::PathBuf;
 use std::process::Command;
 

+ 3 - 1
packages/cli/src/server/web/mod.rs

@@ -5,7 +5,7 @@ use crate::{
         output::{print_console_info, PrettierOptions, WebServerInfo},
         setup_file_watcher, HotReloadState,
     },
-    BuildResult, CrateConfig, Result, WebHttpsConfig,
+    BuildResult, Result,
 };
 use axum::{
     body::{Full, HttpBody},
@@ -19,6 +19,8 @@ use axum::{
     Router,
 };
 use axum_server::tls_rustls::RustlsConfig;
+use dioxus_cli_config::CrateConfig;
+use dioxus_cli_config::WebHttpsConfig;
 
 use dioxus_html::HtmlCtx;
 use dioxus_rsx::hot_reload::*;

+ 2 - 1
packages/cli/src/server/web/proxy.rs

@@ -1,4 +1,5 @@
-use crate::{Result, WebProxyConfig};
+use crate::Result;
+use dioxus_cli_config::WebProxyConfig;
 
 use anyhow::Context;
 use axum::{http::StatusCode, routing::any, Router};