-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
46 lines (39 loc) · 1.6 KB
/
deploy.js
File metadata and controls
46 lines (39 loc) · 1.6 KB
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
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import FtpDeploy from 'ftp-deploy';
const __dirname = dirname(fileURLToPath(import.meta.url));
const ftpDeploy = new FtpDeploy();
let transferedData = {
'totalFiles': {},
'transferedFiles': {},
'name': {}
};
let config = {
user: process.env.FTPUSER,
password: process.env.FTPPASS,
host: process.env.FTPHOST,
port: 21,
localRoot: __dirname + "/",
remoteRoot: "/customers/3/a/f/szczepan.me/httpd.www",
include: ["*.html","dist/*/*.js","css/styles.css","images/*"],
exclude: ["*.**/*","node_modules/**/.*","node_modules","node_modules/**","**/node_modules/**",".git/**/*","*.md","*.json","coverage/**/*",".circleci/**/*","deploy.js","js/*",".babelrc",".gitignore",".circleci","*.yml"],
deleteRemote: false
};
console.log("Deploying from local root:", __dirname + "/");
console.log("Deploying to remote root:", config.remoteRoot);
ftpDeploy.deploy(config)
.then(res => console.log('finished: ' + res))
.catch(err => {
console.log(err);
throw err;
});
ftpDeploy.on('uploading', data => {
transferedData.totalFiles = data.totalFilesCount; // total file count being transferred
transferedData.transferedFiles = data.transferredFileCount; // number of files transferred
transferedData.name = data.filename; // partial path with filename being uploaded
console.log(transferedData);
});
ftpDeploy.on('uploaded', function(data) {
console.log('transferedData :', transferedData); // same data as uploading event
console.log('data :', data);
});