From 9368694dd43d9cdb20e7343395401ac33aafd36e Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Fri, 3 Jan 2025 08:11:46 -0700 Subject: [PATCH] feat: optional `TURBO_SITE` environment variable at compilation time for development (#9660) ### Description To make it easier to test out the links we supply in our error messages, this PR lets us supply a base URL of our own choosing so you can point errors at places like `http://localhost:3000` or a preview build of `turbo.build`. ### Testing Instructions You can try this out yourself with: ```bash TURBO_SITE="http://localhost:3000" cargo build ``` --- CONTRIBUTING.md | 10 ++++++++++ crates/turborepo-errors/src/lib.rs | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2397d64811101..ff301dd17f292 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -144,6 +144,16 @@ There are many open-source Turborepos out in the community that you can test wit ## Debugging tips +### Links in error messages + +Many of Turborepo's error messages include links to information or documentation to help end users. + +The base URL for the links can be set to a value of your choosing by providing a `TURBO_SITE` environment variable at compilation time. + +```bash +TURBO_SITE="http://localhost:3000" cargo build +``` + ### Verbose logging Verbose logging can be enabled by using the `-v`, `-vv`, or `-vvv` flag on your `turbo` command, depending on the level of logging you're looking for. diff --git a/crates/turborepo-errors/src/lib.rs b/crates/turborepo-errors/src/lib.rs index cd7fd8eb91c5c..31e78193cac12 100644 --- a/crates/turborepo-errors/src/lib.rs +++ b/crates/turborepo-errors/src/lib.rs @@ -9,7 +9,15 @@ use miette::{Diagnostic, NamedSource, SourceSpan}; use serde::{Deserialize, Serialize}; use thiserror::Error; -pub const TURBO_SITE: &str = "https://turbo.build"; +/// Base URL for links supplied in error messages. You can use the TURBO_SITE +/// environment variable at compile time to set a base URL for easier debugging. +/// +/// When TURBO_SITE is not provided at compile time, the production site will be +/// used. +pub const TURBO_SITE: &str = match option_env!("TURBO_SITE") { + Some(url) => url, + None => "https://turbo.build", +}; /// A little helper to convert from biome's syntax errors to miette. #[derive(Debug, Error, Diagnostic)]