mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-07 11:26:41 +00:00
Make use of new nplug version
This commit is contained in:
parent
6cd68dab64
commit
91a2453ebb
@ -14,7 +14,7 @@ exports.list =
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
plugins.list 'resin-plugin-', (error, resinPlugins) ->
|
||||
plugins.list (error, resinPlugins) ->
|
||||
return done(error) if error?
|
||||
|
||||
if _.isEmpty(resinPlugins)
|
||||
@ -41,12 +41,9 @@ exports.install =
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
plugins.install "resin-plugin-#{params.name}", (error, installedModules) ->
|
||||
plugins.install params.name, (error) ->
|
||||
return done(error) if error?
|
||||
|
||||
for installedModule in installedModules
|
||||
console.info("Plugin installed: #{installedModule}")
|
||||
|
||||
console.info("Plugin installed: #{params.name}")
|
||||
return done()
|
||||
|
||||
exports.remove =
|
||||
@ -66,10 +63,8 @@ exports.remove =
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
visuals.patterns.remove 'plugin', options.yes, (callback) ->
|
||||
plugins.remove("resin-plugin-#{params.name}", callback)
|
||||
, (error, uninstalledPlugin) ->
|
||||
plugins.remove(params.name, callback)
|
||||
, (error) ->
|
||||
return done(error) if error?
|
||||
|
||||
console.info("Plugin removed: #{uninstalledPlugin}")
|
||||
|
||||
console.info("Plugin removed: #{params.name}")
|
||||
return done()
|
||||
|
@ -114,9 +114,9 @@ changeProjectDirectory = (directory) ->
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
plugins.register('resin-plugin-*', callback)
|
||||
plugins.register('resin-plugin-', callback)
|
||||
|
||||
(loadedPlugins, callback) ->
|
||||
(callback) ->
|
||||
dataPrefix = resin.settings.get('dataPrefix')
|
||||
resin.data.prefix.set(dataPrefix, callback)
|
||||
|
||||
|
@ -1,81 +1,31 @@
|
||||
async = require('async')
|
||||
npm = require('npm')
|
||||
nplugm = require('nplugm')
|
||||
Nplugm = require('nplugm')
|
||||
_ = require('lodash')
|
||||
_.str = require('underscore.string')
|
||||
capitano = require('capitano')
|
||||
|
||||
nplugm = null
|
||||
|
||||
registerPlugin = (plugin) ->
|
||||
return capitano.command(plugin) if not _.isArray(plugin)
|
||||
return _.each(plugin, capitano.command)
|
||||
|
||||
exports.register = (glob, callback) ->
|
||||
nplugm.load glob, (error, plugin) ->
|
||||
return console.error(error.message) if error?
|
||||
registerPlugin(plugin.require())
|
||||
, callback
|
||||
|
||||
# TODO: Move all this npm interaction functionality to nplugm
|
||||
|
||||
exports.install = (name, callback) ->
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
npm.load(loglevel: 'silent', callback)
|
||||
|
||||
(data, callback) ->
|
||||
|
||||
# TODO: This action outputs installation information that cannot
|
||||
# be quieted neither with --quiet nor --silent:
|
||||
# https://github.com/npm/npm/issues/2040
|
||||
npm.commands.install([ name ], callback)
|
||||
|
||||
(installedModules, modules, lite, callback) ->
|
||||
installedModules = _.map(installedModules, _.first)
|
||||
return callback(null, installedModules)
|
||||
|
||||
], (error, installedModules) ->
|
||||
return callback(null, installedModules) if not error?
|
||||
|
||||
if error.code is 'E404'
|
||||
error.message = "Plugin not found: #{params.name}"
|
||||
|
||||
exports.register = (prefix, callback) ->
|
||||
nplugm = new Nplugm(prefix)
|
||||
nplugm.list (error, plugins) ->
|
||||
return callback(error) if error?
|
||||
|
||||
exports.remove = (name, callback) ->
|
||||
async.waterfall([
|
||||
for plugin in plugins
|
||||
try
|
||||
registerPlugin(nplugm.require(plugin))
|
||||
catch error
|
||||
console.error(error.message)
|
||||
|
||||
(callback) ->
|
||||
npm.load(loglevel: 'silent', callback)
|
||||
return callback()
|
||||
|
||||
(data, callback) ->
|
||||
npm.commands.uninstall([ name ], callback)
|
||||
exports.list = ->
|
||||
nplugm.list.apply(nplugm, arguments)
|
||||
|
||||
(uninstalledPlugins, callback) ->
|
||||
if _.isEmpty(uninstalledPlugins)
|
||||
return callback(new Error("Plugin not found: #{name}"))
|
||||
return callback(null, _.first(uninstalledPlugins))
|
||||
exports.install = ->
|
||||
nplugm.install.apply(nplugm, arguments)
|
||||
|
||||
], callback)
|
||||
|
||||
exports.list = (prefix, callback) ->
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
npm.load
|
||||
depth: 0
|
||||
parseable: true
|
||||
, callback
|
||||
|
||||
(data, callback) ->
|
||||
npm.commands.list([], true, callback)
|
||||
|
||||
(data, lite, callback) ->
|
||||
plugins = _.filter _.values(data.dependencies), (plugin) ->
|
||||
|
||||
# TODO: Use node-glob
|
||||
return _.str.startsWith(plugin.name, prefix)
|
||||
|
||||
return callback(null, plugins)
|
||||
|
||||
], callback)
|
||||
exports.remove = ->
|
||||
nplugm.remove.apply(nplugm, arguments)
|
||||
|
@ -8,7 +8,7 @@
|
||||
"url": "git@bitbucket.org:rulemotion/resin-cli.git"
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"bundled_engine": "v0.12.0",
|
||||
"bundled_engine": "v0.12.0",
|
||||
"man": [
|
||||
"./man/resin.1",
|
||||
"./man/resin-completion.1",
|
||||
@ -58,8 +58,7 @@
|
||||
"lodash-contrib": "~241.4.14",
|
||||
"mkdirp": "~0.5.0",
|
||||
"node-binary": "^1.0.0",
|
||||
"nplugm": "^1.0.1",
|
||||
"npm": "^2.5.1",
|
||||
"nplugm": "^2.0.0",
|
||||
"open": "0.0.5",
|
||||
"progress-stream": "^0.5.0",
|
||||
"resin-cli-visuals": "git+https://git@github.com/resin-io/resin-cli-visuals.git",
|
||||
|
Loading…
x
Reference in New Issue
Block a user