Guest User

Untitled

a guest
Feb 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. const FtpDeploy = require('ftp-deploy');
  2. const chalk = require('chalk');
  3. const ora = require('ora');
  4. const logSymbols = require('log-symbols');
  5. const deployer = new FtpDeploy();
  6.  
  7. const config = {
  8. username: 'your-ftp-username',
  9. password: 'your-ftp-password',
  10. host: 'your-server.com',
  11. port: 21,
  12. localRoot: __dirname + '/dist',
  13. remoteRoot: '/',
  14. exclude: ['.DS_Store']
  15. }
  16.  
  17. console.log(chalk.blue('Launching deploy ship...'));
  18. console.log(chalk.blue('========================'));
  19.  
  20. const connectSpinner = ora('Contacting server').start();
  21. const progress = {};
  22.  
  23. deployer.deploy(config, function(err) {
  24. if (err) {
  25. connectSpinner.fail(chalk.red('ERROR') + ' ' + err.message);
  26. process.exit(1);
  27. } else {
  28. console.log(chalk.green(logSymbols.success + ' DEPLOY SUCCESS'));
  29. process.exit();
  30. }
  31. });
  32.  
  33. deployer.on('error', function(err) {
  34. connectSpinner.fail(chalk.red('ERROR') + ' ' + err.message);
  35. });
  36.  
  37. deployer.on('uploading', function(data) {
  38. if (data.transferredFileCount < 1) connectSpinner.succeed('Start uploading process');
  39.  
  40. progress[data.filename] = ora('[ ' + (data.transferredFileCount + 1) + '/' + data.totalFileCount + ' ] ' + data.filename).start();
  41. });
  42.  
  43. deployer.on('uploaded', function(data) {
  44. progress[data.filename].succeed();
  45. });
Add Comment
Please, Sign In to add comment