-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
turbo info
command for debugging (#9368)
### Description A command to provide debugging information for reproductions or otherwise understand a machine better. Output will look something close to this. ``` CLI: Version: 2.2.4-canary.4 Location: /Users/anthonyshew/projects/open/turbo/target/debug/turbo Daemon status: Running Package manager: pnpm Platform: Architecture: aarch64 Operating system: macos Available memory (MB): 13598 Available CPU cores: 10 Environment: CI: None Terminal (TERM): xterm-256color Terminal program (TERM_PROGRAM): tmux Terminal program version (TERM_PROGRAM_VERSION): 3.4 Shell (SHELL): /bin/zsh stdin: false Turborepo System Environment Variables: TURBO_INVOCATION_DIR: /Users/anthonyshew/projects/open/turbo ``` ### Testing Instructions Try it out!
- Loading branch information
1 parent
c03735d
commit 52f6f46
Showing
5 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use std::{env, io}; | ||
|
||
use sysinfo::{System, SystemExt}; | ||
use thiserror::Error; | ||
use turborepo_repository::{package_json::PackageJson, package_manager::PackageManager}; | ||
|
||
use super::CommandBase; | ||
use crate::{DaemonConnector, DaemonConnectorError}; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error("could not get path to turbo binary: {0}")] | ||
NoCurrentExe(#[from] io::Error), | ||
} | ||
|
||
pub async fn run(base: CommandBase) { | ||
let system = System::new_all(); | ||
let connector = DaemonConnector::new(false, false, &base.repo_root); | ||
let daemon_status = match connector.connect().await { | ||
Ok(_status) => "Running", | ||
Err(DaemonConnectorError::NotRunning) => "Not running", | ||
Err(_e) => "Error getting status", | ||
}; | ||
let package_manager = PackageJson::load(&base.repo_root.join_component("package.json")) | ||
.ok() | ||
.and_then(|package_json| { | ||
PackageManager::read_or_detect_package_manager(&package_json, &base.repo_root).ok() | ||
}) | ||
.map_or_else(|| "Not found".to_owned(), |pm| pm.to_string()); | ||
|
||
println!("CLI:"); | ||
println!(" Version: {}", base.version); | ||
|
||
let exe_path = std::env::current_exe().map_or_else( | ||
|e| format!("Cannot determine current binary: {e}").to_owned(), | ||
|path| path.to_string_lossy().into_owned(), | ||
); | ||
|
||
println!(" Path to executable: {}", exe_path); | ||
println!(" Daemon status: {}", daemon_status); | ||
println!(" Package manager: {}", package_manager); | ||
println!(); | ||
|
||
println!("Platform:"); | ||
println!(" Architecture: {}", std::env::consts::ARCH); | ||
println!(" Operating system: {}", std::env::consts::OS); | ||
println!( | ||
" Available memory (MB): {}", | ||
system.available_memory() / 1024 / 1024 | ||
); | ||
println!(" Available CPU cores: {}", num_cpus::get()); | ||
println!(); | ||
|
||
println!("Environment:"); | ||
println!(" CI: {:#?}", turborepo_ci::Vendor::get_name()); | ||
println!( | ||
" Terminal (TERM): {}", | ||
env::var("TERM").unwrap_or_else(|_| "unknown".to_owned()) | ||
); | ||
|
||
println!( | ||
" Terminal program (TERM_PROGRAM): {}", | ||
env::var("TERM_PROGRAM").unwrap_or_else(|_| "unknown".to_owned()) | ||
); | ||
println!( | ||
" Terminal program version (TERM_PROGRAM_VERSION): {}", | ||
env::var("TERM_PROGRAM_VERSION").unwrap_or_else(|_| "unknown".to_owned()) | ||
); | ||
println!( | ||
" Shell (SHELL): {}", | ||
env::var("SHELL").unwrap_or_else(|_| "unknown".to_owned()) | ||
); | ||
println!(" stdin: {}", turborepo_ci::is_ci()); | ||
println!(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters