From 714c6dd46ff383abfa749e6c3d9d82bbbfd6bdb5 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sun, 17 Apr 2022 11:24:17 +0800 Subject: [PATCH 1/2] Upgrade `axum` version --- Cargo.toml | 2 +- src/builder.rs | 8 ++++---- src/cli/serve/mod.rs | 15 ++++----------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5f5ded9be..21e2dad7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ chrono = "0.4.19" anyhow = "1.0.53" hyper = "0.14.17" -axum = { version = "0.4.5", features = ["ws", "headers"] } +axum = { version = "0.5.1", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } headers = "0.3.7" # tools download diff --git a/src/builder.rs b/src/builder.rs index aaaa0278a..09a410458 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -206,16 +206,16 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { file_name = name.clone(); config .target_dir - .join(release_type.to_string()) - .join(name.to_string()) + .join(release_type) + .join(name) } crate::ExecutableType::Example(name) => { file_name = name.clone(); config .target_dir - .join(release_type.to_string()) + .join(release_type) .join("examples") - .join(name.to_string()) + .join(name) } }; diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 21d29cd93..85bd92c74 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -1,9 +1,9 @@ +use super::*; use std::{ io::Write, path::PathBuf, process::{Command, Stdio}, }; -use super::*; /// Run the WASM project on dev-server #[derive(Clone, Debug, Parser)] @@ -47,16 +47,9 @@ impl Serve { if cfg!(windows) { file.set_extension("exe"); } - Command::new( - crate_config - .out_dir - .join(file) - .to_str() - .unwrap() - .to_string(), - ) - .stdout(Stdio::inherit()) - .output()?; + Command::new(crate_config.out_dir.join(file).to_str().unwrap()) + .stdout(Stdio::inherit()) + .output()?; } } return Ok(()); From 001410f1196f2ea6fe35084b5d489f48d104ca83 Mon Sep 17 00:00:00 2001 From: YuKun Liu <41265098+mrxiaozhuox@users.noreply.github.com> Date: Sun, 17 Apr 2022 11:25:53 +0800 Subject: [PATCH 2/2] Format code --- src/builder.rs | 7 ++----- src/cli/build/mod.rs | 1 - src/cli/config/mod.rs | 2 +- src/cli/mod.rs | 2 +- src/cli/tool/mod.rs | 6 ++---- src/config.rs | 2 +- 6 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 09a410458..f7f68e2bc 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -132,7 +132,7 @@ pub fn build(config: &CrateConfig) -> Result<()> { ); } } - + // this code will copy all public file to the output dir let copy_options = fs_extra::dir::CopyOptions { overwrite: true, @@ -204,10 +204,7 @@ pub fn build_desktop(config: &CrateConfig, is_serve: bool) -> Result<()> { let mut res_path = match &config.executable { crate::ExecutableType::Binary(name) | crate::ExecutableType::Lib(name) => { file_name = name.clone(); - config - .target_dir - .join(release_type) - .join(name) + config.target_dir.join(release_type).join(name) } crate::ExecutableType::Example(name) => { file_name = name.clone(); diff --git a/src/cli/build/mod.rs b/src/cli/build/mod.rs index 3b4d343af..4c043091f 100644 --- a/src/cli/build/mod.rs +++ b/src/cli/build/mod.rs @@ -12,7 +12,6 @@ impl Build { pub fn build(self) -> Result<()> { let mut crate_config = crate::CrateConfig::new()?; - // change the release state. crate_config.with_release(self.build.release); diff --git a/src/cli/config/mod.rs b/src/cli/config/mod.rs index fb1e046fb..5f9fa20d0 100644 --- a/src/cli/config/mod.rs +++ b/src/cli/config/mod.rs @@ -21,7 +21,7 @@ pub enum Config { /// Format print Dioxus config. FormatPrint {}, /// Create a custom html file. - CustomHtml {} + CustomHtml {}, } impl Config { diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 2c91c94dd..d639d28a7 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -4,8 +4,8 @@ pub mod clean; pub mod config; pub mod create; pub mod serve; -pub mod translate; pub mod tool; +pub mod translate; use crate::{ cfg::{ConfigOptsBuild, ConfigOptsServe}, diff --git a/src/cli/tool/mod.rs b/src/cli/tool/mod.rs index 51e41e384..d5c4581aa 100644 --- a/src/cli/tool/mod.rs +++ b/src/cli/tool/mod.rs @@ -11,9 +11,7 @@ pub enum Tool { /// Get default app install path. AppPath {}, /// Install a new tool. - Add { - name: String - } + Add { name: String }, } impl Tool { @@ -33,7 +31,7 @@ impl Tool { } Tool::Add { name } => { let tool_list = tools::tool_list(); - + if !tool_list.contains(&name.as_str()) { log::error!("Tool {name} not found."); return Ok(()); diff --git a/src/config.rs b/src/config.rs index 0cdd0bd8b..783c72ccd 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,6 @@ use crate::error::Result; use serde::{Deserialize, Serialize}; -use std::{fs::File, io::Read, path::PathBuf, collections::HashMap}; +use std::{collections::HashMap, fs::File, io::Read, path::PathBuf}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DioxusConfig {