mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-27 22:50:19 +00:00
Merge pull request #53 from mrxiaozhuox/master
feat: clean warning info
This commit is contained in:
commit
4bb8015298
4 changed files with 88 additions and 1476 deletions
1470
Cargo.lock
generated
1470
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -53,7 +53,10 @@ zip = "0.6.2"
|
|||
tower = "0.4.12"
|
||||
|
||||
syn = { version = "1.0" }
|
||||
|
||||
dioxus = { git = "https://github.com/dioxuslabs/dioxus/", features = ["hot-reload"] }
|
||||
dioxus-rsx-interpreter = { git = "https://github.com/dioxuslabs/dioxus/" }
|
||||
|
||||
proc-macro2 = { version = "1.0", features = ["span-locations"] }
|
||||
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ use axum::{
|
|||
extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade},
|
||||
response::IntoResponse,
|
||||
};
|
||||
use dioxus::rsx_interpreter::SetRsxMessage;
|
||||
use dioxus_rsx_interpreter::SetRsxMessage;
|
||||
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
|
||||
use super::BuildManager;
|
||||
pub use crate::hot_reload::{find_rsx, DiffResult};
|
||||
use crate::CrateConfig;
|
||||
pub use dioxus::rsx_interpreter::{error::Error, CodeLocation, SetManyRsxMessage};
|
||||
pub use dioxus_rsx_interpreter::{error::Error, CodeLocation, SetManyRsxMessage};
|
||||
pub use proc_macro2::TokenStream;
|
||||
pub use std::collections::HashMap;
|
||||
pub use std::sync::Mutex;
|
||||
|
|
|
@ -8,7 +8,7 @@ use axum::{
|
|||
};
|
||||
use cargo_metadata::diagnostic::Diagnostic;
|
||||
use colored::Colorize;
|
||||
use dioxus::rsx_interpreter::SetRsxMessage;
|
||||
use dioxus_rsx_interpreter::SetRsxMessage;
|
||||
use notify::{RecommendedWatcher, Watcher};
|
||||
use syn::spanned::Spanned;
|
||||
|
||||
|
@ -453,9 +453,10 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions)
|
|||
|
||||
if options.changed.len() <= 0 {
|
||||
println!(
|
||||
"{} @ v{}\n",
|
||||
"{} @ v{} [{}] \n",
|
||||
"Dioxus".bold().green(),
|
||||
crate::DIOXUS_CLI_VERSION,
|
||||
chrono::Local::now().format("%H:%M:%S").to_string().dimmed()
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
|
@ -500,52 +501,52 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions)
|
|||
log::warn!(
|
||||
"{}",
|
||||
format!(
|
||||
"There were {} warning messages during the build: ",
|
||||
"There were {} warning messages during the build.",
|
||||
options.warnings.len() - 1
|
||||
)
|
||||
.yellow()
|
||||
.bold()
|
||||
);
|
||||
for info in &options.warnings {
|
||||
let message = info.message.clone();
|
||||
if message == format!("{} warnings emitted", options.warnings.len() - 1) {
|
||||
continue;
|
||||
}
|
||||
let mut console = String::new();
|
||||
for span in &info.spans {
|
||||
let file = &span.file_name;
|
||||
let line = (span.line_start, span.line_end);
|
||||
let line_str = if line.0 == line.1 {
|
||||
line.0.to_string()
|
||||
} else {
|
||||
format!("{}~{}", line.0, line.1)
|
||||
};
|
||||
let code = span.text.clone();
|
||||
let span_info = if code.len() == 1 {
|
||||
let code = code.get(0).unwrap().text.trim().blue().bold().to_string();
|
||||
format!(
|
||||
"[{}: {}]: '{}' --> {}",
|
||||
file,
|
||||
line_str,
|
||||
code,
|
||||
message.yellow().bold()
|
||||
)
|
||||
} else {
|
||||
let code = code
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string())
|
||||
.collect::<String>();
|
||||
format!("[{}: {}]:\n{}\n#:{}", file, line_str, code, message)
|
||||
};
|
||||
console = format!("{console}\n\t{span_info}");
|
||||
}
|
||||
println!("{console}");
|
||||
}
|
||||
println!(
|
||||
"\n{}\n",
|
||||
"Resolving all warnings will help your code run better!".yellow()
|
||||
);
|
||||
// for info in &options.warnings {
|
||||
// let message = info.message.clone();
|
||||
// if message == format!("{} warnings emitted", options.warnings.len() - 1) {
|
||||
// continue;
|
||||
// }
|
||||
// let mut console = String::new();
|
||||
// for span in &info.spans {
|
||||
// let file = &span.file_name;
|
||||
// let line = (span.line_start, span.line_end);
|
||||
// let line_str = if line.0 == line.1 {
|
||||
// line.0.to_string()
|
||||
// } else {
|
||||
// format!("{}~{}", line.0, line.1)
|
||||
// };
|
||||
// let code = span.text.clone();
|
||||
// let span_info = if code.len() == 1 {
|
||||
// let code = code.get(0).unwrap().text.trim().blue().bold().to_string();
|
||||
// format!(
|
||||
// "[{}: {}]: '{}' --> {}",
|
||||
// file,
|
||||
// line_str,
|
||||
// code,
|
||||
// message.yellow().bold()
|
||||
// )
|
||||
// } else {
|
||||
// let code = code
|
||||
// .iter()
|
||||
// .enumerate()
|
||||
// .map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string())
|
||||
// .collect::<String>();
|
||||
// format!("[{}: {}]:\n{}\n#:{}", file, line_str, code, message)
|
||||
// };
|
||||
// console = format!("{console}\n\t{span_info}");
|
||||
// }
|
||||
// println!("{console}");
|
||||
// }
|
||||
// println!(
|
||||
// "\n{}\n",
|
||||
// "Resolving all warnings will help your code run better!".yellow()
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue