diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd284a..3e13f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ## main +- [ADD] `serve` コマンドで初回ビルドおよび再ビルド時に処理時間を表示 - [FIX] `serve` コマンドで `ls` 実行時にビルドが誤って走る問題を修正 - `notify-debouncer-mini` から `notify-debouncer-full` に移行し、`EventKind::Access` を除外するようにした - [#46](https://github.com/veltiosoft/vss/pull/46) diff --git a/Cargo.lock b/Cargo.lock index 5fb136d..c687ced 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2206,7 +2206,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vss" -version = "0.18.0" +version = "0.19.0" dependencies = [ "anyhow", "axum", diff --git a/src/subcommand_serve.rs b/src/subcommand_serve.rs index 40fb286..9029c4a 100644 --- a/src/subcommand_serve.rs +++ b/src/subcommand_serve.rs @@ -12,12 +12,19 @@ use std::{ net::SocketAddr, path::{Path, PathBuf}, sync::{Arc, Mutex}, - time::Duration, + time::{Duration, Instant}, }; use tower_http::services::ServeDir; use crate::subcommand_build; +/// ビルドを実行し、処理時間を返す +fn run_build_with_timing(config_path: &Path) -> Result { + let start = Instant::now(); + subcommand_build::run_build(config_path)?; + Ok(start.elapsed()) +} + /// serve コマンドのエントリポイント pub fn run(mut args: noargs::RawArgs) -> noargs::Result<()> { let config: Option = noargs::opt("config") @@ -62,8 +69,9 @@ pub fn run(mut args: noargs::RawArgs) -> noargs::Result<()> { async fn run_serve(config_path: &Path, port: u16) -> Result<()> { // 初回ビルド println!("[INFO] Running initial build..."); - subcommand_build::run_build(config_path)?; + let duration = run_build_with_timing(config_path)?; println!("[INFO] Initial build completed"); + println!("build finished in {} ms", duration.as_millis()); // 設定を読み込んで dist ディレクトリを取得 let dist_dir = get_dist_dir(config_path)?; @@ -145,10 +153,14 @@ fn watch_files(config_path: &Path, _rebuild_flag: Arc>) -> Result<() if should_rebuild { println!("[INFO] File changed, rebuilding..."); - if let Err(e) = subcommand_build::run_build(&config_path_clone) { - eprintln!("[ERROR] Rebuild failed: {:#}", e); - } else { - println!("[INFO] Rebuild completed"); + match run_build_with_timing(&config_path_clone) { + Ok(duration) => { + println!("[INFO] Rebuild completed"); + println!("build finished in {} ms", duration.as_millis()); + } + Err(e) => { + eprintln!("[ERROR] Rebuild failed: {:#}", e); + } } } }