mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 14:10:20 +00:00
Merge pull request #2010 from rtretter/main
added automatic platform detection to cli if none is passed
This commit is contained in:
commit
e6b7f70f31
3 changed files with 20 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2326,7 +2326,7 @@ dependencies = [
|
|||
name = "dioxus-cli-config"
|
||||
version = "0.5.0-alpha.0"
|
||||
dependencies = [
|
||||
"cargo_toml 0.16.3",
|
||||
"cargo_toml 0.18.0",
|
||||
"clap 4.4.18",
|
||||
"once_cell",
|
||||
"serde",
|
||||
|
|
|
@ -13,7 +13,7 @@ clap = { version = "4.2", features = ["derive"], optional = true }
|
|||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
serde_json = "1.0.79"
|
||||
toml = { workspace = true, optional = true }
|
||||
cargo_toml = { version = "0.16.0", optional = true }
|
||||
cargo_toml = { version = "0.18.0", optional = true }
|
||||
once_cell = "1.18.0"
|
||||
tracing = { workspace = true }
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ use dioxus_cli_config::Platform;
|
|||
use manganis_cli_support::AssetManifest;
|
||||
|
||||
use super::*;
|
||||
use cargo_toml::Dependency::{Detailed, Inherited, Simple};
|
||||
use std::{fs::create_dir_all, io::Write, path::PathBuf};
|
||||
|
||||
/// Run the WASM project on dev-server
|
||||
|
@ -41,10 +42,23 @@ impl Serve {
|
|||
|
||||
crate_config.set_cargo_args(self.serve.cargo_args);
|
||||
|
||||
let platform = self
|
||||
.serve
|
||||
.platform
|
||||
.unwrap_or(crate_config.dioxus_config.application.default_platform);
|
||||
let mut platform = self.serve.platform;
|
||||
|
||||
if platform.is_none() {
|
||||
if let Some(dependency) = &crate_config.manifest.dependencies.get("dioxus") {
|
||||
let features = match dependency {
|
||||
Inherited(detail) => detail.features.to_vec(),
|
||||
Detailed(detail) => detail.features.to_vec(),
|
||||
Simple(_) => vec![],
|
||||
};
|
||||
|
||||
platform = features
|
||||
.iter()
|
||||
.find_map(|platform| serde_json::from_str(&format!(r#""{}""#, platform)).ok());
|
||||
}
|
||||
}
|
||||
|
||||
let platform = platform.unwrap_or(crate_config.dioxus_config.application.default_platform);
|
||||
|
||||
match platform {
|
||||
Platform::Web => {
|
||||
|
|
Loading…
Reference in a new issue