This repository has been archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
88 lines (65 loc) · 2.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* jshint node: true */
'use strict';
var DeployPluginBase = require('ember-cli-deploy-plugin');
var Pusher = require('pusher');
function notificationHook(hookName) {
return function(context) {
if (!this.readConfig('enabled')) {
return;
}
var hook = this.readConfig(hookName);
if (hook) {
return hook.call(this, this.readConfig('pusherClient'));
}
};
}
module.exports = {
name: 'ember-cli-deploy-pusher',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
configure: function(/* context */) {
this.log('validating config', { verbose: true });
var defaultProps = Object.keys(this.defaultConfig || {});
defaultProps.forEach(this.applyDefaultConfigProperty.bind(this));
var requiredProps = this.requiredConfig || [];
requiredProps.forEach(this.ensureConfigPropertySet.bind(this));
if (this.pluginConfig.enabled) {
if (!this.pluginConfig.pusherClient) {
this.ensureConfigPropertySet('appId');
this.ensureConfigPropertySet('key');
this.ensureConfigPropertySet('secret');
this.pluginConfig.pusherClient = new Pusher({
appId: this.readConfig('appId'),
key: this.readConfig('key'),
secret: this.readConfig('secret')
});
}
}
this.log('config ok', { verbose: true });
},
defaultConfig: {
enabled: true
},
willDeploy: notificationHook('willDeploy'),
willBuild: notificationHook('willBuild'),
build: notificationHook('build'),
didBuild: notificationHook('didBuild'),
willPrepare: notificationHook('willPrepare'),
prepare: notificationHook('prepare'),
didPrepare: notificationHook('didPrepare'),
willUpload: notificationHook('willUpload'),
upload: notificationHook('upload'),
didUpload: notificationHook('didUpload'),
willActivate: notificationHook('willActivate'),
activate: notificationHook('activate'),
didActivate: notificationHook('didActivate'),
didDeploy: notificationHook('didDeploy'),
teardown: notificationHook('teardown'),
fetchRevisions: notificationHook('fetchRevisions'),
displayRevisions: notificationHook('displayRevisions'),
didFail: notificationHook('didFail')
});
return new DeployPlugin();
}
};