Skip to content

Commit

Permalink
feat(shim): invoke local turbo version via npx if not installed (#8385)
Browse files Browse the repository at this point in the history
### Description

I highly recommend reviewing the first 4 commits on their own as they
are primarily breaking up the massive `shim` module.

This PR adds fallback option when global turbo doesn't find a local
turbo install. If a local install isn't found we will look at:
 - lockfiles
 - package.json
 - turbo.json to identify if turbo 1 is expected

If one of those result in finding a version of `turbo`, then we'll
invoke `turbo` via `npx` to download the correct version on the fly.

This behavior can be disabled with by setting
`TURBO_DOWNLOAD_LOCAL_DISABLED` to `1` or `true`

### Testing Instructions

Added unit tests for detection behavior.

Manual testing of repos with/without a local install of `turbo`.
  • Loading branch information
chris-olszewski committed Jun 10, 2024
1 parent 4176648 commit 0407e47
Show file tree
Hide file tree
Showing 25 changed files with 1,623 additions and 844 deletions.
6 changes: 6 additions & 0 deletions crates/turborepo-lib/fixtures/local_config/turbo.v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// some comments
"pipeline": {
"build": {"dependsOn": ["^build"]}
}
}
6 changes: 6 additions & 0 deletions crates/turborepo-lib/fixtures/local_config/turbo.v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// some comments
"tasks": {
"build": {"dependsOn": ["^build"]}
}
}
116 changes: 116 additions & 0 deletions crates/turborepo-lib/fixtures/local_config/turbov2.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/turborepo-lib/src/engine/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ mod test {
fn global_change(&self, _other: &dyn Lockfile) -> bool {
unreachable!()
}

fn turbo_version(&self) -> Option<String> {
None
}
}

struct MockDiscovery;
Expand Down
Loading

0 comments on commit 0407e47

Please sign in to comment.