Update deps.
This commit is contained in:
parent
b1ee4bdc09
commit
80d8388eb6
@ -4,12 +4,11 @@
|
||||
|
||||
var Bluebird = require('bluebird')
|
||||
Bluebird.longStackTraces()
|
||||
var promisify = Bluebird.promisify
|
||||
|
||||
var createReadStream = require('fs').createReadStream
|
||||
var createWriteStream = require('fs').createWriteStream
|
||||
var resolveUrl = require('url').resolve
|
||||
var stat = promisify(require('fs').stat)
|
||||
var stat = require('fs-promise').stat
|
||||
|
||||
var chalk = require('chalk')
|
||||
var eventToPromise = require('event-to-promise')
|
||||
@ -24,8 +23,7 @@ var nicePipe = require('nice-pipe')
|
||||
var pairs = require('lodash.pairs')
|
||||
var prettyMs = require('pretty-ms')
|
||||
var progressStream = require('progress-stream')
|
||||
var sent = promisify(require('sent'))
|
||||
var Xo = require('xo-lib')
|
||||
var Xo = require('xo-lib').Xo
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@ -45,9 +43,11 @@ function connect () {
|
||||
|
||||
var xo = new Xo(config.server)
|
||||
|
||||
return xo.call('session.signInWithToken', {
|
||||
return xo.signIn({
|
||||
token: config.token
|
||||
}).return(xo)
|
||||
}).then(function () {
|
||||
return xo
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@ -78,18 +78,23 @@ function parseParameters (args) {
|
||||
return params
|
||||
}
|
||||
|
||||
var humanFormatOpts = {
|
||||
unit: 'B',
|
||||
scale: 'binary'
|
||||
}
|
||||
|
||||
function printProgress (progress) {
|
||||
if (progress.length) {
|
||||
console.warn('%s% of %s @ %s/s - ETA %s',
|
||||
Math.round(progress.percentage),
|
||||
humanFormat(progress.length),
|
||||
humanFormat(progress.speed),
|
||||
humanFormat(progress.length, humanFormatOpts),
|
||||
humanFormat(progress.speed, humanFormatOpts),
|
||||
prettyMs(progress.eta * 1e3)
|
||||
)
|
||||
} else {
|
||||
console.warn('%s @ %s/s',
|
||||
humanFormat(progress.transferred),
|
||||
humanFormat(progress.speed)
|
||||
humanFormat(progress.transferred, humanFormatOpts),
|
||||
humanFormat(progress.speed, humanFormatOpts)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -163,17 +168,17 @@ function register (args) {
|
||||
return Bluebird.try(function () {
|
||||
xo = new Xo(args[0])
|
||||
|
||||
return xo.call('session.signInWithPassword', {
|
||||
return xo.signIn({
|
||||
email: args[1],
|
||||
password: args[2]
|
||||
})
|
||||
}).then(function (user) {
|
||||
console.log('Successfully logged with', user.email)
|
||||
}).then(function () {
|
||||
console.log('Successfully logged with', xo.user.email)
|
||||
|
||||
return xo.call('token.create')
|
||||
}).then(function (token) {
|
||||
return config.set({
|
||||
server: xo._url,
|
||||
server: args[0],
|
||||
token: token
|
||||
})
|
||||
})
|
||||
@ -258,7 +263,9 @@ function call (args) {
|
||||
|
||||
var baseUrl
|
||||
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)
|
||||
}).then(function handleResult (result) {
|
||||
var keys, key, url
|
||||
@ -273,7 +280,7 @@ function call (args) {
|
||||
var output = createWriteStream(file)
|
||||
|
||||
return eventToPromise(nicePipe([
|
||||
got(url),
|
||||
got.stream(url),
|
||||
progressStream({ time: 1e3 }, printProgress),
|
||||
output
|
||||
]), 'finish')
|
||||
@ -293,12 +300,15 @@ function call (args) {
|
||||
}, printProgress)
|
||||
])
|
||||
|
||||
return sent(url, input, {
|
||||
return got.post(url, {
|
||||
body: input,
|
||||
headers: {
|
||||
'content-length': length
|
||||
},
|
||||
method: 'POST'
|
||||
}).get(0)
|
||||
}).then(function (response) {
|
||||
return response.body
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "xo-cli",
|
||||
"version": "0.5.0",
|
||||
"license": "AGPL3",
|
||||
"license": "AGPL-3.0",
|
||||
"description": "Basic CLI for Xen-Orchestra",
|
||||
"keywords": [
|
||||
"xo",
|
||||
@ -25,26 +25,26 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"bluebird": "^2.2.2",
|
||||
"chalk": "^0.5.1",
|
||||
"event-to-promise": "^0.3.1",
|
||||
"chalk": "^1.1.1",
|
||||
"event-to-promise": "^0.4.0",
|
||||
"exec-promise": "^0.5.0",
|
||||
"got": "^1.2.0",
|
||||
"human-format": "^0.1.3",
|
||||
"fs-promise": "^0.3.1",
|
||||
"got": "^5.0.0",
|
||||
"human-format": "^0.5.0",
|
||||
"l33teral": "^2.0.4",
|
||||
"lodash.assign": "^2.4.1",
|
||||
"lodash.assign": "^3.2.0",
|
||||
"lodash.filter": "^3.1.1",
|
||||
"lodash.foreach": "^2.4.1",
|
||||
"lodash.isobject": "^2.4.1",
|
||||
"lodash.keys": "^2.4.1",
|
||||
"lodash.pairs": "^2.4.1",
|
||||
"lodash.foreach": "^3.0.3",
|
||||
"lodash.isobject": "^3.0.2",
|
||||
"lodash.keys": "^3.1.2",
|
||||
"lodash.pairs": "^3.0.1",
|
||||
"mkdirp": "^0.5.0",
|
||||
"multiline": "^0.3.4",
|
||||
"multiline": "^1.0.2",
|
||||
"nice-pipe": "0.0.0",
|
||||
"pretty-ms": "^1.0.0",
|
||||
"progress-stream": "^0.5.0",
|
||||
"sent": "^1.1.0",
|
||||
"xdg-basedir": "^1.0.0",
|
||||
"xo-lib": "^0.2.0"
|
||||
"pretty-ms": "^2.1.0",
|
||||
"progress-stream": "^1.1.1",
|
||||
"xdg-basedir": "^2.0.0",
|
||||
"xo-lib": "^0.7.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "^5.3.1"
|
||||
|
Loading…
Reference in New Issue
Block a user