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

v7.21.1 #3688

Merged
merged 13 commits into from Aug 26, 2021
32 changes: 32 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,35 @@
## v7.21.1 (2021-08-26)

### BUG FIXES

* [`4e52217cb`](https://github.com/npm/cli/commit/4e52217cb25a697b0f6b0131bcb8c87e0dbcda53)
[#3684](https://github.com/npm/cli/issues/3684)
fix(config): respect --global, --package-lock-only
([@nlf](https://github.com/nlf))

### DEPENDENCIES

* [`e3878536f`](https://github.com/npm/cli/commit/e3878536f3612d9ddc3002c126cfa9a91021c7db)
`make-fetch-happen@9.1.0`:
* fix: use the same strictSSL default as tls.connect
* [`145f70cc1`](https://github.com/npm/cli/commit/145f70cc1b78dee4ffa53f557fa72d0948696839)
`read-package-json@4.0.1`:
* fix: Add gitHead in subdirectories too
* fix(man): don't resolve paths to man files
* [`3f4d37143`](https://github.com/npm/cli/commit/3f4d371432a1fc8280e73d8467acd0eed0bbef26)
`tar@6.1.11`:
* fix: perf regression on hot string munging path
* [`e63a942c6`](https://github.com/npm/cli/commit/e63a942c685233fa546788981ed9c144220d50e1)
`cacache@15.3.0`:
* feat: introduce @npmcli/fs for tmp dir methods

### DOCUMENTATION

* [`957fa6040`](https://github.com/npm/cli/commit/957fa604035992285572f63c38545eea86bbb1ff)
[#3681](https://github.com/npm/cli/issues/3681)
clarify uninstall lifecycle script
([@fritzy](https://github.com/fritzy))

## v7.21.0 (2021-08-19)

### FEATURES
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -30,7 +30,12 @@ all: docs

docs: mandocs htmldocs

# don't regenerate the snapshot if we're generating
# snapshots, since presumably we just did that.
mandocs: dev-deps $(mandocs)
@ ! [ $${npm_lifecycle_event} = "snap" ] && \
! [ $${npm_lifecycle_event} = "postsnap" ] && \
TAP_SNAPSHOT=1 node test/lib/utils/config/definitions.js || true

$(version_mandocs): package.json

Expand Down
13 changes: 13 additions & 0 deletions docs/content/using-npm/scripts.md
Expand Up @@ -203,6 +203,19 @@ will default the `start` command to `node server.js`. `prestart` and
* `test`
* `posttest`

#### A Note on a lack of [`npm uninstall`](/commands/npm-uninstall) scripts

While npm v6 had `uninstall` lifecycle scripts, npm v7 does not. Removal of a package can happen for a wide variety of reasons, and there's no clear way to currently give the script enough context to be useful.

Reasons for a package removal include:

* a user directly uninstalled this package
* a user uninstalled a dependant package and so this dependency is being uninstalled
* a user uninstalled a dependant package but another package also depends on this version
* this version has been merged as a duplicate with another version
* etc.

Due to the lack of necessary context, `uninstall` lifecycle scripts are not implemented and will not function.

### User

Expand Down
11 changes: 6 additions & 5 deletions lib/config.js
Expand Up @@ -121,7 +121,7 @@ class Config extends BaseCommand {
break
case 'list':
case 'ls':
await (this.npm.config.get('json') ? this.listJson() : this.list())
await (this.npm.flatOptions.json ? this.listJson() : this.list())
break
case 'edit':
await this.edit()
Expand All @@ -138,7 +138,7 @@ class Config extends BaseCommand {
if (!args.length)
throw this.usageError()

const where = this.npm.config.get('location')
const where = this.npm.flatOptions.location
for (const [key, val] of Object.entries(keyValues(args))) {
this.npm.log.info('config', 'set %j %j', key, val)
this.npm.config.set(key, val || '', where)
Expand Down Expand Up @@ -168,15 +168,15 @@ class Config extends BaseCommand {
if (!keys.length)
throw this.usageError()

const where = this.npm.config.get('location')
const where = this.npm.flatOptions.location
for (const key of keys)
this.npm.config.delete(key, where)
await this.npm.config.save(where)
}

async edit () {
const e = this.npm.config.get('editor')
const where = this.npm.config.get('location')
const e = this.npm.flatOptions.editor
const where = this.npm.flatOptions.location
const file = this.npm.config.data.get(where).source

// save first, just to make sure it's synced up
Expand Down Expand Up @@ -232,6 +232,7 @@ ${defData}

async list () {
const msg = []
// long does not have a flattener
const long = this.npm.config.get('long')
for (const [where, { data, source }] of this.npm.config.data.entries()) {
if (where === 'default' && !long)
Expand Down
30 changes: 19 additions & 11 deletions lib/utils/config/definitions.js
Expand Up @@ -804,7 +804,11 @@ define('global', {
* bin files are linked to \`{prefix}/bin\`
* man pages are linked to \`{prefix}/share/man\`
`,
flatten,
flatten: (key, obj, flatOptions) => {
flatten(key, obj, flatOptions)
if (flatOptions.global)
flatOptions.location = 'global'
},
})

define('global-style', {
Expand Down Expand Up @@ -1131,14 +1135,10 @@ define('location', {
description: `
When passed to \`npm config\` this refers to which config file to use.
`,
// NOTE: the flattener here deliberately does not alter the value of global
// for now, this is to avoid inadvertently causing any breakage. the value of
// global, however, does modify this flag.
flatten (key, obj, flatOptions) {
// if global is set, we override ourselves
if (obj.global)
obj.location = 'global'
flatOptions.location = obj.location
flatten: (key, obj, flatOptions) => {
flatten(key, obj, flatOptions)
if (flatOptions.global)
flatOptions.location = 'global'
},
})

Expand Down Expand Up @@ -1359,7 +1359,11 @@ define('package-lock', {
modules will also be disabled. To remove extraneous modules with
package-locks disabled use \`npm prune\`.
`,
flatten,
flatten: (key, obj, flatOptions) => {
flatten(key, obj, flatOptions)
if (flatOptions.packageLockOnly)
flatOptions.packageLock = true
},
})

define('package-lock-only', {
Expand All @@ -1375,7 +1379,11 @@ define('package-lock-only', {
For \`list\` this means the output will be based on the tree described by the
\`package-lock.json\`, rather than the contents of \`node_modules\`.
`,
flatten,
flatten: (key, obj, flatOptions) => {
flatten(key, obj, flatOptions)
if (flatOptions.packageLockOnly)
flatOptions.packageLock = true
},
})

define('pack-destination', {
Expand Down
36 changes: 36 additions & 0 deletions node_modules/@gar/promisify/index.js

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

32 changes: 32 additions & 0 deletions node_modules/@gar/promisify/package.json

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

18 changes: 18 additions & 0 deletions node_modules/@npmcli/fs/LICENSE.md

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

17 changes: 17 additions & 0 deletions node_modules/@npmcli/fs/lib/common/file-url-to-path/index.js

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

120 changes: 120 additions & 0 deletions node_modules/@npmcli/fs/lib/common/file-url-to-path/polyfill.js

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