const FtpDeploy = require("ftp-deploy");

const ftp = new FtpDeploy();

const config = {
  user: process.env.FTP_USER,
  password: process.env.FTP_PASSWORD,
  host: process.env.FTP_HOST,
  port: process.env.FTP_PORT,
  localRoot: __dirname + "/../frontend",
  remoteRoot: "/public_html/car/",
  include: ["build/**"],
  exclude: ["build/**/*.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
};

ftp
  .deploy(config)
  .then(() => {
    console.log("Deployment to FTP finished");
    return;
  })
  .catch((err) => {
    console.log(err);
  });
