Warn if cli-config is not available at compile time (#2135)
* warn if a package relies on the CLI config, but it is not built with the CLI * fix default features --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
1b03bed20a
commit
460a685fa3
9 files changed
+24
-7
No files matched your search
+1
-1
@@ -72,7 +72,7 @@ dioxus-check = { path = "packages/check", version = "0.5.0-alpha.2" }
|
|||||||
dioxus-rsx = { path = "packages/rsx", version = "0.5.0-alpha.2" }
|
dioxus-rsx = { path = "packages/rsx", version = "0.5.0-alpha.2" }
|
||||||
rsx-rosetta = { path = "packages/rsx-rosetta", version = "0.5.0-alpha.2" }
|
rsx-rosetta = { path = "packages/rsx-rosetta", version = "0.5.0-alpha.2" }
|
||||||
dioxus-signals = { path = "packages/signals", version = "0.5.0-alpha.2" }
|
dioxus-signals = { path = "packages/signals", version = "0.5.0-alpha.2" }
|
||||||
dioxus-cli-config = { path = "packages/cli-config", version = "0.5.0-alpha.2" }
|
dioxus-cli-config = { path = "packages/cli-config", version = "0.5.0-alpha.2", default-features = false}
|
||||||
generational-box = { path = "packages/generational-box", version = "0.5.0-alpha.2" }
|
generational-box = { path = "packages/generational-box", version = "0.5.0-alpha.2" }
|
||||||
dioxus-hot-reload = { path = "packages/hot-reload", version = "0.5.0-alpha.2" }
|
dioxus-hot-reload = { path = "packages/hot-reload", version = "0.5.0-alpha.2" }
|
||||||
dioxus-fullstack = { path = "packages/fullstack", version = "0.5.0-alpha.2" }
|
dioxus-fullstack = { path = "packages/fullstack", version = "0.5.0-alpha.2" }
|
||||||
|
|||||||
@@ -22,5 +22,6 @@ tauri-bundler = { version = "=1.4.0", features = ["native-tls-vendored"], option
|
|||||||
tauri-utils = { version = "=1.5.*", optional = true }
|
tauri-utils = { version = "=1.5.*", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = ["read-config"]
|
||||||
cli = ["tauri-bundler", "tauri-utils", "clap", "toml", "cargo_toml"]
|
cli = ["tauri-bundler", "tauri-utils", "clap", "toml", "cargo_toml"]
|
||||||
|
read-config = []
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// warn if the "read-config" feature is enabled, but the DIOXUS_CONFIG environment variable is not set
|
||||||
|
// This means that some library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application.
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("cargo:rerun-if-env-changed=DIOXUS_CONFIG");
|
||||||
|
let dioxus_config = std::env::var("DIOXUS_CONFIG");
|
||||||
|
let built_with_dioxus = dioxus_config.is_ok();
|
||||||
|
if cfg!(feature = "read-config") && !built_with_dioxus {
|
||||||
|
println!("cargo:warning=A library is trying to access the crate's configuration, but the dioxus CLI was not used to build the application. Information about the Dioxus CLI is available at https://dioxuslabs.com/learn/0.5/CLI/installation");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,7 @@ impl std::fmt::Display for DioxusCLINotUsed {
|
|||||||
|
|
||||||
impl std::error::Error for DioxusCLINotUsed {}
|
impl std::error::Error for DioxusCLINotUsed {}
|
||||||
|
|
||||||
|
#[cfg(feature = "read-config")]
|
||||||
/// The current crate's configuration.
|
/// The current crate's configuration.
|
||||||
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>,
|
||||||
@@ -54,5 +55,6 @@ pub static CURRENT_CONFIG: once_cell::sync::Lazy<
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[cfg(feature = "read-config")]
|
||||||
/// The current crate's configuration.
|
/// The current crate's configuration.
|
||||||
pub const CURRENT_CONFIG_JSON: Option<&str> = std::option_env!("DIOXUS_CONFIG");
|
pub const CURRENT_CONFIG_JSON: Option<&str> = std::option_env!("DIOXUS_CONFIG");
|
||||||
@@ -15,7 +15,10 @@ thiserror = { workspace = true }
|
|||||||
wasm-bindgen-cli-support = "0.2"
|
wasm-bindgen-cli-support = "0.2"
|
||||||
wasm-bindgen-shared = "0.2"
|
wasm-bindgen-shared = "0.2"
|
||||||
colored = "2.0.0"
|
colored = "2.0.0"
|
||||||
dioxus-cli-config = { workspace = true, features = ["cli"] }
|
dioxus-cli-config = { workspace = true, features = ["cli"], default-features = false }
|
||||||
|
|
||||||
|
# features
|
||||||
|
log = "0.4.14"
|
||||||
fern = { version = "0.6.0", features = ["colored"] }
|
fern = { version = "0.6.0", features = ["colored"] }
|
||||||
serde = { version = "1.0.136", features = ["derive"] }
|
serde = { version = "1.0.136", features = ["derive"] }
|
||||||
serde_json = "1.0.79"
|
serde_json = "1.0.79"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ dioxus-html = { workspace = true, features = [
|
|||||||
"eval",
|
"eval",
|
||||||
] }
|
] }
|
||||||
dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] }
|
dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] }
|
||||||
dioxus-cli-config = { workspace = true }
|
dioxus-cli-config = { workspace = true, features = ["read-config"] }
|
||||||
generational-box = { workspace = true }
|
generational-box = { workspace = true }
|
||||||
|
|
||||||
serde = "1.0.136"
|
serde = "1.0.136"
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ tower = { workspace = true, features = ["util"], optional = true }
|
|||||||
tower-layer = { version = "0.3.2", optional = true }
|
tower-layer = { version = "0.3.2", optional = true }
|
||||||
web-sys = { version = "0.3.61", optional = true, features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
|
web-sys = { version = "0.3.61", optional = true, features = ["Window", "Document", "Element", "HtmlDocument", "Storage", "console"] }
|
||||||
|
|
||||||
dioxus-cli-config = { workspace = true, optional = true }
|
dioxus-cli-config = { workspace = true, features = ["read-config"], optional = true }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
tokio = { workspace = true, features = ["rt", "sync"], optional = true }
|
tokio = { workspace = true, features = ["rt", "sync"], optional = true }
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ rustc-hash = { workspace = true }
|
|||||||
dioxus-core = { workspace = true, features = ["serialize"] }
|
dioxus-core = { workspace = true, features = ["serialize"] }
|
||||||
dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] }
|
dioxus-interpreter-js = { workspace = true, features = ["binary-protocol"] }
|
||||||
dioxus-hot-reload = { workspace = true, optional = true }
|
dioxus-hot-reload = { workspace = true, optional = true }
|
||||||
dioxus-cli-config = { workspace = true }
|
dioxus-cli-config = { workspace = true, features = ["read-config"] }
|
||||||
generational-box = { workspace = true }
|
generational-box = { workspace = true }
|
||||||
|
|
||||||
# axum
|
# axum
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ dioxus-liveview = { workspace = true, optional = true }
|
|||||||
dioxus-ssr = { workspace = true, optional = true }
|
dioxus-ssr = { workspace = true, optional = true }
|
||||||
dioxus-fullstack = { workspace = true, optional = true }
|
dioxus-fullstack = { workspace = true, optional = true }
|
||||||
tokio = { workspace = true, features = ["full"], optional = true }
|
tokio = { workspace = true, features = ["full"], optional = true }
|
||||||
dioxus-cli-config = { workspace = true }
|
dioxus-cli-config = { workspace = true, features = ["read-config"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|||||||
Reference in new issue
Block a user