Created
November 4, 2019 16:49
-
-
Save mrfambo/f0eb2687ae8298dc48c0558192c8ee4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Continous Integration of React App build to ftp using nodejs. | |
It simply takes the files from build folder and upload them onto your ftp provided destination | |
With best practice add "deploy":"node react-ci-ftp.js" command in your package.json | |
*/ | |
var FtpDeploy = require("ftp-deploy"); // add it as dev dependancy in your react project | |
var ftpDeploy = new FtpDeploy(); | |
var config = { | |
user: "", // user of ftp account | |
password: "", // Password optional, prompted if none given | |
host: "ftp.alimuqaddas.com", // Your ftp host | |
port: 21, // Your FTP Port | |
localRoot: __dirname + "/build", | |
remoteRoot: "/public_html/", | |
include: ["*"], // this would upload everything except dot files | |
// include: ["*.php", "dist/*", ".*"], | |
// e.g. exclude sourcemaps, and ALL files in node_modules (including dot files) | |
// exclude: ["dist/**/*.map", "node_modules/**", "node_modules/**/.*", ".git/**"], | |
// delete ALL existing files at destination before uploading, if true | |
deleteRemote: false, | |
// Passive mode is forced (EPSV command is not sent) | |
forcePasv: true | |
}; | |
ftpDeploy | |
.deploy(config) | |
.then(res => console.log("finished:", res)) | |
.catch(err => console.log(err)); | |
ftpDeploy.on("uploading", function(data) { | |
console.log(data.totalFilesCount); // total file count being transferred | |
console.log(data.transferredFileCount); // number of files transferred | |
console.log(data.filename); // partial path with filename being uploaded | |
}); | |
ftpDeploy.on("uploaded", function(data) { | |
console.log(data); // same data as uploading event | |
}); | |
ftpDeploy.on("log", function(data) { | |
console.log(data); // same data as uploading event | |
}); | |
ftpDeploy.on("upload-error", function(data) { | |
console.log(data.err); // data will also include filename, relativePath, and other goodies | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment