1.0.2 • Published 4 years ago

@wok-cli/plugin-deploy-lftp v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

LFTP Deploy Adapter Plugin

You can use this plugin with the deploy task of @wok-cli/tasks to add the ability to upload and sync your files via FTP, SFTP, FTPS.

This package implements node-ftp and requires lftp to be installed on your machine.

Hook typesProduction onlyPurpose
promisenobuild deploy

Why lftp?

lftp comes with a mirroring feature that tries to keep your local and remote files in sync, removing old files and uploading updated or new files only.

If you have just an ftp connection to your remote host this is the closest you can get to rsync.

Installation

This task requires @wok-cli/core as peer dependency.

npm i @wok-cli/core @wok-cli/plugin-deploy-lftp --save-dev

Usage

First of all update or add your remote target to the wok.config.js file and set the deploy strategy to either 'ftp', 'sftp' or 'ftps' (depending on your remote host's configuration).

// wok.config.js
module.exports = {
  // .... other configs

  targets: {
    ftpserver: {
      host: 'ftp.mydomain.com',
      username: 'ftpuser',
      password: 'password',
      path: 'public',
      deployStrategy: 'ftp',
    },
  },
};

Notes:

  • targets.ftpserver.path will be used as the remote base directory for upload.
  • @wok-cli/plugin-deploy-lftp will ignore any target with other deployStrategy.

Then configure the plugin as a strategy for @wok/tasks's deploy task:

const $ = require('@wok-cli/core');
const { deploy } = require('@wok-cli/tasks');
const lftp = require('@wok-cli/plugin-deploy-lftp');

const deployTask = $.task(deploy, {
  src: 'dist/', // folder where the compiled files is stored
});

deployTask.tap('strategy', 'lftp', lftp);

export.deploy = deployTask

Finally to upload your files run:

gulp deploy --target=ftpserver

Default Deploy Strategy

You can define ftp as the default deploy strategy by adding a deployStrategy key to the root of your wok config object:

// wok.config.js
module.exports = {
  // .... other configs

+ deployStrategy: 'ftp',
  targets: {
    ftpserver: {
      host: 'ftp.mydomain.com',
      username: 'ftpuser',
      password: 'password',
      path: 'public',
-     deployStrategy: 'ftp',
    },
  },
};