From e4a6437a7c610e6e39d3c4bd43b28ab8ed6ca708 Mon Sep 17 00:00:00 2001 From: nicholaslyang Date: Thu, 25 Jul 2024 14:28:14 -0400 Subject: [PATCH 1/2] Printing the turbo version on start up --- crates/turborepo-lib/src/cli/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index e804c4ee09c7d..ba4df3ae70de4 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -21,7 +21,7 @@ use turborepo_telemetry::{ }, init_telemetry, track_usage, TelemetryHandle, }; -use turborepo_ui::UI; +use turborepo_ui::{GREY, UI}; use crate::{ cli::error::print_potential_tasks, @@ -990,6 +990,7 @@ pub async fn run( debug!("Failed to create AnonAPIClient: {:?}", error); } } + println!("{}\n", GREY.apply_to(format!("turbo {}", get_version()))); // If there is no command, we set the command to `Command::Run` with // `self.parsed_args.run_args` as arguments. From cf99d0ad49f29013366c50dbd80e105091a14429 Mon Sep 17 00:00:00 2001 From: nicholaslyang Date: Thu, 25 Jul 2024 14:45:14 -0400 Subject: [PATCH 2/2] Opt out of printing the version with an env var and set it for tests. Also print to stderr because we don't want to break commands that output JSON --- crates/turborepo-lib/src/cli/mod.rs | 8 +++++++- turborepo-tests/helpers/setup.sh | 1 + turborepo-tests/helpers/setup_integration_test.sh | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index ba4df3ae70de4..f02a04217390e 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -990,7 +990,13 @@ pub async fn run( debug!("Failed to create AnonAPIClient: {:?}", error); } } - println!("{}\n", GREY.apply_to(format!("turbo {}", get_version()))); + + let should_print_version = env::var("TURBO_PRINT_VERSION_DISABLED") + .map_or(true, |disable| !matches!(disable.as_str(), "1" | "true")); + + if should_print_version { + eprintln!("{}\n", GREY.apply_to(format!("turbo {}", get_version()))); + } // If there is no command, we set the command to `Command::Run` with // `self.parsed_args.run_args` as arguments. diff --git a/turborepo-tests/helpers/setup.sh b/turborepo-tests/helpers/setup.sh index c8580cd5ac7cb..b732eb2744261 100755 --- a/turborepo-tests/helpers/setup.sh +++ b/turborepo-tests/helpers/setup.sh @@ -13,4 +13,5 @@ fi export TURBO_TELEMETRY_MESSAGE_DISABLED=1 export TURBO_GLOBAL_WARNING_DISABLED=1 export TURBO_DOWNLOAD_LOCAL_ENABLED=0 +export TURBO_PRINT_VERSION_DISABLED=1 TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT} diff --git a/turborepo-tests/helpers/setup_integration_test.sh b/turborepo-tests/helpers/setup_integration_test.sh index 84d682ebd525b..c7c6fd806bdda 100755 --- a/turborepo-tests/helpers/setup_integration_test.sh +++ b/turborepo-tests/helpers/setup_integration_test.sh @@ -37,6 +37,7 @@ fi export TURBO_TELEMETRY_MESSAGE_DISABLED=1 export TURBO_GLOBAL_WARNING_DISABLED=1 +export TURBO_PRINT_VERSION_DISABLED=1 export TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT} # Undo the set -eo pipefail at the top of this script