chore(package): update standard to version 7.0.0
This commit is contained in:
parent
c198350bfa
commit
0770aef4bf
@ -10,10 +10,12 @@ var plumber = require('gulp-plumber')
|
|||||||
var sourceMaps = require('gulp-sourcemaps')
|
var sourceMaps = require('gulp-sourcemaps')
|
||||||
var watch = require('gulp-watch')
|
var watch = require('gulp-watch')
|
||||||
|
|
||||||
|
var join = require('path').join
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
var SRC_DIR = __dirname + '/src'
|
var SRC_DIR = join(__dirname, 'src')
|
||||||
var DIST_DIR = __dirname + '/dist'
|
var DIST_DIR = join(__dirname, 'dist')
|
||||||
|
|
||||||
var PRODUCTION = process.argv.indexOf('--production') !== -1
|
var PRODUCTION = process.argv.indexOf('--production') !== -1
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@
|
|||||||
"mocha": "^2.2.1",
|
"mocha": "^2.2.1",
|
||||||
"must": "^0.13.1",
|
"must": "^0.13.1",
|
||||||
"sinon": "^1.14.1",
|
"sinon": "^1.14.1",
|
||||||
"standard": "^5.2.1"
|
"standard": "^7.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build-indexes && gulp build --production",
|
"build": "npm run build-indexes && gulp build --production",
|
||||||
|
@ -3,7 +3,7 @@ import {JsonRpcError} from 'json-rpc-peer'
|
|||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
// Export standard JSON-RPC errors.
|
// Export standard JSON-RPC errors.
|
||||||
export {
|
export { // eslint-disable-line no-duplicate-imports
|
||||||
InvalidJson,
|
InvalidJson,
|
||||||
InvalidParameters,
|
InvalidParameters,
|
||||||
InvalidRequest,
|
InvalidRequest,
|
||||||
|
@ -74,7 +74,7 @@ installPatch.resolve = {
|
|||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
async function handlePatchUpload (req, res, {pool}) {
|
async function handlePatchUpload (req, res, {pool}) {
|
||||||
const {headers: {['content-length']: contentLength}} = req
|
const contentLength = req.headers['content-length']
|
||||||
if (!contentLength) {
|
if (!contentLength) {
|
||||||
res.writeHead(411)
|
res.writeHead(411)
|
||||||
res.end('Content length is mandatory')
|
res.end('Content length is mandatory')
|
||||||
|
@ -33,10 +33,6 @@ export default class Collection extends EventEmitter {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor () {
|
|
||||||
super()
|
|
||||||
}
|
|
||||||
|
|
||||||
async add (models, opts) {
|
async add (models, opts) {
|
||||||
const array = isArray(models)
|
const array = isArray(models)
|
||||||
if (!array) {
|
if (!array) {
|
||||||
|
@ -15,6 +15,7 @@ import serveStatic from 'serve-static'
|
|||||||
import startsWith from 'lodash.startswith'
|
import startsWith from 'lodash.startswith'
|
||||||
import WebSocket from 'ws'
|
import WebSocket from 'ws'
|
||||||
import { createServer as createProxyServer } from 'http-proxy'
|
import { createServer as createProxyServer } from 'http-proxy'
|
||||||
|
import { join as joinPath } from 'path'
|
||||||
import {compile as compileJade} from 'jade'
|
import {compile as compileJade} from 'jade'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -129,7 +130,7 @@ async function setUpPassport (express, xo) {
|
|||||||
|
|
||||||
// Registers the sign in form.
|
// Registers the sign in form.
|
||||||
const signInPage = compileJade(
|
const signInPage = compileJade(
|
||||||
await readFile(__dirname + '/../signin.jade')
|
await readFile(joinPath(__dirname, '..', 'signin.jade'))
|
||||||
)
|
)
|
||||||
express.get('/signin', (req, res, next) => {
|
express.get('/signin', (req, res, next) => {
|
||||||
res.send(signInPage({
|
res.send(signInPage({
|
||||||
@ -515,7 +516,7 @@ const setUpConsoleProxy = (webServer, xo) => {
|
|||||||
const { token } = parseCookies(req.headers.cookie)
|
const { token } = parseCookies(req.headers.cookie)
|
||||||
|
|
||||||
const user = await xo.authenticateUser({ token })
|
const user = await xo.authenticateUser({ token })
|
||||||
if (!await xo.hasPermissions(user.id, [ [ id, 'operate' ] ])) { // eslint-disable-line space-before-keywords
|
if (!await xo.hasPermissions(user.id, [ [ id, 'operate' ] ])) {
|
||||||
throw new InvalidCredential()
|
throw new InvalidCredential()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
import {expect} from 'chai'
|
import {expect} from 'chai'
|
||||||
import leche from 'leche'
|
import leche from 'leche'
|
||||||
|
|
||||||
import {productParams} from './job-executor'
|
import {
|
||||||
import {_computeCrossProduct} from './job-executor'
|
_computeCrossProduct,
|
||||||
|
productParams
|
||||||
|
} from './job-executor'
|
||||||
|
|
||||||
describe('productParams', function () {
|
describe('productParams', function () {
|
||||||
leche.withData({
|
leche.withData({
|
||||||
|
@ -297,7 +297,7 @@ export function pSettle (promises) {
|
|||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export { // eslint-disable-line no-duplicate-imports
|
||||||
all as pAll,
|
all as pAll,
|
||||||
catchPlus as pCatch,
|
catchPlus as pCatch,
|
||||||
delay as pDelay,
|
delay as pDelay,
|
||||||
@ -351,14 +351,14 @@ export const safeDateFormat = d3TimeFormat('%Y%m%dT%H%M%SZ')
|
|||||||
// This functions are often used throughout xo-server.
|
// This functions are often used throughout xo-server.
|
||||||
//
|
//
|
||||||
// Exports them from here to avoid direct dependencies on lodash.
|
// Exports them from here to avoid direct dependencies on lodash.
|
||||||
export { default as forEach } from 'lodash.foreach'
|
export { default as forEach } from 'lodash.foreach' // eslint-disable-line no-duplicate-imports
|
||||||
export { default as isArray } from 'lodash.isarray'
|
export { default as isArray } from 'lodash.isarray' // eslint-disable-line no-duplicate-imports
|
||||||
export { default as isBoolean } from 'lodash.isboolean'
|
export { default as isBoolean } from 'lodash.isboolean'
|
||||||
export { default as isEmpty } from 'lodash.isempty'
|
export { default as isEmpty } from 'lodash.isempty'
|
||||||
export { default as isFunction } from 'lodash.isfunction'
|
export { default as isFunction } from 'lodash.isfunction'
|
||||||
export { default as isInteger } from 'lodash.isinteger'
|
export { default as isInteger } from 'lodash.isinteger'
|
||||||
export { default as isObject } from 'lodash.isobject'
|
export { default as isObject } from 'lodash.isobject'
|
||||||
export { default as isString } from 'lodash.isstring'
|
export { default as isString } from 'lodash.isstring' // eslint-disable-line no-duplicate-imports
|
||||||
export { default as mapToArray } from 'lodash.map'
|
export { default as mapToArray } from 'lodash.map'
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -528,12 +528,12 @@ export default async function vhdMerge (
|
|||||||
|
|
||||||
// Child must be a delta.
|
// Child must be a delta.
|
||||||
if (childVhd.footer.diskType !== HARD_DISK_TYPE_DIFFERENCING) {
|
if (childVhd.footer.diskType !== HARD_DISK_TYPE_DIFFERENCING) {
|
||||||
throw new Error(`Unable to merge, child is not a delta backup.`)
|
throw new Error('Unable to merge, child is not a delta backup.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merging in differencing disk is prohibited in our case.
|
// Merging in differencing disk is prohibited in our case.
|
||||||
if (parentVhd.footer.diskType !== HARD_DISK_TYPE_DYNAMIC) {
|
if (parentVhd.footer.diskType !== HARD_DISK_TYPE_DYNAMIC) {
|
||||||
throw new Error(`Unable to merge, parent is not a full backup.`)
|
throw new Error('Unable to merge, parent is not a full backup.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocation table map is not yet implemented.
|
// Allocation table map is not yet implemented.
|
||||||
@ -541,7 +541,7 @@ export default async function vhdMerge (
|
|||||||
parentVhd.hasBlockAllocationTableMap() ||
|
parentVhd.hasBlockAllocationTableMap() ||
|
||||||
childVhd.hasBlockAllocationTableMap()
|
childVhd.hasBlockAllocationTableMap()
|
||||||
) {
|
) {
|
||||||
throw new Error(`Unsupported allocation table map.`)
|
throw new Error('Unsupported allocation table map.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read allocation table of child/parent.
|
// Read allocation table of child/parent.
|
||||||
|
@ -322,7 +322,7 @@ const TRANSFORMS = {
|
|||||||
return disks
|
return disks
|
||||||
})(),
|
})(),
|
||||||
install_methods: (function () {
|
install_methods: (function () {
|
||||||
const {['install-methods']: methods} = otherConfig
|
const methods = otherConfig['install-methods']
|
||||||
|
|
||||||
return methods ? methods.split(',') : []
|
return methods ? methods.split(',') : []
|
||||||
})(),
|
})(),
|
||||||
|
@ -32,11 +32,7 @@ export class UnknownLegendFormat extends XapiStatsError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FaultyGranularity extends XapiStatsError {
|
export class FaultyGranularity extends XapiStatsError {}
|
||||||
constructor (msg) {
|
|
||||||
super(msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Utils
|
// Utils
|
||||||
|
23
src/xapi.js
23
src/xapi.js
@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable camelcase */
|
||||||
|
|
||||||
import createDebug from 'debug'
|
import createDebug from 'debug'
|
||||||
import every from 'lodash.every'
|
import every from 'lodash.every'
|
||||||
import fatfs from 'fatfs'
|
import fatfs from 'fatfs'
|
||||||
@ -8,6 +10,7 @@ import includes from 'lodash.includes'
|
|||||||
import pickBy from 'lodash.pickby'
|
import pickBy from 'lodash.pickby'
|
||||||
import sortBy from 'lodash.sortby'
|
import sortBy from 'lodash.sortby'
|
||||||
import unzip from 'julien-f-unzip'
|
import unzip from 'julien-f-unzip'
|
||||||
|
import { defer } from 'promise-toolbox'
|
||||||
import { utcFormat, utcParse } from 'd3-time-format'
|
import { utcFormat, utcParse } from 'd3-time-format'
|
||||||
import {
|
import {
|
||||||
wrapError as wrapXapiError,
|
wrapError as wrapXapiError,
|
||||||
@ -274,8 +277,7 @@ export default class Xapi extends XapiBase {
|
|||||||
// TODO: implements a timeout.
|
// TODO: implements a timeout.
|
||||||
_waitObject (predicate) {
|
_waitObject (predicate) {
|
||||||
if (isFunction(predicate)) {
|
if (isFunction(predicate)) {
|
||||||
let resolve
|
const { promise, resolve } = defer()
|
||||||
const promise = new Promise(resolve_ => resolve = resolve_)
|
|
||||||
|
|
||||||
const unregister = this._registerGenericWatcher(obj => {
|
const unregister = this._registerGenericWatcher(obj => {
|
||||||
if (predicate(obj)) {
|
if (predicate(obj)) {
|
||||||
@ -290,10 +292,7 @@ export default class Xapi extends XapiBase {
|
|||||||
|
|
||||||
let watcher = this._objectWatchers[predicate]
|
let watcher = this._objectWatchers[predicate]
|
||||||
if (!watcher) {
|
if (!watcher) {
|
||||||
let resolve
|
const { promise, resolve } = defer()
|
||||||
const promise = new Promise(resolve_ => {
|
|
||||||
resolve = resolve_
|
|
||||||
})
|
|
||||||
|
|
||||||
// Register the watcher.
|
// Register the watcher.
|
||||||
watcher = this._objectWatchers[predicate] = {
|
watcher = this._objectWatchers[predicate] = {
|
||||||
@ -352,18 +351,8 @@ export default class Xapi extends XapiBase {
|
|||||||
|
|
||||||
let watcher = this._taskWatchers[ref]
|
let watcher = this._taskWatchers[ref]
|
||||||
if (!watcher) {
|
if (!watcher) {
|
||||||
let resolve, reject
|
|
||||||
const promise = new Promise((resolve_, reject_) => {
|
|
||||||
resolve = resolve_
|
|
||||||
reject = reject_
|
|
||||||
})
|
|
||||||
|
|
||||||
// Register the watcher.
|
// Register the watcher.
|
||||||
watcher = this._taskWatchers[ref] = {
|
watcher = this._taskWatchers[ref] = defer()
|
||||||
promise,
|
|
||||||
resolve,
|
|
||||||
reject
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return watcher.promise
|
return watcher.promise
|
||||||
|
@ -151,7 +151,7 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async deleteAuthenticationToken (id) {
|
async deleteAuthenticationToken (id) {
|
||||||
if (!await this._tokens.remove(id)) { // eslint-disable-line space-before-keywords
|
if (!await this._tokens.remove(id)) {
|
||||||
throw new NoSuchAuthenticationToken(id)
|
throw new NoSuchAuthenticationToken(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ export default class {
|
|||||||
|
|
||||||
$onFailure(() => handler.unlink(infoPath)::pCatch(noop))
|
$onFailure(() => handler.unlink(infoPath)::pCatch(noop))
|
||||||
|
|
||||||
const { streams,
|
const {
|
||||||
...infos
|
...infos
|
||||||
} = delta
|
} = delta
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ export default class {
|
|||||||
})
|
})
|
||||||
|
|
||||||
xo.on('start', async () => {
|
xo.on('start', async () => {
|
||||||
if (!(await users.exists())) {
|
if (!await users.exists()) {
|
||||||
const email = 'admin@admin.net'
|
const email = 'admin@admin.net'
|
||||||
const password = 'admin'
|
const password = 'admin'
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getGroup (id) {
|
async getGroup (id) {
|
||||||
const group = (await this._groups.first(id))
|
const group = await this._groups.first(id)
|
||||||
if (!group) {
|
if (!group) {
|
||||||
throw new NoSuchGroup(id)
|
throw new NoSuchGroup(id)
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ export default class {
|
|||||||
async unregisterXenServer (id) {
|
async unregisterXenServer (id) {
|
||||||
this.disconnectXenServer(id)::pCatch(noop)
|
this.disconnectXenServer(id)::pCatch(noop)
|
||||||
|
|
||||||
if (!await this._servers.remove(id)) { // eslint-disable-line space-before-keywords
|
if (!await this._servers.remove(id)) {
|
||||||
throw new NoSuchXenServer(id)
|
throw new NoSuchXenServer(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user