-
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.
Merge branch 'main' into mk/corepack-npm-tests
- Loading branch information
Showing
139 changed files
with
12,772 additions
and
13,657 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
use turborepo_ci::Vendor; | ||
use turborepo_ui::{ceprint, ceprintln, color, ColorConfig, BOLD, GREY, UNDERLINE, YELLOW}; | ||
|
||
use crate::EnvironmentVariableMap; | ||
|
||
pub struct PlatformEnv { | ||
env_keys: Vec<String>, | ||
} | ||
|
||
impl Default for PlatformEnv { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
const TURBO_PLATFORM_ENV_KEY: &str = "TURBO_PLATFORM_ENV"; | ||
const TURBO_PLATFORM_ENV_DISABLED_KEY: &str = "TURBO_PLATFORM_ENV_DISABLED"; | ||
|
||
impl PlatformEnv { | ||
pub fn new() -> Self { | ||
let env_keys = std::env::var(TURBO_PLATFORM_ENV_KEY) | ||
.unwrap_or_default() | ||
.split(',') | ||
.filter(|s| !s.is_empty()) | ||
.map(|s| s.to_string()) | ||
.collect(); | ||
|
||
Self { env_keys } | ||
} | ||
|
||
pub fn disabled() -> bool { | ||
let turbo_platform_env_disabled = | ||
std::env::var(TURBO_PLATFORM_ENV_DISABLED_KEY).unwrap_or_default(); | ||
turbo_platform_env_disabled == "1" || turbo_platform_env_disabled == "true" | ||
} | ||
|
||
pub fn validate(&self, execution_env: &EnvironmentVariableMap) -> Vec<String> { | ||
if Self::disabled() { | ||
return vec![]; | ||
} | ||
|
||
self.diff(execution_env) | ||
} | ||
|
||
pub fn diff(&self, execution_env: &EnvironmentVariableMap) -> Vec<String> { | ||
self.env_keys | ||
.iter() | ||
.filter(|key| !execution_env.contains_key(*key)) | ||
.map(|s| s.to_string()) | ||
.collect() | ||
} | ||
|
||
pub fn output_header(is_strict: bool, color_config: ColorConfig) { | ||
let ci = Vendor::get_constant().unwrap_or("unknown"); | ||
|
||
let strict_message = if is_strict { | ||
"These variables WILL NOT be available to your application and may cause your build to \ | ||
fail." | ||
} else { | ||
"These variables WILL NOT be considered in your cache key and could cause inadvertent \ | ||
cache hits." | ||
}; | ||
|
||
match ci { | ||
"VERCEL" => { | ||
ceprintln!( | ||
color_config, | ||
BOLD, | ||
"Warning - the following environment variables are set on your Vercel \ | ||
project, but missing from \"turbo.json\". {}", | ||
strict_message | ||
); | ||
} | ||
_ => { | ||
ceprintln!( | ||
color_config, | ||
BOLD, | ||
"Warning - the following environment variables are missing from \ | ||
\"turbo.json\". {}", | ||
strict_message | ||
); | ||
} | ||
} | ||
|
||
let docs = color!( | ||
color_config, | ||
UNDERLINE, | ||
"https://turbo.build/repo/docs/platform-environment-variables" | ||
); | ||
ceprintln!(color_config, GREY, "Learn more at {docs}\n"); | ||
} | ||
|
||
pub fn output_for_task( | ||
missing: Vec<String>, | ||
task_id_for_display: &str, | ||
color_config: ColorConfig, | ||
) { | ||
let ci = Vendor::get_constant().unwrap_or("unknown"); | ||
let log_prefix = match ci { | ||
"VERCEL" => "[warn]", | ||
_ => "", | ||
}; | ||
ceprintln!( | ||
color_config, | ||
YELLOW, | ||
"{} {}", | ||
log_prefix, | ||
task_id_for_display | ||
); | ||
for key in missing { | ||
ceprint!(color_config, GREY, "{} - ", log_prefix); | ||
ceprint!(color_config, GREY, "{} \n", key); | ||
} | ||
} | ||
} |
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.