Skip to content

Commit

Permalink
Turborepo 2.0 (#8294)
Browse files Browse the repository at this point in the history
### Description

TSIA

### Testing Instructions

CI

---------

Co-authored-by: Mehul Kar <mehul.kar@vercel.com>
Co-authored-by: Thomas Knickman <tom.knickman@vercel.com>
Co-authored-by: Anthony Shew <anthony.shew@vercel.com>
Co-authored-by: Nicholas Yang <nicholas.yang@vercel.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Turbobot <turbobot@vercel.com>
  • Loading branch information
7 people authored Jun 4, 2024
1 parent 396319b commit 12acb89
Show file tree
Hide file tree
Showing 389 changed files with 4,355 additions and 6,062 deletions.
374 changes: 4 additions & 370 deletions cli/LICENSE

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"repository": "https://github.com/vercel/turbo",
"bugs": "https://github.com/vercel/turbo/issues",
"homepage": "https://turbo.build/repo",
"license": "MPL-2.0",
"license": "MIT",
"os": ["{{Os}}"],
"cpu": ["{{Arch}}"],
"preferUnplugged": true
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-analytics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "turborepo-analytics"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-api-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "turborepo-api-client"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "turborepo-auth"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-cache/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "turborepo-cache"
version = "0.1.0"
license = "MPL-2.0"
license = "MIT"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
24 changes: 6 additions & 18 deletions crates/turborepo-cache/src/async_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,8 @@ mod tests {
// Wait for async cache to process
async_cache.wait().await.unwrap();

let fs_cache_path = repo_root_path.join_components(&[
"node_modules",
".cache",
"turbo",
&format!("{}.tar.zst", hash),
]);
let fs_cache_path =
repo_root_path.join_components(&[".turbo", "cache", &format!("{}.tar.zst", hash)]);

// Confirm that fs cache file does *not* exist
assert!(!fs_cache_path.exists());
Expand Down Expand Up @@ -389,12 +385,8 @@ mod tests {
// Wait for async cache to process
async_cache.wait().await.unwrap();

let fs_cache_path = repo_root_path.join_components(&[
"node_modules",
".cache",
"turbo",
&format!("{}.tar.zst", hash),
]);
let fs_cache_path =
repo_root_path.join_components(&[".turbo", "cache", &format!("{}.tar.zst", hash)]);

// Confirm that fs cache file exists
assert!(fs_cache_path.exists());
Expand Down Expand Up @@ -483,12 +475,8 @@ mod tests {
// Wait for async cache to process
async_cache.wait().await.unwrap();

let fs_cache_path = repo_root_path.join_components(&[
"node_modules",
".cache",
"turbo",
&format!("{}.tar.zst", hash),
]);
let fs_cache_path =
repo_root_path.join_components(&[".turbo", "cache", &format!("{}.tar.zst", hash)]);

// Confirm that fs cache file exists
assert!(fs_cache_path.exists());
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-cache/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl FSCache {
if let Some(override_dir) = override_dir {
AbsoluteSystemPathBuf::from_unknown(repo_root, override_dir)
} else {
repo_root.join_components(&["node_modules", ".cache", "turbo"])
repo_root.join_components(&[".turbo", "cache"])
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-ci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "turborepo-ci"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-dirs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "turborepo-dirs"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-env/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "turborepo-env"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
16 changes: 0 additions & 16 deletions crates/turborepo-env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@ use thiserror::Error;

const DEFAULT_ENV_VARS: [&str; 1] = ["VERCEL_ANALYTICS_ID"];

/// Environment mode after we've resolved the `Infer` variant
#[derive(Debug, Clone, Copy)]
pub enum ResolvedEnvMode {
Loose,
Strict,
}

impl std::fmt::Display for ResolvedEnvMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ResolvedEnvMode::Loose => write!(f, "loose"),
ResolvedEnvMode::Strict => write!(f, "strict"),
}
}
}

#[derive(Clone, Debug, Error)]
pub enum Error {
#[error("Failed to parse regex: {0}")]
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "turborepo-errors"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-filewatch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "turborepo-filewatch"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
4 changes: 3 additions & 1 deletion crates/turborepo-filewatch/src/hash_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,9 @@ mod tests {
.unwrap();
repo_root
.join_component("package.json")
.create_with_contents(r#"{"workspaces": ["packages/*"]}"#)
.create_with_contents(
r#"{"workspaces": ["packages/*"], "packageManager": "npm@10.0.0"}"#,
)
.unwrap();
repo_root
.join_component("package-lock.json")
Expand Down
30 changes: 18 additions & 12 deletions crates/turborepo-filewatch/src/package_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,9 @@ mod test {
// write workspaces to root
repo_root
.join_component("package.json")
.create_with_contents(r#"{"workspaces":["packages/*"]}"#)
.create_with_contents(
r#"{"workspaces":["packages/*"], "packageManager": "npm@10.0.0"}"#,
)
.unwrap();

let watcher = FileSystemWatcher::new_with_default_cookie_dir(&repo_root).unwrap();
Expand Down Expand Up @@ -703,7 +705,9 @@ mod test {
// write workspaces to root
repo_root
.join_component("package.json")
.create_with_contents(r#"{"workspaces":["packages/*", "packages2/*"]}"#)
.create_with_contents(
r#"{"workspaces":["packages/*", "packages2/*"], "packageManager": "npm@10.0.0"}"#,
)
.unwrap();

let watcher = FileSystemWatcher::new_with_default_cookie_dir(&repo_root).unwrap();
Expand Down Expand Up @@ -743,7 +747,9 @@ mod test {
// update workspaces to no longer cover packages2
repo_root
.join_component("package.json")
.create_with_contents(r#"{"workspaces":["packages/*"]}"#)
.create_with_contents(
r#"{"workspaces":["packages/*"], "packageManager": "npm@10.0.0"}"#,
)
.unwrap();

let mut data = package_watcher.discover_packages_blocking().await.unwrap();
Expand Down Expand Up @@ -804,7 +810,7 @@ mod test {
let root_package_json_path = repo_root.join_component("package.json");
// Start with no workspace glob
root_package_json_path
.create_with_contents(r#"{"packageManager": "pnpm@7.0"}"#)
.create_with_contents(r#"{"packageManager": "pnpm@7.0.0"}"#)
.unwrap();
repo_root
.join_component("pnpm-lock.yaml")
Expand Down Expand Up @@ -873,7 +879,7 @@ mod test {
let root_package_json_path = repo_root.join_component("package.json");
// Start with no workspace glob
root_package_json_path
.create_with_contents(r#"{"packageManager": "npm@7.0"}"#)
.create_with_contents(r#"{"packageManager": "npm@7.0.0"}"#)
.unwrap();
repo_root
.join_component("package-lock.json")
Expand All @@ -896,7 +902,7 @@ mod test {
.unwrap_err();

root_package_json_path
.create_with_contents(r#"{"packageManager": "pnpm@7.0", "workspaces": ["foo/*"]}"#)
.create_with_contents(r#"{"packageManager": "npm@7.0.0", "workspaces": ["foo/*"]}"#)
.unwrap();

let resp = package_watcher.discover_packages_blocking().await.unwrap();
Expand All @@ -911,7 +917,7 @@ mod test {

// Create an invalid workspace glob
root_package_json_path
.create_with_contents(r#"{"packageManager": "pnpm@7.0", "workspaces": ["foo/***"]}"#)
.create_with_contents(r#"{"packageManager": "npm@7.0.0", "workspaces": ["foo/***"]}"#)
.unwrap();

// We expect an error due to invalid workspace glob
Expand All @@ -922,7 +928,7 @@ mod test {

// Set it back to valid, ensure we recover
root_package_json_path
.create_with_contents(r#"{"packageManager": "pnpm@7.0", "workspaces": ["foo/*"]}"#)
.create_with_contents(r#"{"packageManager": "npm@7.0.0", "workspaces": ["foo/*"]}"#)
.unwrap();
let resp = package_watcher.discover_packages_blocking().await.unwrap();
assert_eq!(resp.package_manager, PackageManager::Npm);
Expand All @@ -945,7 +951,7 @@ mod test {
let root_package_json_path = repo_root.join_component("package.json");
// Start with no workspace glob
root_package_json_path
.create_with_contents(r#"{"packageManager": "pnpm@7.0"}"#)
.create_with_contents(r#"{"packageManager": "pnpm@7.0.0"}"#)
.unwrap();
let pnpm_lock_file = repo_root.join_component("pnpm-lock.yaml");
pnpm_lock_file.create_with_contents("").unwrap();
Expand All @@ -963,8 +969,8 @@ mod test {
let resp = package_watcher.discover_packages_blocking().await.unwrap();
assert_eq!(resp.package_manager, PackageManager::Pnpm);

pnpm_lock_file.remove_file().unwrap();
// No more lock file, verify we're in an invalid state
workspaces_path.remove_file().unwrap();
// No more workspaces file, verify we're in an invalid state
package_watcher
.discover_packages_blocking()
.await
Expand All @@ -980,7 +986,7 @@ mod test {

// update package.json to complete the transition
root_package_json_path
.create_with_contents(r#"{"packageManager": "npm@7.0", "workspaces": ["foo/*"]}"#)
.create_with_contents(r#"{"packageManager": "npm@7.0.0", "workspaces": ["foo/*"]}"#)
.unwrap();
let resp = package_watcher.discover_packages_blocking().await.unwrap();
assert_eq!(resp.package_manager, PackageManager::Npm);
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-fs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "turborepo-fs"
version = "0.1.0"
license = "MPL-2.0"
license = "MIT"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-globwalk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "globwalk"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
Loading

0 comments on commit 12acb89

Please sign in to comment.