-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
32 lines (27 loc) · 927 Bytes
/
deploy.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
require('dotenv-flow').config();
const FtpDeploy = require('ftp-deploy');
const ftpDeploy = new FtpDeploy();
var config = {
user: process.env.FTP_DEPLOY_USER,
password: process.env.FTP_DEPLOY_PASSWORD,
host: process.env.FTP_DEPLOY_HOST,
port: process.env.FTP_DEPLOY_PORT,
localRoot: __dirname + "/dist",
remoteRoot: process.env.FTP_DEPLOY_REMOTE_ROOT,
include: ["*", "**/*"],
deleteRemote: true,
sftp: process.env.FTP_DEPLOY_SFTP
};
console.log(`📦 Deploying to ${process.env.FTP_DEPLOY_SFTP ? 'sftp' : 'ftp'}://${process.env.FTP_DEPLOY_HOST}:${process.env.FTP_DEPLOY_PORT} ...`);
ftpDeploy
.on('uploading', data => {
console.log(`[${data.transferredFileCount+1}/${data.totalFilesCount}] ${data.filename}`);
})
.deploy(config)
.then(res => {
console.log('✅ Deploy finished sucessfully! 🎉');
})
.catch(err => {
console.log('❌ Deploy failed.');
console.log(err);
});