mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-24 05:03:06 +00:00
feat: clean warning info
This commit is contained in:
parent
14f09e69b2
commit
0adabf68a0
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"
|
tower = "0.4.12"
|
||||||
|
|
||||||
syn = { version = "1.0" }
|
syn = { version = "1.0" }
|
||||||
|
|
||||||
dioxus = { git = "https://github.com/dioxuslabs/dioxus/", features = ["hot-reload"] }
|
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"] }
|
proc-macro2 = { version = "1.0", features = ["span-locations"] }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ use axum::{
|
||||||
extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade},
|
extract::{ws::Message, Extension, TypedHeader, WebSocketUpgrade},
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
};
|
};
|
||||||
use dioxus::rsx_interpreter::SetRsxMessage;
|
use dioxus_rsx_interpreter::SetRsxMessage;
|
||||||
|
|
||||||
use std::{path::PathBuf, sync::Arc};
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use super::BuildManager;
|
use super::BuildManager;
|
||||||
pub use crate::hot_reload::{find_rsx, DiffResult};
|
pub use crate::hot_reload::{find_rsx, DiffResult};
|
||||||
use crate::CrateConfig;
|
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 proc_macro2::TokenStream;
|
||||||
pub use std::collections::HashMap;
|
pub use std::collections::HashMap;
|
||||||
pub use std::sync::Mutex;
|
pub use std::sync::Mutex;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use axum::{
|
||||||
};
|
};
|
||||||
use cargo_metadata::diagnostic::Diagnostic;
|
use cargo_metadata::diagnostic::Diagnostic;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use dioxus::rsx_interpreter::SetRsxMessage;
|
use dioxus_rsx_interpreter::SetRsxMessage;
|
||||||
use notify::{RecommendedWatcher, Watcher};
|
use notify::{RecommendedWatcher, Watcher};
|
||||||
use syn::spanned::Spanned;
|
use syn::spanned::Spanned;
|
||||||
|
|
||||||
|
@ -453,9 +453,10 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions)
|
||||||
|
|
||||||
if options.changed.len() <= 0 {
|
if options.changed.len() <= 0 {
|
||||||
println!(
|
println!(
|
||||||
"{} @ v{}\n",
|
"{} @ v{} [{}] \n",
|
||||||
"Dioxus".bold().green(),
|
"Dioxus".bold().green(),
|
||||||
crate::DIOXUS_CLI_VERSION,
|
crate::DIOXUS_CLI_VERSION,
|
||||||
|
chrono::Local::now().format("%H:%M:%S").to_string().dimmed()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
|
@ -500,52 +501,52 @@ fn print_console_info(port: u16, config: &CrateConfig, options: PrettierOptions)
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"{}",
|
"{}",
|
||||||
format!(
|
format!(
|
||||||
"There were {} warning messages during the build: ",
|
"There were {} warning messages during the build.",
|
||||||
options.warnings.len() - 1
|
options.warnings.len() - 1
|
||||||
)
|
)
|
||||||
.yellow()
|
.yellow()
|
||||||
.bold()
|
.bold()
|
||||||
);
|
);
|
||||||
for info in &options.warnings {
|
// for info in &options.warnings {
|
||||||
let message = info.message.clone();
|
// let message = info.message.clone();
|
||||||
if message == format!("{} warnings emitted", options.warnings.len() - 1) {
|
// if message == format!("{} warnings emitted", options.warnings.len() - 1) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
let mut console = String::new();
|
// let mut console = String::new();
|
||||||
for span in &info.spans {
|
// for span in &info.spans {
|
||||||
let file = &span.file_name;
|
// let file = &span.file_name;
|
||||||
let line = (span.line_start, span.line_end);
|
// let line = (span.line_start, span.line_end);
|
||||||
let line_str = if line.0 == line.1 {
|
// let line_str = if line.0 == line.1 {
|
||||||
line.0.to_string()
|
// line.0.to_string()
|
||||||
} else {
|
// } else {
|
||||||
format!("{}~{}", line.0, line.1)
|
// format!("{}~{}", line.0, line.1)
|
||||||
};
|
// };
|
||||||
let code = span.text.clone();
|
// let code = span.text.clone();
|
||||||
let span_info = if code.len() == 1 {
|
// let span_info = if code.len() == 1 {
|
||||||
let code = code.get(0).unwrap().text.trim().blue().bold().to_string();
|
// let code = code.get(0).unwrap().text.trim().blue().bold().to_string();
|
||||||
format!(
|
// format!(
|
||||||
"[{}: {}]: '{}' --> {}",
|
// "[{}: {}]: '{}' --> {}",
|
||||||
file,
|
// file,
|
||||||
line_str,
|
// line_str,
|
||||||
code,
|
// code,
|
||||||
message.yellow().bold()
|
// message.yellow().bold()
|
||||||
)
|
// )
|
||||||
} else {
|
// } else {
|
||||||
let code = code
|
// let code = code
|
||||||
.iter()
|
// .iter()
|
||||||
.enumerate()
|
// .enumerate()
|
||||||
.map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string())
|
// .map(|(_i, s)| format!("\t{}\n", s.text).blue().bold().to_string())
|
||||||
.collect::<String>();
|
// .collect::<String>();
|
||||||
format!("[{}: {}]:\n{}\n#:{}", file, line_str, code, message)
|
// format!("[{}: {}]:\n{}\n#:{}", file, line_str, code, message)
|
||||||
};
|
// };
|
||||||
console = format!("{console}\n\t{span_info}");
|
// console = format!("{console}\n\t{span_info}");
|
||||||
}
|
// }
|
||||||
println!("{console}");
|
// println!("{console}");
|
||||||
}
|
// }
|
||||||
println!(
|
// println!(
|
||||||
"\n{}\n",
|
// "\n{}\n",
|
||||||
"Resolving all warnings will help your code run better!".yellow()
|
// "Resolving all warnings will help your code run better!".yellow()
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue