-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: turbo info
command for debugging
#9368
Open
anthonyshew
wants to merge
6
commits into
main
Choose a base branch
from
shew-43923
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+114
−5
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,93 @@ | ||||||||||||||||||||||||||
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) -> Result<(), Error> { | ||||||||||||||||||||||||||
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 = match PackageJson::load(&base.repo_root.join_component("package.json")) { | ||||||||||||||||||||||||||
Ok(package_json) => { | ||||||||||||||||||||||||||
match PackageManager::read_or_detect_package_manager(&package_json, &base.repo_root) { | ||||||||||||||||||||||||||
Ok(pm) => pm.to_string(), | ||||||||||||||||||||||||||
Err(_) => "Not found".to_owned(), | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Err(_) => "Not found".to_owned(), | ||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||
Comment on lines
+25
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just some Rust code golf. I'd recommend manually committing this because Rustfmt will probably disagree with this formatting
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
println!("CLI:"); | ||||||||||||||||||||||||||
println!(" Version: {}", base.version); | ||||||||||||||||||||||||||
println!( | ||||||||||||||||||||||||||
" Location: {}", | ||||||||||||||||||||||||||
std::env::current_exe()?.to_string_lossy() | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
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!(); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
println!("Turborepo System Environment Variables:"); | ||||||||||||||||||||||||||
for (key, value) in env::vars() { | ||||||||||||||||||||||||||
// Don't print sensitive information | ||||||||||||||||||||||||||
if key == "TURBO_TEAM" | ||||||||||||||||||||||||||
|| key == "TURBO_TEAMID" | ||||||||||||||||||||||||||
|| key == "TURBO_TOKEN" | ||||||||||||||||||||||||||
|| key == "TURBO_API" | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
continue; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if key.starts_with("TURBO_") { | ||||||||||||||||||||||||||
println!(" {}: {}", key, value); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Ok(()) | ||||||||||||||||||||||||||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but saw it mentioning Go so ✂️