Skip to content

Commit

Permalink
feat(shim): add logger (#3177)
Browse files Browse the repository at this point in the history
This parses verbosity in the shim, and then configures a shim logger
that matches the format of the go logger.

This also moves all messages about detecting local vs global and
inference to DEBUG (hidden by default)
  • Loading branch information
tknickman committed Jan 5, 2023
1 parent daaeabf commit 2b14136
Show file tree
Hide file tree
Showing 29 changed files with 118 additions and 150 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions cli/integration_tests/bad_flag.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Setup

Bad flag should print misuse text
$ ${TURBO} --bad-flag
Repository inference failed: Unable to find `turbo.json` or `package.json` in current path
Running command as global turbo
error: Found argument '--bad-flag' which wasn't expected, or isn't valid in this context

If you tried to supply '--bad-flag' as a value rather than a flag, use '-- --bad-flag'
Expand All @@ -16,8 +14,6 @@ Bad flag should print misuse text

Bad flag with an implied run command should display run flags
$ ${TURBO} build --bad-flag
Repository inference failed: Unable to find `turbo.json` or `package.json` in current path
Running command as global turbo
error: Found argument '--bad-flag' which wasn't expected, or isn't valid in this context

If you tried to supply '--bad-flag' as a value rather than a flag, use '-- --bad-flag'
Expand Down
2 changes: 0 additions & 2 deletions cli/integration_tests/basic_monorepo/profile.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ Setup
Run build and record a trace
Ignore output since we want to focus on testing the generated profile
$ ${TURBO} build --profile=build.trace > turbo.log
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
Make sure the resulting trace is valid JSON
$ node -e "require('./build.trace')"
14 changes: 4 additions & 10 deletions cli/integration_tests/basic_monorepo/verbosity.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Setup

Verbosity level 1
$ ${TURBO} build -v --filter=util --force
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -22,8 +20,6 @@ Verbosity level 1
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --verbosity=1 --filter=util --force
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
[-0-9:.TWZ+]+ \[INFO] turbo: skipping turbod since we appear to be in a non-interactive context (re)
\xe2\x80\xa2 Packages in scope: util (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
Expand All @@ -42,8 +38,8 @@ Verbosity level 1

Verbosity level 2
$ ${TURBO} build -vv --filter=util --force
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
[-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: Running command as global turbo (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)
Expand All @@ -68,8 +64,8 @@ Verbosity level 2
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --verbosity=2 --filter=util --force
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
[-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: Running command as global turbo (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)
Expand Down Expand Up @@ -98,8 +94,6 @@ Verbosity level 2

Make sure users can only use one verbosity flag
$ ${TURBO} build -v --verbosity=1
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
error: The argument '-v...' cannot be used with '--verbosity <COUNT>'

Usage: turbo [OPTIONS] [COMMAND]
Expand Down
2 changes: 0 additions & 2 deletions cli/integration_tests/find_correct_turbo.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

Make sure exit code is 2 when no args are passed
$ CURR=$(${TURBO} --cwd ${TESTDIR}/../.. bin)
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
$ diff <(readlink -f ${TURBO}) <(readlink -f ${CURR})
10 changes: 0 additions & 10 deletions cli/integration_tests/global_turbo/uses_local.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,24 @@ Setup
Make sure we use local and don't pass --skip-infer to old binary
$ . ${TESTDIR}/setup.sh 1.2.3
$ ${TURBO} build --filter foo
Running local turbo binary in .*node_modules/.bin/turbo (re)

build --filter foo --

Make sure we use local and pass --skip-infer to newer binary
$ . ${TESTDIR}/setup.sh 1.8.9
$ ${TURBO} build --filter foo
Running local turbo binary in .*node_modules/.bin/turbo (re)

--skip-infer build --filter foo --single-package --

It finds repo root and uses correct version
$ cd subdir
$ ${TURBO} build --filter foo
Running local turbo binary in .*node_modules/.bin/turbo (re)

--skip-infer build --filter foo --single-package --
$ cd ..

It respects cwd
$ ROOT=$(pwd); cd ..
$ ${TURBO} build --filter foo --cwd ${ROOT}
Running local turbo binary in .*node_modules/.bin/turbo (re)

--skip-infer build --filter foo --single-package --

It respects cwd and finds repo root
$ ${TURBO} build --filter foo --cwd ${ROOT}/subdir
Running local turbo binary in .*node_modules/.bin/turbo (re)

--skip-infer build --filter foo --single-package --
2 changes: 0 additions & 2 deletions cli/integration_tests/link.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Setup

Link Test Run
$ ${TURBO} link --__test-run
Repository inference failed: Unable to find `turbo.json` or `package.json` in current path
Running command as global turbo
Link test run successful
12 changes: 0 additions & 12 deletions cli/integration_tests/lockfile_aware_caching/berry.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Setup

Populate cache
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -17,8 +15,6 @@ Populate cache
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -35,8 +31,6 @@ Only b should have a cache miss
$ patch yarn.lock yarn-lock.patch
patching file yarn.lock
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -49,8 +43,6 @@ Only b should have a cache miss


$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -66,8 +58,6 @@ Bump of root workspace invalidates all packages
$ patch yarn.lock turbo-bump.patch
patching file yarn.lock
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -79,8 +69,6 @@ Bump of root workspace invalidates all packages
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand Down
12 changes: 0 additions & 12 deletions cli/integration_tests/lockfile_aware_caching/npm.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Setup

Populate cache
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -21,8 +19,6 @@ Populate cache
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -43,8 +39,6 @@ Only b should have a cache miss
$ patch package-lock.json package-lock.patch
patching file package-lock.json
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -61,8 +55,6 @@ Only b should have a cache miss


$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -82,8 +74,6 @@ Bump of root workspace invalidates all packages
$ patch package-lock.json turbo-bump.patch
patching file package-lock.json
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -99,8 +89,6 @@ Bump of root workspace invalidates all packages
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand Down
12 changes: 0 additions & 12 deletions cli/integration_tests/lockfile_aware_caching/pnpm.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Setup

Populate cache
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -21,8 +19,6 @@ Populate cache
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -43,8 +39,6 @@ Only b should have a cache miss
$ patch pnpm-lock.yaml pnpm-lock.patch
patching file pnpm-lock.yaml
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -61,8 +55,6 @@ Only b should have a cache miss


$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -82,8 +74,6 @@ Bump of root workspace invalidates all packages
$ patch pnpm-lock.yaml turbo-bump.patch
patching file pnpm-lock.yaml
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -99,8 +89,6 @@ Bump of root workspace invalidates all packages
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand Down
12 changes: 0 additions & 12 deletions cli/integration_tests/lockfile_aware_caching/yarn.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Setup

Populate cache
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -21,8 +19,6 @@ Populate cache
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -43,8 +39,6 @@ Only b should have a cache miss
$ patch yarn.lock yarn-lock.patch
patching file yarn.lock
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -61,8 +55,6 @@ Only b should have a cache miss


$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -82,8 +74,6 @@ Bump of root workspace invalidates all packages
$ patch yarn.lock turbo-bump.patch
patching file yarn.lock
$ ${TURBO} build --filter=a
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand All @@ -99,8 +89,6 @@ Bump of root workspace invalidates all packages
Time:\s*[\.0-9]+m?s (re)

$ ${TURBO} build --filter=b
No local turbo binary found at: .+node_modules/\.bin/turbo (re)
Running command as global turbo
\xe2\x80\xa2 Packages in scope: b (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
Expand Down
4 changes: 1 addition & 3 deletions cli/integration_tests/login.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Setup

Login Test Run
$ ${TURBO} login --__test-run
Repository inference failed: Unable to find `turbo.json` or `package.json` in current path
Running command as global turbo
Login test run successful
Login test run successful
4 changes: 0 additions & 4 deletions cli/integration_tests/logout.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ Setup

Logout while logged in
$ ${TURBO} logout
Repository inference failed: Unable to find `turbo.json` or `package.json` in current path
Running command as global turbo
>>> Logged out

Logout while logged out
$ ${TURBO} logout
Repository inference failed: Unable to find `turbo.json` or `package.json` in current path
Running command as global turbo
>>> Logged out

Loading

0 comments on commit 2b14136

Please sign in to comment.