-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
122 lines (108 loc) · 4.01 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
'use strict';
var path = require('path');
var DeployPluginBase = require('ember-cli-deploy-plugin');
var Ssh = require('./lib/ssh');
module.exports = {
name: 'ember-cli-deploy-ssh-index',
createDeployPlugin: function(options) {
var DeployPlugin = DeployPluginBase.extend({
name: options.name,
defaultConfig: {
allowOverwrite: false,
filePattern: 'index.html',
port: 22,
privateKeyFile: null,
agent: null,
passphrase: null,
distDir: function(context) {
return context.distDir;
},
revisionKey: function(context) {
var revisionKey = context.revisionData && context.revisionData.revisionKey;
return context.commandOptions.revision || revisionKey;
}
},
requiredConfig: ['username', 'host', 'port', 'remoteDir'],
upload() {
var allowOverwrite = this.readConfig('allowOverwrite');
var filePattern = this.readConfig('filePattern');
var distDir = this.readConfig('distDir');
var revisionKey = this.readConfig('revisionKey');
var username = this.readConfig('username');
var host = this.readConfig('host');
var port = this.readConfig('port');
var remoteDir = this.readConfig('remoteDir');
var privateKeyFile = this.readConfig('privateKeyFile');
var passphrase = this.readConfig('passphrase');
var agent = this.readConfig('agent');
var filePath = path.join(distDir, filePattern);
var options = {
allowOverwrite: allowOverwrite,
filePattern: filePattern,
filePath: filePath,
revisionKey: revisionKey,
username: username,
host: host,
port: port,
remoteDir: remoteDir,
passphrase: passphrase,
agent: agent,
privateKeyFile: privateKeyFile
};
var ssh = new Ssh({ plugin: this });
return ssh.upload(options);
},
activate() {
var filePattern = this.readConfig('filePattern');
var revisionKey = this.readConfig('revisionKey');
var username = this.readConfig('username');
var host = this.readConfig('host');
var port = this.readConfig('port');
var remoteDir = this.readConfig('remoteDir');
var passphrase = this.readConfig('passphrase');
var agent = this.readConfig('agent');
var privateKeyFile = this.readConfig('privateKeyFile');
var options = {
filePattern: filePattern,
revisionKey: revisionKey,
username: username,
host: host,
port: port,
remoteDir: remoteDir,
passphrase: passphrase,
agent: agent,
privateKeyFile: privateKeyFile
};
var ssh = new Ssh({ plugin: this });
return ssh.activate(options);
},
fetchRevisions: function(context) {
var filePattern = this.readConfig('filePattern');
var username = this.readConfig('username');
var host = this.readConfig('host');
var port = this.readConfig('port');
var remoteDir = this.readConfig('remoteDir');
var passphrase = this.readConfig('passphrase');
var agent = this.readConfig('agent');
var privateKeyFile = this.readConfig('privateKeyFile');
var options = {
filePattern: filePattern,
username: username,
host: host,
port: port,
remoteDir: remoteDir,
passphrase: passphrase,
agent: agent,
privateKeyFile: privateKeyFile
};
var ssh = new Ssh({ plugin: this });
return ssh.fetchRevisions(options).then(function(revisions) {
if (revisions && revisions.length) {
context.revisions = revisions;
}
});
}
});
return new DeployPlugin();
}
};