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

Release/7.5.1 #2591

Merged
merged 16 commits into from Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS
Expand Up @@ -748,3 +748,5 @@ Jeff Griffiths <jeff@eko-recordings.ca>
Michael Garvin <gar+gh@danger.computer>
Gar <gar+gh@danger.computer>
dr-js <dr@dr.run>
Pavan Bellamkonda <31280326+pavanbellamkonda@users.noreply.github.com>
Alexander Riccio <test35965@gmail.com>
42 changes: 42 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,45 @@
## v7.5.1 (2021-02-01

### BUG FIXES

* [`0ea134e41`](https://github.com/npm/cli/commit/0ea134e4190f322138299c51672eab5387ec41bb)
[#2587](https://github.com/npm/cli/issues/2587)
pass all settings through to pacote.packument, fixes #2060
([@nlf](https://github.com/nlf))
* [`8c5ca2f51`](https://github.com/npm/cli/commit/8c5ca2f516f5ac87f3bbd7f1fd95c0b283a21f14)
Add test for npm-usage.js, and fix 'npm --long' output
([@isaacs](https://github.com/isaacs))

### DEPENDENCIES

* [`7e4e88e93`](https://github.com/npm/cli/commit/7e4e88e938323e34a2a41176472d8e43e84bd4dd)
`@npmcli/arborist@2.1.1`, `pacote@11.2.4`
* Properly raise ERESOLVE errors on root dev dependencies
* Ignore ERESOLVE errors when performing git dep 'prepare' scripts
* Always reinstall packages that are explicitly requested
* fix global update all so it actually updates things
* Install bins properly when global root is a link
([@isaacs](https://github.com/isaacs))

### DOCUMENTATION

* [`23dac2fef`](https://github.com/npm/cli/commit/23dac2feff1d02193791c7e39d9e93bc9bf8e624)
[#2557](https://github.com/npm/cli/issues/2557)
npm team revamp
([@ruyadorno](https://github.com/ruyadorno))
* [`dd05ba0c0`](https://github.com/npm/cli/commit/dd05ba0c0b2f4c70eb8558c0ecc54889efbe98f5)
[#2572](https://github.com/npm/cli/issues/2572)
add note about `--force` overriding peer dependencies
([@isaacs](https://github.com/isaacs))
* [`e27639780`](https://github.com/npm/cli/commit/e276397809aceb01cc468e02a83bc6f2265376d9)
[#2584](https://github.com/npm/cli/issues/2584)
Fixed the spelling of contributor as it was written as conributor
([@pavanbellamkonda](https://github.com/pavanbellamkonda))
* [`13a5e3178`](https://github.com/npm/cli/commit/13a5e31781cdaa37d3f007e1c8583c7cb591c62a)
[#2502](https://github.com/npm/cli/issues/2502)
elaborate that npm help uses browser
([@ariccio](https://github.com/ariccio))

## v7.5.0 (2021-01-28)

### FEATURES
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -29,7 +29,7 @@ $ cd ./npm && npm install
$ npm run test
```

**5. Open a [Pull Request](https://github.com/npm/cli/pulls) for your work & become the newest conributor to `npm`! 🎉**
**5. Open a [Pull Request](https://github.com/npm/cli/pulls) for your work & become the newest contributor to `npm`! 🎉**

## Test Coverage

Expand Down
68 changes: 56 additions & 12 deletions docs/content/commands/npm-team.md
Expand Up @@ -14,8 +14,6 @@ npm team add <scope:team> <user>
npm team rm <scope:team> <user>

npm team ls <scope>|<scope:team>

npm team edit <scope:team>
```

### Description
Expand All @@ -24,31 +22,76 @@ Used to manage teams in organizations, and change team memberships. Does not
handle permissions for packages.

Teams must always be fully qualified with the organization/scope they belong to
when operating on them, separated by a colon (`:`). That is, if you have a `wombats` team in a `wisdom` organization, you must always refer to that team as `wisdom:wombats` in these commands.
when operating on them, separated by a colon (`:`). That is, if you have a
`newteam` team in an `org` organization, you must always refer to that team
as `@org:newteam` in these commands.

If you have two-factor authentication enabled in `auth-and-writes` mode, then you can provide a code from your authenticator with `[--otp <otpcode>]`. If you don't include this then you will be prompted.
If you have two-factor authentication enabled in `auth-and-writes` mode, then
you can provide a code from your authenticator with `[--otp <otpcode>]`.
If you don't include this then you will be prompted.

* create / destroy:
Create a new team, or destroy an existing one. Note: You cannot remove the `developers` team, <a href="https://docs.npmjs.com/about-developers-team" target="_blank">learn more.</a>
* add / rm:
Add a user to an existing team, or remove a user from a team they belong to.
Create a new team, or destroy an existing one. Note: You cannot remove the
`developers` team, <a href="https://docs.npmjs.com/about-developers-team" target="_blank">learn more.</a>

Here's how to create a new team `newteam` under the `org` org:

```bash
npm team create @org:newteam
```

You should see a confirming message such as: `+@org:newteam` once the new
team has been created.

* add:
Add a user to an existing team.

Adding a new user `username` to a team named `newteam` under the `org` org:

```bash
npm team add @org:newteam username
```

On success, you should see a message: `username added to @org:newteam`

* rm:
Using `npm team rm` you can also remove users from a team they belong to.

Here's an example removing user `username` from `newteam` team
in `org` organization:

```bash
npm team rm @org:newteam username
```

Once the user is removed a confirmation message is displayed:
`username removed from @org:newteam`

* ls:
If performed on an organization name, will return a list of existing teams
under that organization. If performed on a team, it will instead return a list
of all users belonging to that particular team.

* edit:
Edit a current team.
Here's an example of how to list all teams from an org named `org`:

```bash
npm team ls @org
```

Example listing all members of a team named `newteam`:

```bash
npm team ls @org:newteam
```

### Details

`npm team` always operates directly on the current registry, configurable from
the command line using `--registry=<registry url>`.

In order to create teams and manage team membership, you must be a *team admin*
under the given organization. Listing teams and team memberships may be done by
any member of the organizations.
You must be a *team admin* to create teams and manage team membership, under
the given organization. Listing teams and team memberships may be done by
any member of the organization.

Organization creation and management of team admins and *organization* members
is done through the website, not the npm CLI.
Expand All @@ -59,4 +102,5 @@ use the `npm access` command to grant or revoke the appropriate permissions.
### See Also

* [npm access](/commands/npm-access)
* [npm config](/commands/npm-config)
* [npm registry](/using-npm/registry)
1 change: 1 addition & 0 deletions docs/content/using-npm/config.md
Expand Up @@ -472,6 +472,7 @@ mistakes, unnecessary performance degradation, and malicious input.
range (including SemVer-major changes).
* Allow a module to be installed as a direct dependency of itself.
* Allow unpublishing all versions of a published package.
* Allow conflicting peerDependencies to be installed in the root project.

If you don't have a clear idea of what you want to do, it is strongly
recommended that you do not use this option!
Expand Down
3 changes: 1 addition & 2 deletions lib/access.js
Expand Up @@ -8,7 +8,6 @@ const output = require('./utils/output.js')
const otplease = require('./utils/otplease.js')
const usageUtil = require('./utils/usage.js')
const getIdentity = require('./utils/get-identity.js')
const { prefix } = npm

const usage = usageUtil(
'npm access',
Expand Down Expand Up @@ -165,7 +164,7 @@ const getPackage = async (name, requireScope) => {
return name.trim()
else {
try {
const pkg = await readPackageJson(path.resolve(prefix, 'package.json'))
const pkg = await readPackageJson(path.resolve(npm.prefix, 'package.json'))
name = pkg.name
} catch (err) {
if (err.code === 'ENOENT') {
Expand Down
14 changes: 13 additions & 1 deletion lib/ci.js
Expand Up @@ -3,6 +3,8 @@ const Arborist = require('@npmcli/arborist')
const rimraf = util.promisify(require('rimraf'))
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 npm = require('./npm.js')
Expand All @@ -13,6 +15,16 @@ const completion = require('./utils/completion/none.js')

const cmd = (args, cb) => ci().then(() => cb()).catch(cb)

const removeNodeModules = async where => {
const rimrafOpts = { glob: false }
process.emit('time', 'npm-ci:rm')
const path = `${where}/node_modules`
// get the list of entries so we can skip the glob for performance
const entries = await readdir(path, null).catch(er => [])
await Promise.all(entries.map(f => rimraf(`${path}/${f}`, rimrafOpts)))
process.emit('timeEnd', 'npm-ci:rm')
}

const ci = async () => {
if (npm.flatOptions.global) {
const err = new Error('`npm ci` does not work for global packages')
Expand All @@ -33,7 +45,7 @@ const ci = async () => {
'later to generate a package-lock.json file, then try again.'
throw new Error(msg)
}),
rimraf(`${where}/node_modules/*`, { glob: { dot: true, nosort: true, silent: true } }),
removeNodeModules(where),
])
// npm ci should never modify the lockfile or package.json
await arb.reify({ ...npm.flatOptions, save: false })
Expand Down
3 changes: 1 addition & 2 deletions lib/help-search.js
Expand Up @@ -135,12 +135,11 @@ const searchFiles = async (args, data, files) => {

// coverage is ignored here because the contents of results are
// nondeterministic due to either glob or readFiles or Object.entries
return results.sort((a, b) =>
return results.sort(/* istanbul ignore next */ (a, b) =>
a.found.length > b.found.length ? -1
: a.found.length < b.found.length ? 1
: a.totalHits > b.totalHits ? -1
: a.totalHits < b.totalHits ? 1
/* istanbul ignore next */
: a.lines.length > b.lines.length ? -1
: a.lines.length < b.lines.length ? 1
: 0).slice(0, 10)
Expand Down
1 change: 1 addition & 0 deletions lib/outdated.js
Expand Up @@ -108,6 +108,7 @@ async function outdated_ (tree, deps, opts) {

async function getPackument (spec) {
const packument = await pacote.packument(spec, {
...npm.flatOptions,
fullMetadata: npm.flatOptions.long,
preferOnline: true,
})
Expand Down
10 changes: 3 additions & 7 deletions lib/utils/ansi-trim.js
@@ -1,7 +1,3 @@
function ansiTrim (str) {
var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
'\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g')
return str.replace(r, '')
}

module.exports = ansiTrim
const r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' +
'\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g')
module.exports = str => str.replace(r, '')
58 changes: 25 additions & 33 deletions lib/utils/npm-usage.js
Expand Up @@ -6,6 +6,8 @@ const { cmdList } = require('./cmd-list')

module.exports = (valid = true) => {
npm.config.set('loglevel', 'silent')
const usesBrowser = npm.config.get('viewer') === 'browser'
? ' (in a browser)' : ''
npm.log.level = 'silent'
output(`
Usage: npm <command>
Expand All @@ -16,8 +18,8 @@ npm test run this project's tests
npm run <foo> run the script named <foo>
npm <command> -h quick help on <command>
npm -l display usage info for all commands
npm help <term> search for help on <term>
npm help npm more involved overview
npm help <term> search for help on <term>${usesBrowser}
npm help npm more involved overview${usesBrowser}

All commands:
${npm.config.get('long') ? usages() : ('\n ' + wrap(cmdList))}
Expand All @@ -40,44 +42,34 @@ npm@${npm.version} ${dirname(dirname(__dirname))}
}

const wrap = (arr) => {
var out = ['']
var l = 0
var line
const out = ['']

line = process.stdout.columns
if (!line)
line = 60
else
line = Math.min(60, Math.max(line - 16, 24))
const line = !process.stdout.columns ? 60
: Math.min(60, Math.max(process.stdout.columns - 16, 24))

arr.sort(function (a, b) {
return a < b ? -1 : 1
})
.forEach(function (c) {
if (out[l].length + c.length + 2 < line)
out[l] += ', ' + c
else {
out[l++] += ','
out[l] = c
}
})
let l = 0
for (const c of arr.sort((a, b) => a < b ? -1 : 1)) {
if (out[l].length + c.length + 2 < line)
out[l] += ', ' + c
else {
out[l++] += ','
out[l] = c
}
}
return out.join('\n ').substr(2)
}

const usages = () => {
// return a string of <command>: <usage>
var maxLen = 0
return cmdList.reduce(function (set, c) {
set.push([c, require(`./${npm.deref(c)}.js`).usage || ''])
let maxLen = 0
return cmdList.reduce((set, c) => {
set.push([c, require(`../${npm.deref(c)}.js`).usage ||
/* istanbul ignore next - all commands should have usage */ ''])
maxLen = Math.max(maxLen, c.length)
return set
}, []).sort((a, b) => {
return a[0].localeCompare(b[0])
}).map(function (item) {
var c = item[0]
var usage = item[1]
return '\n ' +
c + (new Array(maxLen - c.length + 2).join(' ')) +
(usage.split('\n').join('\n' + (new Array(maxLen + 6).join(' '))))
}).join('\n')
}, [])
.sort((a, b) => a[0].localeCompare(b[0]))
.map(([c, usage]) => `\n ${c}${' '.repeat(maxLen - c.length + 1)}${
(usage.split('\n').join('\n' + ' '.repeat(maxLen + 5)))}`)
.join('\n')
}
2 changes: 0 additions & 2 deletions lib/utils/pulse-till-done.js
@@ -1,4 +1,3 @@
const validate = require('aproba')
const log = require('npmlog')

let pulsers = 0
Expand All @@ -18,7 +17,6 @@ function pulseStop () {
}

module.exports = function (prefix, cb) {
validate('SF', [prefix, cb])
if (!prefix)
prefix = 'network'
pulseStart(prefix)
Expand Down

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

6 changes: 3 additions & 3 deletions node_modules/@npmcli/arborist/lib/arborist/reify.js

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