-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (55 loc) · 1.72 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
'use strict';
const BasePlugin = require('ember-cli-deploy-plugin');
const ftp = require("basic-ftp");
module.exports = {
name: 'ember-cli-deploy-ftps',
createDeployPlugin: function(options) {
let DeployPlugin = BasePlugin.extend({
name: options.name,
/*eslint-disable */
// supress avoid-leaking-state-in-ember-objects rule
requiredConfig: ['host'],
defaultConfig: {
port: 21,
username: 'anonymous',
password: 'anonymous',
remoteRoot: '/',
tls: false,
clear: false
},
/*eslint-enable */
upload: async function(context) {
let config = {
host: this.readConfig('host'),
port: this.readConfig('port'),
username: this.readConfig('username'),
password: this.readConfig('password'),
tls: this.readConfig('tls'),
clear: this.readConfig('clear'),
localRoot: context.distDir,
remoteRoot: this.readConfig('remoteRoot'),
};
this.log('Preparing to upload to FTP host `' + config.host + '`', {
verbose: true
});
const client = new ftp.Client();
client.ftp.verbose = this.ui.verbose;
await client.connect(config.host, config.port);
if (config.tls) {
await client.useTLS();
}
await client.login(config.username, config.password);
if(config.remoteRoot != '/') {
await client.cd(config.remoteRoot);
}
await client.useDefaultSettings();
if (config.clear) {
await client.clearWorkingDir();
}
await client.uploadDir(config.localRoot);
client.close();
},
});
return new DeployPlugin();
}
};