diff --git a/Cargo.lock b/Cargo.lock
index ebba9c5a9..008ea6022 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -76,6 +76,20 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
+[[package]]
+name = "assert_cmd"
+version = "2.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9834fcc22e0874394a010230586367d4a3e9f11b560f469262678547e1d2575e"
+dependencies = [
+ "bstr 1.1.0",
+ "doc-comment",
+ "predicates",
+ "predicates-core",
+ "predicates-tree",
+ "wait-timeout",
+]
+
[[package]]
name = "async-trait"
version = "0.1.61"
@@ -250,6 +264,18 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "bstr"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b"
+dependencies = [
+ "memchr",
+ "once_cell",
+ "regex-automata",
+ "serde",
+]
+
[[package]]
name = "bumpalo"
version = "3.11.1"
@@ -654,6 +680,12 @@ version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb"
+[[package]]
+name = "difflib"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
+
[[package]]
name = "digest"
version = "0.10.6"
@@ -684,6 +716,7 @@ name = "dioxus-cli"
version = "0.3.0"
dependencies = [
"anyhow",
+ "assert_cmd",
"atty",
"axum",
"binary-install",
@@ -712,12 +745,14 @@ dependencies = [
"log",
"mlua",
"notify",
+ "predicates",
"proc-macro2",
"regex",
"reqwest",
"rsx-rosetta",
"serde",
"serde_json",
+ "subprocess",
"syn",
"tar",
"thiserror",
@@ -807,6 +842,12 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "doc-comment"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10"
+
[[package]]
name = "either"
version = "1.8.0"
@@ -934,6 +975,15 @@ dependencies = [
"miniz_oxide",
]
+[[package]]
+name = "float-cmp"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
+dependencies = [
+ "num-traits",
+]
+
[[package]]
name = "fnv"
version = "1.0.7"
@@ -1710,7 +1760,7 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ee2ad7a9aa69056b148d9d590344bc155d3ce0d2200e3b2838f7034f6ba33c1"
dependencies = [
- "bstr",
+ "bstr 0.2.17",
"cc",
"futures-core",
"futures-task",
@@ -1769,6 +1819,12 @@ dependencies = [
"static_assertions",
]
+[[package]]
+name = "normalize-line-endings"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
+
[[package]]
name = "notify"
version = "5.0.0"
@@ -2050,6 +2106,36 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+[[package]]
+name = "predicates"
+version = "2.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd"
+dependencies = [
+ "difflib",
+ "float-cmp",
+ "itertools",
+ "normalize-line-endings",
+ "predicates-core",
+ "regex",
+]
+
+[[package]]
+name = "predicates-core"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2"
+
+[[package]]
+name = "predicates-tree"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d"
+dependencies = [
+ "predicates-core",
+ "termtree",
+]
+
[[package]]
name = "prettyplease"
version = "0.1.15"
@@ -2185,6 +2271,12 @@ dependencies = [
"regex-syntax",
]
+[[package]]
+name = "regex-automata"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
+
[[package]]
name = "regex-syntax"
version = "0.6.28"
@@ -2573,6 +2665,16 @@ version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+[[package]]
+name = "subprocess"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c2e86926081dda636c546d8c5e641661049d7562a68f5488be4a1f7f66f6086"
+dependencies = [
+ "libc",
+ "winapi",
+]
+
[[package]]
name = "subtle"
version = "2.4.1"
@@ -2642,6 +2744,12 @@ dependencies = [
"winapi-util",
]
+[[package]]
+name = "termtree"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8"
+
[[package]]
name = "textwrap"
version = "0.16.0"
@@ -3084,6 +3192,15 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+[[package]]
+name = "wait-timeout"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "walkdir"
version = "2.3.2"
diff --git a/Cargo.toml b/Cargo.toml
index f1e89966c..9fe15ba32 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -37,6 +37,7 @@ chrono = "0.4.19"
anyhow = "1.0.53"
hyper = "0.14.17"
indicatif = "0.17.0-rc.11"
+subprocess = "0.2.9"
axum = { version = "0.5.1", features = ["ws", "headers"] }
tower-http = { version = "0.2.2", features = ["fs", "trace"] }
diff --git a/README.md b/README.md
index 4f11ce1ac..5a4f32a4b 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,8 @@
📦✨ Dioxus CLI
Tooling to supercharge Dioxus projects
-**dioxus-cli** (inspired by wasm-pack and webpack) is a tool for getting Dioxus projects up and running. It handles all of the build, bundling, development and publishing to simplify web development.
+**dioxus-cli** (inspired by wasm-pack and webpack) is a tool for getting Dioxus projects up and running.
+It handles all build, bundling, development and publishing to simplify web development.
## Installation
diff --git a/src/builder.rs b/src/builder.rs
index c6e850b58..716903fad 100644
--- a/src/builder.rs
+++ b/src/builder.rs
@@ -48,39 +48,48 @@ pub fn build(config: &CrateConfig, quiet: bool) -> Result {
// [1] Build the .wasm module
log::info!("🚅 Running build command...");
- let mut cmd = Command::new("cargo");
- cmd.current_dir(&crate_dir)
+ let cmd = subprocess::Exec::cmd("cargo");
+ let cmd = cmd.cwd(&crate_dir)
.arg("build")
.arg("--target")
.arg("wasm32-unknown-unknown")
- .arg("--message-format=json")
- .stdout(std::process::Stdio::piped())
- .stderr(std::process::Stdio::piped());
+ .arg("--message-format=json");
- if config.release {
- cmd.arg("--release");
- }
- if config.verbose {
- cmd.arg("--verbose");
- }
+ let cmd = if config.release {
+ cmd.arg("--release")
+ } else {
+ cmd
+ };
+ let cmd = if config.verbose {
+ cmd.arg("--verbose")
+ } else {
+ cmd
+ };
- if quiet {
- cmd.arg("--quiet");
- }
+ let cmd = if quiet {
+ cmd.arg("--quiet")
+ } else {
+ cmd
+ };
- if config.custom_profile.is_some() {
+ let cmd = if config.custom_profile.is_some() {
let custom_profile = config.custom_profile.as_ref().unwrap();
- cmd.arg("--profile");
- cmd.arg(custom_profile);
- }
+ cmd
+ .arg("--profile")
+ .arg(custom_profile)
+ } else {
+ cmd
+ };
- if config.features.is_some() {
+ let cmd = if config.features.is_some() {
let features_str = config.features.as_ref().unwrap().join(" ");
- cmd.arg("--features");
- cmd.arg(features_str);
- }
+ cmd.arg("--features")
+ .arg(features_str)
+ } else {
+ cmd
+ };
- match executable {
+ let cmd = match executable {
ExecutableType::Binary(name) => cmd.arg("--bin").arg(name),
ExecutableType::Lib(name) => cmd.arg("--lib").arg(name),
ExecutableType::Example(name) => cmd.arg("--example").arg(name),
@@ -365,7 +374,7 @@ pub fn build_desktop(config: &CrateConfig, _is_serve: bool) -> Result<()> {
Ok(())
}
-fn prettier_build(mut cmd: Command) -> anyhow::Result> {
+fn prettier_build(cmd: subprocess::Exec) -> anyhow::Result> {
let mut warning_messages: Vec = vec![];
let pb = ProgressBar::new_spinner();
@@ -377,8 +386,8 @@ fn prettier_build(mut cmd: Command) -> anyhow::Result> {
);
pb.set_message("💼 Waiting to start build the project...");
- let mut command = cmd.spawn()?;
- let reader = std::io::BufReader::new(command.stdout.take().unwrap());
+ let stdout = cmd.stream_stdout()?;
+ let reader = std::io::BufReader::new(stdout);
for message in cargo_metadata::Message::parse_stream(reader) {
match message.unwrap() {
Message::CompilerMessage(msg) => {
diff --git a/src/cli/create/mod.rs b/src/cli/create/mod.rs
index 228b87be9..c448e66d1 100644
--- a/src/cli/create/mod.rs
+++ b/src/cli/create/mod.rs
@@ -17,7 +17,7 @@ pub struct Create {
impl Create {
pub fn create(self) -> Result<()> {
if Self::name_valid_check(self.name.clone()) {
- return custom_error!("❗Unsupported project name.");
+ return custom_error!("❗Unsupported project name: '{}'.", &self.name);
}
let project_path = PathBuf::from(&self.name);
@@ -26,7 +26,7 @@ impl Create {
return custom_error!("🧨 Folder '{}' is initialized.", &self.name);
}
- log::info!("🔧 Start to create a new project '{}'.", self.name);
+ log::info!("🔧 Start: Creating new project '{}'.", self.name);
let output = Command::new("cargo")
.arg("generate")
diff --git a/src/config.rs b/src/config.rs
index 99c487fa2..0d9767b97 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -18,7 +18,7 @@ fn default_plugin() -> toml::Value {
impl DioxusConfig {
pub fn load() -> crate::error::Result