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

feat: deprecate some access subcommands #5155

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions docs/content/commands/npm-access.md
Expand Up @@ -35,28 +35,28 @@ For all of the subcommands, `npm access` will perform actions on the packages
in the current working directory if no package name is passed to the
subcommand.

* public / restricted:
* public / restricted (deprecated):
Set a package to be either publicly accessible or restricted.

* grant / revoke:
Add or remove the ability of users and teams to have read-only or read-write
access to a package.

* 2fa-required / 2fa-not-required:
* 2fa-required / 2fa-not-required (deprecated):
Configure whether a package requires that anyone publishing it have two-factor
authentication enabled on their account.

* ls-packages:
* ls-packages (deprecated):
Show all of the packages a user or a team is able to access, along with the
access level, except for read-only public packages (it won't print the whole
registry listing)

* ls-collaborators:
* ls-collaborators (deprecated):
Show all of the access privileges for a package. Will only show permissions
for packages to which you have at least read access. If `<user>` is passed in,
the list is filtered only to teams _that_ user happens to belong to.

* edit:
* edit (deprecated):
Set the access privileges for a package at once using `$EDITOR`.

### Details
Expand Down
14 changes: 14 additions & 0 deletions lib/commands/access.js
Expand Up @@ -3,6 +3,7 @@ const path = require('path')
const libaccess = require('libnpmaccess')
const readPackageJson = require('read-package-json-fast')

const log = require('../utils/log-shim.js')
const otplease = require('../utils/otplease.js')
const getIdentity = require('../utils/get-identity.js')
const BaseCommand = require('../base-command.js')
Expand All @@ -19,6 +20,16 @@ const subcommands = [
'2fa-not-required',
]

const deprecatedSubcommands = new Set([
'2fa-required',
'2fa-not-required',
'public',
'restricted',
'edit',
'ls-packages',
'ls-collaborators',
])

class Access extends BaseCommand {
static description = 'Set access level on published packages'
static name = 'access'
Expand Down Expand Up @@ -73,6 +84,9 @@ class Access extends BaseCommand {
if (!cmd) {
throw this.usageError('Subcommand is required.')
}
if (deprecatedSubcommands.has(cmd)) {
log.warn('access', `${cmd} is deprecated and will be removed in a future version.`)
}

if (!subcommands.includes(cmd) || !this[cmd]) {
throw this.usageError(`${cmd} is not a recognized subcommand.`)
Expand Down