Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v8.2.0 #4115

Merged
merged 17 commits into from
Dec 2, 2021
Merged

v8.2.0 #4115

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
{
"extends": ["@npmcli"]
"extends": ["@npmcli"],
"overrides": [{
"files": "test/**",
"rules": {
"no-extend-native": "off",
"no-global-assign": "off"
}
}, {
"files": ["lib/**"],
"rules": {
"no-console": "warn"
}
}]
}
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -808,3 +808,7 @@ Luke Karrys <[email protected]>
Pelle Wessman <[email protected]>
Daniel Cobo <[email protected]>
Mansur Ali Koroglu <[email protected]>
Yucel Okcu <[email protected]>
Takuya Fukuju <[email protected]>
Jan T. Sott <[email protected]>
yotamselementor <[email protected]>
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
## v8.2.0 (2021-12-02)

### Features

* [`6734ba36d`](https://github.com/npm/cli/commit/6734ba36dd6e07a859ab4d6eb4f264d2c0022276)
[#4062](https://github.com/npm/cli/issues/4062)
feat: streaming debug logfile
([@lukekarrys](https://github.com/lukekarrys))

### Bug Fixes

* [`5f4040aa0`](https://github.com/npm/cli/commit/5f4040aa0e30a3b74caab64958770c682e4d0031)
chore: remove get-project-scope utils
([@Yucel Okcu](https://github.com/Yucel Okcu))
* [`c5c6d1603`](https://github.com/npm/cli/commit/c5c6d1603b06df4c10b503047aeed34d6e0c36c2)
[#4060](https://github.com/npm/cli/issues/4060)
fix: add missing scope on flat options
([@yuqu](https://github.com/yuqu))
* [`47828b766`](https://github.com/npm/cli/commit/47828b766a4a7b50c1245c8f01b99ffbeffd014f)
chore: update one-time password prompt
([@Darcy Clarke](https://github.com/Darcy Clarke))

### Documentation

* [`fc46a7926`](https://github.com/npm/cli/commit/fc46a792621c89354eddc0e1ee2d4f5c26efe5a5)
[#4072](https://github.com/npm/cli/issues/4072)
docs: fix typo in `save-peer` description
([@chalkygames123](https://github.com/chalkygames123))
* [`2fbf1576f`](https://github.com/npm/cli/commit/2fbf1576f5427babab2bdf314b1760adc5f9a575)
[#4081](https://github.com/npm/cli/issues/4081)
docs: Fix typo
([@idleberg](https://github.com/idleberg))
* [`a8bc95f11`](https://github.com/npm/cli/commit/a8bc95f11c9d21319581d7b09baf9f864bea21ac)
[#4089](https://github.com/npm/cli/issues/4089)
docs(workspaces): Fix typo
([@yotamselementor](https://github.com/yotamselementor))
* [`31b098ee2`](https://github.com/npm/cli/commit/31b098ee26ed17facb132278bb3205e80e2a760d)
[#4113](https://github.com/npm/cli/issues/4113)
docs: add logging docs
([@darcyclarke](https://github.com/darcyclarke))
* [`cbae0fb71`](https://github.com/npm/cli/commit/cbae0fb71cea55004f7066c0dfc870137b53ee8b)
[#4114](https://github.com/npm/cli/issues/4114)
docs: update description about where/when debug log is written
([@lukekarrys](https://github.com/lukekarrys))


### Dependencies

* [`037f2cc8c`](https://github.com/npm/cli/commit/037f2cc8c8ed9d9a092475a5a07f2a3a88915633)
[#4078](https://github.com/npm/cli/issues/4078)
`[email protected]`
* [`0e63df612`](https://github.com/npm/cli/commit/0e63df61283a2f7ace991f72e4577c6f23ffc5df)
[#4102](https://github.com/npm/cli/issues/4102)
`@npmcli/[email protected]`:
* fix: always load localPrefix

## v8.1.4 (2021-11-18)

### BUG FIXES
Expand Down
6 changes: 3 additions & 3 deletions docs/content/using-npm/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,8 @@ Ideal if all users are on npm version 7 and higher.
* Type: "silent", "error", "warn", "notice", "http", "timing", "info",
"verbose", or "silly"

What level of logs to report. On failure, *all* logs are written to
`npm-debug.log` in the current working directory.
What level of logs to report. All logs are written to a debug log, with the
path to that file printed if the execution of a command fails.

Any logs of a higher level than the setting are shown. The default is
"notice".
Expand Down Expand Up @@ -1387,7 +1387,7 @@ Save installed packages to a package.json file as `optionalDependencies`.
* Default: false
* Type: Boolean

Save installed packages. to a package.json file as `peerDependencies`
Save installed packages to a package.json file as `peerDependencies`

<!-- automatically generated, do not edit manually -->
<!-- see lib/utils/config/definitions.js -->
Expand Down
60 changes: 60 additions & 0 deletions docs/content/using-npm/logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: Logging
section: 7
description: Why, What & How we Log
---

### Description

The `npm` CLI has various mechanisms for showing different levels of information back to end-users for certain commands, configurations & environments.

### Setting Log Levels

#### `loglevel`

`loglevel` is a global argument/config that can be set to determine the type of information to be displayed.

The default value of `loglevel` is `"notice"` but there are several levels/types of logs available, including:

- `"silent"`
- `"error"`
- `"warn"`
- `"notice"`
- `"http"`
- `"timing"`
- `"info"`
- `"verbose"`
- `"silly"`

All logs pertaining to a level proceeding the current setting will be shown.

All logs are written to a debug log, with the path to that file printed if the execution of a command fails.

##### Aliases

The log levels listed above have various corresponding aliases, including:

- `-d`: `--loglevel info`
- `--dd`: `--loglevel verbose`
- `--verbose`: `--loglevel verbose`
- `--ddd`: `--loglevel silly`
- `-q`: `--loglevel warn`
- `--quiet`: `--loglevel warn`
- `-s`: `--loglevel silent`
- `--silent`: `--loglevel silent`

#### `foreground-scripts`

The `npm` CLI began hiding the output of lifecycle scripts for `npm install` as of `v7`. Notably, this means you will not see logs/output from packages that may be using "install scripts" to display information back to you or from your own project's scripts defined in `package.json`. If you'd like to change this behavior & log this output you can set `foreground-scripts` to `true`.

### Registry Response Headers

#### `npm-notice`

The `npm` CLI reads from & logs any `npm-notice` headers that are returned from the configured registry. This mechanism can be used by third-party registries to provide useful information when network-dependent requests occur.

This header is not cached, and will not be logged if the request is served from the cache.

### See also

* [config](/using-npm/config)
2 changes: 1 addition & 1 deletion docs/content/using-npm/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ package.json file, then your package scripts would have the
in your code with `process.env.npm_package_name` and
`process.env.npm_package_version`, and so on for other fields.

See [`package-json.md`](/configuring-npm/package-json) for more on package configs.
See [`package.json`](/configuring-npm/package-json) for more on package configs.

#### current lifecycle event

Expand Down
2 changes: 1 addition & 1 deletion docs/content/using-npm/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Working with workspaces

**Workspaces** is a generic term that refers to the set of features in the
npm cli that provides support to managing multiple packages from your local
files system from within a singular top-level, root package.
file system from within a singular top-level, root package.

This set of features makes up for a much more streamlined workflow handling
linked packages from the local file system. Automating the linking process
Expand Down
3 changes: 3 additions & 0 deletions docs/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@
- title: Config
url: /using-npm/config
description: About npm configuration
- title: Logging
url: /using-npm/logging
description: Why, What & How we Log
- title: Scope
url: /using-npm/scope
description: Scoped packages
Expand Down
11 changes: 4 additions & 7 deletions lib/auth/legacy.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const log = require('npmlog')
const profile = require('npm-profile')

const log = require('../utils/log-shim')
const openUrl = require('../utils/open-url.js')
const read = require('../utils/read-user-info.js')

const loginPrompter = async (creds) => {
const opts = { log: log }

creds.username = await read.username('Username:', creds.username, opts)
creds.username = await read.username('Username:', creds.username)
creds.password = await read.password('Password:', creds.password)
creds.email = await read.email('Email: (this IS public) ', creds.email, opts)
creds.email = await read.email('Email: (this IS public) ', creds.email)

return creds
}
Expand All @@ -19,7 +16,7 @@ const login = async (npm, opts) => {

const requestOTP = async () => {
const otp = await read.otp(
'Enter one-time password from your authenticator app: '
'Enter one-time password: '
)

return profile.loginCouch(
Expand Down
3 changes: 1 addition & 2 deletions lib/auth/sso.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
// CLI, we can remove this, and fold the lib/auth/legacy.js back into
// lib/adduser.js

const log = require('npmlog')
const profile = require('npm-profile')
const npmFetch = require('npm-registry-fetch')

const log = require('../utils/log-shim')
const openUrl = require('../utils/open-url.js')
const otplease = require('../utils/otplease.js')

Expand Down
33 changes: 17 additions & 16 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ module.exports = async process => {
// leak any private CLI configs to other programs
process.title = 'npm'

const { checkForBrokenNode, checkForUnsupportedNode } = require('../lib/utils/unsupported.js')

// We used to differentiate between known broken and unsupported
// versions of node and attempt to only log unsupported but still run.
// After we dropped node 10 support, we can use new features
// (like static, private, etc) which will only give vague syntax errors,
// so now both broken and unsupported use console, but only broken
// will process.exit. It is important to now perform *both* of these
// checks as early as possible so the user gets the error message.
const { checkForBrokenNode, checkForUnsupportedNode } = require('./utils/unsupported.js')
checkForBrokenNode()

const log = require('npmlog')
// pause it here so it can unpause when we've loaded the configs
// and know what loglevel we should be printing.
log.pause()

checkForUnsupportedNode()

const Npm = require('../lib/npm.js')
const exitHandler = require('./utils/exit-handler.js')
process.on('uncaughtException', exitHandler)
process.on('unhandledRejection', exitHandler)

const Npm = require('./npm.js')
const npm = new Npm()
const exitHandler = require('../lib/utils/exit-handler.js')
exitHandler.setNpm(npm)

// if npm is called as "npmg" or "npm_g", then
Expand All @@ -26,16 +29,14 @@ module.exports = async process => {
process.argv.splice(1, 1, 'npm', '-g')
}

const replaceInfo = require('../lib/utils/replace-info.js')
const log = require('./utils/log-shim.js')
const replaceInfo = require('./utils/replace-info.js')
log.verbose('cli', replaceInfo(process.argv))

log.info('using', 'npm@%s', npm.version)
log.info('using', 'node@%s', process.version)

process.on('uncaughtException', exitHandler)
process.on('unhandledRejection', exitHandler)

const updateNotifier = require('../lib/utils/update-notifier.js')
const updateNotifier = require('./utils/update-notifier.js')

let cmd
// now actually fire up npm and run the command.
Expand Down Expand Up @@ -63,7 +64,7 @@ module.exports = async process => {
}

await npm.exec(cmd, npm.argv)
exitHandler()
return exitHandler()
} catch (err) {
if (err.code === 'EUNKNOWNCOMMAND') {
const didYouMean = require('./utils/did-you-mean.js')
Expand Down
3 changes: 2 additions & 1 deletion lib/commands/adduser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const log = require('npmlog')
const log = require('../utils/log-shim.js')
const replaceInfo = require('../utils/replace-info.js')
const BaseCommand = require('../base-command.js')
const authTypes = {
Expand Down Expand Up @@ -31,6 +31,7 @@ class AddUser extends BaseCommand {
creds,
registry,
scope,
log,
})

await this.updateConfig({
Expand Down
1 change: 1 addition & 0 deletions lib/commands/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Bin extends BaseCommand {
const b = this.npm.bin
this.npm.output(b)
if (this.npm.config.get('global') && !envPath.includes(b)) {
// XXX: does this need to be console?
console.error('(not in PATH env variable)')
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/bugs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const log = require('npmlog')
const pacote = require('pacote')
const log = require('../utils/log-shim')
const openUrl = require('../utils/open-url.js')
const hostedFromMani = require('../utils/hosted-git-info-from-manifest.js')
const BaseCommand = require('../base-command.js')
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/cache.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const cacache = require('cacache')
const { promisify } = require('util')
const log = require('npmlog')
const pacote = require('pacote')
const path = require('path')
const rimraf = promisify(require('rimraf'))
Expand All @@ -9,6 +8,7 @@ const BaseCommand = require('../base-command.js')
const npa = require('npm-package-arg')
const jsonParse = require('json-parse-even-better-errors')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const log = require('../utils/log-shim')

const searchCachePackage = async (path, spec, cacheKeys) => {
const parsed = npa(spec)
Expand Down Expand Up @@ -141,7 +141,7 @@ class Cache extends BaseCommand {
try {
entry = await cacache.get(cachePath, key)
} catch (err) {
this.npm.log.warn(`Not Found: ${key}`)
log.warn(`Not Found: ${key}`)
break
}
this.npm.output(`Deleted: ${key}`)
Expand Down
5 changes: 2 additions & 3 deletions lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const reifyFinish = require('../utils/reify-finish.js')
const runScript = require('@npmcli/run-script')
const fs = require('fs')
const readdir = util.promisify(fs.readdir)

const log = require('npmlog')
const log = require('../utils/log-shim.js')

const removeNodeModules = async where => {
const rimrafOpts = { glob: false }
Expand Down Expand Up @@ -39,7 +38,7 @@ class CI extends ArboristWorkspaceCmd {
const opts = {
...this.npm.flatOptions,
path: where,
log: this.npm.log,
log,
save: false, // npm ci should never modify the lockfile or package.json
workspaces: this.workspaceNames,
}
Expand Down
Loading