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.1.3 #3997

Merged
merged 15 commits into from Nov 4, 2021
Merged

v8.1.3 #3997

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 .gitattributes
@@ -0,0 +1,2 @@
/node_modules/** linguist-generated=false
/package-lock.json linguist-generated=false
24 changes: 19 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_8.yml
Expand Up @@ -10,6 +10,13 @@ body:
options:
- label: I have searched the existing issues
required: true
- type: checkboxes
attributes:
label: This issue exists in the latest npm version
description: Please make sure you have installed the latest npm and verified it is still an issue.
options:
- label: I am using the latest npm
required: true
- type: textarea
attributes:
label: Current Behavior
Expand Down Expand Up @@ -38,12 +45,19 @@ body:
label: Environment
description: |
examples:
- **OS**: Ubuntu 20.04
- **Node**: 13.14.0
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
- **`npm config ls`**: `; "user" config from ...`
value: |
- OS:
- Node:
- npm:
- npm:
- Node:
- OS:
- platform:
- npm config:
```ini
; copy and paste output from `npm config ls` here
```
validations:
required: false
28 changes: 20 additions & 8 deletions .github/workflows/ci.yml
@@ -1,17 +1,24 @@
name: Node CI

on: [push, pull_request]

on:
pull_request:
branches:
- '*'
push:
branches:
- release-next
- latest
jobs:
lint:
runs-on: ubuntu-latest
steps:
# Checkout the npm/cli repo
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 14.x
cache: npm
- name: Install dependencies
run: |
node ./bin/npm-cli.js install --ignore-scripts --no-audit
Expand All @@ -26,9 +33,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 14.x
cache: npm
- name: Install dependencies
run: |
node ./bin/npm-cli.js install --ignore-scripts --no-audit
Expand All @@ -44,9 +52,10 @@ jobs:
# Checkout the npm/cli repo
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 14.x
cache: npm
- name: Install dependencies
run: |
node ./bin/npm-cli.js install --ignore-scripts --no-audit
Expand Down Expand Up @@ -80,9 +89,10 @@ jobs:

# Installs the specific version of Node.js
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm

# Run the installer script
- name: Install dependencies
Expand Down Expand Up @@ -122,9 +132,10 @@ jobs:

# Installs the specific version of Node.js
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm

# Run the installer script
- name: Install dependencies
Expand Down Expand Up @@ -163,9 +174,10 @@ jobs:

# Installs the specific version of Node.js
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: npm

# Run the installer script
- name: Install dependencies
Expand Down
39 changes: 38 additions & 1 deletion CHANGELOG.md
@@ -1,3 +1,40 @@
## v8.1.3 (2021-11-04)

### BUG FIXES

* [`8ffeb71df`](https://github.com/npm/cli/commit/8ffeb71dfb248b4a76744bd06cd4d6100f17c8ae)
[#3959](https://github.com/npm/cli/issues/3959)
fix: refactor commands
([@wraithgar](https://github.com/wraithgar))
* [`e5bfdaca4`](https://github.com/npm/cli/commit/e5bfdaca455e294109ba026f4d8b5cc80d3dfd20)
[#3978](https://github.com/npm/cli/issues/3978)
fix: shrinkwrap setting incorrect lockfileVersion
([@lukekarrys](https://github.com/lukekarrys))
* [`32ccd3c27`](https://github.com/npm/cli/commit/32ccd3c2767a14198a1803f04e747ef848f7c938)
[#3988](https://github.com/npm/cli/issues/3988)
fix: remove usage of unnecessary util.promisify
([@lukekarrys](https://github.com/lukekarrys))
* [`1e9c31c4e`](https://github.com/npm/cli/commit/1e9c31c4e3929483580a0a554d7515095b5418ca)
[#3994](https://github.com/npm/cli/issues/3994)
fix: npm help on windows
([@wraithgar](https://github.com/wraithgar))
* [`22230ef3d`](https://github.com/npm/cli/commit/22230ef3dd590def31c274b3412106b4cfbd212f)
[#3987](https://github.com/npm/cli/issues/3987)
fix: make prefixed usage errors more consistent
([@lukekarrys](https://github.com/lukekarrys))

### DEPENDENCIES

* [`ac2fabb86`](https://github.com/npm/cli/commit/ac2fabb8604db0dac852913d61c8415ae7464485)
[#3990](https://github.com/npm/cli/issues/3990)
`@npmcli/arborist@4.0.4`
* fix: don't compare spec for local dep vs existing
* fix: stop pruning peerSets when entryEdge is from a workspace
* [`a0d35ff20`](https://github.com/npm/cli/commit/a0d35ff20aed6aab8508123eb540bc9c61fb127d)
[#3996](https://github.com/npm/cli/issues/3996)
`@npmcli/config@2.3.1`:
* fix: dont load project configs in global mode

## v8.1.2 (2021-10-28)

### BUG FIXES
Expand All @@ -20,7 +57,7 @@
fix: set lockfileVersion from file during reset
* [`d310bd3`](https://github.com/npm/arborist/commit/d310bd3290c3a81e8285ceeb6eda9c9b5aa867d7)
[#339](https://github.com/npm/arborist/pull/339)
fix: always set originalLockfileVersion when doing shrinkwrap reset
fix: always set originalLockfileVersion when doing shrinkwrap reset

## v8.1.1 (2021-10-21)

Expand Down
5 changes: 2 additions & 3 deletions index.js
@@ -1,5 +1,4 @@
if (require.main === module) {
if (require.main === module)
require('./lib/cli.js')(process)
} else {
else
throw new Error('The programmatic API was removed in npm v8.0.0')
}
11 changes: 4 additions & 7 deletions lib/workspaces/arborist-cmd.js → lib/arborist-cmd.js
Expand Up @@ -2,7 +2,7 @@
// a list of workspace names and passes it on to new Arborist() to
// be able to run a filtered Arborist.reify() at some point.

const BaseCommand = require('../base-command.js')
const BaseCommand = require('./base-command.js')
class ArboristCmd extends BaseCommand {
get isArboristCmd () {
return true
Expand All @@ -17,12 +17,9 @@ class ArboristCmd extends BaseCommand {
]
}

execWorkspaces (args, filters, cb) {
this.setWorkspaces(filters, true)
.then(() => {
this.exec(args, cb)
})
.catch(er => cb(er))
async execWorkspaces (args, filters) {
await this.setWorkspaces(filters)
return this.exec(args)
}
}

Expand Down
16 changes: 6 additions & 10 deletions lib/base-command.js
@@ -1,4 +1,4 @@
// Base class for npm.commands[cmd]
// Base class for npm commands
const usageUtil = require('./utils/usage.js')
const ConfigDefinitions = require('./utils/config/definitions.js')
const getWorkspaces = require('./workspaces/get-workspaces.js')
Expand Down Expand Up @@ -53,19 +53,15 @@ class BaseCommand {
return results
}

usageError (msg) {
if (!msg) {
return Object.assign(new Error(`\nUsage: ${this.usage}`), {
code: 'EUSAGE',
})
}

return Object.assign(new Error(`\nUsage: ${msg}\n\n${this.usage}`), {
usageError (prefix = '') {
if (prefix)
prefix += '\n\n'
return Object.assign(new Error(`\nUsage: ${prefix}${this.usage}`), {
code: 'EUSAGE',
})
}

execWorkspaces (args, filters, cb) {
async execWorkspaces (args, filters) {
throw Object.assign(
new Error('This command does not support workspaces.'),
{ code: 'ENOWORKSPACES' }
Expand Down
17 changes: 9 additions & 8 deletions lib/cli.js
Expand Up @@ -18,7 +18,8 @@ module.exports = async (process) => {

checkForUnsupportedNode()

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

Expand All @@ -38,6 +39,7 @@ module.exports = async (process) => {

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

let cmd
// now actually fire up npm and run the command.
// this is how to use npm programmatically:
try {
Expand All @@ -55,24 +57,23 @@ module.exports = async (process) => {

updateNotifier(npm)

const cmd = npm.argv.shift()
cmd = npm.argv.shift()
if (!cmd) {
npm.output(npm.usage)
npm.output(await npm.usage)
process.exitCode = 1
return exitHandler()
}

const impl = npm.commands[cmd]
if (!impl) {
await npm.exec(cmd, npm.argv)
exitHandler()
} catch (err) {
if (err.code === 'EUNKNOWNCOMMAND') {
const didYouMean = require('./utils/did-you-mean.js')
const suggestions = await didYouMean(npm, npm.localPrefix, cmd)
npm.output(`Unknown command: "${cmd}"${suggestions}\n\nTo see a list of supported npm commands, run:\n npm help`)
process.exitCode = 1
return exitHandler()
}

impl(npm.argv, exitHandler)
} catch (err) {
return exitHandler(err)
}
}
12 changes: 4 additions & 8 deletions lib/access.js → lib/commands/access.js
Expand Up @@ -3,9 +3,9 @@ const path = require('path')
const libaccess = require('libnpmaccess')
const readPackageJson = require('read-package-json-fast')

const otplease = require('./utils/otplease.js')
const getIdentity = require('./utils/get-identity.js')
const BaseCommand = require('./base-command.js')
const otplease = require('../utils/otplease.js')
const getIdentity = require('../utils/get-identity.js')
const BaseCommand = require('../base-command.js')

const subcommands = [
'public',
Expand Down Expand Up @@ -76,11 +76,7 @@ class Access extends BaseCommand {
}
}

exec (args, cb) {
this.access(args).then(() => cb()).catch(cb)
}

async access ([cmd, ...args]) {
async exec ([cmd, ...args]) {
if (!cmd)
throw this.usageError('Subcommand is required.')

Expand Down
18 changes: 7 additions & 11 deletions lib/adduser.js → lib/commands/adduser.js
@@ -1,11 +1,11 @@
const log = require('npmlog')
const replaceInfo = require('./utils/replace-info.js')
const BaseCommand = require('./base-command.js')
const replaceInfo = require('../utils/replace-info.js')
const BaseCommand = require('../base-command.js')
const authTypes = {
legacy: require('./auth/legacy.js'),
oauth: require('./auth/oauth.js'),
saml: require('./auth/saml.js'),
sso: require('./auth/sso.js'),
legacy: require('../auth/legacy.js'),
oauth: require('../auth/oauth.js'),
saml: require('../auth/saml.js'),
sso: require('../auth/sso.js'),
}

class AddUser extends BaseCommand {
Expand All @@ -24,11 +24,7 @@ class AddUser extends BaseCommand {
]
}

exec (args, cb) {
this.adduser(args).then(() => cb()).catch(cb)
}

async adduser (args) {
async exec (args) {
const { scope } = this.npm.flatOptions
const registry = this.getRegistry(this.npm.flatOptions)
const auth = this.getAuthType(this.npm.flatOptions)
Expand Down
12 changes: 4 additions & 8 deletions lib/audit.js → lib/commands/audit.js
@@ -1,8 +1,8 @@
const Arborist = require('@npmcli/arborist')
const auditReport = require('npm-audit-report')
const reifyFinish = require('./utils/reify-finish.js')
const auditError = require('./utils/audit-error.js')
const ArboristWorkspaceCmd = require('./workspaces/arborist-cmd.js')
const reifyFinish = require('../utils/reify-finish.js')
const auditError = require('../utils/audit-error.js')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')

class Audit extends ArboristWorkspaceCmd {
/* istanbul ignore next - see test/lib/load-all-commands.js */
Expand Down Expand Up @@ -47,11 +47,7 @@ class Audit extends ArboristWorkspaceCmd {
}
}

exec (args, cb) {
this.audit(args).then(() => cb()).catch(cb)
}

async audit (args) {
async exec (args) {
const reporter = this.npm.config.get('json') ? 'json' : 'detail'
const opts = {
...this.npm.flatOptions,
Expand Down
10 changes: 3 additions & 7 deletions lib/bin.js → lib/commands/bin.js
@@ -1,5 +1,5 @@
const envPath = require('./utils/path.js')
const BaseCommand = require('./base-command.js')
const envPath = require('../utils/path.js')
const BaseCommand = require('../base-command.js')

class Bin extends BaseCommand {
static get description () {
Expand All @@ -14,11 +14,7 @@ class Bin extends BaseCommand {
return ['global']
}

exec (args, cb) {
this.bin(args).then(() => cb()).catch(cb)
}

async bin (args) {
async exec (args) {
const b = this.npm.bin
this.npm.output(b)
if (this.npm.config.get('global') && !envPath.includes(b))
Expand Down