feat: commit code
This commit is contained in:
1 parent
8dbf571891
commit
81b712ec0b
1 file changed
+36
-8
+36
-8
@@ -11,7 +11,7 @@ use dioxus::rsx_interpreter::SetRsxMessage;
|
|||||||
use notify::{RecommendedWatcher, Watcher};
|
use notify::{RecommendedWatcher, Watcher};
|
||||||
use syn::spanned::Spanned;
|
use syn::spanned::Spanned;
|
||||||
|
|
||||||
use std::{path::PathBuf, process::Command, sync::Arc, net::UdpSocket};
|
use std::{net::UdpSocket, path::PathBuf, process::Command, sync::Arc};
|
||||||
use tower::ServiceBuilder;
|
use tower::ServiceBuilder;
|
||||||
use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody};
|
use tower_http::services::fs::{ServeDir, ServeFileSystemResponseBody};
|
||||||
|
|
||||||
@@ -270,12 +270,17 @@ pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
|
|||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| vec![PathBuf::from("src")]);
|
.unwrap_or_else(|| vec![PathBuf::from("src")]);
|
||||||
|
|
||||||
let mut watcher = RecommendedWatcher::new(move |_: notify::Result<notify::Event>| {
|
let mut watcher = RecommendedWatcher::new(move |info: notify::Result<notify::Event>| {
|
||||||
// log::info!("🚧 reload required");
|
if info.is_ok() {
|
||||||
if chrono::Local::now().timestamp() > last_update_time {
|
let info = info.unwrap();
|
||||||
match build_manager.build() {
|
if chrono::Local::now().timestamp() > last_update_time {
|
||||||
Ok(_) => last_update_time = chrono::Local::now().timestamp(),
|
match build_manager.build() {
|
||||||
Err(e) => log::error!("{}", e),
|
Ok(_) => {
|
||||||
|
last_update_time = chrono::Local::now().timestamp();
|
||||||
|
print_rebuild_info(info.paths);
|
||||||
|
}
|
||||||
|
Err(e) => log::error!("{}", e),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -414,7 +419,8 @@ fn print_console_info(port: u16, config: &CrateConfig) {
|
|||||||
"http://{}:{}/",
|
"http://{}:{}/",
|
||||||
get_ip().unwrap_or(String::from("0.0.0.0")),
|
get_ip().unwrap_or(String::from("0.0.0.0")),
|
||||||
port
|
port
|
||||||
).blue()
|
)
|
||||||
|
.blue()
|
||||||
);
|
);
|
||||||
println!("");
|
println!("");
|
||||||
println!("\t> Profile : {}", profile.green());
|
println!("\t> Profile : {}", profile.green());
|
||||||
@@ -426,6 +432,28 @@ fn print_console_info(port: u16, config: &CrateConfig) {
|
|||||||
println!("\n{}\n", "Server startup completed.".green().bold());
|
println!("\n{}\n", "Server startup completed.".green().bold());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_rebuild_info(paths: Vec<PathBuf>) {
|
||||||
|
print!(
|
||||||
|
"{}",
|
||||||
|
String::from_utf8_lossy(
|
||||||
|
&Command::new(if cfg!(target_os = "windows") {
|
||||||
|
"cls"
|
||||||
|
} else {
|
||||||
|
"clear"
|
||||||
|
})
|
||||||
|
.output()
|
||||||
|
.unwrap()
|
||||||
|
.stdout
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
for path in paths {
|
||||||
|
let path = path.strip_prefix(crate::crate_root().unwrap()).unwrap().to_path_buf();
|
||||||
|
log::info!("Updated {}", format!("{}", path.to_str().unwrap()).green());
|
||||||
|
}
|
||||||
|
log::info!("Project rebuild done.")
|
||||||
|
}
|
||||||
|
|
||||||
fn get_ip() -> Option<String> {
|
fn get_ip() -> Option<String> {
|
||||||
let socket = match UdpSocket::bind("0.0.0.0:0") {
|
let socket = match UdpSocket::bind("0.0.0.0:0") {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
|
|||||||
Reference in new issue
Block a user