From b75b04d4d0b61bcfdd7a33b53ec593e1499ff853 Mon Sep 17 00:00:00 2001 From: Nathan Hammond Date: Mon, 27 Feb 2023 14:30:00 +0800 Subject: [PATCH] Root inference: skip turbo.json (#3946) Integration tests for inferring the root. This demonstrates that detection based upon `turbo.json` (and the change made in #3938) is not (particularly) relevant to root identification. How to review: - Each commit is pretty self-contained. You can see me adding a debug line to assert against in the first commit. - The third commit is both a revert of #3938 and a full deletion of the `turbo.json`-included detection logic.
OUTDATED There is _one_ behavior change. If you previously: 1. Had nested workspaces (which is not supported by us or any package manager). 2. Had a `turbo.json` at the "outer" one. 3. Did _not_ have a `turbo.json` at the "inner" one Then we would have selected the outer one. We now select the inner one, and throw an error because the inner one does not have a `turbo.json`. I believe this to be an _improvement_.
*** #3938 treats any `turbo.json` that has comments in it as nonexistent since `serde_json` doesn't support JSONC. That everything still worked with parsing that is throwing an error made it clear that the `turbo.json` check was not being used except for the described edge case. --- .../basic_monorepo/verbosity.t | 2 + .../inference/has-workspaces.t | 113 +++++++++ .../has-workspaces/apps/docs/package.json | 3 + .../has-workspaces/apps/web/package.json | 3 + .../tests/test-package/package.json | 3 + .../inference/has-workspaces/package.json | 9 + .../eslint-config-custom/package.json | 3 + .../packages/ui-library/package.json | 3 + .../packages/ui-library/src/.gitkeep | 0 .../packages/ui-library/turbo.json | 5 + .../inference/has-workspaces/turbo.json | 7 + .../inference/nested-workspaces.t | 228 ++++++++++++++++++ .../inference/nested-workspaces/README.md | 1 + .../outer-no-turbo/apps/docs/package.json | 3 + .../outer-no-turbo/apps/web/package.json | 3 + .../inner-no-turbo/apps/docs/package.json | 3 + .../inner-no-turbo/apps/web/package.json | 3 + .../inner-no-turbo/package.json | 8 + .../eslint-config-custom/package.json | 3 + .../packages/ui-library/package.json | 3 + .../inner/apps/docs/package.json | 3 + .../inner/apps/web/package.json | 3 + .../outer-no-turbo/inner/package.json | 8 + .../eslint-config-custom/package.json | 3 + .../inner/packages/ui-library/package.json | 3 + .../outer-no-turbo/inner/turbo.json | 6 + .../outer-no-turbo/package-lock.json | 1 + .../outer-no-turbo/package.json | 8 + .../eslint-config-custom/package.json | 3 + .../packages/ui-library/package.json | 3 + .../outer/apps/docs/package.json | 3 + .../outer/apps/web/package.json | 3 + .../inner-no-turbo/apps/docs/package.json | 3 + .../inner-no-turbo/apps/web/package.json | 3 + .../outer/inner-no-turbo/package.json | 8 + .../eslint-config-custom/package.json | 3 + .../packages/ui-library/package.json | 3 + .../outer/inner/apps/docs/package.json | 3 + .../outer/inner/apps/web/package.json | 3 + .../outer/inner/package.json | 8 + .../eslint-config-custom/package.json | 3 + .../inner/packages/ui-library/package.json | 3 + .../nested-workspaces/outer/inner/turbo.json | 6 + .../nested-workspaces/outer/package-lock.json | 1 + .../nested-workspaces/outer/package.json | 8 + .../eslint-config-custom/package.json | 3 + .../outer/packages/ui-library/package.json | 3 + .../nested-workspaces/outer/turbo.json | 6 + .../inference/nested_workspaces_setup.sh | 13 + .../inference/no-workspaces.t | 64 +++++ .../inference/no-workspaces/package.json | 4 + .../no-workspaces/parent/child/package.json | 4 + .../no-workspaces/parent/package.json | 4 + .../inference/no_workspaces_setup.sh | 9 + cli/integration_tests/inference/setup.sh | 8 + crates/turborepo-lib/src/lib.rs | 1 - crates/turborepo-lib/src/shim.rs | 72 ++++-- crates/turborepo-lib/src/turbo_json.rs | 33 --- 58 files changed, 676 insertions(+), 56 deletions(-) create mode 100644 cli/integration_tests/inference/has-workspaces.t create mode 100644 cli/integration_tests/inference/has-workspaces/apps/docs/package.json create mode 100644 cli/integration_tests/inference/has-workspaces/apps/web/package.json create mode 100644 cli/integration_tests/inference/has-workspaces/crates/super-crate/tests/test-package/package.json create mode 100644 cli/integration_tests/inference/has-workspaces/package.json create mode 100644 cli/integration_tests/inference/has-workspaces/packages/eslint-config-custom/package.json create mode 100644 cli/integration_tests/inference/has-workspaces/packages/ui-library/package.json create mode 100644 cli/integration_tests/inference/has-workspaces/packages/ui-library/src/.gitkeep create mode 100644 cli/integration_tests/inference/has-workspaces/packages/ui-library/turbo.json create mode 100644 cli/integration_tests/inference/has-workspaces/turbo.json create mode 100644 cli/integration_tests/inference/nested-workspaces.t create mode 100644 cli/integration_tests/inference/nested-workspaces/README.md create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/docs/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/web/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/docs/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/web/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/eslint-config-custom/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/ui-library/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/docs/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/web/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/eslint-config-custom/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/ui-library/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/turbo.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package-lock.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/eslint-config-custom/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/ui-library/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/apps/docs/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/apps/web/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/docs/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/web/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/eslint-config-custom/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/ui-library/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner/apps/docs/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner/apps/web/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner/packages/eslint-config-custom/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner/packages/ui-library/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/inner/turbo.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/package-lock.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/packages/eslint-config-custom/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/packages/ui-library/package.json create mode 100644 cli/integration_tests/inference/nested-workspaces/outer/turbo.json create mode 100644 cli/integration_tests/inference/nested_workspaces_setup.sh create mode 100644 cli/integration_tests/inference/no-workspaces.t create mode 100644 cli/integration_tests/inference/no-workspaces/package.json create mode 100644 cli/integration_tests/inference/no-workspaces/parent/child/package.json create mode 100644 cli/integration_tests/inference/no-workspaces/parent/package.json create mode 100644 cli/integration_tests/inference/no_workspaces_setup.sh create mode 100644 cli/integration_tests/inference/setup.sh delete mode 100644 crates/turborepo-lib/src/turbo_json.rs diff --git a/cli/integration_tests/basic_monorepo/verbosity.t b/cli/integration_tests/basic_monorepo/verbosity.t index a1f202b4747f9..40e6b1e5d1dbb 100644 --- a/cli/integration_tests/basic_monorepo/verbosity.t +++ b/cli/integration_tests/basic_monorepo/verbosity.t @@ -40,6 +40,7 @@ Verbosity level 2 $ ${TURBO} build -vv --filter=util --force [-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: .*/verbosity\.t (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 "" (re) [-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re) @@ -69,6 +70,7 @@ Verbosity level 2 $ ${TURBO} build --verbosity=2 --filter=util --force [-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: .*/verbosity\.t (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 "" (re) [-0-9:.TWZ+]+ \[DEBUG] turbo: Found go binary at "[\-\w\/]+" (re) diff --git a/cli/integration_tests/inference/has-workspaces.t b/cli/integration_tests/inference/has-workspaces.t new file mode 100644 index 0000000000000..447a78fc2bb97 --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces.t @@ -0,0 +1,113 @@ +Setup + $ . ${TESTDIR}/../setup.sh + $ . ${TESTDIR}/setup.sh $(pwd) "has-workspaces" + + $ cd $TARGET_DIR && ${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: .*/has-workspaces\.t (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 "" (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: 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) + + $ cd $TARGET_DIR/apps/web && ${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: .*/has-workspaces\.t (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 "apps/web" (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 apps/web 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) + + $ cd $TARGET_DIR/crates && ${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: .*/has-workspaces\.t (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 "crates" (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 crates 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) + + $ cd $TARGET_DIR/crates/super-crate/tests/test-package && ${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: .*/has-workspaces\.t (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 "crates/super-crate/tests/test-package" (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 crates/super-crate/tests/test-package 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) + + $ cd $TARGET_DIR/packages/ui-library/src && ${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: .*/has-workspaces\.t (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 "packages/ui-library/src" (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 packages/ui-library/src 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) + \ No newline at end of file diff --git a/cli/integration_tests/inference/has-workspaces/apps/docs/package.json b/cli/integration_tests/inference/has-workspaces/apps/docs/package.json new file mode 100644 index 0000000000000..0ae4dfd4810ce --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/apps/docs/package.json @@ -0,0 +1,3 @@ +{ + "name": "docs" +} diff --git a/cli/integration_tests/inference/has-workspaces/apps/web/package.json b/cli/integration_tests/inference/has-workspaces/apps/web/package.json new file mode 100644 index 0000000000000..81fca2803c019 --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/apps/web/package.json @@ -0,0 +1,3 @@ +{ + "name": "web" +} diff --git a/cli/integration_tests/inference/has-workspaces/crates/super-crate/tests/test-package/package.json b/cli/integration_tests/inference/has-workspaces/crates/super-crate/tests/test-package/package.json new file mode 100644 index 0000000000000..ad8ade827ae15 --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/crates/super-crate/tests/test-package/package.json @@ -0,0 +1,3 @@ +{ + "name": "test-package" +} diff --git a/cli/integration_tests/inference/has-workspaces/package.json b/cli/integration_tests/inference/has-workspaces/package.json new file mode 100644 index 0000000000000..3d10cd9d0844a --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/package.json @@ -0,0 +1,9 @@ +{ + "name": "inference", + "workspaces": [ + "apps/*", + "packages/*", + "crates/super-crate/tests/test-package" + ], + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/has-workspaces/packages/eslint-config-custom/package.json b/cli/integration_tests/inference/has-workspaces/packages/eslint-config-custom/package.json new file mode 100644 index 0000000000000..505c76aa0482e --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/packages/eslint-config-custom/package.json @@ -0,0 +1,3 @@ +{ + "name": "eslint-config-custom" +} diff --git a/cli/integration_tests/inference/has-workspaces/packages/ui-library/package.json b/cli/integration_tests/inference/has-workspaces/packages/ui-library/package.json new file mode 100644 index 0000000000000..4d3650c34aca2 --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/packages/ui-library/package.json @@ -0,0 +1,3 @@ +{ + "name": "ui-library" +} diff --git a/cli/integration_tests/inference/has-workspaces/packages/ui-library/src/.gitkeep b/cli/integration_tests/inference/has-workspaces/packages/ui-library/src/.gitkeep new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/cli/integration_tests/inference/has-workspaces/packages/ui-library/turbo.json b/cli/integration_tests/inference/has-workspaces/packages/ui-library/turbo.json new file mode 100644 index 0000000000000..924a1fc613ae9 --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/packages/ui-library/turbo.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://turbo.build/schema.json", + "extends": ["//"], + "pipeline": {} +} diff --git a/cli/integration_tests/inference/has-workspaces/turbo.json b/cli/integration_tests/inference/has-workspaces/turbo.json new file mode 100644 index 0000000000000..2fc9d06fe4d5a --- /dev/null +++ b/cli/integration_tests/inference/has-workspaces/turbo.json @@ -0,0 +1,7 @@ +// Has a comment! +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": {} + } +} diff --git a/cli/integration_tests/inference/nested-workspaces.t b/cli/integration_tests/inference/nested-workspaces.t new file mode 100644 index 0000000000000..a85ca3a265e1e --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces.t @@ -0,0 +1,228 @@ +Setup + $ . ${TESTDIR}/../setup.sh + $ . ${TESTDIR}/nested_workspaces_setup.sh $(pwd) + + $ cd $TARGET_DIR/outer && ${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: Running command as global 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: 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) + + $ cd $TARGET_DIR/outer/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: Running command as global turbo (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 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) + + $ cd $TARGET_DIR/outer/inner && ${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/inner (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 "" (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: 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) + + $ cd $TARGET_DIR/outer/inner/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/inner (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 "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 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) + + $ 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: 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] 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) + + $ 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: 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] 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) + + $ 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) + [-0-9:.TWZ+]+ \[DEBUG] turborepo_lib::shim: Repository Root: .*/nested-workspaces\.t/outer-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 "" (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+]+ \[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/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-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 "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+]+ \[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/inner && ${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-no-turbo/inner (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 "" (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: 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) + + $ cd $TARGET_DIR/outer-no-turbo/inner/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-no-turbo/inner (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 "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 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) + + $ cd $TARGET_DIR/outer-no-turbo/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-no-turbo/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 "" (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+]+ \[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/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-no-turbo/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 "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+]+ \[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] diff --git a/cli/integration_tests/inference/nested-workspaces/README.md b/cli/integration_tests/inference/nested-workspaces/README.md new file mode 100644 index 0000000000000..a6ab30e08efbb --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/README.md @@ -0,0 +1 @@ +This is _not_ a valid configuration. It tests our behavior when given bad input. diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/docs/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/docs/package.json new file mode 100644 index 0000000000000..0ae4dfd4810ce --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/docs/package.json @@ -0,0 +1,3 @@ +{ + "name": "docs" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/web/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/web/package.json new file mode 100644 index 0000000000000..81fca2803c019 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/apps/web/package.json @@ -0,0 +1,3 @@ +{ + "name": "web" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/docs/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/docs/package.json new file mode 100644 index 0000000000000..0ae4dfd4810ce --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/docs/package.json @@ -0,0 +1,3 @@ +{ + "name": "docs" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/web/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/web/package.json new file mode 100644 index 0000000000000..81fca2803c019 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/apps/web/package.json @@ -0,0 +1,3 @@ +{ + "name": "web" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/package.json new file mode 100644 index 0000000000000..2f5423b2f9969 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/package.json @@ -0,0 +1,8 @@ +{ + "name": "inner-no-turbo", + "workspaces": [ + "apps/*", + "packages/*" + ], + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/eslint-config-custom/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/eslint-config-custom/package.json new file mode 100644 index 0000000000000..505c76aa0482e --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/eslint-config-custom/package.json @@ -0,0 +1,3 @@ +{ + "name": "eslint-config-custom" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/ui-library/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/ui-library/package.json new file mode 100644 index 0000000000000..4d3650c34aca2 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner-no-turbo/packages/ui-library/package.json @@ -0,0 +1,3 @@ +{ + "name": "ui-library" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/docs/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/docs/package.json new file mode 100644 index 0000000000000..0ae4dfd4810ce --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/docs/package.json @@ -0,0 +1,3 @@ +{ + "name": "docs" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/web/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/web/package.json new file mode 100644 index 0000000000000..81fca2803c019 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/apps/web/package.json @@ -0,0 +1,3 @@ +{ + "name": "web" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/package.json new file mode 100644 index 0000000000000..8d7eb237802c7 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/package.json @@ -0,0 +1,8 @@ +{ + "name": "inner", + "workspaces": [ + "apps/*", + "packages/*" + ], + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/eslint-config-custom/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/eslint-config-custom/package.json new file mode 100644 index 0000000000000..505c76aa0482e --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/eslint-config-custom/package.json @@ -0,0 +1,3 @@ +{ + "name": "eslint-config-custom" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/ui-library/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/ui-library/package.json new file mode 100644 index 0000000000000..4d3650c34aca2 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/packages/ui-library/package.json @@ -0,0 +1,3 @@ +{ + "name": "ui-library" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/turbo.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/turbo.json new file mode 100644 index 0000000000000..d4487028869da --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/inner/turbo.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": {} + } +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package-lock.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package-lock.json new file mode 100644 index 0000000000000..0967ef424bce6 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package-lock.json @@ -0,0 +1 @@ +{} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package.json new file mode 100644 index 0000000000000..ab1d316fca125 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/package.json @@ -0,0 +1,8 @@ +{ + "name": "outer", + "workspaces": [ + "apps/*", + "packages/*" + ], + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/eslint-config-custom/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/eslint-config-custom/package.json new file mode 100644 index 0000000000000..505c76aa0482e --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/eslint-config-custom/package.json @@ -0,0 +1,3 @@ +{ + "name": "eslint-config-custom" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/ui-library/package.json b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/ui-library/package.json new file mode 100644 index 0000000000000..4d3650c34aca2 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer-no-turbo/packages/ui-library/package.json @@ -0,0 +1,3 @@ +{ + "name": "ui-library" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/apps/docs/package.json b/cli/integration_tests/inference/nested-workspaces/outer/apps/docs/package.json new file mode 100644 index 0000000000000..0ae4dfd4810ce --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/apps/docs/package.json @@ -0,0 +1,3 @@ +{ + "name": "docs" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/apps/web/package.json b/cli/integration_tests/inference/nested-workspaces/outer/apps/web/package.json new file mode 100644 index 0000000000000..81fca2803c019 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/apps/web/package.json @@ -0,0 +1,3 @@ +{ + "name": "web" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/docs/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/docs/package.json new file mode 100644 index 0000000000000..0ae4dfd4810ce --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/docs/package.json @@ -0,0 +1,3 @@ +{ + "name": "docs" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/web/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/web/package.json new file mode 100644 index 0000000000000..81fca2803c019 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/apps/web/package.json @@ -0,0 +1,3 @@ +{ + "name": "web" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/package.json new file mode 100644 index 0000000000000..2f5423b2f9969 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/package.json @@ -0,0 +1,8 @@ +{ + "name": "inner-no-turbo", + "workspaces": [ + "apps/*", + "packages/*" + ], + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/eslint-config-custom/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/eslint-config-custom/package.json new file mode 100644 index 0000000000000..505c76aa0482e --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/eslint-config-custom/package.json @@ -0,0 +1,3 @@ +{ + "name": "eslint-config-custom" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/ui-library/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/ui-library/package.json new file mode 100644 index 0000000000000..4d3650c34aca2 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner-no-turbo/packages/ui-library/package.json @@ -0,0 +1,3 @@ +{ + "name": "ui-library" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner/apps/docs/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner/apps/docs/package.json new file mode 100644 index 0000000000000..0ae4dfd4810ce --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner/apps/docs/package.json @@ -0,0 +1,3 @@ +{ + "name": "docs" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner/apps/web/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner/apps/web/package.json new file mode 100644 index 0000000000000..81fca2803c019 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner/apps/web/package.json @@ -0,0 +1,3 @@ +{ + "name": "web" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner/package.json new file mode 100644 index 0000000000000..8d7eb237802c7 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner/package.json @@ -0,0 +1,8 @@ +{ + "name": "inner", + "workspaces": [ + "apps/*", + "packages/*" + ], + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner/packages/eslint-config-custom/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner/packages/eslint-config-custom/package.json new file mode 100644 index 0000000000000..505c76aa0482e --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner/packages/eslint-config-custom/package.json @@ -0,0 +1,3 @@ +{ + "name": "eslint-config-custom" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner/packages/ui-library/package.json b/cli/integration_tests/inference/nested-workspaces/outer/inner/packages/ui-library/package.json new file mode 100644 index 0000000000000..4d3650c34aca2 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner/packages/ui-library/package.json @@ -0,0 +1,3 @@ +{ + "name": "ui-library" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/inner/turbo.json b/cli/integration_tests/inference/nested-workspaces/outer/inner/turbo.json new file mode 100644 index 0000000000000..d4487028869da --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/inner/turbo.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": {} + } +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/package-lock.json b/cli/integration_tests/inference/nested-workspaces/outer/package-lock.json new file mode 100644 index 0000000000000..0967ef424bce6 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/package-lock.json @@ -0,0 +1 @@ +{} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/package.json b/cli/integration_tests/inference/nested-workspaces/outer/package.json new file mode 100644 index 0000000000000..ab1d316fca125 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/package.json @@ -0,0 +1,8 @@ +{ + "name": "outer", + "workspaces": [ + "apps/*", + "packages/*" + ], + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/packages/eslint-config-custom/package.json b/cli/integration_tests/inference/nested-workspaces/outer/packages/eslint-config-custom/package.json new file mode 100644 index 0000000000000..505c76aa0482e --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/packages/eslint-config-custom/package.json @@ -0,0 +1,3 @@ +{ + "name": "eslint-config-custom" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/packages/ui-library/package.json b/cli/integration_tests/inference/nested-workspaces/outer/packages/ui-library/package.json new file mode 100644 index 0000000000000..4d3650c34aca2 --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/packages/ui-library/package.json @@ -0,0 +1,3 @@ +{ + "name": "ui-library" +} diff --git a/cli/integration_tests/inference/nested-workspaces/outer/turbo.json b/cli/integration_tests/inference/nested-workspaces/outer/turbo.json new file mode 100644 index 0000000000000..d4487028869da --- /dev/null +++ b/cli/integration_tests/inference/nested-workspaces/outer/turbo.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": {} + } +} diff --git a/cli/integration_tests/inference/nested_workspaces_setup.sh b/cli/integration_tests/inference/nested_workspaces_setup.sh new file mode 100644 index 0000000000000..0ddae3103b333 --- /dev/null +++ b/cli/integration_tests/inference/nested_workspaces_setup.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) +TARGET_DIR=$1 + +cp -a ${SCRIPT_DIR}/nested-workspaces/. ${TARGET_DIR}/ +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/outer +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/outer/inner +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/outer/inner-no-turbo + +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/outer-no-turbo +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/outer-no-turbo/inner +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/outer-no-turbo/inner-no-turbo diff --git a/cli/integration_tests/inference/no-workspaces.t b/cli/integration_tests/inference/no-workspaces.t new file mode 100644 index 0000000000000..b57cc7df2f97e --- /dev/null +++ b/cli/integration_tests/inference/no-workspaces.t @@ -0,0 +1,64 @@ +Setup + $ . ${TESTDIR}/../setup.sh + $ . ${TESTDIR}/no_workspaces_setup.sh $(pwd) "no-workspaces" + + $ cd $TARGET_DIR && ${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: .*/no-workspaces\.t (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 "" (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: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re) + [-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=4c73ae6c71119fad (re) + [-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re) + \xe2\x80\xa2 Running build (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) + + $ cd $TARGET_DIR/parent && ${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: .*/no-workspaces\.t/parent (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 "" (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: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re) + [-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=96793eaf8b145bde (re) + [-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re) + \xe2\x80\xa2 Running build (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) + + $ cd $TARGET_DIR/parent/child && ${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: .*/no-workspaces\.t/parent/child (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 "" (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: global hash env vars: vars=\["VERCEL_ANALYTICS_ID"] (re) + [-0-9:.TWZ+]+ \[DEBUG] turbo: global hash: value=67527326c7931f8b (re) + [-0-9:.TWZ+]+ \[DEBUG] turbo: local cache folder: path="" (re) + \xe2\x80\xa2 Running build (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) + \ No newline at end of file diff --git a/cli/integration_tests/inference/no-workspaces/package.json b/cli/integration_tests/inference/no-workspaces/package.json new file mode 100644 index 0000000000000..550b58b06871d --- /dev/null +++ b/cli/integration_tests/inference/no-workspaces/package.json @@ -0,0 +1,4 @@ +{ + "name": "no-workspaces", + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/no-workspaces/parent/child/package.json b/cli/integration_tests/inference/no-workspaces/parent/child/package.json new file mode 100644 index 0000000000000..ad16470c8510f --- /dev/null +++ b/cli/integration_tests/inference/no-workspaces/parent/child/package.json @@ -0,0 +1,4 @@ +{ + "name": "child", + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/no-workspaces/parent/package.json b/cli/integration_tests/inference/no-workspaces/parent/package.json new file mode 100644 index 0000000000000..6be6cae031236 --- /dev/null +++ b/cli/integration_tests/inference/no-workspaces/parent/package.json @@ -0,0 +1,4 @@ +{ + "name": "parent", + "packageManager": "npm@8.0.0" +} diff --git a/cli/integration_tests/inference/no_workspaces_setup.sh b/cli/integration_tests/inference/no_workspaces_setup.sh new file mode 100644 index 0000000000000..049d83bb3c229 --- /dev/null +++ b/cli/integration_tests/inference/no_workspaces_setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) +TARGET_DIR=$1 + +cp -a ${SCRIPT_DIR}/no-workspaces/. ${TARGET_DIR}/ +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR} +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/parent +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR}/parent/child diff --git a/cli/integration_tests/inference/setup.sh b/cli/integration_tests/inference/setup.sh new file mode 100644 index 0000000000000..da909b2889ff3 --- /dev/null +++ b/cli/integration_tests/inference/setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) +TARGET_DIR=$1 +MONOREPO_DIR=$2 + +cp -a ${SCRIPT_DIR}/$MONOREPO_DIR/. ${TARGET_DIR}/ +${SCRIPT_DIR}/../setup_git.sh ${TARGET_DIR} diff --git a/crates/turborepo-lib/src/lib.rs b/crates/turborepo-lib/src/lib.rs index dfe3068a3beca..ca9d8ba0b4250 100644 --- a/crates/turborepo-lib/src/lib.rs +++ b/crates/turborepo-lib/src/lib.rs @@ -5,7 +5,6 @@ mod config; mod package_manager; mod retry; mod shim; -mod turbo_json; mod ui; use anyhow::Result; diff --git a/crates/turborepo-lib/src/shim.rs b/crates/turborepo-lib/src/shim.rs index ebb0695b5670d..c1bd5547fa403 100644 --- a/crates/turborepo-lib/src/shim.rs +++ b/crates/turborepo-lib/src/shim.rs @@ -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 @@ -235,41 +235,65 @@ impl RepoState { /// /// returns: Result pub fn infer(current_dir: &Path) -> Result { - // 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())); + // What we look for first are all directories that contain both a `package.json` + // and a `turbo.json`. + let potential_turbo_roots = current_dir.ancestors().filter(|path| { + fs::metadata(path.join("package.json")).is_ok() + && fs::metadata(path.join("turbo.json")).is_ok() + }); + + let mut first_package_json_dir = None; + + // We loop through these directories and see if there are workspaces defined in + // them, either in the `package.json` or `pnm-workspaces.yml` + for dir in potential_turbo_roots { + if first_package_json_dir.is_none() { + first_package_json_dir = Some(dir) + } - // 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 is_workspace = + pnpm.get_workspace_globs(dir).is_ok() || npm.get_workspace_globs(dir).is_ok(); - let mode = if is_workspace { - RepoMode::MultiPackage - } else { - RepoMode::SinglePackage - }; + if is_workspace { + let local_turbo_state = LocalTurboState::infer(dir); - let local_turbo_state = LocalTurboState::infer(root_path); + return Ok(Self { + root: dir.to_path_buf(), + mode: RepoMode::MultiPackage, + local_turbo_state, + }); + } + } + // No dice? Time to see if there is a `turbo.json` for this set. + if first_package_json_dir.is_some() { + let root = first_package_json_dir + .ok_or_else(|| { + anyhow!( + "Unable to find `{}` or `package.json` in current path", + TURBO_JSON + ) + })? + .to_path_buf(); + + let local_turbo_state = LocalTurboState::infer(&root); return Ok(Self { - root: root_path.to_path_buf(), - mode, + root, + mode: RepoMode::SinglePackage, local_turbo_state, }); } - // What we look for next is a directory that contains a `package.json`. + // Well, you didn't create a turbo.json, so we're going to do the best we can + // from just package.json + + // Now we try to find the closest workspace. let potential_roots = current_dir .ancestors() .filter(|path| fs::metadata(path.join("package.json")).is_ok()); - let mut first_package_json_dir = None; // We loop through these directories and see if there are workspaces defined in // them, either in the `package.json` or `pnm-workspaces.yml` for dir in potential_roots { @@ -524,11 +548,15 @@ pub fn run() -> Result { // and `--cwd` flags. if is_turbo_binary_path_set() { let repo_state = RepoState::infer(&args.cwd)?; + debug!("Repository Root: {}", repo_state.root.to_string_lossy()); return cli::run(Some(repo_state)); } match RepoState::infer(&args.cwd) { - Ok(repo_state) => repo_state.run_correct_turbo(args), + Ok(repo_state) => { + debug!("Repository Root: {}", repo_state.root.to_string_lossy()); + repo_state.run_correct_turbo(args) + } Err(err) => { // If we cannot infer, we still run global turbo. This allows for global // commands like login/logout/link/unlink to still work diff --git a/crates/turborepo-lib/src/turbo_json.rs b/crates/turborepo-lib/src/turbo_json.rs deleted file mode 100644 index f803a11ae19fb..0000000000000 --- a/crates/turborepo-lib/src/turbo_json.rs +++ /dev/null @@ -1,33 +0,0 @@ -use std::{fs::File, path::Path}; - -use anyhow::Result; -use serde::Deserialize; - -#[derive(Debug, Deserialize)] -pub struct TurboJson { - extends: Option>, -} - -impl TurboJson { - pub fn open(path: impl AsRef) -> Result { - Ok(serde_json::from_reader(File::open(path)?)?) - } - pub fn no_extends(&self) -> bool { - self.extends.is_none() - } -} - -#[test] -fn test_turbo_json() { - let turbo_json: TurboJson = serde_json::from_str("{}").unwrap(); - assert_eq!(turbo_json.extends, None); - - let turbo_json: TurboJson = serde_json::from_str(r#"{ "extends": ["//"] }"#).unwrap(); - assert_eq!(turbo_json.extends, Some(vec!["//".to_string()])); - - let turbo_json: TurboJson = serde_json::from_str(r#"{ "extends": ["//", "~"] }"#).unwrap(); - assert_eq!( - turbo_json.extends, - Some(vec!["//".to_string(), "~".to_string()]) - ); -}