Compare commits
24 Commits
xo-server-
...
xo-server-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
090d48b636 | ||
|
|
55567bf666 | ||
|
|
5867d84eaa | ||
|
|
4d8f1ab169 | ||
|
|
6a2963be41 | ||
|
|
fdd33abe91 | ||
|
|
81062638eb | ||
|
|
4530d95f48 | ||
|
|
5e86e64e18 | ||
|
|
92c4dda801 | ||
|
|
3e59ba4563 | ||
|
|
99c95626df | ||
|
|
20a9fc2497 | ||
|
|
9b3668423e | ||
|
|
3c11f0acda | ||
|
|
588c369615 | ||
|
|
14156b0911 | ||
|
|
1fd91de50d | ||
|
|
7587458f99 | ||
|
|
6980e2b959 | ||
|
|
f49f3fb2a6 | ||
|
|
6b82cc7510 | ||
|
|
592adcf42e | ||
|
|
978c881ab7 |
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"comments": false,
|
||||
"compact": true,
|
||||
"optional": [
|
||||
"es7.asyncFunctions",
|
||||
"es7.decorators",
|
||||
"es7.exportExtensions",
|
||||
"es7.functionBind",
|
||||
"runtime"
|
||||
]
|
||||
}
|
||||
@@ -11,7 +11,7 @@ root = true
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespaces = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# CoffeeScript
|
||||
#
|
||||
@@ -28,12 +28,12 @@ indent_style = space
|
||||
# Package.json
|
||||
#
|
||||
# This indentation style is the one used by npm.
|
||||
[/package.json]
|
||||
[package.json]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
# Jade
|
||||
[*.jade]
|
||||
# Pug (Jade)
|
||||
[*.{jade,pug}]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
@@ -41,7 +41,7 @@ indent_style = space
|
||||
#
|
||||
# Two spaces seems to be the standard most common style, at least in
|
||||
# Node.js (http://nodeguide.com/style.html#tabs-vs-spaces).
|
||||
[*.js]
|
||||
[*.{js,jsx,ts,tsx}]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
|
||||
10
packages/xo-server-transport-email/.gitignore
vendored
10
packages/xo-server-transport-email/.gitignore
vendored
@@ -1,9 +1,9 @@
|
||||
/.nyc_output/
|
||||
/bower_components/
|
||||
/coverage/
|
||||
/dist/
|
||||
/node_modules/
|
||||
|
||||
npm-debug.log
|
||||
npm-debug.log.*
|
||||
|
||||
!node_modules/*
|
||||
node_modules/*/
|
||||
pnpm-debug.log
|
||||
pnpm-debug.log.*
|
||||
yarn-error.log
|
||||
|
||||
@@ -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
|
||||
@@ -1,10 +1,24 @@
|
||||
/benchmark/
|
||||
/benchmarks/
|
||||
*.bench.js
|
||||
*.bench.js.map
|
||||
|
||||
/examples/
|
||||
example.js
|
||||
example.js.map
|
||||
*.example.js
|
||||
*.example.js.map
|
||||
|
||||
/fixture/
|
||||
/fixtures/
|
||||
*.fixture.js
|
||||
*.fixture.js.map
|
||||
*.fixtures.js
|
||||
*.fixtures.js.map
|
||||
|
||||
/test/
|
||||
/tests/
|
||||
*.spec.js
|
||||
*.spec.js.map
|
||||
|
||||
__snapshots__/
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 'stable'
|
||||
- '4'
|
||||
- '0.12'
|
||||
- '0.10'
|
||||
- stable
|
||||
- 6
|
||||
- 4
|
||||
|
||||
# Use containers.
|
||||
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||
|
||||
@@ -1,45 +1,37 @@
|
||||
# xo-server-transport-email [](https://travis-ci.org/vatesfr/xo-server-transport-email)
|
||||
|
||||
> ${pkg.description}
|
||||
> xo-server plugin to send emails
|
||||
|
||||
## Install
|
||||
|
||||
Go inside your `xo-server` folder and install it:
|
||||
Installation of the [npm package](https://npmjs.org/package/xo-server-transport-email):
|
||||
|
||||
```
|
||||
> npm install xo-server-transport-email
|
||||
> npm install --global xo-server-transport-email
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Edit your `xo-server` configuration and add the plugin name in the `plugins` section.
|
||||
|
||||
```yaml
|
||||
plugins:
|
||||
|
||||
xo-server-transport-email:
|
||||
```
|
||||
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).
|
||||
|
||||
## Development
|
||||
|
||||
### Installing dependencies
|
||||
|
||||
```
|
||||
# Install dependencies
|
||||
> npm install
|
||||
```
|
||||
|
||||
### Compilation
|
||||
# Run the tests
|
||||
> npm test
|
||||
|
||||
The sources files are watched and automatically recompiled on changes.
|
||||
|
||||
```
|
||||
# Continuously compile
|
||||
> npm run dev
|
||||
```
|
||||
|
||||
### Tests
|
||||
# Continuously run the tests
|
||||
> npm run dev-test
|
||||
|
||||
```
|
||||
> npm run test-dev
|
||||
# Build for production (automatically called by npm install)
|
||||
> npm run build
|
||||
```
|
||||
|
||||
## Contributions
|
||||
@@ -49,7 +41,7 @@ the code.
|
||||
|
||||
You may:
|
||||
|
||||
- report any [issue](https://google.com/vatesfr/xo-server-transport-email/issues)
|
||||
- report any [issue](https://github.com/vatesfr/xo-server-transport-email/issues)
|
||||
you've encountered;
|
||||
- fork and create a pull request.
|
||||
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
{
|
||||
"name": "xo-server-transport-email",
|
||||
"version": "0.0.6",
|
||||
"version": "0.3.2",
|
||||
"license": "AGPL-3.0",
|
||||
"description": "",
|
||||
"description": "xo-server plugin to send emails",
|
||||
"keywords": [
|
||||
"xo-server",
|
||||
"email",
|
||||
"mail"
|
||||
"mail",
|
||||
"orchestra",
|
||||
"xen",
|
||||
"xen-orchestra",
|
||||
"xo-server"
|
||||
],
|
||||
"homepage": "https://google.com/vatesfr/xo-server-transport-email",
|
||||
"bugs": "https://google.com/vatesfr/xo-server-transport-email/issues",
|
||||
"homepage": "https://github.com/vatesfr/xo-server-transport-email",
|
||||
"bugs": "https://github.com/vatesfr/xo-server-transport-email/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://google.com/vatesfr/xo-server-transport-email"
|
||||
"url": "https://github.com/vatesfr/xo-server-transport-email"
|
||||
},
|
||||
"author": {
|
||||
"name": "Julien Fontanet",
|
||||
@@ -24,37 +27,64 @@
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "^5.8.34",
|
||||
"nodemailer": "^1.10.0",
|
||||
"nodemailer-markdown": "^1.0.0",
|
||||
"pify": "^2.3.0"
|
||||
"lodash": "^4.17.4",
|
||||
"nodemailer": "2.6.4",
|
||||
"nodemailer-markdown": "^1.0.1",
|
||||
"promise-toolbox": "^0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel": "^5.8.34",
|
||||
"babel-eslint": "^4.1.5",
|
||||
"clarify": "^1.0.5",
|
||||
"dependency-check": "^2.5.1",
|
||||
"mocha": "^2.3.4",
|
||||
"must": "^0.13.1",
|
||||
"nyc": "^3.2.2",
|
||||
"source-map-support": "^0.3.3",
|
||||
"standard": "^5.4.1",
|
||||
"trace": "^2.0.1"
|
||||
"babel-cli": "^6.18.0",
|
||||
"babel-eslint": "^7.1.1",
|
||||
"babel-plugin-lodash": "^3.2.11",
|
||||
"babel-preset-env": "^1.1.8",
|
||||
"babel-preset-stage-3": "^6.17.0",
|
||||
"cross-env": "^3.1.4",
|
||||
"dependency-check": "^2.7.0",
|
||||
"husky": "^0.12.0",
|
||||
"jest": "^18.1.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"standard": "^8.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "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",
|
||||
"posttest": "npm run lint && npm run depcheck",
|
||||
"build": "cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
|
||||
"commit-msg": "npm test",
|
||||
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
|
||||
"dev-test": "jest --bail --watch",
|
||||
"posttest": "standard && dependency-check ./package.json",
|
||||
"prebuild": "rimraf dist/",
|
||||
"predev": "npm run prebuild",
|
||||
"prepublish": "npm run build",
|
||||
"test": "nyc mocha --opts .mocha.opts \"dist/**/*.spec.js\""
|
||||
"test": "jest"
|
||||
},
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"lodash"
|
||||
],
|
||||
"presets": [
|
||||
[
|
||||
"env",
|
||||
{
|
||||
"targets": {
|
||||
"node": 4
|
||||
}
|
||||
}
|
||||
],
|
||||
"stage-3"
|
||||
]
|
||||
},
|
||||
"jest": {
|
||||
"testPathDirs": [
|
||||
"<rootDir>/src"
|
||||
],
|
||||
"testRegex": "\\.spec\\.js$"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"dist/**"
|
||||
"dist"
|
||||
],
|
||||
"parser": "babel-eslint"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import pify from 'pify'
|
||||
import { bind } from 'lodash'
|
||||
import { createTransport } from 'nodemailer'
|
||||
import { markdown as nodemailerMarkdown } from 'nodemailer-markdown'
|
||||
import { promisify } from 'promise-toolbox'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
@@ -23,10 +24,12 @@ export const configurationSchema = {
|
||||
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
description: 'human readable name of the sender'
|
||||
},
|
||||
address: {
|
||||
type: 'string'
|
||||
type: 'string',
|
||||
description: 'email address of the sender'
|
||||
}
|
||||
},
|
||||
|
||||
@@ -93,12 +96,26 @@ export const configurationSchema = {
|
||||
required: ['from', 'transport']
|
||||
}
|
||||
|
||||
export const testSchema = {
|
||||
type: 'object',
|
||||
|
||||
properties: {
|
||||
to: {
|
||||
type: 'string',
|
||||
description: 'recipient of the test mail'
|
||||
}
|
||||
},
|
||||
|
||||
additionalProperties: false,
|
||||
required: ['to']
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class TransportEmailPlugin {
|
||||
constructor (xo) {
|
||||
this._sendEmail = ::this._sendEmail
|
||||
this._set = ::xo.defineProperty
|
||||
constructor ({ xo }) {
|
||||
this._sendEmail = bind(this._sendEmail, this)
|
||||
this._set = bind(xo.defineProperty, xo)
|
||||
this._unset = null
|
||||
|
||||
// Defined in configure().
|
||||
@@ -130,7 +147,7 @@ class TransportEmailPlugin {
|
||||
transport.use('compile', markdownCompiler)
|
||||
|
||||
this._conf = conf
|
||||
this._send = pify(::transport.sendMail, Promise)
|
||||
this._send = promisify(transport.sendMail, transport)
|
||||
}
|
||||
|
||||
load () {
|
||||
@@ -141,22 +158,36 @@ class TransportEmailPlugin {
|
||||
this._unset()
|
||||
}
|
||||
|
||||
async _sendEmail ({
|
||||
from,
|
||||
test ({to}) {
|
||||
return this._sendEmail({
|
||||
to,
|
||||
subject: '[Xen Orchestra] Test of transport-email plugin',
|
||||
markdown: `Hi there,
|
||||
|
||||
The transport-email plugin for Xen Orchestra server seems to be working fine, nicely done :)`
|
||||
})
|
||||
}
|
||||
|
||||
_sendEmail ({
|
||||
from = this._conf.from,
|
||||
to, cc, bcc,
|
||||
subject,
|
||||
markdown
|
||||
markdown,
|
||||
attachments
|
||||
}) {
|
||||
// TODO: handle errors
|
||||
await this._send({
|
||||
from: from || this._conf.from,
|
||||
to, cc, bcc,
|
||||
return this._send({
|
||||
from,
|
||||
to,
|
||||
cc,
|
||||
bcc,
|
||||
subject,
|
||||
markdown
|
||||
markdown,
|
||||
attachments
|
||||
}).catch(logAndRethrow)
|
||||
}
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export default ({ xo }) => new TransportEmailPlugin(xo)
|
||||
export default opts => new TransportEmailPlugin(opts)
|
||||
|
||||
3578
packages/xo-server-transport-email/yarn.lock
Normal file
3578
packages/xo-server-transport-email/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user