Skip to content

Commit

Permalink
fix: updated to use new config
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 3, 2018
1 parent 5bffd51 commit 68b8959
Show file tree
Hide file tree
Showing 14 changed files with 307 additions and 197 deletions.
2 changes: 1 addition & 1 deletion bin/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

require('@anycli/engine').run()
require('@anycli/command').run()
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"author": "Jeff Dickey @jdxcode",
"anycli": {
"commands": "./lib/commands",
"plugins": "./lib/load",
"pluginScope": "heroku-cli",
"devPlugins": [
"@anycli/plugin-version",
Expand All @@ -14,40 +13,44 @@
},
"bugs": "https://github.com/anycli/plugin-plugins/issues",
"dependencies": {
"@anycli/command": "^0.3.7",
"@anycli/manifest-file": "^0.3.8",
"@anycli/command": "^1.2.2",
"@heroku-cli/color": "^1.1.3",
"chalk": "^2.3.0",
"cli-ux": "^3.3.13",
"debug": "^3.1.0",
"fs-extra": "^5.0.0",
"http-call": "^5.0.2",
"load-json-file": "^4.0.0",
"lodash": "^4.17.4",
"npm-run-path": "^2.0.2",
"semver": "^5.5.0",
"tslib": "^1.9.0",
"yarn": "^1.3.2"
},
"devDependencies": {
"@anycli/config": "^0.3.0",
"@anycli/config": "^1.0.16",
"@anycli/dev-cli": "^0.1.3",
"@anycli/engine": "^0.3.1",
"@anycli/plugin-help": "^0.4.5",
"@anycli/plugin-version": "^0.1.30",
"@anycli/test": "^0.10.3",
"@anycli/tslint": "^0.2.2",
"@anycli/engine": "^0.3.6",
"@anycli/plugin-help": "^0.5.0",
"@anycli/plugin-version": "^0.1.31",
"@anycli/test": "^0.10.8",
"@anycli/tslint": "^0.2.5",
"@types/chai": "^4.1.2",
"@types/fs-extra": "^5.0.0",
"@types/load-json-file": "^2.0.7",
"@types/lodash": "^4.14.100",
"@types/mocha": "^2.2.48",
"@types/nock": "^9.1.2",
"@types/node": "^9.4.0",
"@types/node-notifier": "^0.0.28",
"@types/read-pkg": "^3.0.0",
"@types/semver": "^5.5.0",
"@types/supports-color": "^3.1.0",
"chai": "^4.1.2",
"concurrently": "^3.5.1",
"eslint": "^4.16.0",
"eslint-config-anycli": "^1.3.1",
"eslint": "^4.17.0",
"eslint-config-anycli": "^1.3.2",
"fancy-test": "^0.6.10",
"mocha": "^5.0.0",
"ts-node": "^4.1.0",
"typescript": "^2.7.1"
Expand Down
39 changes: 17 additions & 22 deletions src/commands/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,36 @@ import * as _ from 'lodash'

import Plugins from '../../plugins'

export default class PluginsIndex extends Command {
static flags = {
core: flags.boolean({description: 'show core plugins'})
}
static description = 'list installed plugins'
static examples = [`<%
let examplePlugins = {
'heroku-ci': {version: '1.8.0'},
'heroku-cli-status': {version: '3.0.10', type: 'link'},
'heroku-fork': {version: '4.1.22'},
}
let bin = 'heroku'
const g = global as any
if (g.anycli && g.anycli.config) {
const config = g.anycli.config
bin = config
let pjson = config.pjson.anycli || config.pjson['cli-engine']
if (pjson.help && pjson.help.plugins) {
examplePlugins = pjson.help.plugins
}
}
const examplePluginsHelp = Object.entries(examplePlugins).map(([name, p]: [string, any]) => ` ${name} ${p.version}`)
const examplePluginsHelp = Object.entries(examplePlugins).map(([name, p]: [string, any]) => \` \${name} \${p.version}\`)
%>Example:
$ <%- config.bin> plugins
<%- examplePluginsHelp.join('\n') %>
`]

export default class PluginsIndex extends Command {
static flags = {
core: flags.boolean({description: 'show core plugins'})
}
static description = 'list installed plugins'
static help = `Example:
$ ${bin} plugins
${examplePluginsHelp.join('\n')}
`
plugins = new Plugins(this.config)
options = parse(this.argv, PluginsIndex)

async run() {
let plugins = this.config.engine!.plugins
let plugins = this.config.plugins
_.sortBy(plugins, 'name')
if (!this.options.flags.core) plugins = plugins.filter(p => p.type !== 'core' && p.type !== 'dev')
if (!this.options.flags.core) {
plugins = plugins.filter(p => p.type !== 'core' && p.type !== 'dev')
}
if (!plugins.length) {
cli.info('no plugins installed')
return
}
for (let plugin of plugins) {
let output = `${this.plugins.friendlyName(plugin.name)} ${color.dim(plugin.version)}`
Expand Down
30 changes: 15 additions & 15 deletions src/commands/plugins/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import cli from 'cli-ux'

import Plugins from '../../plugins'

let examplePlugin = 'heroku-production-status'
let bin = 'heroku'
const g = global as any
if (g.anycli && g.anycli.config) {
const config = g.anycli.config
bin = config.bin
let pjson = config.pjson.anycli || config.pjson['cli-engine']
if (pjson.help && pjson.help.plugins) {
examplePlugin = Object.keys(pjson.help.plugins)[0]
}
}
// let examplePlugin = 'heroku-production-status'
// let bin = 'heroku'
// const g = global as any
// if (g.anycli && g.anycli.config) {
// const config = g.anycli.config
// bin = config.bin
// let pjson = config.pjson.anycli || config.pjson['cli-engine']
// if (pjson.help && pjson.help.plugins) {
// examplePlugin = Object.keys(pjson.help.plugins)[0]
// }
// }

export default class PluginsInstall extends Command {
static description = 'installs a plugin into the CLI'
static usage = 'plugins:install PLUGIN...'
static help = `
Example:
$ ${bin} plugins:install ${examplePlugin}
`
static examples = [`
Example:
$ <%= config.bin %> plugins:install \${examplePlugin}
`]
static strict = false
static args = [{name: 'plugin', description: 'plugin to install', required: true}]

Expand Down
2 changes: 1 addition & 1 deletion src/commands/plugins/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class PluginsUninstall extends Command {
cli.warn(`${friendly} is not installed`)
continue
}
await this.plugins.uninstall(unfriendly)
await this.plugins.uninstall(unfriendly.name)
cli.action.stop()
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/commands/plugins/update.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Command, parse} from '@anycli/command'

import Plugins from '../../plugins'

export default class PluginsUpdate extends Command {
static topic = 'plugins'
static command = 'update'
static description = 'update installed plugins'

options = parse(this.argv, PluginsUpdate)
plugins = new Plugins(this.config)

async run() {
await this.plugins.update()
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './plugins'
11 changes: 0 additions & 11 deletions src/load.ts

This file was deleted.

38 changes: 0 additions & 38 deletions src/manifest.ts

This file was deleted.

Loading

0 comments on commit 68b8959

Please sign in to comment.