Skip to content

Commit

Permalink
Remove turbo.json checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhammond committed Feb 24, 2023
1 parent 5c53ad8 commit 187432a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 98 deletions.
46 changes: 14 additions & 32 deletions cli/integration_tests/inference/nested-workspaces.t
Original file line number Diff line number Diff line change
Expand Up @@ -91,47 +91,29 @@ Setup
$ cd $TARGET_DIR/outer/inner-no-turbo && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/nested-workspaces\.t/outer (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/nested-workspaces\.t/outer/inner-no-turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "inner-no-turbo" (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Using inner-no-turbo as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=c1fb8f74a026cdb8 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Tasks: 0 successful, 0 total
Cached: 0 cached, 0 total
Time:\s*[\.0-9]+m?s (re)

[-0-9:.TWZ+]+ \[ERROR] turbo: error: EXTRA_VALUE_AT_END="run failed: Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one: file does not exist" (re)
ERROR run failed: Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one: file does not exist
Turbo error: Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one: file does not exist
[1]

$ cd $TARGET_DIR/outer/inner-no-turbo/apps && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/nested-workspaces\.t/outer (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/nested-workspaces\.t/outer/inner-no-turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Running command as global turbo (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "inner-no-turbo/apps" (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::cli: pkg_inference_root set to "apps" (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re)
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: Using inner-no-turbo/apps as a basis for selecting packages (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=c1fb8f74a026cdb8 (re)
[-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re)
\xe2\x80\xa2 Packages in scope: (esc)
\xe2\x80\xa2 Running build in 0 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

No tasks were executed as part of this run.

Tasks: 0 successful, 0 total
Cached: 0 cached, 0 total
Time:\s*[\.0-9]+m?s (re)

[-0-9:.TWZ+]+ \[ERROR] turbo: error: EXTRA_VALUE_AT_END="run failed: Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one: file does not exist" (re)
ERROR run failed: Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one: file does not exist
Turbo error: Could not find turbo.json. Follow directions at https://turbo.build/repo/docs to create one: file does not exist
[1]

$ cd $TARGET_DIR/outer-no-turbo && ${TURBO} run build --filter=nothing -vv
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Global turbo version: .* (re)
[-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Expand Down
1 change: 0 additions & 1 deletion crates/turborepo-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod config;
mod package_manager;
mod retry;
mod shim;
mod turbo_json;
mod ui;

use anyhow::Result;
Expand Down
34 changes: 2 additions & 32 deletions crates/turborepo-lib/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
use tiny_gradient::{GradientStr, RGB};
use turbo_updater::check_for_updates;

use crate::{cli, get_version, turbo_json::TurboJson, PackageManager, Payload};
use crate::{cli, get_version, PackageManager, Payload};

static TURBO_JSON: &str = "turbo.json";
// all arguments that result in a stdout that much be directly parsable and
Expand Down Expand Up @@ -235,36 +235,7 @@ impl RepoState {
///
/// returns: Result<RepoState, Error>
pub fn infer(current_dir: &Path) -> Result<Self> {
// First we look for a `turbo.json`. This iterator returns the first ancestor
// that contains a `turbo.json` file.
let root_path = current_dir
.ancestors()
.find(|p| TurboJson::open(p.join(TURBO_JSON)).map_or(false, |t| t.no_extends()));

// If that directory exists, then we figure out if there are workspaces defined
// in it NOTE: This may change with multiple `turbo.json` files
if let Some(root_path) = root_path {
let pnpm = PackageManager::Pnpm;
let npm = PackageManager::Npm;
let is_workspace = pnpm.get_workspace_globs(root_path).is_ok()
|| npm.get_workspace_globs(root_path).is_ok();

let mode = if is_workspace {
RepoMode::MultiPackage
} else {
RepoMode::SinglePackage
};

let local_turbo_state = LocalTurboState::infer(root_path);

return Ok(Self {
root: root_path.to_path_buf(),
mode,
local_turbo_state,
});
}

// What we look for next is a directory that contains a `package.json`.
// What we look for first are all directories that contain a `package.json`.
let potential_roots = current_dir
.ancestors()
.filter(|path| fs::metadata(path.join("package.json")).is_ok());
Expand All @@ -284,7 +255,6 @@ impl RepoState {

if is_workspace {
let local_turbo_state = LocalTurboState::infer(dir);

return Ok(Self {
root: dir.to_path_buf(),
mode: RepoMode::MultiPackage,
Expand Down
33 changes: 0 additions & 33 deletions crates/turborepo-lib/src/turbo_json.rs

This file was deleted.

0 comments on commit 187432a

Please sign in to comment.