diff --git a/lib/arborist-cmd.js b/lib/arborist-cmd.js index 48ba3b0c94257..931ead8143dff 100644 --- a/lib/arborist-cmd.js +++ b/lib/arborist-cmd.js @@ -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) diff --git a/lib/commands/access.js b/lib/commands/access.js index df783c35fe0f7..f61c97d6f90de 100644 --- a/lib/commands/access.js +++ b/lib/commands/access.js @@ -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 []', - 'restricted []', - 'grant []', - 'revoke []', - '2fa-required []', - '2fa-not-required []', - 'ls-packages [||]', - 'ls-collaborators [ []]', - 'edit []', - ] - } + static description = 'Set access level on published packages' + static name = 'access' + static params = [ + 'registry', + 'otp', + ] + + static usage = [ + 'public []', + 'restricted []', + 'grant []', + 'revoke []', + '2fa-required []', + '2fa-not-required []', + 'ls-packages [||]', + 'ls-collaborators [ []]', + 'edit []', + ] async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/adduser.js b/lib/commands/adduser.js index aa3d8a336a51b..6cd6d3001c0e1 100644 --- a/lib/commands/adduser.js +++ b/lib/commands/adduser.js @@ -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 diff --git a/lib/commands/audit.js b/lib/commands/audit.js index ebc9f65c58e1f..fad43fe902df9 100644 --- a/lib/commands/audit.js +++ b/lib/commands/audit.js @@ -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 diff --git a/lib/commands/bin.js b/lib/commands/bin.js index 68559e4133e90..8f5ae0cc524e3 100644 --- a/lib/commands/bin.js +++ b/lib/commands/bin.js @@ -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 diff --git a/lib/commands/birthday.js b/lib/commands/birthday.js index 5dd9331d836c8..27fe2c50cab02 100644 --- a/lib/commands/birthday.js +++ b/lib/commands/birthday.js @@ -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']) diff --git a/lib/commands/bugs.js b/lib/commands/bugs.js index ecf50f32e35f9..8ca8188ccd793 100644 --- a/lib/commands/bugs.js +++ b/lib/commands/bugs.js @@ -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 ['[]'] - } - - /* 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 = ['[]'] + static params = ['browser', 'registry'] async exec (args) { if (!args || !args.length) { diff --git a/lib/commands/cache.js b/lib/commands/cache.js index 9a089c562e162..b1c045bbfae7f 100644 --- a/lib/commands/cache.js +++ b/lib/commands/cache.js @@ -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 ', - 'add ', - 'add ', - 'add ', - 'add @', - 'clean []', - 'ls [@]', - 'verify', - ] - } + static description = 'Manipulates packages cache' + static name = 'cache' + static params = ['cache'] + static usage = [ + 'add ', + 'add ', + 'add ', + 'add ', + 'add @', + 'clean []', + 'ls [@]', + 'verify', + ] async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/ci.js b/lib/commands/ci.js index a53c580670581..e928a01d15b54 100644 --- a/lib/commands/ci.js +++ b/lib/commands/ci.js @@ -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')) { diff --git a/lib/commands/completion.js b/lib/commands/completion.js index 504528c906ec5..4ded2de385afb 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -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) { diff --git a/lib/commands/config.js b/lib/commands/config.js index 0e92f6f3e50ba..0cdcd576f527a 100644 --- a/lib/commands/config.js +++ b/lib/commands/config.js @@ -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 = [= ...]', - 'get [ [ ...]]', - 'delete [ ...]', - '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 = [= ...]', + 'get [ [ ...]]', + 'delete [ ...]', + 'list [--json]', + 'edit', + ] + + static params = [ + 'json', + 'global', + 'editor', + 'location', + 'long', + ] async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/dedupe.js b/lib/commands/dedupe.js index f9314cfc5155a..e1eafbe3bc58d 100644 --- a/lib/commands/dedupe.js +++ b/lib/commands/dedupe.js @@ -5,32 +5,21 @@ const reifyFinish = require('../utils/reify-finish.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Dedupe extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Reduce duplication in the package tree' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'dedupe' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'global-style', - 'legacy-bundling', - 'strict-peer-deps', - 'package-lock', - 'omit', - 'ignore-scripts', - 'audit', - 'bin-links', - 'fund', - 'dry-run', - ...super.params, - ] - } + static description = 'Reduce duplication in the package tree' + static name = 'dedupe' + static params = [ + 'global-style', + 'legacy-bundling', + 'strict-peer-deps', + 'package-lock', + 'omit', + 'ignore-scripts', + 'audit', + 'bin-links', + 'fund', + 'dry-run', + ...super.params, + ] async exec (args) { if (this.npm.config.get('global')) { diff --git a/lib/commands/deprecate.js b/lib/commands/deprecate.js index 1e33b98bf312f..839e974caf09b 100644 --- a/lib/commands/deprecate.js +++ b/lib/commands/deprecate.js @@ -7,27 +7,13 @@ const libaccess = require('libnpmaccess') const BaseCommand = require('../base-command.js') class Deprecate extends BaseCommand { - static get description () { - return 'Deprecate a version of a package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'deprecate' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[@] '] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'registry', - 'otp', - ] - } + static description = 'Deprecate a version of a package' + static name = 'deprecate' + static usage = ['[@] '] + static params = [ + 'registry', + 'otp', + ] async completion (opts) { if (opts.conf.argv.remain.length > 1) { diff --git a/lib/commands/diff.js b/lib/commands/diff.js index f6e2cce8b70e9..3134f502ea151 100644 --- a/lib/commands/diff.js +++ b/lib/commands/diff.js @@ -12,40 +12,27 @@ const readPackageName = require('../utils/read-package-name.js') const BaseCommand = require('../base-command.js') class Diff extends BaseCommand { - static get description () { - return 'The registry diff command' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'diff' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - '[...]', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'diff', - 'diff-name-only', - 'diff-unified', - 'diff-ignore-all-space', - 'diff-no-prefix', - 'diff-src-prefix', - 'diff-dst-prefix', - 'diff-text', - 'global', - 'tag', - 'workspace', - 'workspaces', - 'include-workspace-root', - ] - } + static description = 'The registry diff command' + static name = 'diff' + static usage = [ + '[...]', + ] + + static params = [ + 'diff', + 'diff-name-only', + 'diff-unified', + 'diff-ignore-all-space', + 'diff-no-prefix', + 'diff-src-prefix', + 'diff-dst-prefix', + 'diff-text', + 'global', + 'tag', + 'workspace', + 'workspaces', + 'include-workspace-root', + ] async exec (args) { const specs = this.npm.config.get('diff').filter(d => d) diff --git a/lib/commands/dist-tag.js b/lib/commands/dist-tag.js index 9c938851afd83..fa79b293c50d0 100644 --- a/lib/commands/dist-tag.js +++ b/lib/commands/dist-tag.js @@ -8,28 +8,14 @@ const readPackageName = require('../utils/read-package-name.js') const BaseCommand = require('../base-command.js') class DistTag extends BaseCommand { - static get description () { - return 'Modify package distribution tags' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['workspace', 'workspaces', 'include-workspace-root'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'dist-tag' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - 'add @ []', - 'rm ', - 'ls []', - ] - } + static description = 'Modify package distribution tags' + static params = ['workspace', 'workspaces', 'include-workspace-root'] + static name = 'dist-tag' + static usage = [ + 'add @ []', + 'rm ', + 'ls []', + ] async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/docs.js b/lib/commands/docs.js index e73528d180993..9aba242057178 100644 --- a/lib/commands/docs.js +++ b/lib/commands/docs.js @@ -5,31 +5,17 @@ const hostedFromMani = require('../utils/hosted-git-info-from-manifest.js') const BaseCommand = require('../base-command.js') class Docs extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Open documentation for a package in a web browser' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'docs' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'browser', - 'registry', - 'workspace', - 'workspaces', - 'include-workspace-root', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[ [ ...]]'] - } + static description = 'Open documentation for a package in a web browser' + static name = 'docs' + static params = [ + 'browser', + 'registry', + 'workspace', + 'workspaces', + 'include-workspace-root', + ] + + static usage = ['[ [ ...]]'] async exec (args) { if (!args || !args.length) { diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index 8cb774ee33e57..6b8878b6f4f12 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -37,20 +37,9 @@ const maskLabel = mask => { const BaseCommand = require('../base-command.js') class Doctor extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Check your npm environment' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'doctor' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['registry'] - } + static description = 'Check your npm environment' + static name = 'doctor' + static params = ['registry'] async exec (args) { this.npm.log.info('Running checkup') diff --git a/lib/commands/edit.js b/lib/commands/edit.js index 3a9a10b400449..5f069c4f132e5 100644 --- a/lib/commands/edit.js +++ b/lib/commands/edit.js @@ -9,26 +9,13 @@ const completion = require('../utils/completion/installed-shallow.js') const BaseCommand = require('../base-command.js') class Edit extends BaseCommand { - static get description () { - return 'Edit an installed package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'edit' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[/...]'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['editor'] - } + static description = 'Edit an installed package' + static name = 'edit' + static usage = ['[/...]'] + static params = ['editor'] - /* istanbul ignore next - see test/lib/load-all-commands.js */ + // TODO + /* istanbul ignore next */ async completion (opts) { return completion(this.npm, opts) } diff --git a/lib/commands/exec.js b/lib/commands/exec.js index 86a806eb525db..515ac910f80e4 100644 --- a/lib/commands/exec.js +++ b/lib/commands/exec.js @@ -28,36 +28,22 @@ const getLocationMsg = require('../exec/get-workspace-location-msg.js') // process.env.npm_lifecycle_event = 'npx' class Exec extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Run a command from a local or remote npm package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'package', - 'call', - 'workspace', - 'workspaces', - 'include-workspace-root', - ] - } + static description = 'Run a command from a local or remote npm package' + static params = [ + 'package', + 'call', + 'workspace', + 'workspaces', + 'include-workspace-root', + ] - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'exec' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - '-- [@] [args...]', - '--package=[@] -- [args...]', - '-c \' [args...]\'', - '--package=foo -c \' [args...]\'', - ] - } + static name = 'exec' + static usage = [ + '-- [@] [args...]', + '--package=[@] -- [args...]', + '-c \' [args...]\'', + '--package=foo -c \' [args...]\'', + ] async exec (_args, { locationMsg, path, runPath } = {}) { if (!path) { diff --git a/lib/commands/explain.js b/lib/commands/explain.js index 03930c2f71777..fd62b87fc869d 100644 --- a/lib/commands/explain.js +++ b/lib/commands/explain.js @@ -8,29 +8,16 @@ const validName = require('validate-npm-package-name') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Explain extends ArboristWorkspaceCmd { - static get description () { - return 'Explain installed packages' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'explain' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [''] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'json', - 'workspace', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ + static description = 'Explain installed packages' + static name = 'explain' + static usage = [''] + static params = [ + 'json', + 'workspace', + ] + + // TODO + /* istanbul ignore next */ async completion (opts) { return completion(this.npm, opts) } diff --git a/lib/commands/explore.js b/lib/commands/explore.js index d7397262cd8f1..f94fff01c42eb 100644 --- a/lib/commands/explore.js +++ b/lib/commands/explore.js @@ -8,26 +8,13 @@ const completion = require('../utils/completion/installed-shallow.js') const BaseCommand = require('../base-command.js') class Explore extends BaseCommand { - static get description () { - return 'Browse an installed package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'explore' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [' [ -- ]'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['shell'] - } + static description = 'Browse an installed package' + static name = 'explore' + static usage = [' [ -- ]'] + static params = ['shell'] - /* istanbul ignore next - see test/lib/load-all-commands.js */ + // TODO + /* istanbul ignore next */ async completion (opts) { return completion(this.npm, opts) } diff --git a/lib/commands/find-dupes.js b/lib/commands/find-dupes.js index 5467a94dd9fcf..a9de2410ec0d7 100644 --- a/lib/commands/find-dupes.js +++ b/lib/commands/find-dupes.js @@ -2,31 +2,20 @@ const ArboristWorkspaceCmd = require('../arborist-cmd.js') class FindDupes extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Find duplication in the package tree' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'find-dupes' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'global-style', - 'legacy-bundling', - 'strict-peer-deps', - 'package-lock', - 'omit', - 'ignore-scripts', - 'audit', - 'bin-links', - 'fund', - ...super.params, - ] - } + static description = 'Find duplication in the package tree' + static name = 'find-dupes' + static params = [ + 'global-style', + 'legacy-bundling', + 'strict-peer-deps', + 'package-lock', + 'omit', + 'ignore-scripts', + 'audit', + 'bin-links', + 'fund', + ...super.params, + ] async exec (args, cb) { this.npm.config.set('dry-run', true) diff --git a/lib/commands/fund.js b/lib/commands/fund.js index e2a158bd4cce9..81c6d9a1b0726 100644 --- a/lib/commands/fund.js +++ b/lib/commands/fund.js @@ -17,27 +17,13 @@ const getPrintableName = ({ name, version }) => { } class Fund extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Retrieve funding information' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'fund' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['json', 'browser', 'unicode', 'workspace', 'which'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[[<@scope>/]]'] - } + static description = 'Retrieve funding information' + static name = 'fund' + static params = ['json', 'browser', 'unicode', 'workspace', 'which'] + static usage = ['[[<@scope>/]]'] - /* istanbul ignore next - see test/lib/load-all-commands.js */ + // TODO + /* istanbul ignore next */ async completion (opts) { return completion(this.npm, opts) } diff --git a/lib/commands/get.js b/lib/commands/get.js index 0e314efe7144c..7583ade23d600 100644 --- a/lib/commands/get.js +++ b/lib/commands/get.js @@ -1,22 +1,12 @@ const BaseCommand = require('../base-command.js') class Get extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Get a value from the npm configuration' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'get' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[ ...] (See `npm config`)'] - } + static description = 'Get a value from the npm configuration' + static name = 'get' + static usage = ['[ ...] (See `npm config`)'] - /* istanbul ignore next - see test/lib/load-all-commands.js */ + // TODO + /* istanbul ignore next */ async completion (opts) { const config = await this.npm.cmd('config') return config.completion(opts) diff --git a/lib/commands/help-search.js b/lib/commands/help-search.js index a2586f30958c2..6025a6dabd74b 100644 --- a/lib/commands/help-search.js +++ b/lib/commands/help-search.js @@ -7,24 +7,10 @@ const readFile = promisify(fs.readFile) const BaseCommand = require('../base-command.js') class HelpSearch extends BaseCommand { - static get description () { - return 'Search npm help documentation' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'help-search' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [''] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['long'] - } + static description = 'Search npm help documentation' + static name = 'help-search' + static usage = [''] + static params = ['long'] async exec (args) { if (!args.length) { diff --git a/lib/commands/help.js b/lib/commands/help.js index 2986f917f9e0f..f94178dd5d1d6 100644 --- a/lib/commands/help.js +++ b/lib/commands/help.js @@ -13,25 +13,10 @@ const BaseCommand = require('../base-command.js') const manNumberRegex = /\.(\d+)(\.[^/\\]*)?$/ class Help extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Get help on npm' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'help' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [' []'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['viewer'] - } + static description = 'Get help on npm' + static name = 'help' + static usage = [' []'] + static params = ['viewer'] async completion (opts) { if (opts.conf.argv.remain.length > 2) { diff --git a/lib/commands/hook.js b/lib/commands/hook.js index 3ae2e07b4ea4f..2881f044e8e28 100644 --- a/lib/commands/hook.js +++ b/lib/commands/hook.js @@ -5,30 +5,19 @@ const Table = require('cli-table3') const BaseCommand = require('../base-command.js') class Hook extends BaseCommand { - static get description () { - return 'Manage registry hooks' - } - - static get name () { - return 'hook' - } + static description = 'Manage registry hooks' + static name = 'hook' + static params = [ + 'registry', + 'otp', + ] - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'registry', - 'otp', - ] - } - - static get usage () { - return [ - 'add [--type=]', - 'ls [pkg]', - 'rm ', - 'update ', - ] - } + static usage = [ + 'add [--type=]', + 'ls [pkg]', + 'rm ', + 'update ', + ] async exec (args) { return otplease(this.npm.flatOptions, (opts) => { diff --git a/lib/commands/init.js b/lib/commands/init.js index 1eb6fbf24a52b..eaca2716ee112 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -12,29 +12,14 @@ const getLocationMsg = require('../exec/get-workspace-location-msg.js') const BaseCommand = require('../base-command.js') class Init extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Create a package.json file' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['yes', 'force', 'workspace', 'workspaces', 'include-workspace-root'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'init' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - '[--force|-f|--yes|-y|--scope]', - '<@scope> (same as `npx <@scope>/create`)', - '[<@scope>/] (same as `npx [<@scope>/]create-`)', - ] - } + static description = 'Create a package.json file' + static params = ['yes', 'force', 'workspace', 'workspaces', 'include-workspace-root'] + static name = 'init' + static usage = [ + '[--force|-f|--yes|-y|--scope]', + '<@scope> (same as `npx <@scope>/create`)', + '[<@scope>/] (same as `npx [<@scope>/]create-`)', + ] async exec (args) { // npm exec style diff --git a/lib/commands/install-ci-test.js b/lib/commands/install-ci-test.js index 7b121f776666a..9977a2edc5641 100644 --- a/lib/commands/install-ci-test.js +++ b/lib/commands/install-ci-test.js @@ -4,14 +4,8 @@ const CI = require('./ci.js') class InstallCITest extends CI { - static get description () { - return 'Install a project with a clean slate and run tests' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'install-ci-test' - } + static description = 'Install a project with a clean slate and run tests' + static name = 'install-ci-test' async exec (args, cb) { await this.npm.exec('ci', args) diff --git a/lib/commands/install-test.js b/lib/commands/install-test.js index 74e7ebcf86c90..191d70909f9e7 100644 --- a/lib/commands/install-test.js +++ b/lib/commands/install-test.js @@ -4,14 +4,8 @@ const Install = require('./install.js') class InstallTest extends Install { - static get description () { - return 'Install package(s) and run tests' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'install-test' - } + static description = 'Install package(s) and run tests' + static name = 'install-test' async exec (args, cb) { await this.npm.exec('install', args) diff --git a/lib/commands/install.js b/lib/commands/install.js index fa24b4b54cc24..02ccb57248341 100644 --- a/lib/commands/install.js +++ b/lib/commands/install.js @@ -12,51 +12,37 @@ const checks = require('npm-install-checks') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Install extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Install a package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'install' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'save', - 'save-exact', - 'global', - 'global-style', - 'legacy-bundling', - 'strict-peer-deps', - 'package-lock', - 'omit', - 'ignore-scripts', - 'audit', - 'bin-links', - 'fund', - 'dry-run', - ...super.params, - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - '[<@scope>/]', - '[<@scope>/]@', - '[<@scope>/]@', - '[<@scope>/]@', - '@npm:', - '', - '', - '', - '', - '/', - ] - } + static description = 'Install a package' + static name = 'install' + static params = [ + 'save', + 'save-exact', + 'global', + 'global-style', + 'legacy-bundling', + 'strict-peer-deps', + 'package-lock', + 'omit', + 'ignore-scripts', + 'audit', + 'bin-links', + 'fund', + 'dry-run', + ...super.params, + ] + + static usage = [ + '[<@scope>/]', + '[<@scope>/]@', + '[<@scope>/]@', + '[<@scope>/]@', + '@npm:', + '', + '', + '', + '', + '/', + ] async completion (opts) { const { partialWord } = opts diff --git a/lib/commands/link.js b/lib/commands/link.js index b4f4a1289ddb1..8755af6f68266 100644 --- a/lib/commands/link.js +++ b/lib/commands/link.js @@ -12,43 +12,29 @@ const reifyFinish = require('../utils/reify-finish.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Link extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Symlink a package folder' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'link' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - '(in package dir)', - '[<@scope>/][@]', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'save', - 'save-exact', - 'global', - 'global-style', - 'legacy-bundling', - 'strict-peer-deps', - 'package-lock', - 'omit', - 'ignore-scripts', - 'audit', - 'bin-links', - 'fund', - 'dry-run', - ...super.params, - ] - } + static description = 'Symlink a package folder' + static name = 'link' + static usage = [ + '(in package dir)', + '[<@scope>/][@]', + ] + + static params = [ + 'save', + 'save-exact', + 'global', + 'global-style', + 'legacy-bundling', + 'strict-peer-deps', + 'package-lock', + 'omit', + 'ignore-scripts', + 'audit', + 'bin-links', + 'fund', + 'dry-run', + ...super.params, + ] async completion (opts) { const dir = this.npm.globalDir diff --git a/lib/commands/ll.js b/lib/commands/ll.js index d438de61e2fe7..99a144fde36fe 100644 --- a/lib/commands/ll.js +++ b/lib/commands/ll.js @@ -1,15 +1,8 @@ const LS = require('./ls.js') class LL extends LS { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'll' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[[<@scope>/] ...]'] - } + static name = 'll' + static usage = ['[[<@scope>/] ...]'] async exec (args) { this.npm.config.set('long', true) diff --git a/lib/commands/logout.js b/lib/commands/logout.js index 43a04bb577cd8..e17b2b879002c 100644 --- a/lib/commands/logout.js +++ b/lib/commands/logout.js @@ -4,23 +4,12 @@ const npmFetch = require('npm-registry-fetch') const BaseCommand = require('../base-command.js') class Logout extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Log out of the registry' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'logout' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'registry', - 'scope', - ] - } + static description = 'Log out of the registry' + static name = 'logout' + static params = [ + 'registry', + 'scope', + ] async exec (args) { const registry = this.npm.config.get('registry') diff --git a/lib/commands/ls.js b/lib/commands/ls.js index b8c1f0ef9c221..8c338c0647586 100644 --- a/lib/commands/ls.js +++ b/lib/commands/ls.js @@ -25,39 +25,25 @@ const ArboristWorkspaceCmd = require('../arborist-cmd.js') const localeCompare = require('@isaacs/string-locale-compare')('en') class LS extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'List installed packages' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'ls' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[[<@scope>/] ...]'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'all', - 'json', - 'long', - 'parseable', - 'global', - 'depth', - 'omit', - 'link', - 'package-lock-only', - 'unicode', - ...super.params, - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ + static description = 'List installed packages' + static name = 'ls' + static usage = ['[[<@scope>/] ...]'] + static params = [ + 'all', + 'json', + 'long', + 'parseable', + 'global', + 'depth', + 'omit', + 'link', + 'package-lock-only', + 'unicode', + ...super.params, + ] + + // TODO + /* istanbul ignore next */ async completion (opts) { return completion(this.npm, opts) } diff --git a/lib/commands/org.js b/lib/commands/org.js index 18f73cb59f017..c6882a8e26313 100644 --- a/lib/commands/org.js +++ b/lib/commands/org.js @@ -4,28 +4,15 @@ const Table = require('cli-table3') const BaseCommand = require('../base-command.js') class Org extends BaseCommand { - static get description () { - return 'Manage orgs' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'org' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - 'set orgname username [developer | admin | owner]', - 'rm orgname username', - 'ls orgname []', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['registry', 'otp', 'json', 'parseable'] - } + static description = 'Manage orgs' + static name = 'org' + static usage = [ + 'set orgname username [developer | admin | owner]', + 'rm orgname username', + 'ls orgname []', + ] + + static params = ['registry', 'otp', 'json', 'parseable'] async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/outdated.js b/lib/commands/outdated.js index 01047b4d37018..e1a6f8150aae1 100644 --- a/lib/commands/outdated.js +++ b/lib/commands/outdated.js @@ -14,32 +14,17 @@ const ansiTrim = require('../utils/ansi-trim.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Outdated extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Check for outdated packages' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'outdated' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[[<@scope>/] ...]'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'all', - 'json', - 'long', - 'parseable', - 'global', - 'workspace', - ] - } + static description = 'Check for outdated packages' + static name = 'outdated' + static usage = ['[[<@scope>/] ...]'] + static params = [ + 'all', + 'json', + 'long', + 'parseable', + 'global', + 'workspace', + ] async exec (args) { const global = path.resolve(this.npm.globalDir, '..') diff --git a/lib/commands/owner.js b/lib/commands/owner.js index 4d1fe9b9f8d0e..8f0b1f1eff686 100644 --- a/lib/commands/owner.js +++ b/lib/commands/owner.js @@ -8,31 +8,18 @@ const readLocalPkgName = require('../utils/read-package-name.js') const BaseCommand = require('../base-command.js') class Owner extends BaseCommand { - static get description () { - return 'Manage package owners' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'owner' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'registry', - 'otp', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - 'add [<@scope>/]', - 'rm [<@scope>/]', - 'ls [<@scope>/]', - ] - } + static description = 'Manage package owners' + static name = 'owner' + static params = [ + 'registry', + 'otp', + ] + + static usage = [ + 'add [<@scope>/]', + 'rm [<@scope>/]', + 'ls [<@scope>/]', + ] async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/pack.js b/lib/commands/pack.js index 27682878cb613..d84dde86e83ec 100644 --- a/lib/commands/pack.js +++ b/lib/commands/pack.js @@ -12,32 +12,18 @@ const writeFile = util.promisify(require('fs').writeFile) const BaseCommand = require('../base-command.js') class Pack extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Create a tarball from a package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'pack' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'dry-run', - 'json', - 'pack-destination', - 'workspace', - 'workspaces', - 'include-workspace-root', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[[<@scope>/]...]'] - } + static description = 'Create a tarball from a package' + static name = 'pack' + static params = [ + 'dry-run', + 'json', + 'pack-destination', + 'workspace', + 'workspaces', + 'include-workspace-root', + ] + + static usage = ['[[<@scope>/]...]'] async exec (args) { if (args.length === 0) { diff --git a/lib/commands/ping.js b/lib/commands/ping.js index 0025573d6016f..a049d24127daf 100644 --- a/lib/commands/ping.js +++ b/lib/commands/ping.js @@ -3,20 +3,9 @@ const pingUtil = require('../utils/ping.js') const BaseCommand = require('../base-command.js') class Ping extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Ping npm registry' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['registry'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'ping' - } + static description = 'Ping npm registry' + static params = ['registry'] + static name = 'ping' async exec (args) { log.notice('PING', this.npm.config.get('registry')) diff --git a/lib/commands/pkg.js b/lib/commands/pkg.js index 53e6431ee4d44..007932429d661 100644 --- a/lib/commands/pkg.js +++ b/lib/commands/pkg.js @@ -3,33 +3,20 @@ const BaseCommand = require('../base-command.js') const Queryable = require('../utils/queryable.js') class Pkg extends BaseCommand { - static get description () { - return 'Manages your package.json' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'pkg' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - 'set = [= ...]', - 'get [ [ ...]]', - 'delete [ ...]', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'force', - 'json', - 'workspace', - 'workspaces', - ] - } + static description = 'Manages your package.json' + static name = 'pkg' + static usage = [ + 'set = [= ...]', + 'get [ [ ...]]', + 'delete [ ...]', + ] + + static params = [ + 'force', + 'json', + 'workspace', + 'workspaces', + ] async exec (args, { prefix } = {}) { if (!prefix) { diff --git a/lib/commands/prefix.js b/lib/commands/prefix.js index 1f2a78c312a4f..264b819fc7692 100644 --- a/lib/commands/prefix.js +++ b/lib/commands/prefix.js @@ -1,25 +1,10 @@ const BaseCommand = require('../base-command.js') class Prefix extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Display prefix' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'prefix' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['global'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[-g]'] - } + static description = 'Display prefix' + static name = 'prefix' + static params = ['global'] + static usage = ['[-g]'] async exec (args) { return this.npm.output(this.npm.prefix) diff --git a/lib/commands/profile.js b/lib/commands/profile.js index 72e4bb849f46d..0939013cc2c61 100644 --- a/lib/commands/profile.js +++ b/lib/commands/profile.js @@ -38,34 +38,21 @@ const writableProfileKeys = [ const BaseCommand = require('../base-command.js') class Profile extends BaseCommand { - static get description () { - return 'Change settings on your registry profile' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'profile' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - 'enable-2fa [auth-only|auth-and-writes]', - 'disable-2fa', - 'get []', - 'set ', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'registry', - 'json', - 'parseable', - 'otp', - ] - } + static description = 'Change settings on your registry profile' + static name = 'profile' + static usage = [ + 'enable-2fa [auth-only|auth-and-writes]', + 'disable-2fa', + 'get []', + 'set ', + ] + + static params = [ + 'registry', + 'json', + 'parseable', + 'otp', + ] async completion (opts) { var argv = opts.conf.argv.remain diff --git a/lib/commands/prune.js b/lib/commands/prune.js index 334ee4dd4a9ba..403575e024b27 100644 --- a/lib/commands/prune.js +++ b/lib/commands/prune.js @@ -4,25 +4,10 @@ const reifyFinish = require('../utils/reify-finish.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Prune extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Remove extraneous packages' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'prune' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['omit', 'dry-run', 'json', ...super.params] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[[<@scope>/]...]'] - } + static description = 'Remove extraneous packages' + static name = 'prune' + static params = ['omit', 'dry-run', 'json', ...super.params] + static usage = ['[[<@scope>/]...]'] async exec () { const where = this.npm.prefix diff --git a/lib/commands/publish.js b/lib/commands/publish.js index efa1485654b2b..88ddcae7bbdf2 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -26,34 +26,19 @@ const readJson = util.promisify(require('read-package-json')) const BaseCommand = require('../base-command.js') class Publish extends BaseCommand { - static get description () { - return 'Publish a package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'publish' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'tag', - 'access', - 'dry-run', - 'otp', - 'workspace', - 'workspaces', - 'include-workspace-root', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [ - '[]', - ] - } + static description = 'Publish a package' + static name = 'publish' + static params = [ + 'tag', + 'access', + 'dry-run', + 'otp', + 'workspace', + 'workspaces', + 'include-workspace-root', + ] + + static usage = ['[]'] async exec (args) { if (args.length === 0) { diff --git a/lib/commands/rebuild.js b/lib/commands/rebuild.js index d95a865b49320..471d60b740df1 100644 --- a/lib/commands/rebuild.js +++ b/lib/commands/rebuild.js @@ -6,32 +6,19 @@ const completion = require('../utils/completion/installed-deep.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') class Rebuild extends ArboristWorkspaceCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Rebuild a package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'rebuild' - } + static description = 'Rebuild a package' + static name = 'rebuild' + static params = [ + 'global', + 'bin-links', + 'ignore-scripts', + ...super.params, + ] - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'global', - 'bin-links', - 'ignore-scripts', - ...super.params, - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[[<@scope>/][@] ...]'] - } + static usage = ['[[<@scope>/][@] ...]'] - /* istanbul ignore next - see test/lib/load-all-commands.js */ + // TODO + /* istanbul ignore next */ async completion (opts) { return completion(this.npm, opts) } diff --git a/lib/commands/repo.js b/lib/commands/repo.js index f873098967f02..cc68e85650235 100644 --- a/lib/commands/repo.js +++ b/lib/commands/repo.js @@ -7,25 +7,10 @@ const openUrl = require('../utils/open-url.js') const BaseCommand = require('../base-command.js') class Repo extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Open package repository page in the browser' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'repo' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['browser', 'workspace', 'workspaces', 'include-workspace-root'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[ [ ...]]'] - } + static description = 'Open package repository page in the browser' + static name = 'repo' + static params = ['browser', 'workspace', 'workspaces', 'include-workspace-root'] + static usage = ['[ [ ...]]'] async exec (args) { if (!args || !args.length) { diff --git a/lib/commands/restart.js b/lib/commands/restart.js index f832d6a1e3458..a12368644a13b 100644 --- a/lib/commands/restart.js +++ b/lib/commands/restart.js @@ -2,22 +2,11 @@ const LifecycleCmd = require('../lifecycle-cmd.js') // This ends up calling run-script(['restart', ...args]) class Restart extends LifecycleCmd { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Restart a package' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'restart' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'ignore-scripts', - 'script-shell', - ] - } + static description = 'Restart a package' + static name = 'restart' + static params = [ + 'ignore-scripts', + 'script-shell', + ] } module.exports = Restart diff --git a/lib/commands/root.js b/lib/commands/root.js index acfc5c70ef1b7..7749c602456b7 100644 --- a/lib/commands/root.js +++ b/lib/commands/root.js @@ -1,19 +1,8 @@ const BaseCommand = require('../base-command.js') class Root extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Display npm root' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'root' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['global'] - } + static description = 'Display npm root' + static name = 'root' + static params = ['global'] async exec () { this.npm.output(this.npm.dir) diff --git a/lib/commands/run-script.js b/lib/commands/run-script.js index 832e166a684b0..37140c8c539c6 100644 --- a/lib/commands/run-script.js +++ b/lib/commands/run-script.js @@ -28,32 +28,18 @@ const nocolor = { const BaseCommand = require('../base-command.js') class RunScript extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Run arbitrary package scripts' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'workspace', - 'workspaces', - 'include-workspace-root', - 'if-present', - 'ignore-scripts', - 'script-shell', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'run-script' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return [' [-- ]'] - } + static description = 'Run arbitrary package scripts' + static params = [ + 'workspace', + 'workspaces', + 'include-workspace-root', + 'if-present', + 'ignore-scripts', + 'script-shell', + ] + + static name = 'run-script' + static usage = [' [-- ]'] async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/search.js b/lib/commands/search.js index 6c5c995c38c80..ff533ebbd1c1b 100644 --- a/lib/commands/search.js +++ b/lib/commands/search.js @@ -27,37 +27,23 @@ function prepareExcludes (searchexclude) { const BaseCommand = require('../base-command.js') class Search extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Search for packages' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'search' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return [ - 'long', - 'json', - 'color', - 'parseable', - 'description', - 'searchopts', - 'searchexclude', - 'registry', - 'prefer-online', - 'prefer-offline', - 'offline', - ] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[search terms ...]'] - } + static description = 'Search for packages' + static name = 'search' + static params = [ + 'long', + 'json', + 'color', + 'parseable', + 'description', + 'searchopts', + 'searchexclude', + 'registry', + 'prefer-online', + 'prefer-offline', + 'offline', + ] + + static usage = ['[search terms ...]'] async exec (args) { const opts = { diff --git a/lib/commands/set-script.js b/lib/commands/set-script.js index d99487e6713b4..58fd2726db601 100644 --- a/lib/commands/set-script.js +++ b/lib/commands/set-script.js @@ -5,25 +5,10 @@ const PackageJson = require('@npmcli/package-json') const BaseCommand = require('../base-command.js') class SetScript extends BaseCommand { - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get description () { - return 'Set tasks in the scripts section of package.json' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get params () { - return ['workspace', 'workspaces', 'include-workspace-root'] - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get name () { - return 'set-script' - } - - /* istanbul ignore next - see test/lib/load-all-commands.js */ - static get usage () { - return ['[