From 74b1092e9a964e0ad9eb690d4ae0ab2af6707cb2 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 12 Feb 2015 09:41:25 -0400 Subject: [PATCH] Implement plugins command --- lib/actions/index.coffee | 1 + lib/actions/plugin.coffee | 48 +++++++++++++++++++++++++++++++++++++++ lib/app.coffee | 3 +++ 3 files changed, 52 insertions(+) create mode 100644 lib/actions/plugin.coffee diff --git a/lib/actions/index.coffee b/lib/actions/index.coffee index 6ef4f12f..ee2ce1ab 100644 --- a/lib/actions/index.coffee +++ b/lib/actions/index.coffee @@ -12,3 +12,4 @@ module.exports = os: require('./os') help: require('./help') examples: require('./examples') + plugin: require('./plugin') diff --git a/lib/actions/plugin.coffee b/lib/actions/plugin.coffee new file mode 100644 index 00000000..5cb3a2ff --- /dev/null +++ b/lib/actions/plugin.coffee @@ -0,0 +1,48 @@ +_ = require('lodash') +_.str = require('underscore.string') +async = require('async') +npm = require('npm') +visuals = require('resin-cli-visuals') + +exports.list = + signature: 'plugins' + description: 'list all plugins' + help: ''' + Use this command to list all the installed resin plugins. + + Examples: + $ resin plugins + ''' + permission: 'user' + action: (params, options, done) -> + async.waterfall([ + + (callback) -> + npm.load + + # TODO: Maybe we should check the local modules as well? + global: true + + depth: 0 + parseable: true + , callback + + (data, callback) -> + npm.commands.list([], true, callback) + + (data, lite, callback) -> + resinModules = _.filter _.values(data.dependencies), (resinModule) -> + + # TODO: Reuse plugin glob from app.coffee + return _.str.startsWith(resinModule.name, 'resin-plugin') + + console.log visuals.widgets.table.horizontal resinModules, [ + 'name' + 'version' + 'description' + 'license' + ] + + return callback() + + ], done) diff --git a/lib/app.coffee b/lib/app.coffee index 829f15c8..750dcf72 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -100,6 +100,9 @@ capitano.command(actions.examples.list) capitano.command(actions.examples.clone) capitano.command(actions.examples.info) +# ---------- Plugins Module ---------- +capitano.command(actions.plugin.list) + changeProjectDirectory = (directory) -> try process.chdir(directory)