Skip to content

Commit

Permalink
chore(turbo)!: remove check for legacy turbo config in package.json (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulkar authored and chris-olszewski committed Apr 30, 2024
1 parent e082fda commit 22b3161
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 61 deletions.
28 changes: 0 additions & 28 deletions crates/turborepo-lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use turbopath::{AbsoluteSystemPathBuf, AnchoredSystemPath};
use turborepo_auth::{TURBO_TOKEN_DIR, TURBO_TOKEN_FILE, VERCEL_TOKEN_DIR, VERCEL_TOKEN_FILE};
use turborepo_dirs::{config_dir, vercel_config_dir};
use turborepo_errors::TURBO_SITE;
use turborepo_repository::package_json::{Error as PackageJsonError, PackageJson};

pub use crate::turbo_json::RawTurboJson;
use crate::{commands::CommandBase, turbo_json};
Expand Down Expand Up @@ -256,21 +255,6 @@ trait ResolvedConfigurationOptions {
fn get_configuration_options(self) -> Result<ConfigurationOptions, Error>;
}

impl ResolvedConfigurationOptions for PackageJson {
fn get_configuration_options(self) -> Result<ConfigurationOptions, Error> {
match &self.legacy_turbo_config {
Some(legacy_turbo_config) => {
let synthetic_raw_turbo_json: RawTurboJson = RawTurboJson::parse(
&legacy_turbo_config.to_string(),
AnchoredSystemPath::new("package.json").unwrap(),
)?;
synthetic_raw_turbo_json.get_configuration_options()
}
None => Ok(ConfigurationOptions::default()),
}
}
}

impl ResolvedConfigurationOptions for RawTurboJson {
fn get_configuration_options(self) -> Result<ConfigurationOptions, Error> {
let mut opts = if let Some(remote_cache_options) = &self.remote_cache {
Expand Down Expand Up @@ -596,24 +580,13 @@ impl TurborepoConfigBuilder {

pub fn build(&self) -> Result<ConfigurationOptions, Error> {
// Priority, from least significant to most significant:
// - shared configuration (package.json .turbo)
// - shared configuration (turbo.json)
// - global configuration (~/.turbo/config.json)
// - local configuration (<REPO_ROOT>/.turbo/config.json)
// - environment variables
// - CLI arguments
// - builder pattern overrides.

let root_package_json = PackageJson::load(&self.repo_root.join_component("package.json"))
.or_else(|e| {
if let PackageJsonError::Io(e) = &e {
if matches!(e.kind(), std::io::ErrorKind::NotFound) {
return Ok(Default::default());
}
}

Err(e)
})?;
let turbo_json = RawTurboJson::read(
&self.repo_root,
AnchoredSystemPath::new("turbo.json").unwrap(),
Expand All @@ -635,7 +608,6 @@ impl TurborepoConfigBuilder {
let override_env_var_config = get_override_env_var_config(&env_vars)?;

let sources = [
root_package_json.get_configuration_options(),
turbo_json.get_configuration_options(),
global_config.get_configuration_options(),
global_auth.get_configuration_options(),
Expand Down
16 changes: 0 additions & 16 deletions crates/turborepo-lib/src/turbo_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,6 @@ impl TurboJson {
root_package_json: &PackageJson,
include_synthesized_from_root_package_json: bool,
) -> Result<TurboJson, Error> {
if root_package_json.legacy_turbo_config.is_some() {
println!(
"[WARNING] \"turbo\" in package.json is no longer supported. Migrate to {} by \
running \"npx @turbo/codemod create-turbo-config\"\n",
CONFIG_FILE
);
}

let turbo_from_files = Self::read(repo_root, &dir.join_component(CONFIG_FILE));
let turbo_from_trace =
Self::read(repo_root, &dir.join_components(&TASK_ACCESS_CONFIG_PATH));
Expand Down Expand Up @@ -839,14 +831,6 @@ mod tests {
..TurboJson::default()
}
)]
#[test_case(
Some("{}"),
PackageJson {
legacy_turbo_config: Some(serde_json::Value::String("build".to_string())),
..PackageJson::default()
},
TurboJson::default()
)]
#[test_case(
Some(r#"{
"pipeline": {
Expand Down
17 changes: 0 additions & 17 deletions crates/turborepo-repository/src/package_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ pub struct PackageJson {
pub optional_dependencies: Option<BTreeMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub peer_dependencies: Option<BTreeMap<String, String>>,
#[serde(rename = "turbo", default, skip_serializing_if = "Option::is_none")]
pub legacy_turbo_config: Option<Value>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub scripts: BTreeMap<String, String>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -108,19 +106,4 @@ mod test {
let actual = serde_json::to_value(package_json).unwrap();
assert_eq!(actual, json);
}

#[test]
fn test_legacy_turbo_config() -> Result<()> {
let contents = r#"{"turbo": {}}"#;
let package_json = serde_json::from_str::<PackageJson>(contents)?;

assert!(package_json.legacy_turbo_config.is_some());

let contents = r#"{"turbo": { "globalDependencies": [".env"] } }"#;
let package_json = serde_json::from_str::<PackageJson>(contents)?;

assert!(package_json.legacy_turbo_config.is_some());

Ok(())
}
}

0 comments on commit 22b3161

Please sign in to comment.