const options ={
host:"",
port:"21",
user:"",
password:""// proxy:{// host: '',// port: '',// }};const FtpDeploy =require("ftp-deploy");const ftpDeploy =newFtpDeploy();const config ={...options,// localRoot: path.resolve(__dirname,'../zip'),// include: ["dist.zip"], // this would upload everything except dot files
localRoot: path.resolve(__dirname,'./.vitepress/dist'),
include:["*","**/*"],// this would upload everything except dot files
remoteRoot:"/",// include: ["*.php", "dist/*", ".*"],// e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)// exclude: ["dist/**/*.map", "node_modules/**", "node_modules/**/.*", ".git/**"],
exclude:[],// delete ALL existing files at destination before uploading, if true
deleteRemote:false,// Passive mode is forced (EPSV command is not sent)
forcePasv:false};// use with callback
ftpDeploy.deploy(config,(err, res)=>{if(err){
console.log(err);}else{
console.log("finished:", res);axios(webHookConfig).then(function(response){
console.log(JSON.stringify(response.data));}).catch(function(error){
console.log(error);});}});
ftpDeploy.on("uploading",data=>{
console.log(`start up ${data.filename} ,fileSize ${data.totalFilesCount}`);// partial path with filename being uploaded});
ftpDeploy.on("uploaded",data=>{
console.log("\033[33m "+ data.filename +" upload done \033[39m");// same data as uploading event});
ftpDeploy.on("log",data=>{
console.log(data);// same data as uploading event});
ftpDeploy.on("upload-error",data=>{
console.log(data.err);// data will also include filename, relativePath, and other goodies});