4.0.9 • Published 9 months ago

@winner-fed/ftp-deploy v4.0.9

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

ftp-deploy

配置说明

interface UserConfig {
  /**
   * 目标服务器登录用户
   */
  user: string;
  /**
   * 目标服务器登录密码
   */
  password: string;
  /**
   * 目标服务器主机地址,ftp 常用端口为21,sftp 为 22
   */
  host: string;
  /**
   * 目标服务器端口
   */
  port: number;
  /**
   * 本地路径
   */
  localPath: string;
  /**
   * 目标服务器上传路径
   */
  remotePath: string;
  /**
   * 包含的文件
   */
  // ["*.php", "dist/*", ".*"]
  include: Array<string>;
  /**
   * 不包含的文件
   **/
  // [
  //  "dist/**/*.map",
  // "node_modules/**",
  // "node_modules/**/.*",
  // ".git/**",
  // ]
  exclude: Array<string>;
  /**
   * 上传之前,删除目标服务器路径的所有文件
   * @default false
   */
  deleteRemote: boolean;
  /**
   * @default true
   */
  forcePasv: boolean;
  /**
   * 使用 sftp 或 ftp
   * @default false
   */
  sftp: boolean;
}

使用说明

const { FtpDeployer } = require('@winner-fed/ftp-deploy');
const path = require('path');

const ftpDeploy = new FtpDeployer();
const config = {
  localPath: path.join(__dirname, '/resource'),
  remotePath: '/usr/local/nginx/html/deploy-test',
  user: '***',
  password: '****',
  host: '****',
  port: 22,
  // include: ["*", "**/*"],      // this would upload everything except dot files
  include: ['*'],
  // 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,
  // use sftp or ftp
  sftp: true
};

ftpDeploy
  .deploy(config)
  .then((res) => console.log('上传成功:', res))
  .catch((err) => console.log(err));