summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/libnpmaccess
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/libnpmaccess')
-rw-r--r--deps/npm/node_modules/libnpmaccess/.github/settings.yml2
-rw-r--r--deps/npm/node_modules/libnpmaccess/.github/workflows/ci.yml94
-rw-r--r--deps/npm/node_modules/libnpmaccess/.travis.yml7
-rw-r--r--deps/npm/node_modules/libnpmaccess/CHANGELOG.md37
-rw-r--r--deps/npm/node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE7
-rw-r--r--deps/npm/node_modules/libnpmaccess/README.md39
-rw-r--r--deps/npm/node_modules/libnpmaccess/appveyor.yml22
-rw-r--r--deps/npm/node_modules/libnpmaccess/index.js201
-rw-r--r--deps/npm/node_modules/libnpmaccess/package.json86
-rw-r--r--deps/npm/node_modules/libnpmaccess/test/fixtures/tnock.js (renamed from deps/npm/node_modules/libnpmaccess/test/util/tnock.js)0
-rw-r--r--deps/npm/node_modules/libnpmaccess/test/index.js170
11 files changed, 387 insertions, 278 deletions
diff --git a/deps/npm/node_modules/libnpmaccess/.github/settings.yml b/deps/npm/node_modules/libnpmaccess/.github/settings.yml
new file mode 100644
index 0000000000..4aaa0dd57e
--- /dev/null
+++ b/deps/npm/node_modules/libnpmaccess/.github/settings.yml
@@ -0,0 +1,2 @@
+---
+_extends: 'open-source-project-boilerplate'
diff --git a/deps/npm/node_modules/libnpmaccess/.github/workflows/ci.yml b/deps/npm/node_modules/libnpmaccess/.github/workflows/ci.yml
new file mode 100644
index 0000000000..71189bae7b
--- /dev/null
+++ b/deps/npm/node_modules/libnpmaccess/.github/workflows/ci.yml
@@ -0,0 +1,94 @@
+---
+################################################################################
+# Template - Node CI
+#
+# Description:
+# This contains the basic information to: install dependencies, run tests,
+# get coverage, and run linting on a nodejs project. This template will run
+# over the MxN matrix of all operating systems, and all current LTS versions
+# of NodeJS.
+#
+# Dependencies:
+# This template assumes that your project is using the `tap` module for
+# testing. If you're not using this module, then the step that runs your
+# coverage will need to be adjusted.
+#
+################################################################################
+name: Node CI
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ node-version: [10.x, 12.x, 13.x]
+ os: [ubuntu-latest, windows-latest, macOS-latest]
+
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ # Checkout the repository
+ - uses: actions/checkout@v2
+ # Installs the specific version of Node.js
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node-version }}
+
+ ################################################################################
+ # Install Dependencies
+ #
+ # ASSUMPTIONS:
+ # - The project has a package-lock.json file
+ #
+ # Simply run the tests for the project.
+ ################################################################################
+ - name: Install dependencies
+ run: npm ci
+
+ ################################################################################
+ # Run Testing
+ #
+ # ASSUMPTIONS:
+ # - The project has `tap` as a devDependency
+ # - There is a script called "test" in the package.json
+ #
+ # Simply run the tests for the project.
+ ################################################################################
+ - name: Run tests
+ run: npm test -- --no-coverage
+
+ ################################################################################
+ # Run coverage check
+ #
+ # ASSUMPTIONS:
+ # - The project has `tap` as a devDependency
+ # - There is a script called "coverage" in the package.json
+ #
+ # Coverage should only be posted once, we are choosing the latest LTS of
+ # node, and ubuntu as the matrix point to post coverage from. We limit
+ # to the 'push' event so that coverage ins't posted twice from the
+ # pull-request event, and push event (line 3).
+ ################################################################################
+ - name: Run coverage report
+ if: github.event_name == 'push' && matrix.node-version == '12.x' && matrix.os == 'ubuntu-latest'
+ run: npm test
+ env:
+ # The environment variable name is leveraged by `tap`
+ COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
+
+ ################################################################################
+ # Run linting
+ #
+ # ASSUMPTIONS:
+ # - There is a script called "lint" in the package.json
+ #
+ # We run linting AFTER we run testing and coverage checks, because if a step
+ # fails in an GitHub Action, all other steps are not run. We don't want to
+ # fail to run tests or coverage because of linting. It should be the lowest
+ # priority of all the steps.
+ ################################################################################
+ - name: Run linter
+ run: npm run lint
diff --git a/deps/npm/node_modules/libnpmaccess/.travis.yml b/deps/npm/node_modules/libnpmaccess/.travis.yml
deleted file mode 100644
index db5ea8b018..0000000000
--- a/deps/npm/node_modules/libnpmaccess/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: node_js
-sudo: false
-node_js:
- - "10"
- - "9"
- - "8"
- - "6"
diff --git a/deps/npm/node_modules/libnpmaccess/CHANGELOG.md b/deps/npm/node_modules/libnpmaccess/CHANGELOG.md
index cbec879a7d..6d8036a9da 100644
--- a/deps/npm/node_modules/libnpmaccess/CHANGELOG.md
+++ b/deps/npm/node_modules/libnpmaccess/CHANGELOG.md
@@ -1,5 +1,42 @@
# Change Log
+<a name="4.0.0"></a>
+## [4.0.0](https://github.com/npm/libnpmaccess/compare/v3.0.2...v4.0.0) (2020-03-02)
+
+### BREAKING CHANGES
+- `25ac61b` fix: remove figgy-pudding ([@claudiahdz](https://github.com/claudiahdz))
+- `8d6f692` chore: rename opts.mapJson to opts.mapJSON ([@mikemimik](https://github.com/mikemimik))
+
+### Features
+- `257879a` chore: removed standard-version as a dep; updated scripts for version/publishing ([@mikemimik](https://github.com/mikemimik))
+- `46c6740` fix: pull-request feedback; read full commit message ([@mikemimik](https://github.com/mikemimik))
+- `778c102` chore: updated test, made case more clear ([@mikemimik](https://github.com/mikemimik))
+- `6dc9852` fix: refactored 'pwrap' function out of code base; use native promises ([@mikemimik](https://github.com/mikemimik))
+- `d2e7219` chore: updated package scripts; update CI workflow ([@mikemimik](https://github.com/mikemimik))
+- `5872364` chore: renamed test/util/ to test/fixture/; tap will ignore now ([@mikemimik](https://github.com/mikemimik))
+- `3c6b71d` chore: linted test file; made tap usage 'better' ([@mikemimik](https://github.com/mikemimik))
+- `20f0858` fix: added default values to params for API functions (with tests) ([@mikemimik](https://github.com/mikemimik))
+- `3218289` feat: replace get-stream with minipass ([@mikemimik](https://github.com/mikemimik))
+
+### Documentation
+- `6c8ffa0` docs: removed opts.Promise from docs; no longer in use ([@mikemimik](https://github.com/mikemimik))
+- `311bff5` chore: added return types to function docs in README ([@mikemimik](https://github.com/mikemimik))
+- `823726a` chore: removed travis badge, added github actions badge ([@mikemimik](https://github.com/mikemimik))
+- `80e80ac` chore: updated README ([@mikemimik](https://github.com/mikemimik))
+
+### Dependencies
+- `baed2b9` deps: standard-version@7.1.0 (audit fix) ([@mikemimik](https://github.com/mikemimik))
+- `65c2204` deps: nock@12.0.1 (audit fix) ([@mikemimik](https://github.com/mikemimik))
+- `2668386` deps: npm-registry-fetch@8.0.0 ([@mikemimik](https://github.com/mikemimik))
+- `ef093e2` deps: tap@14.10.6 ([@mikemimik](https://github.com/mikemimik))
+
+### Miscellanieous
+- `8e33902` chore: basic project updates ([@claudiahdz](https://github.com/claudiahdz))
+- `50e1433` fix: update return value; add tests ([@mikemimik](https://github.com/mikemimik))
+- `36d5c80` chore: updated gitignore; includes coverage folder ([@mikemimik](https://github.com/mikemimik))
+
+---
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
<a name="3.0.2"></a>
diff --git a/deps/npm/node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE b/deps/npm/node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE
deleted file mode 100644
index 9471c6d325..0000000000
--- a/deps/npm/node_modules/libnpmaccess/PULL_REQUEST_TEMPLATE
+++ /dev/null
@@ -1,7 +0,0 @@
-<!--
-⚠️🚨 BEFORE FILING A PR: 🚨⚠️
-
-👉🏼 CONTRIBUTING.md 👈🏼 (the "contribution guidelines" up there ☝🏼)
-
-I PROMISE IT'S A VERY VERY SHORT READ.🙇🏼
--->
diff --git a/deps/npm/node_modules/libnpmaccess/README.md b/deps/npm/node_modules/libnpmaccess/README.md
index 2b639823a0..c079344597 100644
--- a/deps/npm/node_modules/libnpmaccess/README.md
+++ b/deps/npm/node_modules/libnpmaccess/README.md
@@ -1,4 +1,9 @@
-# libnpmaccess [![npm version](https://img.shields.io/npm/v/libnpmaccess.svg)](https://npm.im/libnpmaccess) [![license](https://img.shields.io/npm/l/libnpmaccess.svg)](https://npm.im/libnpmaccess) [![Travis](https://img.shields.io/travis/npm/libnpmaccess/latest.svg)](https://travis-ci.org/npm/libnpmaccess) [![AppVeyor](https://img.shields.io/appveyor/ci/zkat/libnpmaccess/latest.svg)](https://ci.appveyor.com/project/zkat/libnpmaccess) [![Coverage Status](https://coveralls.io/repos/github/npm/libnpmaccess/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmaccess?branch=latest)
+# libnpmaccess
+
+[![npm version](https://img.shields.io/npm/v/libnpmaccess.svg)](https://npm.im/libnpmaccess)
+[![license](https://img.shields.io/npm/l/libnpmaccess.svg)](https://npm.im/libnpmaccess)
+[![GitHub Actions](https://github.com/npm/libnpmaccess/workflows/Node%20CI/badge.svg)](https://github.com/npm/libnpmaccess/actions?query=workflow%3A%22Node+CI%22)
+[![Coverage Status](https://coveralls.io/repos/github/npm/libnpmaccess/badge.svg?branch=latest)](https://coveralls.io/github/npm/libnpmaccess?branch=latest)
[`libnpmaccess`](https://github.com/npm/libnpmaccess) is a Node.js
library that provides programmatic access to the guts of the npm CLI's `npm
@@ -37,21 +42,6 @@ console.log(Object.keys(await access.lsPackages('zkat')))
`$ npm install libnpmaccess`
-### Contributing
-
-The npm team enthusiastically welcomes contributions and project participation!
-There's a bunch of things you can do if you want to contribute! The [Contributor
-Guide](CONTRIBUTING.md) has all the information you need for everything from
-reporting bugs to contributing entire new features. Please don't hesitate to
-jump in if you'd like to, or even ask us questions if something isn't clear.
-
-All participants and maintainers in this project are expected to follow [Code of
-Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other.
-
-Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
-
-Happy hacking!
-
### API
#### <a name="opts"></a> `opts` for `libnpmaccess` commands
@@ -66,9 +56,8 @@ A couple of options of note for those in a hurry:
* `opts.token` - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs.
* `opts.otp` - certain operations will require an OTP token to be passed in. If a `libnpmaccess` command fails with `err.code === EOTP`, please retry the request with `{otp: <2fa token>}`
-* `opts.Promise` - If you pass this in, the Promises returned by `libnpmaccess` commands will use this Promise class instead. For example: `{Promise: require('bluebird')}`
-#### <a name="public"></a> `> access.public(spec, [opts]) -> Promise`
+#### <a name="public"></a> `> access.public(spec, [opts]) -> Promise<Boolean>`
`spec` must be an [`npm-package-arg`](https://npm.im/npm-package-arg)-compatible
registry spec.
@@ -82,7 +71,7 @@ await access.public('@foo/bar', {token: 'myregistrytoken'})
// `@foo/bar` is now public
```
-#### <a name="restricted"></a> `> access.restricted(spec, [opts]) -> Promise`
+#### <a name="restricted"></a> `> access.restricted(spec, [opts]) -> Promise<Boolean>`
`spec` must be an [`npm-package-arg`](https://npm.im/npm-package-arg)-compatible
registry spec.
@@ -96,7 +85,7 @@ await access.restricted('@foo/bar', {token: 'myregistrytoken'})
// `@foo/bar` is now private
```
-#### <a name="grant"></a> `> access.grant(spec, team, permissions, [opts]) -> Promise`
+#### <a name="grant"></a> `> access.grant(spec, team, permissions, [opts]) -> Promise<Boolean>`
`spec` must be an [`npm-package-arg`](https://npm.im/npm-package-arg)-compatible
registry spec. `team` must be a fully-qualified team name, in the `scope:team`
@@ -114,7 +103,7 @@ await access.grant('@foo/bar', '@foo:myteam', 'read-write', {
// `@foo/bar` is now read/write enabled for the @foo:myteam team.
```
-#### <a name="revoke"></a> `> access.revoke(spec, team, [opts]) -> Promise`
+#### <a name="revoke"></a> `> access.revoke(spec, team, [opts]) -> Promise<Boolean>`
`spec` must be an [`npm-package-arg`](https://npm.im/npm-package-arg)-compatible
registry spec. `team` must be a fully-qualified team name, in the `scope:team`
@@ -132,7 +121,7 @@ await access.revoke('@foo/bar', '@foo:myteam', {
// @foo:myteam can no longer access `@foo/bar`
```
-#### <a name="tfa-required"></a> `> access.tfaRequired(spec, [opts]) -> Promise`
+#### <a name="tfa-required"></a> `> access.tfaRequired(spec, [opts]) -> Promise<Boolean>`
`spec` must be an [`npm-package-arg`](https://npm.im/npm-package-arg)-compatible
registry spec.
@@ -147,7 +136,7 @@ await access.tfaRequires('lodash', {token: 'myregistrytoken'})
// Publishing or changing dist-tags on `lodash` now require OTP to be enabled.
```
-#### <a name="tfa-not-required"></a> `> access.tfaNotRequired(spec, [opts]) -> Promise`
+#### <a name="tfa-not-required"></a> `> access.tfaNotRequired(spec, [opts]) -> Promise<Boolean>`
`spec` must be an [`npm-package-arg`](https://npm.im/npm-package-arg)-compatible
registry spec.
@@ -163,7 +152,7 @@ await access.tfaNotRequired('lodash', {otp: '123654', token: 'myregistrytoken'})
// enabled.
```
-#### <a name="ls-packages"></a> `> access.lsPackages(entity, [opts]) -> Promise`
+#### <a name="ls-packages"></a> `> access.lsPackages(entity, [opts]) -> Promise<Object | null>`
`entity` must be either a valid org or user name, or a fully-qualified team name
in the `scope:team` format, with or without the `@` prefix.
@@ -213,7 +202,7 @@ for await (let [pkg, perm] of access.lsPackages.stream('zkat')) {
// zkat has read-only access to @npmcorp/secret
```
-#### <a name="ls-collaborators"></a> `> access.lsCollaborators(spec, [user], [opts]) -> Promise`
+#### <a name="ls-collaborators"></a> `> access.lsCollaborators(spec, [user], [opts]) -> Promise<Object | null>`
`spec` must be an [`npm-package-arg`](https://npm.im/npm-package-arg)-compatible
registry spec. `user` must be a valid user name, with or without the `@`
diff --git a/deps/npm/node_modules/libnpmaccess/appveyor.yml b/deps/npm/node_modules/libnpmaccess/appveyor.yml
deleted file mode 100644
index 9cc64c58e0..0000000000
--- a/deps/npm/node_modules/libnpmaccess/appveyor.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-environment:
- matrix:
- - nodejs_version: "10"
- - nodejs_version: "9"
- - nodejs_version: "8"
- - nodejs_version: "6"
-
-platform:
- - x64
-
-install:
- - ps: Install-Product node $env:nodejs_version $env:platform
- - npm config set spin false
- - npm install
-
-test_script:
- - npm test
-
-matrix:
- fast_finish: true
-
-build: off
diff --git a/deps/npm/node_modules/libnpmaccess/index.js b/deps/npm/node_modules/libnpmaccess/index.js
index e241fcbfc6..883110b289 100644
--- a/deps/npm/node_modules/libnpmaccess/index.js
+++ b/deps/npm/node_modules/libnpmaccess/index.js
@@ -1,16 +1,10 @@
'use strict'
-const figgyPudding = require('figgy-pudding')
-const getStream = require('get-stream')
+const Minipass = require('minipass')
const npa = require('npm-package-arg')
const npmFetch = require('npm-registry-fetch')
-const {PassThrough} = require('stream')
const validate = require('aproba')
-const AccessConfig = figgyPudding({
- Promise: {default: () => Promise}
-})
-
const eu = encodeURIComponent
const npar = spec => {
spec = npa(spec)
@@ -19,129 +13,130 @@ const npar = spec => {
}
return spec
}
+const mapJSON = (value, [key]) => {
+ if (value === 'read') {
+ return [key, 'read-only']
+ } else if (value === 'write') {
+ return [key, 'read-write']
+ } else {
+ return [key, value]
+ }
+}
const cmd = module.exports = {}
cmd.public = (spec, opts) => setAccess(spec, 'public', opts)
cmd.restricted = (spec, opts) => setAccess(spec, 'restricted', opts)
-function setAccess (spec, access, opts) {
- opts = AccessConfig(opts)
- return pwrap(opts, () => {
+function setAccess (spec, access, opts = {}) {
+ return Promise.resolve().then(() => {
spec = npar(spec)
validate('OSO', [spec, access, opts])
const uri = `/-/package/${eu(spec.name)}/access`
- return npmFetch(uri, opts.concat({
+ return npmFetch(uri, {
+ ...opts,
method: 'POST',
- body: {access},
+ body: { access },
spec
- }))
- }).then(res => res.body.resume() && true)
+ }).then(() => true)
+ })
}
-cmd.grant = (spec, entity, permissions, opts) => {
- opts = AccessConfig(opts)
- return pwrap(opts, () => {
+cmd.grant = (spec, entity, permissions, opts = {}) => {
+ return Promise.resolve().then(() => {
spec = npar(spec)
- const {scope, team} = splitEntity(entity)
+ const { scope, team } = splitEntity(entity)
validate('OSSSO', [spec, scope, team, permissions, opts])
if (permissions !== 'read-write' && permissions !== 'read-only') {
throw new Error('`permissions` must be `read-write` or `read-only`. Got `' + permissions + '` instead')
}
const uri = `/-/team/${eu(scope)}/${eu(team)}/package`
- return npmFetch(uri, opts.concat({
+ return npmFetch(uri, {
+ ...opts,
method: 'PUT',
- body: {package: spec.name, permissions},
+ body: { package: spec.name, permissions },
scope,
spec,
ignoreBody: true
- }))
- }).then(() => true)
+ })
+ .then(() => true)
+ })
}
-cmd.revoke = (spec, entity, opts) => {
- opts = AccessConfig(opts)
- return pwrap(opts, () => {
+cmd.revoke = (spec, entity, opts = {}) => {
+ return Promise.resolve().then(() => {
spec = npar(spec)
- const {scope, team} = splitEntity(entity)
+ const { scope, team } = splitEntity(entity)
validate('OSSO', [spec, scope, team, opts])
const uri = `/-/team/${eu(scope)}/${eu(team)}/package`
- return npmFetch(uri, opts.concat({
+ return npmFetch(uri, {
+ ...opts,
method: 'DELETE',
- body: {package: spec.name},
+ body: { package: spec.name },
scope,
spec,
ignoreBody: true
- }))
- }).then(() => true)
+ })
+ .then(() => true)
+ })
}
cmd.lsPackages = (entity, opts) => {
- opts = AccessConfig(opts)
- return pwrap(opts, () => {
- return getStream.array(
- cmd.lsPackages.stream(entity, opts)
- ).then(data => data.reduce((acc, [key, val]) => {
- if (!acc) {
- acc = {}
- }
- acc[key] = val
- return acc
- }, null))
- })
+ return cmd.lsPackages.stream(entity, opts)
+ .collect()
+ .then(data => {
+ return data.reduce((acc, [key, val]) => {
+ if (!acc) {
+ acc = {}
+ }
+ acc[key] = val
+ return acc
+ }, null)
+ })
}
-cmd.lsPackages.stream = (entity, opts) => {
+cmd.lsPackages.stream = (entity, opts = {}) => {
validate('SO|SZ', [entity, opts])
- opts = AccessConfig(opts)
- const {scope, team} = splitEntity(entity)
+ const { scope, team } = splitEntity(entity)
let uri
if (team) {
uri = `/-/team/${eu(scope)}/${eu(team)}/package`
} else {
uri = `/-/org/${eu(scope)}/package`
}
- opts = opts.concat({
- query: {format: 'cli'},
- mapJson (value, [key]) {
- if (value === 'read') {
- return [key, 'read-only']
- } else if (value === 'write') {
- return [key, 'read-write']
+ const nextOpts = {
+ ...opts,
+ query: { format: 'cli' },
+ mapJSON
+ }
+ const ret = new Minipass({ objectMode: true })
+ npmFetch.json.stream(uri, '*', nextOpts)
+ .on('error', err => {
+ if (err.code === 'E404' && !team) {
+ uri = `/-/user/${eu(scope)}/package`
+ npmFetch.json.stream(uri, '*', nextOpts)
+ .on('error', err => ret.emit('error', err))
+ .pipe(ret)
} else {
- return [key, value]
+ ret.emit('error', err)
}
- }
- })
- const ret = new PassThrough({objectMode: true})
- npmFetch.json.stream(uri, '*', opts).on('error', err => {
- if (err.code === 'E404' && !team) {
- uri = `/-/user/${eu(scope)}/package`
- npmFetch.json.stream(uri, '*', opts).on(
- 'error', err => ret.emit('error', err)
- ).pipe(ret)
- } else {
- ret.emit('error', err)
- }
- }).pipe(ret)
+ })
+ .pipe(ret)
return ret
}
cmd.lsCollaborators = (spec, user, opts) => {
- if (typeof user === 'object' && !opts) {
- opts = user
- user = undefined
- }
- opts = AccessConfig(opts)
- return pwrap(opts, () => {
- return getStream.array(
- cmd.lsCollaborators.stream(spec, user, opts)
- ).then(data => data.reduce((acc, [key, val]) => {
- if (!acc) {
- acc = {}
- }
- acc[key] = val
- return acc
- }, null))
+ return Promise.resolve().then(() => {
+ return cmd.lsCollaborators.stream(spec, user, opts)
+ .collect()
+ .then(data => {
+ return data.reduce((acc, [key, val]) => {
+ if (!acc) {
+ acc = {}
+ }
+ acc[key] = val
+ return acc
+ }, null)
+ })
})
}
@@ -149,40 +144,34 @@ cmd.lsCollaborators.stream = (spec, user, opts) => {
if (typeof user === 'object' && !opts) {
opts = user
user = undefined
+ } else if (!opts) {
+ opts = {}
}
- opts = AccessConfig(opts)
spec = npar(spec)
validate('OSO|OZO', [spec, user, opts])
const uri = `/-/package/${eu(spec.name)}/collaborators`
- return npmFetch.json.stream(uri, '*', opts.concat({
- query: {format: 'cli', user: user || undefined},
- mapJson (value, [key]) {
- if (value === 'read') {
- return [key, 'read-only']
- } else if (value === 'write') {
- return [key, 'read-write']
- } else {
- return [key, value]
- }
- }
- }))
+ return npmFetch.json.stream(uri, '*', {
+ ...opts,
+ query: { format: 'cli', user: user || undefined },
+ mapJSON
+ })
}
cmd.tfaRequired = (spec, opts) => setRequires2fa(spec, true, opts)
cmd.tfaNotRequired = (spec, opts) => setRequires2fa(spec, false, opts)
-function setRequires2fa (spec, required, opts) {
- opts = AccessConfig(opts)
- return new opts.Promise((resolve, reject) => {
+function setRequires2fa (spec, required, opts = {}) {
+ return Promise.resolve().then(() => {
spec = npar(spec)
validate('OBO', [spec, required, opts])
const uri = `/-/package/${eu(spec.name)}/access`
- return npmFetch(uri, opts.concat({
+ return npmFetch(uri, {
+ ...opts,
method: 'POST',
- body: {publish_requires_tfa: required},
+ body: { publish_requires_tfa: required },
spec,
ignoreBody: true
- })).then(resolve, reject)
- }).then(() => true)
+ }).then(() => true)
+ })
}
cmd.edit = () => {
@@ -190,12 +179,6 @@ cmd.edit = () => {
}
function splitEntity (entity = '') {
- let [, scope, team] = entity.match(/^@?([^:]+)(?::(.*))?$/) || []
- return {scope, team}
-}
-
-function pwrap (opts, fn) {
- return new opts.Promise((resolve, reject) => {
- fn().then(resolve, reject)
- })
+ const [, scope, team] = entity.match(/^@?([^:]+)(?::(.*))?$/) || []
+ return { scope, team }
}
diff --git a/deps/npm/node_modules/libnpmaccess/package.json b/deps/npm/node_modules/libnpmaccess/package.json
index 943b0aeb46..a727e18721 100644
--- a/deps/npm/node_modules/libnpmaccess/package.json
+++ b/deps/npm/node_modules/libnpmaccess/package.json
@@ -1,67 +1,37 @@
{
- "_from": "libnpmaccess@3.0.2",
- "_id": "libnpmaccess@3.0.2",
- "_inBundle": false,
- "_integrity": "sha512-01512AK7MqByrI2mfC7h5j8N9V4I7MHJuk9buo8Gv+5QgThpOgpjB7sQBDDkeZqRteFb1QM/6YNdHfG7cDvfAQ==",
- "_location": "/libnpmaccess",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "libnpmaccess@3.0.2",
- "name": "libnpmaccess",
- "escapedName": "libnpmaccess",
- "rawSpec": "3.0.2",
- "saveSpec": null,
- "fetchSpec": "3.0.2"
- },
- "_requiredBy": [
- "#USER",
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/libnpmaccess/-/libnpmaccess-3.0.2.tgz",
- "_shasum": "8b2d72345ba3bef90d3b4f694edd5c0417f58923",
- "_spec": "libnpmaccess@3.0.2",
- "_where": "/Users/isaacs/dev/npm/cli",
- "author": {
- "name": "Kat Marchán",
- "email": "kzm@zkat.tech"
- },
- "bugs": {
- "url": "https://github.com/npm/libnpmaccess/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "aproba": "^2.0.0",
- "get-stream": "^4.0.0",
- "npm-package-arg": "^6.1.0",
- "npm-registry-fetch": "^4.0.0"
- },
- "deprecated": false,
+ "name": "libnpmaccess",
+ "version": "4.0.0",
"description": "programmatic library for `npm access` commands",
+ "author": "Kat Marchán <kzm@sykosomatic.org>",
+ "license": "ISC",
+ "scripts": {
+ "preversion": "npm test",
+ "postversion": "npm publish",
+ "postpublish": "git push origin --follow-tags",
+ "lint": "standard",
+ "test": "tap"
+ },
"devDependencies": {
- "nock": "^9.6.1",
- "standard": "*",
- "standard-version": "*",
- "tap": "*",
- "weallbehave": "*",
- "weallcontribute": "*"
+ "nock": "^12.0.1",
+ "standard": "^14.3.0",
+ "tap": "^14.10.6"
},
- "homepage": "https://npmjs.com/package/libnpmaccess",
- "license": "ISC",
- "name": "libnpmaccess",
"repository": {
"type": "git",
- "url": "git+https://github.com/npm/libnpmaccess.git"
+ "url": "https://github.com/npm/libnpmaccess.git"
},
- "scripts": {
- "postrelease": "npm publish && git push --follow-tags",
- "prerelease": "npm t",
- "pretest": "standard",
- "release": "standard-version -s",
- "test": "tap -J --100 test/*.js",
- "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
- "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'"
+ "bugs": "https://github.com/npm/libnpmaccess/issues",
+ "homepage": "https://npmjs.com/package/libnpmaccess",
+ "dependencies": {
+ "aproba": "^2.0.0",
+ "minipass": "^3.1.1",
+ "npm-package-arg": "^8.0.0",
+ "npm-registry-fetch": "^8.0.0"
+ },
+ "engines": {
+ "node": ">=10"
},
- "version": "3.0.2"
+ "tap": {
+ "check-coverage": true
+ }
}
diff --git a/deps/npm/node_modules/libnpmaccess/test/util/tnock.js b/deps/npm/node_modules/libnpmaccess/test/fixtures/tnock.js
index 00b6e160e1..00b6e160e1 100644
--- a/deps/npm/node_modules/libnpmaccess/test/util/tnock.js
+++ b/deps/npm/node_modules/libnpmaccess/test/fixtures/tnock.js
diff --git a/deps/npm/node_modules/libnpmaccess/test/index.js b/deps/npm/node_modules/libnpmaccess/test/index.js
index b48815e79a..c6d939c3d8 100644
--- a/deps/npm/node_modules/libnpmaccess/test/index.js
+++ b/deps/npm/node_modules/libnpmaccess/test/index.js
@@ -1,54 +1,72 @@
'use strict'
-const figgyPudding = require('figgy-pudding')
-const getStream = require('get-stream')
-const {test} = require('tap')
-const tnock = require('./util/tnock.js')
+const t = require('tap')
+const tnock = require('./fixtures/tnock.js')
const access = require('../index.js')
const REG = 'http://localhost:1337'
-const OPTS = figgyPudding({})({
+const OPTS = {
registry: REG
-})
+}
-test('access public', t => {
+t.test('access public', t => {
tnock(t, REG).post(
- '/-/package/%40foo%2Fbar/access', {access: 'public'}
+ '/-/package/%40foo%2Fbar/access', { access: 'public' }
).reply(200)
return access.public('@foo/bar', OPTS).then(ret => {
t.deepEqual(ret, true, 'request succeeded')
})
})
-test('access restricted', t => {
+t.test('access public - failure', t => {
+ tnock(t, REG).post(
+ '/-/package/%40foo%2Fbar/access', { access: 'public' }
+ ).reply(418)
+ return access.public('@foo/bar', OPTS)
+ .catch(err => {
+ t.equals(err.statusCode, 418, 'fails with code from registry')
+ })
+})
+
+t.test('access restricted', t => {
tnock(t, REG).post(
- '/-/package/%40foo%2Fbar/access', {access: 'restricted'}
+ '/-/package/%40foo%2Fbar/access', { access: 'restricted' }
).reply(200)
return access.restricted('@foo/bar', OPTS).then(ret => {
t.deepEqual(ret, true, 'request succeeded')
})
})
-test('access 2fa-required', t => {
+t.test('access restricted - failure', t => {
+ tnock(t, REG).post(
+ '/-/package/%40foo%2Fbar/access', { access: 'restricted' }
+ ).reply(418)
+ return access.restricted('@foo/bar', OPTS)
+ .catch(err => {
+ t.equals(err.statusCode, 418, 'fails with code from registry')
+ })
+})
+
+t.test('access 2fa-required', t => {
tnock(t, REG).post('/-/package/%40foo%2Fbar/access', {
publish_requires_tfa: true
- }).reply(200, {ok: true})
+ }).reply(200, { ok: true })
return access.tfaRequired('@foo/bar', OPTS).then(ret => {
t.deepEqual(ret, true, 'request succeeded')
})
})
-test('access 2fa-not-required', t => {
+t.test('access 2fa-not-required', t => {
tnock(t, REG).post('/-/package/%40foo%2Fbar/access', {
publish_requires_tfa: false
- }).reply(200, {ok: true})
+ }).reply(200, { ok: true })
return access.tfaNotRequired('@foo/bar', OPTS).then(ret => {
t.deepEqual(ret, true, 'request succeeded')
})
})
-test('access grant basic read-write', t => {
+t.test('access grant basic read-write', t => {
tnock(t, REG).put('/-/team/myorg/myteam/package', {
package: '@foo/bar',
permissions: 'read-write'
@@ -60,7 +78,7 @@ test('access grant basic read-write', t => {
})
})
-test('access grant basic read-only', t => {
+t.test('access grant basic read-only', t => {
tnock(t, REG).put('/-/team/myorg/myteam/package', {
package: '@foo/bar',
permissions: 'read-only'
@@ -72,7 +90,7 @@ test('access grant basic read-only', t => {
})
})
-test('access grant bad perm', t => {
+t.test('access grant bad perm', t => {
return access.grant(
'@foo/bar', 'myorg:myteam', 'unknown', OPTS
).then(ret => {
@@ -86,7 +104,7 @@ test('access grant bad perm', t => {
})
})
-test('access grant no entity', t => {
+t.test('access grant no entity', t => {
return access.grant(
'@foo/bar', undefined, 'read-write', OPTS
).then(ret => {
@@ -100,7 +118,7 @@ test('access grant no entity', t => {
})
})
-test('access grant basic unscoped', t => {
+t.test('access grant basic unscoped', t => {
tnock(t, REG).put('/-/team/myorg/myteam/package', {
package: 'bar',
permissions: 'read-write'
@@ -112,7 +130,22 @@ test('access grant basic unscoped', t => {
})
})
-test('access revoke basic', t => {
+t.test('access grant no opts passed', t => {
+ // NOTE: mocking real url, because no opts variable means `registry` value
+ // will be defauled to real registry url
+ tnock(t, 'https://registry.npmjs.org')
+ .put('/-/team/myorg/myteam/package', {
+ package: 'bar',
+ permissions: 'read-write'
+ })
+ .reply(201)
+ return access.grant('bar', 'myorg:myteam', 'read-write')
+ .then(ret => {
+ t.equals(ret, true, 'request succeeded')
+ })
+})
+
+t.test('access revoke basic', t => {
tnock(t, REG).delete('/-/team/myorg/myteam/package', {
package: '@foo/bar'
}).reply(200)
@@ -121,16 +154,30 @@ test('access revoke basic', t => {
})
})
-test('access revoke basic unscoped', t => {
+t.test('access revoke basic unscoped', t => {
tnock(t, REG).delete('/-/team/myorg/myteam/package', {
package: 'bar'
- }).reply(200, {accessChanged: true})
+ }).reply(200, { accessChanged: true })
return access.revoke('bar', 'myorg:myteam', OPTS).then(ret => {
t.deepEqual(ret, true, 'request succeeded')
})
})
-test('ls-packages on team', t => {
+t.test('access revoke no opts passed', t => {
+ // NOTE: mocking real url, because no opts variable means `registry` value
+ // will be defauled to real registry url
+ tnock(t, 'https://registry.npmjs.org')
+ .delete('/-/team/myorg/myteam/package', {
+ package: 'bar'
+ })
+ .reply(201)
+ return access.revoke('bar', 'myorg:myteam')
+ .then(ret => {
+ t.equals(ret, true, 'request succeeded')
+ })
+})
+
+t.test('ls-packages on team', t => {
const serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read',
@@ -149,7 +196,7 @@ test('ls-packages on team', t => {
})
})
-test('ls-packages on org', t => {
+t.test('ls-packages on org', t => {
const serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read',
@@ -168,7 +215,7 @@ test('ls-packages on org', t => {
})
})
-test('ls-packages on user', t => {
+t.test('ls-packages on user', t => {
const serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read',
@@ -180,14 +227,14 @@ test('ls-packages on user', t => {
'@foo/other': 'shrödinger'
}
const srv = tnock(t, REG)
- srv.get('/-/org/myuser/package?format=cli').reply(404, {error: 'not found'})
+ srv.get('/-/org/myuser/package?format=cli').reply(404, { error: 'not found' })
srv.get('/-/user/myuser/package?format=cli').reply(200, serverPackages)
return access.lsPackages('myuser', OPTS).then(data => {
t.deepEqual(data, clientPackages, 'got client package info')
})
})
-test('ls-packages error on team', t => {
+t.test('ls-packages error on team', t => {
tnock(t, REG).get('/-/team/myorg/myteam/package?format=cli').reply(404)
return access.lsPackages('myorg:myteam', OPTS).then(
() => { throw new Error('should not have succeeded') },
@@ -195,17 +242,17 @@ test('ls-packages error on team', t => {
)
})
-test('ls-packages error on user', t => {
+t.test('ls-packages error on user', t => {
const srv = tnock(t, REG)
- srv.get('/-/org/myuser/package?format=cli').reply(404, {error: 'not found'})
- srv.get('/-/user/myuser/package?format=cli').reply(404, {error: 'not found'})
+ srv.get('/-/org/myuser/package?format=cli').reply(404, { error: 'not found' })
+ srv.get('/-/user/myuser/package?format=cli').reply(404, { error: 'not found' })
return access.lsPackages('myuser', OPTS).then(
() => { throw new Error('should not have succeeded') },
err => t.equal(err.code, 'E404', 'spit out 404 if both reqs fail')
)
})
-test('ls-packages bad response', t => {
+t.test('ls-packages bad response', t => {
tnock(t, REG).get(
'/-/team/myorg/myteam/package?format=cli'
).reply(200, JSON.stringify(null))
@@ -214,7 +261,7 @@ test('ls-packages bad response', t => {
})
})
-test('ls-packages stream', t => {
+t.test('ls-packages stream', t => {
const serverPackages = {
'@foo/bar': 'write',
'@foo/util': 'read',
@@ -228,14 +275,37 @@ test('ls-packages stream', t => {
tnock(t, REG).get(
'/-/team/myorg/myteam/package?format=cli'
).reply(200, serverPackages)
- return getStream.array(
- access.lsPackages.stream('myorg:myteam', OPTS)
- ).then(data => {
- t.deepEqual(data, clientPackages, 'got streamed client package info')
- })
+ return access.lsPackages.stream('myorg:myteam', OPTS)
+ .collect()
+ .then(data => {
+ t.deepEqual(data, clientPackages, 'got streamed client package info')
+ })
+})
+
+t.test('ls-packages stream no opts', t => {
+ const serverPackages = {
+ '@foo/bar': 'write',
+ '@foo/util': 'read',
+ '@foo/other': 'shrödinger'
+ }
+ const clientPackages = [
+ ['@foo/bar', 'read-write'],
+ ['@foo/util', 'read-only'],
+ ['@foo/other', 'shrödinger']
+ ]
+ // NOTE: mocking real url, because no opts variable means `registry` value
+ // will be defauled to real registry url
+ tnock(t, 'https://registry.npmjs.org')
+ .get('/-/team/myorg/myteam/package?format=cli')
+ .reply(200, serverPackages)
+ return access.lsPackages.stream('myorg:myteam')
+ .collect()
+ .then(data => {
+ t.deepEqual(data, clientPackages, 'got streamed client package info')
+ })
})
-test('ls-collaborators', t => {
+t.test('ls-collaborators', t => {
const serverCollaborators = {
'myorg:myteam': 'write',
'myorg:anotherteam': 'read',
@@ -254,7 +324,7 @@ test('ls-collaborators', t => {
})
})
-test('ls-collaborators stream', t => {
+t.test('ls-collaborators stream', t => {
const serverCollaborators = {
'myorg:myteam': 'write',
'myorg:anotherteam': 'read',
@@ -268,14 +338,14 @@ test('ls-collaborators stream', t => {
tnock(t, REG).get(
'/-/package/%40foo%2Fbar/collaborators?format=cli'
).reply(200, serverCollaborators)
- return getStream.array(
- access.lsCollaborators.stream('@foo/bar', OPTS)
- ).then(data => {
- t.deepEqual(data, clientCollaborators, 'got collaborators')
- })
+ return access.lsCollaborators.stream('@foo/bar', OPTS)
+ .collect()
+ .then(data => {
+ t.deepEqual(data, clientCollaborators, 'got collaborators')
+ })
})
-test('ls-collaborators w/scope', t => {
+t.test('ls-collaborators w/scope', t => {
const serverCollaborators = {
'myorg:myteam': 'write',
'myorg:anotherteam': 'read',
@@ -294,7 +364,7 @@ test('ls-collaborators w/scope', t => {
})
})
-test('ls-collaborators w/o scope', t => {
+t.test('ls-collaborators w/o scope', t => {
const serverCollaborators = {
'myorg:myteam': 'write',
'myorg:anotherteam': 'read',
@@ -313,7 +383,7 @@ test('ls-collaborators w/o scope', t => {
})
})
-test('ls-collaborators bad response', t => {
+t.test('ls-collaborators bad response', t => {
tnock(t, REG).get(
'/-/package/%40foo%2Fbar/collaborators?format=cli'
).reply(200, JSON.stringify(null))
@@ -322,13 +392,13 @@ test('ls-collaborators bad response', t => {
})
})
-test('error on non-registry specs', t => {
+t.test('error on non-registry specs', t => {
const resolve = () => { throw new Error('should not succeed') }
const reject = err => t.match(
err.message, /spec.*must be a registry spec/, 'registry spec required'
)
return Promise.all([
- access.public('foo/bar').then(resolve, reject),
+ access.public('githubusername/reponame').then(resolve, reject),
access.restricted('foo/bar').then(resolve, reject),
access.grant('foo/bar', 'myorg', 'myteam', 'read-only').then(resolve, reject),
access.revoke('foo/bar', 'myorg', 'myteam').then(resolve, reject),
@@ -338,7 +408,7 @@ test('error on non-registry specs', t => {
])
})
-test('edit', t => {
+t.test('edit', t => {
t.equal(typeof access.edit, 'function', 'access.edit exists')
t.throws(() => {
access.edit()