Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
feat: streaming debug logfile
This decouples the log file writing from the terminal logging. We now open an append only file at the start of the process and stream logs to it. We still only display the log file message in timing mode or if there is an error, but the file is still written regardless. All logging now goes through `proc-log` and this is the first step to removing `npmlog`. For now `npmlog` is still used for the terminal logging but with a shim in front of it to make it easier to test and use in conjunction with `proc-log`. Ref: npm/statusboard#366 This also refactors many of the tests to always use an explicit `t.testdir` for their cache since the file is opened on each `new Npm()`. Tests are also refactored to use more of `MockNpm` with behavior to add config items and load `npm` if necessary. A new fixture `mockGlobals` was also added to make much of this more ergonomic. Ref: npm/statusboard#410 Closes npm/statusboard#411 Closes npm/statusboard#367 PR-URL: #4062 Credit: @lukekarrys Close: #4062 Reviewed-by: @wraithgar
- Loading branch information
Showing
with
4,631 additions
and 3,286 deletions.
- +13 −1 .eslintrc.json
- +3 −6 lib/auth/legacy.js
- +1 −2 lib/auth/sso.js
- +17 −16 lib/cli.js
- +2 −1 lib/commands/adduser.js
- +1 −0 lib/commands/bin.js
- +1 −1 lib/commands/bugs.js
- +2 −2 lib/commands/cache.js
- +2 −3 lib/commands/ci.js
- +6 −5 lib/commands/config.js
- +2 −1 lib/commands/dedupe.js
- +7 −9 lib/commands/diff.js
- +1 −2 lib/commands/dist-tag.js
- +1 −2 lib/commands/docs.js
- +9 −8 lib/commands/doctor.js
- +1 −1 lib/commands/exec.js
- +4 −3 lib/commands/explore.js
- +2 −1 lib/commands/fund.js
- +8 −8 lib/commands/init.js
- +3 −3 lib/commands/install.js
- +6 −5 lib/commands/link.js
- +1 −1 lib/commands/logout.js
- +1 −2 lib/commands/owner.js
- +3 −6 lib/commands/pack.js
- +1 −1 lib/commands/ping.js
- +1 −1 lib/commands/profile.js
- +2 −1 lib/commands/prune.js
- +3 −3 lib/commands/publish.js
- +1 −2 lib/commands/repo.js
- +1 −1 lib/commands/run-script.js
- +1 −1 lib/commands/search.js
- +1 −1 lib/commands/set-script.js
- +1 −2 lib/commands/shrinkwrap.js
- +1 −2 lib/commands/star.js
- +1 −2 lib/commands/stars.js
- +1 −1 lib/commands/token.js
- +2 −1 lib/commands/uninstall.js
- +4 −4 lib/commands/unpublish.js
- +2 −2 lib/commands/update.js
- +2 −2 lib/commands/view.js
- +101 −52 lib/npm.js
- +3 −1 lib/utils/audit-error.js
- +0 −35 lib/utils/cleanup-log-files.js
- +8 −1 lib/utils/config/definitions.js
- +1 −1 lib/utils/deref-command.js
- +119 −0 lib/utils/display.js
- +6 −3 lib/utils/error-message.js
- +77 −130 lib/utils/exit-handler.js
- +245 −0 lib/utils/log-file.js
- +59 −0 lib/utils/log-shim.js
- +0 −22 lib/utils/proc-log-listener.js
- +1 −1 lib/utils/pulse-till-done.js
- +7 −7 lib/utils/read-user-info.js
- +1 −1 lib/utils/reify-output.js
- +0 −66 lib/utils/setup-log.js
- +2 −2 lib/utils/tar.js
- +111 −0 lib/utils/timers.js
- +11 −5 lib/utils/unsupported.js
- +2 −1 lib/utils/update-notifier.js
- +1 −1 lib/utils/usage.js
- +13 −0 lib/utils/with-chown-sync.js
- +2 −0 package-lock.json
- +2 −0 package.json
- +4 −2 tap-snapshots/test/lib/commands/config.js.test.cjs
- +35 −35 tap-snapshots/test/lib/commands/shrinkwrap.js.test.cjs
- +4 −4 tap-snapshots/test/lib/commands/view.js.test.cjs
- +60 −23 tap-snapshots/test/lib/utils/error-message.js.test.cjs
- +51 −11 tap-snapshots/test/lib/utils/exit-handler.js.test.cjs
- +68 −0 tap-snapshots/test/lib/utils/log-file.js.test.cjs
- +19 −0 test/fixtures/clean-snapshot.js
- +210 −0 test/fixtures/mock-globals.js
- +71 −0 test/fixtures/mock-logs.js
- +115 −75 test/fixtures/mock-npm.js
- +25 −21 test/fixtures/sandbox.js
- +3 −1 test/index.js
- +1 −1 test/lib/auth/legacy.js
- +1 −1 test/lib/auth/sso.js
- +79 −103 test/lib/cli.js
- +151 −156 test/lib/commands/access.js
- +9 −0 test/lib/commands/adduser.js
- +70 −73 test/lib/commands/audit.js
- +7 −6 test/lib/commands/birthday.js
- +8 −11 test/lib/commands/cache.js
- +1 −1 test/lib/commands/ci.js
- +87 −162 test/lib/commands/completion.js
- +32 −29 test/lib/commands/dedupe.js
- +1 −1 test/lib/commands/diff.js
- +1 −1 test/lib/commands/dist-tag.js
- +40 −43 test/lib/commands/doctor.js
- +19 −11 test/lib/commands/exec.js
- +7 −4 test/lib/commands/explore.js
- +18 −17 test/lib/commands/find-dupes.js
- +2 −4 test/lib/commands/get.js
- +17 −15 test/lib/commands/init.js
- +21 −41 test/lib/commands/install.js
- +70 −61 test/lib/commands/logout.js
- +11 −11 test/lib/commands/owner.js
- +73 −73 test/lib/commands/pack.js
- +3 −3 test/lib/commands/ping.js
- +2 −3 test/lib/commands/prefix.js
- +17 −15 test/lib/commands/profile.js
- +14 −12 test/lib/commands/prune.js
- +22 −9 test/lib/commands/publish.js
- +45 −46 test/lib/commands/repo.js
- +17 −17 test/lib/commands/restart.js
- +2 −3 test/lib/commands/root.js
- +9 −3 test/lib/commands/run-script.js
- +1 −1 test/lib/commands/set-script.js
- +1 −0 test/lib/commands/set.js
- +13 −21 test/lib/commands/shrinkwrap.js
- +5 −5 test/lib/commands/star.js
- +6 −6 test/lib/commands/stars.js
- +17 −16 test/lib/commands/start.js
- +15 −15 test/lib/commands/stop.js
- +16 −16 test/lib/commands/test.js
- +17 −7 test/lib/commands/token.js
- +5 −4 test/lib/commands/unpublish.js
- +15 −13 test/lib/commands/update.js
- +256 −248 test/lib/commands/version.js
- +10 −8 test/lib/commands/view.js
- +9 −11 test/lib/commands/whoami.js
- +321 −0 test/lib/fixtures/mock-globals.js
- +4 −9 test/lib/load-all-commands.js
- +18 −21 test/lib/load-all.js
- +261 −267 test/lib/npm.js
- +5 −4 test/lib/utils/audit-error.js
- +0 −79 test/lib/utils/cleanup-log-files.js
- +67 −40 test/lib/utils/config/definitions.js
- +2 −4 test/lib/utils/did-you-mean.js
- +85 −0 test/lib/utils/display.js
- +104 −160 test/lib/utils/error-message.js
- +332 −286 test/lib/utils/exit-handler.js
- +18 −16 test/lib/utils/is-windows-bash.js
- +333 −0 test/lib/utils/log-file.js
- +100 −0 test/lib/utils/log-shim.js
- +2 −4 test/lib/utils/npm-usage.js
- +0 −41 test/lib/utils/proc-log-listener.js
- +9 −10 test/lib/utils/pulse-till-done.js
- +14 −16 test/lib/utils/read-user-info.js
- +4 −3 test/lib/utils/reify-output.js
- +0 −296 test/lib/utils/setup-log.js
- +16 −36 test/lib/utils/tar.js
- +82 −0 test/lib/utils/timers.js
- +21 −31 test/lib/utils/unsupported.js
- +31 −39 test/lib/utils/update-notifier.js
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,3 +1,15 @@ | ||
{ | ||
"extends": ["@npmcli"], | ||
"overrides": [{ | ||
"files": "test/**", | ||
"rules": { | ||
"no-extend-native": "off", | ||
"no-global-assign": "off" | ||
} | ||
}, { | ||
"files": ["lib/**"], | ||
"rules": { | ||
"no-console": "warn" | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.