diff options
author | Gar <gar+gh@danger.computer> | 2022-03-24 17:18:56 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-03-28 23:21:36 +0300 |
commit | d8dcc02cfd354c1314c45d6530ec926cd138210c (patch) | |
tree | ba3721d4c4f153fe005bf9e08d450d9e2473a9a4 /lib/utils/cmd-list.js | |
parent | a64acc0bf01e4bc68b26ead5b2d5c6db47ef16c2 (diff) |
fix: consolidate command alias code
Diffstat (limited to 'lib/utils/cmd-list.js')
-rw-r--r-- | lib/utils/cmd-list.js | 158 |
1 files changed, 80 insertions, 78 deletions
diff --git a/lib/utils/cmd-list.js b/lib/utils/cmd-list.js index 1469ebdd6..c1d20186a 100644 --- a/lib/utils/cmd-list.js +++ b/lib/utils/cmd-list.js @@ -1,5 +1,23 @@ -// short names for common things -const shorthands = { +const abbrev = require('abbrev') + +// plumbing should not have any aliases +const aliases = { + + // aliases + login: 'adduser', + author: 'owner', + home: 'docs', + issues: 'bugs', + info: 'view', + show: 'view', + find: 'search', + add: 'install', + unlink: 'uninstall', + remove: 'uninstall', + rm: 'uninstall', + r: 'uninstall', + + // short names for common things un: 'uninstall', rb: 'rebuild', list: 'ls', @@ -21,12 +39,11 @@ const shorthands = { 'clean-install-test': 'cit', x: 'exec', why: 'explain', -} - -const affordances = { la: 'll', verison: 'version', ic: 'ci', + + // typos innit: 'init', // manually abbrev so that install-test doesn't make insta stop working in: 'install', @@ -44,105 +61,90 @@ const affordances = { 'dist-tags': 'dist-tag', upgrade: 'update', udpate: 'update', - login: 'adduser', - 'add-user': 'adduser', - author: 'owner', - home: 'docs', - issues: 'bugs', - info: 'view', - show: 'view', - find: 'search', - add: 'install', - unlink: 'uninstall', - remove: 'uninstall', - rm: 'uninstall', - r: 'uninstall', rum: 'run-script', sit: 'cit', urn: 'run-script', ogr: 'org', + 'add-user': 'adduser', } // these are filenames in . +// Keep these sorted so that lib/utils/npm-usage.js outputs in order const cmdList = [ - 'ci', - 'install-ci-test', - 'install', - 'install-test', - 'uninstall', + 'access', + 'adduser', + 'audit', + 'bin', + 'bugs', 'cache', + 'ci', + 'completion', 'config', - 'set', - 'get', - 'update', - 'outdated', - 'prune', - 'pack', - 'find-dupes', 'dedupe', + 'deprecate', + 'diff', + 'dist-tag', + 'docs', + 'doctor', + 'edit', + 'exec', + 'explain', + 'explore', + 'find-dupes', + 'fund', + 'get', + 'help', 'hook', - - 'rebuild', + 'init', + 'install', + 'install-ci-test', + 'install-test', 'link', - - 'publish', - 'star', - 'stars', - 'unstar', - 'adduser', + 'll', 'login', // This is an alias for `adduser` but it can be confusing 'logout', - 'unpublish', - 'owner', - 'access', - 'team', - 'deprecate', - 'shrinkwrap', - 'token', - 'profile', - 'audit', - 'fund', - 'org', - - 'help', 'ls', - 'll', - 'search', - 'view', - 'init', - 'version', - 'edit', - 'explore', - 'docs', - 'repo', - 'bugs', - 'root', - 'prefix', - 'bin', - 'whoami', - 'diff', - 'dist-tag', + 'org', + 'outdated', + 'owner', + 'pack', 'ping', 'pkg', - - 'test', - 'stop', - 'start', + 'prefix', + 'profile', + 'prune', + 'publish', + 'rebuild', + 'repo', 'restart', + 'root', 'run-script', + 'search', + 'set', 'set-script', - 'completion', - 'doctor', - 'exec', - 'explain', + 'shrinkwrap', + 'star', + 'stars', + 'start', + 'stop', + 'team', + 'test', + 'token', + 'uninstall', + 'unpublish', + 'unstar', + 'update', + 'version', + 'view', + 'whoami', ] const plumbing = ['birthday', 'help-search'] +const abbrevs = abbrev(cmdList.concat(Object.keys(aliases))) module.exports = { - aliases: Object.assign({}, shorthands, affordances), - shorthands, - affordances, + abbrevs, + aliases, cmdList, plumbing, } |