terminal improvements (vercel/turbo#133)
* Adds next-like event type styling * No tasks in logs Closes: - https://github.com/vercel/web-tooling-internal/issues/58 Screenshot: ![CleanShot 2022-10-20 at 17 59 45@2x](https://user-images.githubusercontent.com/8146736/196999636-dcf3757d-6c5f-4c52-9257-86caabf6a5d6.png) Co-authored-by: Maia Teegarden <dev@padmaia.rocks> Co-authored-by: Justin Ridgewell <justin@ridgewell.name> Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
This commit is contained in:
parent
a442eab26e
commit
b1caa9ec34
4 changed files with 30 additions and 11 deletions
|
@ -32,6 +32,7 @@ console-subscriber = { version = "0.1.6", optional = true }
|
|||
futures = "0.3.21"
|
||||
mime = "0.3.16"
|
||||
next-core = { path = "../next-core" }
|
||||
owo-colors = "3"
|
||||
portpicker = "0.1.1"
|
||||
serde = "1.0.136"
|
||||
serde_json = "1.0.85"
|
||||
|
|
|
@ -14,6 +14,7 @@ use chromiumoxide::{
|
|||
Browser, Page,
|
||||
};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use owo_colors::OwoColorize;
|
||||
use tokio::task::spawn_blocking;
|
||||
use url::Url;
|
||||
|
||||
|
@ -181,12 +182,20 @@ fn stop_process(proc: &mut Child) -> Result<()> {
|
|||
std::thread::sleep(KILL_DEADLINE / KILL_DEADLINE_CHECK_STEPS);
|
||||
}
|
||||
if let Ok(None) = proc.try_wait() {
|
||||
eprintln!("Process {} did not exit after SIGINT, sending SIGKILL", pid);
|
||||
eprintln!(
|
||||
"{event_type} - process {pid} did not exit after SIGINT, sending SIGKILL",
|
||||
event_type = "error".red(),
|
||||
pid = pid
|
||||
);
|
||||
kill_process(proc)?;
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
eprintln!("Failed to send SIGINT to process {}, sending SIGKILL", pid);
|
||||
eprintln!(
|
||||
"{event_type} - failed to send SIGINT to process {pid}, sending SIGKILL",
|
||||
event_type = "error".red(),
|
||||
pid = pid
|
||||
);
|
||||
kill_process(proc)?;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::{
|
|||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
use next_dev::{register, NextDevServerBuilder};
|
||||
use owo_colors::OwoColorize;
|
||||
use turbo_tasks::{util::FormatDuration, TurboTasks};
|
||||
use turbo_tasks_memory::MemoryBackend;
|
||||
use turbopack_cli_utils::issue::IssueSeverityCliOption;
|
||||
|
@ -114,7 +115,8 @@ async fn main() -> Result<()> {
|
|||
format!("http://{}", server.addr)
|
||||
};
|
||||
println!(
|
||||
"started server on {}:{}, url: {}",
|
||||
"{event_type} - started server on {}:{}, url: {}",
|
||||
event_type = "ready".green(),
|
||||
server.addr.ip(),
|
||||
server.addr.port(),
|
||||
index_uri
|
||||
|
@ -125,19 +127,21 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
let stats_future = async move {
|
||||
let (elapsed, count) = tt_clone.get_or_wait_update_info(Duration::ZERO).await;
|
||||
println!(
|
||||
"initial compilation {} ({} task execution, {} tasks)",
|
||||
FormatDuration(start.elapsed()),
|
||||
FormatDuration(elapsed),
|
||||
count
|
||||
"{event_type} - initial compilation {start}",
|
||||
event_type = "event".purple(),
|
||||
start = FormatDuration(start.elapsed()),
|
||||
);
|
||||
|
||||
loop {
|
||||
let (elapsed, count) = tt_clone
|
||||
let (elapsed, _count) = tt_clone
|
||||
.get_or_wait_update_info(Duration::from_millis(100))
|
||||
.await;
|
||||
println!("updated in {} ({} tasks)", FormatDuration(elapsed), count);
|
||||
println!(
|
||||
"{event_type} - updated in {elapsed}",
|
||||
event_type = "event".purple(),
|
||||
elapsed = FormatDuration(elapsed),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ use chromiumoxide::{
|
|||
use futures::StreamExt;
|
||||
use lazy_static::lazy_static;
|
||||
use next_dev::{register, NextDevServerBuilder};
|
||||
use owo_colors::OwoColorize;
|
||||
use serde::Deserialize;
|
||||
use test_generator::test_resources;
|
||||
use tokio::{net::TcpSocket, task::JoinHandle};
|
||||
|
@ -141,7 +142,11 @@ async fn run_test(resource: &str) -> JestRunResult {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
println!("server started at http://{}", server.addr);
|
||||
println!(
|
||||
"{event_type} - server started at http://{address}",
|
||||
event_type = "ready".green(),
|
||||
address = server.addr
|
||||
);
|
||||
|
||||
tokio::select! {
|
||||
r = run_browser(server.addr) => r.unwrap(),
|
||||
|
|
Loading…
Reference in a new issue