Skip to content

chore: switch to true static attributes #3989

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

Merged
merged 1 commit into from
Nov 10, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lib/arborist-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ class ArboristCmd extends BaseCommand {
return true
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return [
'workspace',
'workspaces',
'include-workspace-root',
]
}
static params = [
'workspace',
'workspaces',
'include-workspace-root',
]

async execWorkspaces (args, filters) {
await this.setWorkspaces(filters)
Expand Down
47 changes: 18 additions & 29 deletions lib/commands/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,24 @@ const subcommands = [
]

class Access extends BaseCommand {
static get description () {
return 'Set access level on published packages'
}

static get name () {
return 'access'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return [
'registry',
'otp',
]
}

static get usage () {
return [
'public [<package>]',
'restricted [<package>]',
'grant <read-only|read-write> <scope:team> [<package>]',
'revoke <scope:team> [<package>]',
'2fa-required [<package>]',
'2fa-not-required [<package>]',
'ls-packages [<user>|<scope>|<scope:team>]',
'ls-collaborators [<package> [<user>]]',
'edit [<package>]',
]
}
static description = 'Set access level on published packages'
static name = 'access'
static params = [
'registry',
'otp',
]

static usage = [
'public [<package>]',
'restricted [<package>]',
'grant <read-only|read-write> <scope:team> [<package>]',
'revoke <scope:team> [<package>]',
'2fa-required [<package>]',
'2fa-not-required [<package>]',
'ls-packages [<user>|<scope>|<scope:team>]',
'ls-collaborators [<package> [<user>]]',
'edit [<package>]',
]

async completion (opts) {
const argv = opts.conf.argv.remain
Expand Down
20 changes: 6 additions & 14 deletions lib/commands/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@ const authTypes = {
}

class AddUser extends BaseCommand {
static get description () {
return 'Add a registry user account'
}

static get name () {
return 'adduser'
}

static get params () {
return [
'registry',
'scope',
]
}
static description = 'Add a registry user account'
static name = 'adduser'
static params = [
'registry',
'scope',
]

async exec (args) {
const { scope } = this.npm.flatOptions
Expand Down
40 changes: 13 additions & 27 deletions lib/commands/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,19 @@ 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 */
static get description () {
return 'Run a security audit'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'audit'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return [
'audit-level',
'dry-run',
'force',
'json',
'package-lock-only',
'omit',
...super.params,
]
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get usage () {
return ['[fix]']
}
static description = 'Run a security audit'
static name = 'audit'
static params = [
'audit-level',
'dry-run',
'force',
'json',
'package-lock-only',
'omit',
...super.params,
]

static usage = ['[fix]']

async completion (opts) {
const argv = opts.conf.argv.remain
Expand Down
14 changes: 3 additions & 11 deletions lib/commands/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@ const envPath = require('../utils/path.js')
const BaseCommand = require('../base-command.js')

class Bin extends BaseCommand {
static get description () {
return 'Display npm bin folder'
}

static get name () {
return 'bin'
}

static get params () {
return ['global']
}
static description = 'Display npm bin folder'
static name = 'bin'
static params = ['global']

async exec (args) {
const b = this.npm.bin
Expand Down
1 change: 1 addition & 0 deletions lib/commands/birthday.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const BaseCommand = require('../base-command.js')

class Birthday extends BaseCommand {
static name = 'birthday'
async exec () {
this.npm.config.set('yes', true)
return this.npm.exec('exec', ['@npmcli/npm-birthday'])
Expand Down
20 changes: 4 additions & 16 deletions lib/commands/bugs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@ const hostedFromMani = require('../utils/hosted-git-info-from-manifest.js')
const BaseCommand = require('../base-command.js')

class Bugs extends BaseCommand {
static get description () {
return 'Report bugs for a package in a web browser'
}

static get name () {
return 'bugs'
}

static get usage () {
return ['[<pkgname>]']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['browser', 'registry']
}
static description = 'Report bugs for a package in a web browser'
static name = 'bugs'
static usage = ['[<pkgname>]']
static params = ['browser', 'registry']

async exec (args) {
if (!args || !args.length) {
Expand Down
40 changes: 13 additions & 27 deletions lib/commands/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,33 +67,19 @@ const searchCachePackage = async (path, spec, cacheKeys) => {
}

class Cache extends BaseCommand {
static get description () {
return 'Manipulates packages cache'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'cache'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['cache']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get usage () {
return [
'add <tarball file>',
'add <folder>',
'add <tarball url>',
'add <git url>',
'add <name>@<version>',
'clean [<key>]',
'ls [<name>@<version>]',
'verify',
]
}
static description = 'Manipulates packages cache'
static name = 'cache'
static params = ['cache']
static usage = [
'add <tarball file>',
'add <folder>',
'add <tarball url>',
'add <git url>',
'add <name>@<version>',
'clean [<key>]',
'ls [<name>@<version>]',
'verify',
]

async completion (opts) {
const argv = opts.conf.argv.remain
Expand Down
25 changes: 7 additions & 18 deletions lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,13 @@ const removeNodeModules = async where => {
const ArboristWorkspaceCmd = require('../arborist-cmd.js')

class CI extends ArboristWorkspaceCmd {
/* istanbul ignore next - see test/lib/load-all-commands.js */
static get description () {
return 'Install a project with a clean slate'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'ci'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return [
'audit',
'ignore-scripts',
'script-shell',
]
}
static description = 'Install a project with a clean slate'
static name = 'ci'
static params = [
'audit',
'ignore-scripts',
'script-shell',
]

async exec () {
if (this.npm.config.get('global')) {
Expand Down
11 changes: 2 additions & 9 deletions lib/commands/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,8 @@ const { promisify } = require('util')
const BaseCommand = require('../base-command.js')

class Completion extends BaseCommand {
/* istanbul ignore next - see test/lib/load-all-commands.js */
static get description () {
return 'Tab Completion for npm'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'completion'
}
static description = 'Tab Completion for npm'
static name = 'completion'

// completion for the completion command
async completion (opts) {
Expand Down
47 changes: 17 additions & 30 deletions lib/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,23 @@ const publicVar = k => !/^(\/\/[^:]+:)?_/.test(k)

const BaseCommand = require('../base-command.js')
class Config extends BaseCommand {
static get description () {
return 'Manage the npm configuration files'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'config'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get usage () {
return [
'set <key>=<value> [<key>=<value> ...]',
'get [<key> [<key> ...]]',
'delete <key> [<key> ...]',
'list [--json]',
'edit',
]
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return [
'json',
'global',
'editor',
'location',
'long',
]
}
static description = 'Manage the npm configuration files'
static name = 'config'
static usage = [
'set <key>=<value> [<key>=<value> ...]',
'get [<key> [<key> ...]]',
'delete <key> [<key> ...]',
'list [--json]',
'edit',
]

static params = [
'json',
'global',
'editor',
'location',
'long',
]

async completion (opts) {
const argv = opts.conf.argv.remain
Expand Down
Loading