From cf2819210327952696346486002239f9fc184a3e Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 5 Aug 2020 16:29:31 -0700 Subject: [PATCH] Improve abbrevs for install and help The existence of 'install-test' and 'install-clean' make 'npm inst' no longer de-reference to 'npm install'. Similarly, the existence of 'help-search' prevents 'hel' from being a shorthand for 'help'. This adds some artisanally hand-crafted abbreviations for these cases. Fix: #1617 PR-URL: https://github.com/npm/cli/pull/1622 Credit: @isaacs Close: #1622 Reviewed-by: @ruyadorno --- lib/config/cmd-list.js | 15 ++++++++---- .../test-lib-config-cmd-list.js-TAP.test.js | 24 +++++++++++++++---- ...t-lib-utils-update-notifier.js-TAP.test.js | 24 +++++++++---------- tap-snapshots/test-lib-view.js-TAP.test.js | 2 +- 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/lib/config/cmd-list.js b/lib/config/cmd-list.js index 629556d13f473..85e456a835805 100644 --- a/lib/config/cmd-list.js +++ b/lib/config/cmd-list.js @@ -28,11 +28,19 @@ const affordances = { verison: 'version', ic: 'ci', innit: 'init', - isntall: 'install', + // manually abbrev so that install-test doesn't make insta stop working + in: 'install', + ins: 'install', + inst: 'install', + insta: 'install', + instal: 'install', + isnt: 'install', + isnta: 'install', + isntal: 'install', 'install-clean': 'ci', 'isntall-clean': 'ci', + hlep: 'help', 'dist-tags': 'dist-tag', - apihelp: 'help', upgrade: 'update', udpate: 'update', login: 'adduser', @@ -95,7 +103,6 @@ const cmdList = [ 'org', 'help', - 'help-search', 'ls', 'll', 'search', @@ -124,7 +131,7 @@ const cmdList = [ 'exec' ] -const plumbing = ['birthday'] +const plumbing = ['birthday', 'help-search'] module.exports = { aliases: Object.assign({}, shorthands, affordances), shorthands, diff --git a/tap-snapshots/test-lib-config-cmd-list.js-TAP.test.js b/tap-snapshots/test-lib-config-cmd-list.js-TAP.test.js index 3a0c47d3c67b5..d7db532f402b8 100644 --- a/tap-snapshots/test-lib-config-cmd-list.js-TAP.test.js +++ b/tap-snapshots/test-lib-config-cmd-list.js-TAP.test.js @@ -10,16 +10,23 @@ Object { "affordances": Object { "add": "install", "add-user": "adduser", - "apihelp": "help", "author": "owner", "dist-tags": "dist-tag", "find": "search", + "hlep": "help", "home": "docs", "ic": "ci", + "in": "install", "info": "view", "innit": "init", + "ins": "install", + "inst": "install", + "insta": "install", + "instal": "install", "install-clean": "ci", - "isntall": "install", + "isnt": "install", + "isnta": "install", + "isntal": "install", "isntall-clean": "ci", "issues": "bugs", "la": "ll", @@ -40,7 +47,6 @@ Object { "aliases": Object { "add": "install", "add-user": "adduser", - "apihelp": "help", "author": "owner", "c": "config", "cit": "install-ci-test", @@ -50,13 +56,21 @@ Object { "ddp": "dedupe", "dist-tags": "dist-tag", "find": "search", + "hlep": "help", "home": "docs", "i": "install", "ic": "ci", + "in": "install", "info": "view", "innit": "init", + "ins": "install", + "inst": "install", + "insta": "install", + "instal": "install", "install-clean": "ci", - "isntall": "install", + "isnt": "install", + "isnta": "install", + "isntal": "install", "isntall-clean": "ci", "issues": "bugs", "it": "install-test", @@ -125,7 +139,6 @@ Object { "fund", "org", "help", - "help-search", "ls", "ll", "search", @@ -154,6 +167,7 @@ Object { ], "plumbing": Array [ "birthday", + "help-search", ], "shorthands": Object { "c": "config", diff --git a/tap-snapshots/test-lib-utils-update-notifier.js-TAP.test.js b/tap-snapshots/test-lib-utils-update-notifier.js-TAP.test.js index 0e2841a3fc1f4..cab4cdf18a78a 100644 --- a/tap-snapshots/test-lib-utils-update-notifier.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-update-notifier.js-TAP.test.js @@ -6,73 +6,73 @@ */ 'use strict' exports[`test/lib/utils/update-notifier.js TAP notification situations color and unicode major > must match snapshot 1`] = ` -New major version of npm available! <>-beta.0 → 7.0.0 +New major version of npm available! <>-beta.1 → 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm install -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations color and unicode minor > must match snapshot 1`] = ` -New minor version of npm available! <>-beta.0 → 7.0.0 +New minor version of npm available! <>-beta.1 → 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm install -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations color and unicode minor > must match snapshot 2`] = ` -New patch version of npm available! <>-beta.0 → 7.0.0 +New patch version of npm available! <>-beta.1 → 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm install -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations color, no unicode major > must match snapshot 1`] = ` -New major version of npm available! <>-beta.0 -> 7.0.0 +New major version of npm available! <>-beta.1 -> 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm install -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations color, no unicode minor > must match snapshot 1`] = ` -New minor version of npm available! <>-beta.0 -> 7.0.0 +New minor version of npm available! <>-beta.1 -> 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm install -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations color, no unicode minor > must match snapshot 2`] = ` -New patch version of npm available! <>-beta.0 -> 7.0.0 +New patch version of npm available! <>-beta.1 -> 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm install -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations no color, no unicode major > must match snapshot 1`] = ` -New major version of npm available! <>-beta.0 -> 7.0.0 +New major version of npm available! <>-beta.1 -> 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm i -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations no color, no unicode minor > must match snapshot 1`] = ` -New minor version of npm available! <>-beta.0 -> 7.0.0 +New minor version of npm available! <>-beta.1 -> 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm i -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations no color, no unicode minor > must match snapshot 2`] = ` -New patch version of npm available! <>-beta.0 -> 7.0.0 +New patch version of npm available! <>-beta.1 -> 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm i -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations unicode, no color major > must match snapshot 1`] = ` -New major version of npm available! <>-beta.0 → 7.0.0 +New major version of npm available! <>-beta.1 → 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm i -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations unicode, no color minor > must match snapshot 1`] = ` -New minor version of npm available! <>-beta.0 → 7.0.0 +New minor version of npm available! <>-beta.1 → 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm i -g npm to update! ` exports[`test/lib/utils/update-notifier.js TAP notification situations unicode, no color minor > must match snapshot 2`] = ` -New patch version of npm available! <>-beta.0 → 7.0.0 +New patch version of npm available! <>-beta.1 → 7.0.0 Changelog: https://github.com/npm/cli/releases/tag/v7.0.0 Run npm i -g npm to update! ` diff --git a/tap-snapshots/test-lib-view.js-TAP.test.js b/tap-snapshots/test-lib-view.js-TAP.test.js index 473ad227d1c5a..6bccea684fc1d 100644 --- a/tap-snapshots/test-lib-view.js-TAP.test.js +++ b/tap-snapshots/test-lib-view.js-TAP.test.js @@ -282,7 +282,7 @@ dist dist-tags: -published 12 months ago +published a year ago ` exports[`test/lib/view.js TAP should log package info package with no versions > must match snapshot 1`] = `