Skip to content

Commit

Permalink
feat: added aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jun 12, 2018
1 parent 23c8042 commit 60bbdc0
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 58 deletions.
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"bugs": "https://github.com/oclif/plugin-plugins/issues",
"dependencies": {
"@heroku-cli/color": "^1.1.5",
"@oclif/command": "^1.4.32",
"@oclif/command": "^1.4.33",
"chalk": "^2.4.1",
"cli-ux": "^4.6.1",
"cli-ux": "^4.6.2",
"debug": "^3.1.0",
"fs-extra": "^6.0.1",
"http-call": "^5.1.4",
Expand All @@ -19,25 +19,25 @@
"yarn": "^1.7.0"
},
"devDependencies": {
"@oclif/config": "^1.6.27",
"@oclif/dev-cli": "^1.13.30",
"@oclif/config": "^1.6.28",
"@oclif/dev-cli": "^1.13.31",
"@oclif/errors": "^1.1.2",
"@oclif/plugin-help": "^2.0.4",
"@oclif/plugin-help": "^2.0.5",
"@oclif/test": "^1.0.9",
"@oclif/tslint": "^1.1.2",
"@types/chai": "^4.1.3",
"@types/fs-extra": "^5.0.2",
"@types/fs-extra": "^5.0.3",
"@types/load-json-file": "^2.0.7",
"@types/mocha": "^5.2.1",
"@types/node": "^10.3.0",
"@types/node": "^10.3.2",
"@types/semver": "^5.5.0",
"@types/supports-color": "^5.3.0",
"chai": "^4.1.2",
"concurrently": "^3.5.1",
"fancy-test": "^1.1.4",
"globby": "^8.0.1",
"mocha": "^5.2.0",
"ts-node": "^6.0.5",
"ts-node": "^6.1.0",
"tslint": "^5.10.0",
"typescript": "^2.9.1"
},
Expand All @@ -63,6 +63,9 @@
"devPlugins": [
"@oclif/plugin-help"
],
"aliases": {
"aliasme": "oclif-debug"
},
"bin": "mycli"
},
"repository": "oclif/plugin-plugins",
Expand Down
3 changes: 3 additions & 0 deletions src/commands/plugins/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ Can be installed from npm or a git url.
async run() {
const {flags, argv} = this.parse(PluginsInstall)
if (flags.verbose) this.plugins.verbose = true
const aliases = this.config.pjson.oclif.aliases || {}
for (let name of argv) {
if (aliases[name] === null) this.error(`${name} is blacklisted`)
name = aliases[name] || name
let p = parsePlugin(name)
let plugin
if (p.type === 'npm') {
Expand Down
14 changes: 14 additions & 0 deletions test/commands/plugins/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ describe('command', () => {
.do(output => expect(output.stdout).to.equal('no plugins installed\n'))
.it('installs and uninstalls @oclif/example-plugin-ts')

test
.command(['plugins:install', 'aliasme'], {reset: true})
.stdout()
.command(['plugins'], {reset: true})
.do(output => expect(output.stdout).to.contain('oclif-debug'))
.stdout()
.command(['debug'], {reset: true})
.do(output => expect(output.stdout).to.contain('debug'))
.command(['plugins:uninstall', 'oclif-debug'])
.stdout()
.command(['plugins'], {reset: true})
.do(output => expect(output.stdout).to.equal('no plugins installed\n'))
.it('installs via an alias')

test
.command(['plugins:install', 'jdxcode/oclif-debug'], {reset: true})
.stdout()
Expand Down
88 changes: 38 additions & 50 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
debug "^3.1.0"
semver "^5.5.0"

"@oclif/command@^1.4.32":
version "1.4.32"
resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.4.32.tgz#1cb2eb9637340a1ac69da35e407316688f736647"
"@oclif/command@^1.4.33":
version "1.4.33"
resolved "https://registry.yarnpkg.com/@oclif/command/-/command-1.4.33.tgz#40a48e7384d6b4394c2ca20e5c05ff45541087f5"
dependencies:
"@oclif/errors" "^1.1.2"
"@oclif/parser" "^3.4.1"
"@oclif/parser" "^3.5.1"
debug "^3.1.0"
semver "^5.5.0"

Expand All @@ -63,15 +63,22 @@
debug "^3.1.0"
tslib "^1.9.2"

"@oclif/dev-cli@^1.13.30":
version "1.13.30"
resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.13.30.tgz#bcda36f634b82d4591447f229cc5f735b477a598"
"@oclif/config@^1.6.28":
version "1.6.28"
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.6.28.tgz#bfda0718ba5dfbdeb364350990ed79540f9c3d0b"
dependencies:
"@oclif/command" "^1.4.32"
debug "^3.1.0"
tslib "^1.9.2"

"@oclif/dev-cli@^1.13.31":
version "1.13.31"
resolved "https://registry.yarnpkg.com/@oclif/dev-cli/-/dev-cli-1.13.31.tgz#ddcca19e1346de3656b63210305c87acdc98fd44"
dependencies:
"@oclif/command" "^1.4.33"
"@oclif/config" "^1.6.27"
"@oclif/errors" "^1.1.2"
"@oclif/plugin-help" "^2.0.4"
cli-ux "^4.6.0"
"@oclif/plugin-help" "^2.0.5"
cli-ux "^4.6.2"
debug "^3.1.0"
fs-extra "^6.0.1"
lodash "^4.17.10"
Expand Down Expand Up @@ -101,16 +108,16 @@
"@oclif/linewrap" "^1.0.0"
chalk "^2.4.1"

"@oclif/parser@^3.4.1":
version "3.4.1"
resolved "https://registry.yarnpkg.com/@oclif/parser/-/parser-3.4.1.tgz#83942276f3cf9406a1a3dcf3eb917183d6333e1d"
"@oclif/parser@^3.5.1":
version "3.5.1"
resolved "https://registry.yarnpkg.com/@oclif/parser/-/parser-3.5.1.tgz#2f60ac9773565786b6e1afff967b36a6399defcc"
dependencies:
"@oclif/linewrap" "^1.0.0"
chalk "^2.4.1"

"@oclif/plugin-help@^2.0.4":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-2.0.4.tgz#32cf1dc7696f626a6065109a17b0f061adb14243"
"@oclif/plugin-help@^2.0.5":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-2.0.5.tgz#98084286099b44c8c6ed6214e3589f32525f4827"
dependencies:
"@oclif/command" "^1.4.30"
chalk "^2.4.1"
Expand Down Expand Up @@ -140,9 +147,9 @@
version "4.1.3"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.3.tgz#b8a74352977a23b604c01aa784f5b793443fb7dc"

"@types/fs-extra@^5.0.2":
version "5.0.2"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.2.tgz#235a7e2b56452cc0a6a4809b53e1d1eaffff9c96"
"@types/fs-extra@^5.0.3":
version "5.0.3"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-5.0.3.tgz#feb31d55eeae3ccd5f92dbce806344a6c777a713"
dependencies:
"@types/node" "*"

Expand Down Expand Up @@ -176,6 +183,10 @@
version "10.3.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.3.0.tgz#078516315a84d56216b5d4fed8f75d59d3b16cac"

"@types/node@^10.3.2":
version "10.3.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.3.2.tgz#3840ec6c12556fdda6e0e6d036df853101d732a4"

"@types/semver@^5.5.0":
version "5.5.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45"
Expand Down Expand Up @@ -435,31 +446,9 @@ clean-stack@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-1.3.0.tgz#9e821501ae979986c46b1d66d2d432db2fd4ae31"

cli-ux@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-4.6.0.tgz#b3c6c4525c66ae0b6c0003db119609cd65c0a9ab"
dependencies:
"@oclif/linewrap" "^1.0.0"
"@oclif/screen" "^1.0.2"
ansi-styles "^3.2.1"
cardinal "^2.1.1"
chalk "^2.4.1"
clean-stack "^1.3.0"
extract-stack "^1.0.0"
fs-extra "^6.0.1"
hyperlinker "^1.0.0"
indent-string "^3.2.0"
is-wsl "^1.1.0"
lodash "^4.17.10"
password-prompt "^1.0.6"
semver "^5.5.0"
strip-ansi "^4.0.0"
supports-color "^5.4.0"
supports-hyperlinks "^1.0.1"

cli-ux@^4.6.1:
version "4.6.1"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-4.6.1.tgz#2cc7feb4d48932a95bffe712426eaa36ec861004"
cli-ux@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-4.6.2.tgz#77a4eeb93ffb40c697e4f1d60975804134ba7a5a"
dependencies:
"@oclif/linewrap" "^1.0.0"
"@oclif/screen" "^1.0.2"
Expand Down Expand Up @@ -1579,7 +1568,7 @@ source-map-resolve@^0.5.0:
source-map-url "^0.4.0"
urix "^0.1.0"

source-map-support@^0.5.3:
source-map-support@^0.5.6:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.6.tgz#4435cee46b1aab62b8e8610ce60f788091c51c13"
dependencies:
Expand Down Expand Up @@ -1771,17 +1760,16 @@ tree-kill@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.0.tgz#5846786237b4239014f05db156b643212d4c6f36"

ts-node@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-6.0.5.tgz#977c1c931da7a2b09ae2930101f0104a5c2271e9"
ts-node@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-6.1.0.tgz#a2c37a11fdb58e60eca887a1269b025cf4d2f8b8"
dependencies:
arrify "^1.0.0"
chalk "^2.3.0"
diff "^3.1.0"
make-error "^1.1.1"
minimist "^1.2.0"
mkdirp "^0.5.1"
source-map-support "^0.5.3"
source-map-support "^0.5.6"
yn "^2.0.0"

tslib@1.9.0:
Expand Down

0 comments on commit 60bbdc0

Please sign in to comment.