Skip to content

Commit 8bf2985

Browse files
committed
Merge branch 'latest' into docs-using-npm-workspaces-order
2 parents de78f0c + 7fe0d8b commit 8bf2985

File tree

145 files changed

+4634
-2228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+4634
-2228
lines changed

AUTHORS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,3 +792,10 @@ Demira Dimitrova <[email protected]>
792792
793793
austincho <[email protected]>
794794
Nathan Fritz <[email protected]>
795+
796+
797+
Anders Kaseorg <[email protected]>
798+
799+
Ayush Rawal <[email protected]>
800+
Nate Green <[email protected]>
801+
Jacob Yacovelli <[email protected]>

CHANGELOG.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
1+
## v7.24.0 (2021-09-16)
2+
3+
### FEATURES
4+
5+
* [`c7787b3fb`](https://github.com/npm/cli/commit/c7787b3fb7630aab84aae83ebf9a7117c7173b6b)
6+
[`1fbbe1e04`](https://github.com/npm/cli/commit/1fbbe1e04be5d79c7b49910324e64c19ed599eeb)
7+
bundled npm-install-checks ([@wraithgar](https://github.com/wraithgar))
8+
9+
### BUG FIXES
10+
11+
* [`0320bd77e`](https://github.com/npm/cli/commit/0320bd77e2a38f48a88e377df4b122fd21043a83)
12+
[#3739](https://github.com/npm/cli/issues/3739)
13+
fix(view): Show the correct publish date for versions selected by range ([@andersk](https://github.com/andersk))
14+
* [`e4a521857`](https://github.com/npm/cli/commit/e4a5218573583149af795982a39fa64a4116cdab)
15+
[#3748](https://github.com/npm/cli/issues/3748)
16+
fix(install.sh): don't remove old npm first
17+
([@wraithgar](https://github.com/wraithgar))
18+
* [`b4aac345b`](https://github.com/npm/cli/commit/b4aac345b0a7cdec4d713c5be4daea37330b2b26)
19+
[#3754](https://github.com/npm/cli/issues/3754)
20+
fix(config): user-agent properly shows ci
21+
([@wraithgar](https://github.com/wraithgar))
22+
* [`b807cd62e`](https://github.com/npm/cli/commit/b807cd62eabe337e3243415c9870ea36d9289e12)
23+
[#3738](https://github.com/npm/cli/issues/3738)
24+
fix(search): return valid json for no results
25+
([@AyushRawal](https://github.com/AyushRawal))
26+
* [`2def17a3b`](https://github.com/npm/cli/commit/2def17a3b625b92b40c6185ff4b47e8ed006492c)
27+
[#3760](https://github.com/npm/cli/issues/3760)
28+
fix(install): use configured registry when checking manifest
29+
([@yacoman89](https://github.com/yacoman89))
30+
* [`ca792acdd`](https://github.com/npm/cli/commit/ca792acdd4ba683d8415c88188ec6739033fb4fd)
31+
[#3761](https://github.com/npm/cli/issues/3761)
32+
fix(logs): clean args for failed commands
33+
([@wraithgar](https://github.com/wraithgar))
34+
35+
### DEPENDENCIES
36+
37+
* [`59743972c`](https://github.com/npm/cli/commit/59743972c2ae1d2dd601aaa6c59974c686b1cb29)
38+
[#3747](https://github.com/npm/cli/issues/3747)
39+
fix(did-you-mean): succeed if cwd is not a package
40+
([@wraithgar](https://github.com/wraithgar))
41+
* [`ac8e4ad18`](https://github.com/npm/cli/commit/ac8e4ad18a6b726dd2c3abcb0f605701cca0ae2c)
42+
43+
* fix: bin script path
44+
* [`371655a6b`](https://github.com/npm/cli/commit/371655a6b0e6664fec67f16cb247cc9f174a5197)
45+
46+
* fix: re-emit 'error' event if missed and new listener added
47+
* fix: do not blow up if process is missing
48+
49+
### DOCUMENTATION
50+
51+
* [`4d93b484a`](https://github.com/npm/cli/commit/4d93b484abb50e3704fb436db572b93fb36c7ac3)
52+
[#3759](https://github.com/npm/cli/issues/3759)
53+
fix(docs): use correct hyperlink to package-json
54+
([@nategreen](https://github.com/nategreen))
55+
56+
## v7.23.0 (2021-09-09)
57+
58+
### FEATURES
59+
60+
* [`6c12500ae`](https://github.com/npm/cli/commit/6c12500ae14a6f8b78e3ab091ee6cc8e2ea9fd23)
61+
[#3731](https://github.com/npm/cli/issues/3731)
62+
feat(install): very strict global npm engines
63+
([@wraithgar](https://github.com/wraithgar))
64+
65+
### BUG FIXES
66+
67+
* [`1ad093824`](https://github.com/npm/cli/commit/1ad0938243110d983284e8763da41a57b561563d)
68+
[#3732](https://github.com/npm/cli/issues/3732)
69+
fix(error-message): clean urls from 404 error
70+
([@wraithgar](https://github.com/wraithgar))
71+
72+
### DOCUMENTATION
73+
74+
* [`64f7d1a55`](https://github.com/npm/cli/commit/64f7d1a55db99b1aaf8fb59557b3dedcdcd954a0)
75+
[#3727](https://github.com/npm/cli/issues/3727)
76+
docs(contributing): add note on changes to tooling
77+
([@darcyclarke](https://github.com/darcyclarke))
78+
* [`eda9162f2`](https://github.com/npm/cli/commit/eda9162f2db19b512d3af6b0d43201d54045c13a)
79+
[#3715](https://github.com/npm/cli/issues/3715)
80+
Add --if-present flag documentation to workspaces
81+
([@Matsuuu](https://github.com/Matsuuu))
82+
83+
## v7.22.0 (2021-09-02)
84+
85+
### BUG FIXES
86+
* [`6f431fe23`](https://github.com/npm/cli/commit/6f431fe2325f77b4370f95848359a36fe7a011d1)
87+
[#3690](https://github.com/npm/cli/issues/3690)
88+
Fix one “see also” link
89+
([@tripu](https://github.com/tripu))
90+
91+
### DEPENDENCIES
92+
* [`033e948c9`](https://github.com/npm/cli/commit/033e948c95b3455812e03a860ad1bd96a635e7eb)
93+
94+
* feat: add types lookup
95+
* fix(man): don't lose relative man path
96+
* [`1fa549db0`](https://github.com/npm/cli/commit/1fa549db0955b55fd680a658809a6d97be306b06)
97+
`@npmcli/[email protected]`:
98+
* feat: export npm_config_local_prefix and npm_config_global_prefix to the environment
99+
* [`e91578d10`](https://github.com/npm/cli/commit/e91578d10b1d5d930fec32e7070d975af4892140)
100+
101+
* Made rejectUnauthorized depend on NODE_TLS_REJECT_UNAUTHORIZED
102+
* [`6125db545`](https://github.com/npm/cli/commit/6125db545315da0217fe7b05062fd0a504c9a45b)
103+
104+
* [`0dcda73b0`](https://github.com/npm/cli/commit/0dcda73b022083338c4cb755390a275757b9627b)
105+
106+
* [`4b913417c`](https://github.com/npm/cli/commit/4b913417c4e30980505a02eec50810f895dd52d7)
107+
108+
* [`876c755eb`](https://github.com/npm/cli/commit/876c755eb0dfc215123682f798b5fca415f7c7d9)
109+
`@npmcli/[email protected]`:
110+
* fix: do not fail adding unresolvable optional dep
111+
1112
## v7.21.1 (2021-08-26)
2113

3114
### BUG FIXES

CONTRIBUTING.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
All interactions in the **npm** organization on GitHub are considered to be covered by our standard [Code of Conduct](https://docs.npmjs.com/policies/conduct).
66

7+
## Reporting Bugs
8+
9+
When submitting a new bug report, please first [search](https://github.com/npm/cli/issues) for an existing or similar report & then use one of our existing [issue templates](https://github.com/npm/cli/issues/new/choose) if you believe you've come across a unique problem. Duplicate issues, or issues that don't use one of our templates may get closed without a response.
10+
711
## Development
812

913
**1. Clone this repository...**
@@ -33,7 +37,7 @@ $ npm run test
3337

3438
## Test Coverage
3539

36-
We expect that every new feature or bug fix comes with corresponding tests that validate the solutions. We strive to have as close to, if not exactly, 100% code coverage.
40+
We use [`tap`](https://node-tap.org/) for testing & expect that every new feature or bug fix comes with corresponding tests that validate the solutions. We strive to have as close to, if not exactly, 100% code coverage.
3741

3842
**You can find out what the current test coverage percentage is by running...**
3943

@@ -51,10 +55,12 @@ We've set up an automated [benchmark](https://github.com/npm/benchmarks) integra
5155

5256
You can learn more about this tool, including how to run & configure it manually, [here](https://github.com/npm/benchmarks)
5357

54-
## Dependency Updates
58+
## What _not_ to contribute?
59+
60+
### Dependencies
5561

5662
It should be noted that our team does not accept third-party dependency updates/PRs. We have a [release process](https://github.com/npm/cli/wiki/Release-Process) that includes checks to ensure dependencies are staying up-to-date & will ship security patches for CVEs as they occur. If you submit a PR trying to update our dependencies we will close it with or without a reference to these contribution guidelines.
5763

58-
## Reporting Bugs
64+
### Tools/Automation
5965

60-
When submitting a new bug report, please first [search](https://github.com/npm/cli/issues) for an existing or similar report & then use one of our existing [issue templates](https://github.com/npm/cli/issues/new/choose) if you believe you've come across a unique problem. Duplicate issues, or issues that don't use one of our templates may get closed without a response.
66+
Our core team is responsible for the maintenance of the tooling/automation in this project & we ask collaborators to kindly not make changes to these when contributing (ex. `.github/*`, `.eslintrc.json`, `.licensee.json` etc.)

docs/content/commands/npm-deprecate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ password, npm will prompt on the command line for one.
7676
* [npm publish](/commands/npm-publish)
7777
* [npm registry](/using-npm/registry)
7878
* [npm owner](/commands/npm-owner)
79-
* [npm owner](/commands/npm-adduser)
79+
* [npm adduser](/commands/npm-adduser)

docs/content/using-npm/scripts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ package.json file, then your package scripts would have the
259259
in your code with `process.env.npm_package_name` and
260260
`process.env.npm_package_version`, and so on for other fields.
261261

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

264264
#### current lifecycle event
265265

docs/content/using-npm/workspaces.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ Order of run is different with:
190190
{
191191
"workspaces": [ "packages/b", "packages/a" ]
192192
}
193+
194+
195+
### Ignoring missing scripts
196+
197+
It is not required for all of the workspaces to implement scripts run with the `npm run` command.
198+
199+
By running the command with the `--if-present` flag, npm will ignore workspaces missing target script.
200+
201+
```
202+
npm run test --workspaces --if-present
193203
```
194204
195205
### See also

lib/install.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const log = require('npmlog')
88
const { resolve, join } = require('path')
99
const Arborist = require('@npmcli/arborist')
1010
const runScript = require('@npmcli/run-script')
11+
const pacote = require('pacote')
12+
const checks = require('npm-install-checks')
1113

1214
const ArboristWorkspaceCmd = require('./workspaces/arborist-cmd.js')
1315
class Install extends ArboristWorkspaceCmd {
@@ -126,6 +128,24 @@ class Install extends ArboristWorkspaceCmd {
126128
const ignoreScripts = this.npm.config.get('ignore-scripts')
127129
const isGlobalInstall = this.npm.config.get('global')
128130
const where = isGlobalInstall ? globalTop : this.npm.prefix
131+
const forced = this.npm.config.get('force')
132+
const isDev = this.npm.config.get('dev')
133+
const scriptShell = this.npm.config.get('script-shell') || undefined
134+
135+
// be very strict about engines when trying to update npm itself
136+
const npmInstall = args.find(arg => arg.startsWith('npm@') || arg === 'npm')
137+
if (isGlobalInstall && npmInstall) {
138+
const npmOptions = this.npm.flatOptions
139+
const npmManifest = await pacote.manifest(npmInstall, npmOptions)
140+
try {
141+
checks.checkEngine(npmManifest, npmManifest.version, process.version)
142+
} catch (e) {
143+
if (forced)
144+
this.npm.log.warn('install', `Forcing global npm install with incompatible version ${npmManifest.version} into node ${process.version}`)
145+
else
146+
throw e
147+
}
148+
}
129149

130150
// don't try to install the prefix into itself
131151
args = args.filter(a => resolve(a) !== this.npm.prefix)
@@ -135,7 +155,7 @@ class Install extends ArboristWorkspaceCmd {
135155
args = ['.']
136156

137157
// TODO: Add warnings for other deprecated flags? or remove this one?
138-
if (this.npm.config.get('dev'))
158+
if (isDev)
139159
log.warn('install', 'Usage of the `--dev` option is deprecated. Use `--include=dev` instead.')
140160

141161
const opts = {
@@ -150,7 +170,6 @@ class Install extends ArboristWorkspaceCmd {
150170
await arb.reify(opts)
151171

152172
if (!args.length && !isGlobalInstall && !ignoreScripts) {
153-
const scriptShell = this.npm.config.get('script-shell') || undefined
154173
const scripts = [
155174
'preinstall',
156175
'install',

lib/search/format-package-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class JSONOutputStream extends Minipass {
4242
}
4343

4444
end () {
45-
super.write(this._didFirst ? ']\n' : '\n]\n')
45+
super.write(this._didFirst ? ']\n' : '\n[]\n')
4646
super.end()
4747
}
4848
}

lib/utils/config/definitions.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,10 +2053,14 @@ define('user-agent', {
20532053
.replace(/\{workspaces\}/gi, inWorkspaces)
20542054
.replace(/\{ci\}/gi, ciName ? `ci/${ciName}` : '')
20552055
.trim()
2056+
2057+
// We can't clobber the original or else subsequent flattening will fail
2058+
// (i.e. when we change the underlying config values)
2059+
// obj[key] = flatOptions.userAgent
2060+
20562061
// user-agent is a unique kind of config item that gets set from a template
20572062
// and ends up translated. Because of this, the normal "should we set this
20582063
// to process.env also doesn't work
2059-
obj[key] = flatOptions.userAgent
20602064
process.env.npm_config_user_agent = flatOptions.userAgent
20612065
},
20622066
})
@@ -2140,6 +2144,9 @@ define('workspace', {
21402144
a workspace which does not yet exist, to create the folder and set it
21412145
up as a brand new workspace within the project.
21422146
`,
2147+
flatten: (key, obj, flatOptions) => {
2148+
definitions['user-agent'].flatten('user-agent', obj, flatOptions)
2149+
},
21432150
})
21442151

21452152
define('workspaces', {
@@ -2151,6 +2158,9 @@ define('workspaces', {
21512158
Enable running a command in the context of **all** the configured
21522159
workspaces.
21532160
`,
2161+
flatten: (key, obj, flatOptions) => {
2162+
definitions['user-agent'].flatten('user-agent', obj, flatOptions)
2163+
},
21542164
})
21552165

21562166
define('yes', {

lib/utils/did-you-mean.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ const readJson = require('read-package-json-fast')
33
const { cmdList } = require('./cmd-list.js')
44

55
const didYouMean = async (npm, path, scmd) => {
6-
const bestCmd = cmdList
6+
let best = cmdList
77
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 && scmd !== cmd)
88
.map(str => ` npm ${str} # ${npm.commands[str].description}`)
99

10-
const pkg = await readJson(`${path}/package.json`)
11-
const { scripts } = pkg
1210
// We would already be suggesting this in `npm x` so omit them here
1311
const runScripts = ['stop', 'start', 'test', 'restart']
14-
const bestRun = Object.keys(scripts || {})
15-
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 &&
16-
!runScripts.includes(cmd))
17-
.map(str => ` npm run ${str} # run the "${str}" package script`)
18-
19-
const { bin } = pkg
20-
const bestBin = Object.keys(bin || {})
21-
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4)
22-
.map(str => ` npm exec ${str} # run the "${str}" command from either this or a remote npm package`)
23-
24-
const best = [...bestCmd, ...bestRun, ...bestBin]
12+
try {
13+
const { bin, scripts } = await readJson(`${path}/package.json`)
14+
best = best.concat(
15+
Object.keys(scripts || {})
16+
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4 &&
17+
!runScripts.includes(cmd))
18+
.map(str => ` npm run ${str} # run the "${str}" package script`),
19+
Object.keys(bin || {})
20+
.filter(cmd => distance(scmd, cmd) < scmd.length * 0.4)
21+
.map(str => ` npm exec ${str} # run the "${str}" command from either this or a remote npm package`)
22+
)
23+
} catch (_) {
24+
// gracefully ignore not being in a folder w/ a package.json
25+
}
2526

2627
if (best.length === 0)
2728
return ''

0 commit comments

Comments
 (0)