mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 09:26:42 +00:00
Implement resin update command
This commit is contained in:
parent
acbf3e64b2
commit
9038b76d73
@ -13,7 +13,8 @@
|
||||
os: require('./os'),
|
||||
help: require('./help'),
|
||||
examples: require('./examples'),
|
||||
plugin: require('./plugin')
|
||||
plugin: require('./plugin'),
|
||||
update: require('./update')
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
38
build/actions/update.js
Normal file
38
build/actions/update.js
Normal file
@ -0,0 +1,38 @@
|
||||
(function() {
|
||||
var _, async, npm, packageJSON;
|
||||
|
||||
async = require('async');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
npm = require('npm');
|
||||
|
||||
packageJSON = require('../../package.json');
|
||||
|
||||
exports.update = {
|
||||
signature: 'update',
|
||||
description: 'update the resin cli',
|
||||
help: 'Use this command to update the Resin CLI\n\nThis command outputs information about the update process.\nUse `--quiet` to remove that output.\n\nExamples:\n\n $ resin update',
|
||||
action: function(params, options, done) {
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
options = {
|
||||
loglevel: 'silent',
|
||||
global: true
|
||||
};
|
||||
return npm.load(options, _.unary(callback));
|
||||
}, function(callback) {
|
||||
return npm.commands.update([packageJSON.name], callback);
|
||||
}, function(data, lite, callback) {
|
||||
var newVersion;
|
||||
if (_.isEmpty(data)) {
|
||||
return done(new Error('You are already running the latest version'));
|
||||
}
|
||||
newVersion = _.last(_.first(_.last(data)).split('@'));
|
||||
return console.info("Upgraded " + packageJSON.name + " to v" + newVersion + ".");
|
||||
}
|
||||
], done);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
@ -133,6 +133,8 @@
|
||||
|
||||
capitano.command(actions.plugin.remove);
|
||||
|
||||
capitano.command(actions.update.update);
|
||||
|
||||
changeProjectDirectory = function(directory) {
|
||||
try {
|
||||
return process.chdir(directory);
|
||||
|
10
doc/update/update.md
Normal file
10
doc/update/update.md
Normal file
@ -0,0 +1,10 @@
|
||||
# update
|
||||
|
||||
Use this command to update the Resin CLI
|
||||
|
||||
This command outputs information about the update process.
|
||||
Use `--quiet` to remove that output.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin update
|
@ -13,3 +13,4 @@ module.exports =
|
||||
help: require('./help')
|
||||
examples: require('./examples')
|
||||
plugin: require('./plugin')
|
||||
update: require('./update')
|
||||
|
43
lib/actions/update.coffee
Normal file
43
lib/actions/update.coffee
Normal file
@ -0,0 +1,43 @@
|
||||
async = require('async')
|
||||
_ = require('lodash-contrib')
|
||||
npm = require('npm')
|
||||
packageJSON = require('../../package.json')
|
||||
|
||||
exports.update =
|
||||
signature: 'update'
|
||||
description: 'update the resin cli'
|
||||
help: '''
|
||||
Use this command to update the Resin CLI
|
||||
|
||||
This command outputs information about the update process.
|
||||
Use `--quiet` to remove that output.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin update
|
||||
'''
|
||||
action: (params, options, done) ->
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
options =
|
||||
|
||||
# TODO: There is no way to quiet npm install completely.
|
||||
# Some output is still shown once the module is updated
|
||||
# https://github.com/npm/npm/issues/2040
|
||||
loglevel: 'silent'
|
||||
global: true
|
||||
|
||||
npm.load(options, _.unary(callback))
|
||||
|
||||
(callback) ->
|
||||
npm.commands.update([ packageJSON.name ], callback)
|
||||
|
||||
(data, lite, callback) ->
|
||||
if _.isEmpty(data)
|
||||
return done(new Error('You are already running the latest version'))
|
||||
|
||||
newVersion = _.last(_.first(_.last(data)).split('@'))
|
||||
console.info("Upgraded #{packageJSON.name} to v#{newVersion}.")
|
||||
|
||||
], done)
|
@ -106,6 +106,9 @@ capitano.command(actions.plugin.install)
|
||||
capitano.command(actions.plugin.update)
|
||||
capitano.command(actions.plugin.remove)
|
||||
|
||||
# ---------- Update Module ----------
|
||||
capitano.command(actions.update.update)
|
||||
|
||||
changeProjectDirectory = (directory) ->
|
||||
try
|
||||
process.chdir(directory)
|
||||
|
@ -58,6 +58,7 @@
|
||||
"lodash-contrib": "~241.4.14",
|
||||
"mkdirp": "~0.5.0",
|
||||
"nplugm": "^2.1.0",
|
||||
"npm": "^2.6.1",
|
||||
"open": "0.0.5",
|
||||
"progress-stream": "^0.5.0",
|
||||
"resin-cli-visuals": "resin-io/resin-cli-visuals",
|
||||
|
Loading…
x
Reference in New Issue
Block a user