chore(package): update all dependencies
This commit is contained in:
parent
ab1f08f687
commit
ab3a594884
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"comments": false,
|
|
||||||
"compact": true,
|
|
||||||
"optional": [
|
|
||||||
"es7.asyncFunctions",
|
|
||||||
"es7.decorators",
|
|
||||||
"es7.exportExtensions",
|
|
||||||
"es7.functionBind",
|
|
||||||
"runtime"
|
|
||||||
]
|
|
||||||
}
|
|
5
packages/xo-server-backup-reports/.gitignore
vendored
5
packages/xo-server-backup-reports/.gitignore
vendored
@ -1,9 +1,6 @@
|
|||||||
/.nyc_output/
|
/.nyc_output/
|
||||||
/bower_components/
|
|
||||||
/dist/
|
/dist/
|
||||||
|
/node_modules/
|
||||||
|
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
npm-debug.log.*
|
npm-debug.log.*
|
||||||
|
|
||||||
!node_modules/*
|
|
||||||
node_modules/*/
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
Error.stackTraceLimit = 100
|
|
||||||
|
|
||||||
try { require('trace') } catch (_) {}
|
|
||||||
try { require('clarify') } catch (_) {}
|
|
||||||
try { require('source-map-support/register') } catch (_) {}
|
|
@ -1 +0,0 @@
|
|||||||
--require ./.mocha.js
|
|
@ -3,7 +3,6 @@ node_js:
|
|||||||
- 'stable'
|
- 'stable'
|
||||||
- '4'
|
- '4'
|
||||||
- '0.12'
|
- '0.12'
|
||||||
- '0.10'
|
|
||||||
|
|
||||||
# Use containers.
|
# Use containers.
|
||||||
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||||
|
@ -6,25 +6,16 @@ XO-Server plugin which sends email reports and Xmpp messages when backup jobs ar
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Go inside your `xo-server` folder and install it:
|
Installation of the [npm package](https://npmjs.org/package/xo-server-backup-reports):
|
||||||
|
|
||||||
```
|
```
|
||||||
> npm install xo-server-backup-reports
|
> npm install --global xo-server-backup-reports
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Prerequisite
|
Like all other xo-server plugins, it can be configured directly via
|
||||||
|
the web iterface, see [the plugin documentation](https://xen-orchestra.com/docs/plugins.html).
|
||||||
You must have the [xo-server-transport-email](https://github.com/vatesfr/xo-server-transport-email) plugin enabled to use xo-server-backup-reports or/and the [xo-server-transport-xmpp](https://github.com/vatesfr/xo-server-transport-xmpp) plugin.
|
|
||||||
|
|
||||||
### Add the plugin to XO-Server config
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
plugins:
|
|
||||||
|
|
||||||
xo-server-backup-reports:
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
@ -26,37 +26,45 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"dist/"
|
"dist/"
|
||||||
],
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-runtime": "^5.8.34",
|
"lodash": "^4.13.1",
|
||||||
"lodash.foreach": "^3.0.3",
|
"moment": "^2.13.0"
|
||||||
"moment": "^2.10.6"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel": "^5.8.34",
|
"babel-cli": "^6.10.1",
|
||||||
"babel-eslint": "^4.1.5",
|
"babel-eslint": "^6.1.0",
|
||||||
"clarify": "^1.0.5",
|
"babel-preset-es2015": "^6.9.0",
|
||||||
|
"babel-preset-stage-0": "^6.5.0",
|
||||||
"dependency-check": "^2.5.1",
|
"dependency-check": "^2.5.1",
|
||||||
"mocha": "^2.3.4",
|
"ghooks": "^1.2.4",
|
||||||
"must": "^0.13.1",
|
"standard": "^7.1.2"
|
||||||
"nyc": "^3.2.2",
|
|
||||||
"source-map-support": "^0.3.3",
|
|
||||||
"standard": "^5.4.1",
|
|
||||||
"trace": "^2.0.1"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "babel --source-maps --out-dir=dist/ src/",
|
"build": "NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
|
||||||
"dev": "babel --watch --source-maps --out-dir=dist/ src/",
|
|
||||||
"dev-test": "mocha --opts .mocha.opts --watch --reporter=min \"dist/**/*.spec.js\"",
|
|
||||||
"lint": "standard",
|
|
||||||
"depcheck": "dependency-check ./package.json",
|
"depcheck": "dependency-check ./package.json",
|
||||||
|
"dev": "babel --watch --source-maps --out-dir=dist/ src/",
|
||||||
|
"lint": "standard",
|
||||||
"posttest": "npm run lint && npm run depcheck",
|
"posttest": "npm run lint && npm run depcheck",
|
||||||
"prepublish": "npm run build",
|
"prepublish": "npm run build"
|
||||||
"test": "nyc mocha --opts .mocha.opts \"dist/**/*.spec.js\""
|
},
|
||||||
|
"babel": {
|
||||||
|
"presets": [
|
||||||
|
"stage-0",
|
||||||
|
"es2015"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"dist/**"
|
"dist"
|
||||||
],
|
],
|
||||||
"parser": "babel-eslint"
|
"parser": "babel-eslint"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"ghooks": {
|
||||||
|
"commit-msg": "npm test"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import forEach from 'lodash.foreach'
|
import forEach from 'lodash/forEach'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
|
||||||
export const configurationSchema = {
|
export const configurationSchema = {
|
||||||
@ -30,6 +30,10 @@ export const configurationSchema = {
|
|||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
|
const logError = e => {
|
||||||
|
console.error('backup report error:', e)
|
||||||
|
}
|
||||||
|
|
||||||
class BackupReportsXoPlugin {
|
class BackupReportsXoPlugin {
|
||||||
constructor (xo) {
|
constructor (xo) {
|
||||||
this._xo = xo
|
this._xo = xo
|
||||||
@ -49,15 +53,11 @@ class BackupReportsXoPlugin {
|
|||||||
this._xo.removeListener('job:terminated', this._report)
|
this._xo.removeListener('job:terminated', this._report)
|
||||||
}
|
}
|
||||||
|
|
||||||
async _wrapper (status) {
|
_wrapper (status) {
|
||||||
try {
|
return new Promise(resolve => resolve(this._listener(status))).catch(logError)
|
||||||
await this._listener(status)
|
|
||||||
} catch (e) {
|
|
||||||
console.error('backup report error: ' + e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _listener (status) {
|
_listener (status) {
|
||||||
let nSuccess = 0
|
let nSuccess = 0
|
||||||
let nCalls = 0
|
let nCalls = 0
|
||||||
let reportWhen
|
let reportWhen
|
||||||
@ -116,7 +116,7 @@ class BackupReportsXoPlugin {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const globalStatus = nSuccess === nCalls ? 'Success' : 'Fail'
|
const globalSuccess = nSuccess === nCalls
|
||||||
const start = moment(status.start)
|
const start = moment(status.start)
|
||||||
const end = moment(status.end)
|
const end = moment(status.end)
|
||||||
const duration = moment.duration(end - start).humanize()
|
const duration = moment.duration(end - start).humanize()
|
||||||
@ -125,13 +125,13 @@ class BackupReportsXoPlugin {
|
|||||||
.replace(/([A-Z])/g, ' $1').replace(/^./, letter => letter.toUpperCase()) // humanize
|
.replace(/([A-Z])/g, ' $1').replace(/^./, letter => letter.toUpperCase()) // humanize
|
||||||
const tag = status.calls[Object.keys(status.calls)[0]].params.tag
|
const tag = status.calls[Object.keys(status.calls)[0]].params.tag
|
||||||
|
|
||||||
if (reportWhen === 'fail' && globalStatus === 'Success') {
|
if (globalSuccess && reportWhen === 'fail') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global status.
|
// Global status.
|
||||||
text.unshift([
|
text.unshift([
|
||||||
`## Global status for "${tag}" (${method}): ${globalStatus}`,
|
`## Global status for "${tag}" (${method}): ${globalSuccess ? 'Success' : 'Fail'}`,
|
||||||
` - Start time: ${String(start)}`,
|
` - Start time: ${String(start)}`,
|
||||||
` - End time: ${String(end)}`,
|
` - End time: ${String(end)}`,
|
||||||
` - Duration: ${duration}`,
|
` - Duration: ${duration}`,
|
||||||
@ -143,23 +143,21 @@ class BackupReportsXoPlugin {
|
|||||||
|
|
||||||
// TODO : Handle errors when `sendEmail` isn't present. (Plugin dependencies)
|
// TODO : Handle errors when `sendEmail` isn't present. (Plugin dependencies)
|
||||||
|
|
||||||
if (this._xo.sendEmail) {
|
const xo = this._xo
|
||||||
await this._xo.sendEmail({
|
return Promise.all([
|
||||||
|
xo.sendEmail && xo.sendEmail({
|
||||||
to: this._mailsReceivers,
|
to: this._mailsReceivers,
|
||||||
subject: `Backup Reports for "${tag}" (XenOrchestra)`,
|
subject: `Backup Reports for "${tag}" (Xen Orchestra)`,
|
||||||
markdown
|
markdown
|
||||||
})
|
}),
|
||||||
}
|
xo.sendToXmppClient && xo.sendToXmppClient({
|
||||||
|
|
||||||
if (this._xo.sendToXmppClient) {
|
|
||||||
this._xo.sendToXmppClient({
|
|
||||||
to: this._xmppReceivers,
|
to: this._xmppReceivers,
|
||||||
message: markdown
|
message: markdown
|
||||||
})
|
})
|
||||||
}
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
export default ({xo}) => new BackupReportsXoPlugin(xo)
|
export default ({ xo }) => new BackupReportsXoPlugin(xo)
|
||||||
|
Loading…
Reference in New Issue
Block a user