1. 'use strict'
    2. const chalk = require('chalk')
    3. const ora = require('ora')
    4. const path = require('path')
    5. const { sh } = require('tasksfile')
    6. var FtpDeploy = require('ftp-deploy')
    7. var ftpDeploy = new FtpDeploy()
    8. console.log(chalk.yellow('Cordova www Build start.\n'))
    9. sh('cd ../ && cordova-hcp build')
    10. console.log(chalk.green('==== 1.热更新配置文件更新完成 ====.\n'))
    11. sh('cd ../ && cordova build android')
    12. console.log(chalk.green('==== 2.apk 打包完成 ====.\n'))
    13. var config = {
    14. user: '',
    15. password: '',
    16. host: '',
    17. port: 21,
    18. localRoot: path.resolve(__dirname, '../../www'),
    19. remoteRoot: '/public/download/merchant_app/latest/www',
    20. include: ['*', '**/*'], // 这样会上传所有文件
    21. // include: ['*.php', 'dist/*', '.*'],
    22. // e.g. exclude sourcemaps, and ALL files in node_modules (including dot files)
    23. // exclude: ['dist/**/*.map', 'node_modules/**', 'node_modules/**/.*', '.git/**'],
    24. // 如果为true,则在上载之前删除目标上的所有现有文件
    25. deleteRemote: true,
    26. // Passive mode is forced (EPSV command is not sent)
    27. forcePasv: false
    28. }
    29. const spinner = ora('文件上传中')
    30. spinner.start()
    31. ftpDeploy
    32. .deploy(config)
    33. .then(res => {
    34. spinner.stop()
    35. console.log(chalk.green('==== 3.热更新文件上传完成 ====.\n'))
    36. })
    37. .catch(err => console.log(err))