0.3.1 • Published 5 years ago

@front-lib/deploy-ftp v0.3.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

deploy-ftp

基于ftp协议的文件deploy工具

// 安装为正式依赖
npm i @front-lib/deploy-ftp -S

// 安装为环境依赖
npm i @front-lib/deploy-ftp -D

用法

引入基础类

const DeployFtp = require('@front-lib/deploy-ftp')

实例化并执行deploy方法

const ins = new MyDeploy({
  // 一共可以重试上传的次数, 默认一共尝试3次上传,如果全部失败则中断上传
  times: 3,

  // 要deploy的文件夹根目录
  localRoot: path.join(__dirname, 'path/to'),

  // localRoot 下要忽略的文件,遵守glob规则,支持数组/字符串格式
  // ignores: '**/.git/**',
  ignores: ['**/.git/**', 'node_modules/**'],

  // 是否把文件内容hash后与远程地图里面的文件hash比较后,只deploy有变化的文件
  // 如果设置为false,则不与远程地图比较,全部重新deploy
  compare: true,

  // glob的options设置
  glob: {},

  // ftp服务器相关配置
  ftp: {
    host: '',
    user: '',
    pass: ''
  },

  // jsftp扩展函数
  jsftpHook: async (ftp) => {
    ftp.timeout = 1000 * 60 * 10
  }

  // localRoot下的文件上传到ftp服务器哪个目录下
  remoteRoot: '/',

  // ftp服务器上map文件路径, 默认为 `.deploy_ftp_map.json`
  remoteMap: '.deploy_ftp_map.json'
})

async function foo () {
  // 开始 deploy
  await ins.deploy()
  // deploy 结束
}
foo()

相关

ignores与glob pattern关系

  • 如果ignores为字符串,则直接作为glob pattern
  • 如果ignores为数组且长度为1,则ignores[0]作为glob pattern
  • 如果ignores为数组,则经'{' + ignores.join(',') + '}'处理后作为glob pattern

ignores参数怎么配置?

glob pattern文档

glob参数怎么配置?

glob options文档

ftp参数怎么配置?

该参数传递给 jsftp options

remoteMap在远程的路径是相对于remoteRoot下的吗?

不是

0.3.1

5 years ago

0.3.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago