fix cli configuration environment variable
This commit is contained in:
1 parent
06be18a591
commit
1ed66a54cc
6 files changed
+13
-81
No files matched your search
@@ -19,6 +19,7 @@ cargo_toml = "0.16.0"
|
|||||||
tauri-bundler = { version = "=1.3.0", features = ["native-tls-vendored"], optional = true }
|
tauri-bundler = { version = "=1.3.0", features = ["native-tls-vendored"], optional = true }
|
||||||
tauri-utils = { version = "=1.4.*", optional = true }
|
tauri-utils = { version = "=1.4.*", optional = true }
|
||||||
once_cell = "1.18.0"
|
once_cell = "1.18.0"
|
||||||
|
tracing.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
[application]
|
|
||||||
|
|
||||||
# dioxus project name
|
|
||||||
name = "{{project-name}}"
|
|
||||||
|
|
||||||
# default platfrom
|
|
||||||
# you can also use `dx serve/build --platform XXX` to use other platform
|
|
||||||
# value: web | desktop
|
|
||||||
default_platform = "{{default-platform}}"
|
|
||||||
|
|
||||||
# Web `build` & `serve` dist path
|
|
||||||
out_dir = "dist"
|
|
||||||
|
|
||||||
# resource (static) file folder
|
|
||||||
asset_dir = "public"
|
|
||||||
|
|
||||||
[web.app]
|
|
||||||
|
|
||||||
# HTML title tag content
|
|
||||||
title = "Dioxus | An elegant GUI library for Rust"
|
|
||||||
|
|
||||||
[web.watcher]
|
|
||||||
|
|
||||||
index_on_404 = true
|
|
||||||
|
|
||||||
watch_path = ["src", "examples"]
|
|
||||||
|
|
||||||
# include `assets` in web platform
|
|
||||||
[web.resource]
|
|
||||||
|
|
||||||
# CSS style file
|
|
||||||
style = []
|
|
||||||
|
|
||||||
# Javascript code file
|
|
||||||
script = []
|
|
||||||
|
|
||||||
[web.resource.dev]
|
|
||||||
|
|
||||||
# Javascript code file
|
|
||||||
# serve: [dev-server] only
|
|
||||||
script = []
|
|
||||||
|
|
||||||
[application.plugins]
|
|
||||||
|
|
||||||
available = true
|
|
||||||
|
|
||||||
required = []
|
|
||||||
|
|
||||||
[bundler]
|
|
||||||
# Bundle identifier
|
|
||||||
identifier = "io.github.{{project-name}}"
|
|
||||||
|
|
||||||
# Bundle publisher
|
|
||||||
publisher = "{{project-name}}"
|
|
||||||
|
|
||||||
# Bundle icon
|
|
||||||
icon = ["icons/icon.png"]
|
|
||||||
|
|
||||||
# Bundle resources
|
|
||||||
resources = ["public/*"]
|
|
||||||
|
|
||||||
# Bundle copyright
|
|
||||||
copyright = ""
|
|
||||||
|
|
||||||
# Bundle category
|
|
||||||
category = "Utility"
|
|
||||||
|
|
||||||
# Bundle short description
|
|
||||||
short_description = "An amazing dioxus application."
|
|
||||||
|
|
||||||
# Bundle long description
|
|
||||||
long_description = """
|
|
||||||
An amazing dioxus application.
|
|
||||||
"""
|
|
||||||
@@ -231,6 +231,7 @@ pub enum WebviewInstallMode {
|
|||||||
FixedRuntime { path: PathBuf },
|
FixedRuntime { path: PathBuf },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "cli")]
|
||||||
impl WebviewInstallMode {
|
impl WebviewInstallMode {
|
||||||
fn into(self) -> tauri_utils::config::WebviewInstallMode {
|
fn into(self) -> tauri_utils::config::WebviewInstallMode {
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -46,8 +46,13 @@ impl std::error::Error for DioxusCLINotUsed {}
|
|||||||
pub static CURRENT_CONFIG: once_cell::sync::Lazy<
|
pub static CURRENT_CONFIG: once_cell::sync::Lazy<
|
||||||
Result<crate::config::CrateConfig, DioxusCLINotUsed>,
|
Result<crate::config::CrateConfig, DioxusCLINotUsed>,
|
||||||
> = once_cell::sync::Lazy::new(|| {
|
> = once_cell::sync::Lazy::new(|| {
|
||||||
std::env::var(crate::__private::CONFIG_ENV)
|
CURRENT_CONFIG_JSON
|
||||||
.ok()
|
|
||||||
.and_then(|config| serde_json::from_str(&config).ok())
|
.and_then(|config| serde_json::from_str(&config).ok())
|
||||||
.ok_or(DioxusCLINotUsed)
|
.ok_or_else(|| {
|
||||||
|
tracing::error!("A library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application.");
|
||||||
|
DioxusCLINotUsed
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// The current crate's configuration.
|
||||||
|
pub const CURRENT_CONFIG_JSON: Option<&str> = std::option_env!("DIOXUS_CONFIG");
|
||||||
@@ -47,6 +47,7 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
|
|||||||
let ignore_files = build_assets(config)?;
|
let ignore_files = build_assets(config)?;
|
||||||
|
|
||||||
let t_start = std::time::Instant::now();
|
let t_start = std::time::Instant::now();
|
||||||
|
let _guard = dioxus_cli_config::__private::save_config(config);
|
||||||
|
|
||||||
// [1] Build the .wasm module
|
// [1] Build the .wasm module
|
||||||
log::info!("🚅 Running build command...");
|
log::info!("🚅 Running build command...");
|
||||||
@@ -90,8 +91,6 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result<BuildResult> {
|
|||||||
ExecutableType::Example(name) => cmd.arg("--example").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 warning_messages = prettier_build(cmd)?;
|
||||||
|
|
||||||
// [2] Establish the output directory structure
|
// [2] Establish the output directory structure
|
||||||
@@ -254,6 +253,7 @@ pub fn build_desktop(config: &CrateConfig, _is_serve: bool) -> Result<BuildResul
|
|||||||
|
|
||||||
let t_start = std::time::Instant::now();
|
let t_start = std::time::Instant::now();
|
||||||
let ignore_files = build_assets(config)?;
|
let ignore_files = build_assets(config)?;
|
||||||
|
let _guard = dioxus_cli_config::__private::save_config(config);
|
||||||
|
|
||||||
let mut cmd = subprocess::Exec::cmd("cargo")
|
let mut cmd = subprocess::Exec::cmd("cargo")
|
||||||
.cwd(&config.crate_dir)
|
.cwd(&config.crate_dir)
|
||||||
@@ -284,8 +284,6 @@ pub fn build_desktop(config: &CrateConfig, _is_serve: bool) -> Result<BuildResul
|
|||||||
ExecutableType::Example(name) => cmd.arg("--example").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 warning_messages = prettier_build(cmd)?;
|
||||||
|
|
||||||
let release_type = match config.release {
|
let release_type = match config.release {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use dioxus_cli_config::DioxusConfig;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
|
|||||||
Reference in new issue
Block a user