Implement plugins command

This commit is contained in:
Juan Cruz Viotti 2015-02-12 09:41:25 -04:00
parent a84c3d5c9f
commit 74b1092e9a
3 changed files with 52 additions and 0 deletions

View File

@ -12,3 +12,4 @@ module.exports =
os: require('./os') os: require('./os')
help: require('./help') help: require('./help')
examples: require('./examples') examples: require('./examples')
plugin: require('./plugin')

48
lib/actions/plugin.coffee Normal file
View File

@ -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)

View File

@ -100,6 +100,9 @@ capitano.command(actions.examples.list)
capitano.command(actions.examples.clone) capitano.command(actions.examples.clone)
capitano.command(actions.examples.info) capitano.command(actions.examples.info)
# ---------- Plugins Module ----------
capitano.command(actions.plugin.list)
changeProjectDirectory = (directory) -> changeProjectDirectory = (directory) ->
try try
process.chdir(directory) process.chdir(directory)