-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.js
More file actions
55 lines (49 loc) · 1.61 KB
/
Copy pathdeploy.js
File metadata and controls
55 lines (49 loc) · 1.61 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
47
48
49
50
51
52
53
54
55
const FtpDeploy = require('ftp-deploy');
const ftpDeploy = new FtpDeploy();
require('dotenv').config({ path: '.env.local' });
console.log('process.env.FTP_USER',process.env.FTP_USER);
const config = {
sftp: process.env.FTP_SFTP,
user: process.env.FTP_USER,
// Password optional, prompted if none given
password: process.env.FTP_PASS,
host: process.env.FTP_HOST,
port: process.env.FTP_PORT || 21,
localRoot: __dirname + '/src/',
remoteRoot: process.env.FTP_REMOTE_ROOT,
// this would upload everything
include: ['*'],
// e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
exclude: [],
// delete ALL existing files at destination before uploading, if true
deleteRemote: process.env.FTP_DELETE,
// Passive mode is forced (EPSV command is not sent)
forcePasv: true,
debugMode: false,
};
ftpDeploy
.deploy(config)
.then((res) => console.log('finished:', res))
.catch((err) => console.log(err));
// .deploy(config)
// .then((res) => {
// return axios
// .get(`${process.env.PUBLIC_URL}/customer/settings/reset`, {}, {})
// .then((res) => {
// console.log('finished ;)\n',res.data)
// // return res.data;
// })
// .catch((err) => {
// console.error('err in axios => ', err);
// // return err;
// });
// })
// .catch((err) => console.log(err));
ftpDeploy.on('uploading', (d) => {
console.log(
`${d.transferredFileCount} / ${d.totalFilesCount} => ${d.filename}`
);
});
ftpDeploy.on('upload-error', function (data) {
console.log('upload-error =>', data.err); // data will also include filename, relativePath, and other goodies
});