Update deps.

This commit is contained in:
Julien Fontanet 2015-10-27 16:12:09 +01:00
parent b1ee4bdc09
commit 80d8388eb6
2 changed files with 44 additions and 34 deletions

View File

@ -4,12 +4,11 @@
var Bluebird = require('bluebird') var Bluebird = require('bluebird')
Bluebird.longStackTraces() Bluebird.longStackTraces()
var promisify = Bluebird.promisify
var createReadStream = require('fs').createReadStream var createReadStream = require('fs').createReadStream
var createWriteStream = require('fs').createWriteStream var createWriteStream = require('fs').createWriteStream
var resolveUrl = require('url').resolve var resolveUrl = require('url').resolve
var stat = promisify(require('fs').stat) var stat = require('fs-promise').stat
var chalk = require('chalk') var chalk = require('chalk')
var eventToPromise = require('event-to-promise') var eventToPromise = require('event-to-promise')
@ -24,8 +23,7 @@ var nicePipe = require('nice-pipe')
var pairs = require('lodash.pairs') var pairs = require('lodash.pairs')
var prettyMs = require('pretty-ms') var prettyMs = require('pretty-ms')
var progressStream = require('progress-stream') var progressStream = require('progress-stream')
var sent = promisify(require('sent')) var Xo = require('xo-lib').Xo
var Xo = require('xo-lib')
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -45,9 +43,11 @@ function connect () {
var xo = new Xo(config.server) var xo = new Xo(config.server)
return xo.call('session.signInWithToken', { return xo.signIn({
token: config.token token: config.token
}).return(xo) }).then(function () {
return xo
})
}) })
} }
@ -78,18 +78,23 @@ function parseParameters (args) {
return params return params
} }
var humanFormatOpts = {
unit: 'B',
scale: 'binary'
}
function printProgress (progress) { function printProgress (progress) {
if (progress.length) { if (progress.length) {
console.warn('%s% of %s @ %s/s - ETA %s', console.warn('%s% of %s @ %s/s - ETA %s',
Math.round(progress.percentage), Math.round(progress.percentage),
humanFormat(progress.length), humanFormat(progress.length, humanFormatOpts),
humanFormat(progress.speed), humanFormat(progress.speed, humanFormatOpts),
prettyMs(progress.eta * 1e3) prettyMs(progress.eta * 1e3)
) )
} else { } else {
console.warn('%s @ %s/s', console.warn('%s @ %s/s',
humanFormat(progress.transferred), humanFormat(progress.transferred, humanFormatOpts),
humanFormat(progress.speed) humanFormat(progress.speed, humanFormatOpts)
) )
} }
} }
@ -163,17 +168,17 @@ function register (args) {
return Bluebird.try(function () { return Bluebird.try(function () {
xo = new Xo(args[0]) xo = new Xo(args[0])
return xo.call('session.signInWithPassword', { return xo.signIn({
email: args[1], email: args[1],
password: args[2] password: args[2]
}) })
}).then(function (user) { }).then(function () {
console.log('Successfully logged with', user.email) console.log('Successfully logged with', xo.user.email)
return xo.call('token.create') return xo.call('token.create')
}).then(function (token) { }).then(function (token) {
return config.set({ return config.set({
server: xo._url, server: args[0],
token: token token: token
}) })
}) })
@ -258,7 +263,9 @@ function call (args) {
var baseUrl var baseUrl
return connect().then(function (xo) { return connect().then(function (xo) {
baseUrl = xo._url // FIXME: do not use private properties.
baseUrl = xo._api._url.replace(/^ws/, 'http')
return xo.call(method, params) return xo.call(method, params)
}).then(function handleResult (result) { }).then(function handleResult (result) {
var keys, key, url var keys, key, url
@ -273,7 +280,7 @@ function call (args) {
var output = createWriteStream(file) var output = createWriteStream(file)
return eventToPromise(nicePipe([ return eventToPromise(nicePipe([
got(url), got.stream(url),
progressStream({ time: 1e3 }, printProgress), progressStream({ time: 1e3 }, printProgress),
output output
]), 'finish') ]), 'finish')
@ -293,12 +300,15 @@ function call (args) {
}, printProgress) }, printProgress)
]) ])
return sent(url, input, { return got.post(url, {
body: input,
headers: { headers: {
'content-length': length 'content-length': length
}, },
method: 'POST' method: 'POST'
}).get(0) }).then(function (response) {
return response.body
})
}) })
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "xo-cli", "name": "xo-cli",
"version": "0.5.0", "version": "0.5.0",
"license": "AGPL3", "license": "AGPL-3.0",
"description": "Basic CLI for Xen-Orchestra", "description": "Basic CLI for Xen-Orchestra",
"keywords": [ "keywords": [
"xo", "xo",
@ -25,26 +25,26 @@
}, },
"dependencies": { "dependencies": {
"bluebird": "^2.2.2", "bluebird": "^2.2.2",
"chalk": "^0.5.1", "chalk": "^1.1.1",
"event-to-promise": "^0.3.1", "event-to-promise": "^0.4.0",
"exec-promise": "^0.5.0", "exec-promise": "^0.5.0",
"got": "^1.2.0", "fs-promise": "^0.3.1",
"human-format": "^0.1.3", "got": "^5.0.0",
"human-format": "^0.5.0",
"l33teral": "^2.0.4", "l33teral": "^2.0.4",
"lodash.assign": "^2.4.1", "lodash.assign": "^3.2.0",
"lodash.filter": "^3.1.1", "lodash.filter": "^3.1.1",
"lodash.foreach": "^2.4.1", "lodash.foreach": "^3.0.3",
"lodash.isobject": "^2.4.1", "lodash.isobject": "^3.0.2",
"lodash.keys": "^2.4.1", "lodash.keys": "^3.1.2",
"lodash.pairs": "^2.4.1", "lodash.pairs": "^3.0.1",
"mkdirp": "^0.5.0", "mkdirp": "^0.5.0",
"multiline": "^0.3.4", "multiline": "^1.0.2",
"nice-pipe": "0.0.0", "nice-pipe": "0.0.0",
"pretty-ms": "^1.0.0", "pretty-ms": "^2.1.0",
"progress-stream": "^0.5.0", "progress-stream": "^1.1.1",
"sent": "^1.1.0", "xdg-basedir": "^2.0.0",
"xdg-basedir": "^1.0.0", "xo-lib": "^0.7.3"
"xo-lib": "^0.2.0"
}, },
"devDependencies": { "devDependencies": {
"standard": "^5.3.1" "standard": "^5.3.1"