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.24.2 #3818

Closed
wants to merge 14 commits into from
3 changes: 3 additions & 0 deletions AUTHORS
Expand Up @@ -800,3 +800,6 @@ Ayush Rawal <royalrawal.2001@gmail.com>
Nate Green <heynategreen@gmail.com>
Jacob Yacovelli <jjyacovelli@gmail.com>
Caleb ツ Everett <calebev@amazon.com>
gfyoung <gfyoung17@gmail.com>
Edward Thomson <ethomson@github.com>
Behnam Mohammadi <itten@live.com>
43 changes: 43 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,46 @@
## v7.24.2 (2021-09-30)

### BUG FIXES

* [`56d6cfdc0`](https://github.com/npm/cli/commit/56d6cfdc0745fe919645389b94efb36760eb4179)
[#3804](https://github.com/npm/cli/issues/3804)
encode url before opening
([@isaacs](https://github.com/isaacs))
* [`075fe5056`](https://github.com/npm/cli/commit/075fe50565ae5c66df727cdd7df9dd5ed8cd4015)
[#3799](https://github.com/npm/cli/issues/3799)
restore exit code on "npm outdated"
([@gfyoung](https://github.com/gfyoung))
* [`dbb90f799`](https://github.com/npm/cli/commit/dbb90f7997900b8ae6026dddaa718efe9a1db2f4)
[#3809](https://github.com/npm/cli/issues/3809)
use Intl.Collator for string sorting when available
([@isaacs](https://github.com/isaacs))

### DEPENDENCIES

* [`69ab10bbf`](https://github.com/npm/cli/commit/69ab10bbf83d42a5d3b5d3f43e5e5b861f3dfed0)
`is-core-module@2.7.0`
* [`e94ddeaca`](https://github.com/npm/cli/commit/e94ddeaca1e75ecc8f54ebcb3df222965e3635d1)
`@npmcli/arborist@2.9.0`:
* fix: avoid infinite loops in peer dep replacements
* fix: use Intl.Collator for string sorting when available
* feat(vuln): expose isDirect
* [`8349c3c15`](https://github.com/npm/cli/commit/8349c3c1557ac52973ad08c10db492e3a5a30204)
[#3815](https://github.com/npm/cli/issues/3815)
`arborist@2.10.0`:
* includeWorkspaceRoot support
* workspacesEnabled=false support

### DOCUMENTATION

* [`f425950a6`](https://github.com/npm/cli/commit/f425950a6ca671b2df20703f70b59022c2858d4d)
[#3805](https://github.com/npm/cli/issues/3805)
remove npm Enterprise from documentation
([@ethomson](https://github.com/ethomson))
* [`bb0b2da6c`](https://github.com/npm/cli/commit/bb0b2da6c0275dd8c9eda894452ce45b2e8c4c51)
[#3699](https://github.com/npm/cli/issues/3699)
fix(docs): add note about workspace script order
([@behnammodi](https://github.com/behnammodi))

## v7.24.1 (2021-09-23)

### DEPENDENCIES
Expand Down
3 changes: 2 additions & 1 deletion docs/content/using-npm/scope.md
Expand Up @@ -98,7 +98,8 @@ desired, with `npm access` or on the npmjs.com website.

Scopes can be associated with a separate registry. This allows you to
seamlessly use a mix of packages from the primary npm registry and one or more
private registries, such as npm Enterprise.
private registries, such as [GitHub Packages](https://github.com/features/packages) or the open source [Verdaccio](https://verdaccio.org)
project.

You can associate a scope with a registry at login, e.g.

Expand Down
16 changes: 16 additions & 0 deletions docs/content/using-npm/workspaces.md
Expand Up @@ -176,6 +176,22 @@ npm run test --workspaces

Will run the `test` script in both `./packages/a` and `./packages/b`.

Commands will be run in each workspace in the order they appear in your `package.json`

```
{
"workspaces": [ "packages/a", "packages/b" ]
}
```

Order of run is different with:

```
{
"workspaces": [ "packages/b", "packages/a" ]
}
```

### Ignoring missing scripts

It is not required for all of the workspaces to implement scripts run with the `npm run` command.
Expand Down
5 changes: 3 additions & 2 deletions lib/cache.js
Expand Up @@ -8,6 +8,7 @@ const semver = require('semver')
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 searchCachePackage = async (path, spec, cacheKeys) => {
const parsed = npa(spec)
Expand Down Expand Up @@ -212,10 +213,10 @@ class Cache extends BaseCommand {
for (const key of keySet)
results.add(key)
}
[...results].sort((a, b) => a.localeCompare(b, 'en')).forEach(key => this.npm.output(key))
[...results].sort(localeCompare).forEach(key => this.npm.output(key))
return
}
cacheKeys.sort((a, b) => a.localeCompare(b, 'en')).forEach(key => this.npm.output(key))
cacheKeys.sort(localeCompare).forEach(key => this.npm.output(key))
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/config.js
Expand Up @@ -10,6 +10,7 @@ const writeFile = promisify(fs.writeFile)
const { spawn } = require('child_process')
const { EOL } = require('os')
const ini = require('ini')
const localeCompare = require('@isaacs/string-locale-compare')('en')

// take an array of `[key, value, k2=v2, k3, v3, ...]` and turn into
// { key: value, k2: v2, k3: v3 }
Expand Down Expand Up @@ -209,7 +210,7 @@ class Config extends BaseCommand {
; Configs like \`//<hostname>/:_authToken\` are auth that is restricted
; to the registry host specified.

${data.split('\n').sort((a, b) => a.localeCompare(b, 'en')).join('\n').trim()}
${data.split('\n').sort(localeCompare).join('\n').trim()}

;;;;
; all available options shown below with default values
Expand Down Expand Up @@ -238,7 +239,7 @@ ${defData}
if (where === 'default' && !long)
continue

const keys = Object.keys(data).sort((a, b) => a.localeCompare(b, 'en'))
const keys = Object.keys(data).sort(localeCompare)
if (!keys.length)
continue

Expand Down
3 changes: 2 additions & 1 deletion lib/help.js
Expand Up @@ -3,6 +3,7 @@ const path = require('path')
const openUrl = require('./utils/open-url.js')
const { promisify } = require('util')
const glob = promisify(require('glob'))
const localeCompare = require('@isaacs/string-locale-compare')('en')

const BaseCommand = require('./base-command.js')

Expand Down Expand Up @@ -82,7 +83,7 @@ class Help extends BaseCommand {
if (aManNumber !== bManNumber)
return aManNumber - bManNumber

return a.localeCompare(b, 'en')
return localeCompare(a, b)
})
const man = mans[0]

Expand Down
4 changes: 2 additions & 2 deletions lib/ls.js
Expand Up @@ -22,6 +22,7 @@ const _problems = Symbol('problems')
const _required = Symbol('required')
const _type = Symbol('type')
const ArboristWorkspaceCmd = require('./workspaces/arborist-cmd.js')
const localeCompare = require('@isaacs/string-locale-compare')('en')

class LS extends ArboristWorkspaceCmd {
/* istanbul ignore next - see test/lib/load-all-commands.js */
Expand Down Expand Up @@ -503,8 +504,7 @@ const augmentNodesWithMetadata = ({
return node
}

const sortAlphabetically = (a, b) =>
a.pkgid.localeCompare(b.pkgid, 'en')
const sortAlphabetically = ({ pkgid: a }, { pkgid: b }) => localeCompare(a, b)

const humanOutput = ({ color, result, seenItems, unicode }) => {
// we need to traverse the entire tree in order to determine which items
Expand Down
6 changes: 5 additions & 1 deletion lib/outdated.js
Expand Up @@ -6,6 +6,7 @@ const color = require('chalk')
const styles = require('ansistyles')
const npa = require('npm-package-arg')
const pickManifest = require('npm-pick-manifest')
const localeCompare = require('@isaacs/string-locale-compare')('en')

const Arborist = require('@npmcli/arborist')

Expand Down Expand Up @@ -85,7 +86,10 @@ class Outdated extends ArboristWorkspaceCmd {
}))

// sorts list alphabetically
const outdated = this.list.sort((a, b) => a.name.localeCompare(b.name, 'en'))
const outdated = this.list.sort((a, b) => localeCompare(a.name, b.name))

if (outdated.length > 0)
process.exitCode = 1

// return if no outdated packages
if (outdated.length === 0 && !this.npm.config.get('json'))
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/completion/installed-deep.js
@@ -1,5 +1,6 @@
const { resolve } = require('path')
const Arborist = require('@npmcli/arborist')
const localeCompare = require('@isaacs/string-locale-compare')('en')

const installedDeep = async (npm) => {
const {
Expand All @@ -15,8 +16,7 @@ const installedDeep = async (npm) => {
return i
})
.filter(i => (i.depth - 1) <= depth)
.sort((a, b) => a.depth - b.depth)
.sort((a, b) => a.depth === b.depth ? a.name.localeCompare(b.name, 'en') : 0)
.sort((a, b) => (a.depth - b.depth) || localeCompare(a.name, b.name))

const res = new Set()
const gArb = new Arborist({ global: true, path: resolve(npm.globalDir, '..') })
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/config/describe-all.js
@@ -1,4 +1,5 @@
const definitions = require('./definitions.js')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const describeAll = () => {
// sort not-deprecated ones to the top
/* istanbul ignore next - typically already sorted in the definitions file,
Expand All @@ -7,7 +8,7 @@ const describeAll = () => {
const sort = ([keya, {deprecated: depa}], [keyb, {deprecated: depb}]) => {
return depa && !depb ? 1
: !depa && depb ? -1
: keya.localeCompare(keyb, 'en')
: localeCompare(keya, keyb)
}
return Object.entries(definitions).sort(sort)
.map(([key, def]) => def.describe())
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/npm-usage.js
@@ -1,5 +1,6 @@
const { dirname } = require('path')
const { cmdList } = require('./cmd-list')
const localeCompare = require('@isaacs/string-locale-compare')('en')

module.exports = (npm) => {
const usesBrowser = npm.config.get('viewer') === 'browser'
Expand Down Expand Up @@ -62,7 +63,7 @@ const usages = (npm) => {
maxLen = Math.max(maxLen, c.length)
return set
}, [])
.sort((a, b) => a[0].localeCompare(b[0], 'en'))
.sort(([a], [b]) => localeCompare(a, b))
.map(([c, usage]) => `\n ${c}${' '.repeat(maxLen - c.length + 1)}${
(usage.split('\n').join('\n' + ' '.repeat(maxLen + 5)))}`)
.join('\n')
Expand Down
1 change: 1 addition & 0 deletions lib/utils/open-url.js
Expand Up @@ -4,6 +4,7 @@ const { URL } = require('url')

// attempt to open URL in web-browser, print address otherwise:
const open = async (npm, url, errMsg) => {
url = encodeURI(url)
const browser = npm.config.get('browser')

function printAlternateMsg () {
Expand Down
11 changes: 5 additions & 6 deletions lib/utils/tar.js
Expand Up @@ -3,6 +3,10 @@ const ssri = require('ssri')
const npmlog = require('npmlog')
const formatBytes = require('./format-bytes.js')
const columnify = require('columnify')
const localeCompare = require('@isaacs/string-locale-compare')('en', {
sensitivity: 'case',
numeric: true,
})

const logTar = (tarball, opts = {}) => {
const { unicode = false, log = npmlog } = opts
Expand Down Expand Up @@ -75,12 +79,7 @@ const getContents = async (manifest, tarball) => {
algorithms: ['sha1', 'sha512'],
})

const comparator = (a, b) => {
return a.path.localeCompare(b.path, 'en', {
sensitivity: 'case',
numeric: true,
})
}
const comparator = ({ path: a }, { path: b }) => localeCompare(a, b)

const isUpper = (str) => {
const ch = str.charAt(0)
Expand Down
15 changes: 15 additions & 0 deletions node_modules/@isaacs/string-locale-compare/LICENSE

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

42 changes: 42 additions & 0 deletions node_modules/@isaacs/string-locale-compare/index.js

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

28 changes: 28 additions & 0 deletions node_modules/@isaacs/string-locale-compare/package.json

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

4 changes: 3 additions & 1 deletion node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js

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