UNPKG

1.5 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _cliEngineCommand = require('cli-engine-command');
8
9var _cliEngineCommand2 = _interopRequireDefault(_cliEngineCommand);
10
11var _plugins = require('../../plugins');
12
13var _plugins2 = _interopRequireDefault(_plugins);
14
15var _hooks = require('../../hooks');
16
17function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19let examplePlugin = 'heroku-production-status';
20
21let cli = 'heroku';
22if (global.config) {
23 cli = global.config.bin;
24 let pjson = global.config.pjson['cli-engine'];
25 if (pjson['help'] && pjson['help']['plugins']) {
26 examplePlugin = Object.keys(pjson['help']['plugins'])[0];
27 }
28}
29
30class PluginsInstall extends _cliEngineCommand2.default {
31
32 async run() {
33 this.plugins = new _plugins2.default(this.config);
34 const [plugin, tag = 'latest'] = this.argv[0].split('@');
35 if (!this.config.debug) this.out.action.start(`Installing plugin ${plugin}${tag === 'latest' ? '' : '@' + tag}`);
36 await this.plugins.install(plugin, tag);
37 const hooks = new _hooks.Hooks({ config: this.config });
38 await hooks.run('update');
39 }
40}
41exports.default = PluginsInstall;
42PluginsInstall.topic = 'plugins';
43PluginsInstall.command = 'install';
44PluginsInstall.description = 'installs a plugin into the CLI';
45PluginsInstall.help = `
46 Example:
47 $ ${cli} plugins:install ${examplePlugin}
48 `;
49PluginsInstall.args = [{ name: 'plugin', description: 'plugin to install' }];
\No newline at end of file