1.3.1 ā€¢ Published 4 months ago

@frylo/pftp v1.3.1

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

šŸš€ @frylo/pftp - Progressive FTP

This package using LFTP to deploy your code to FTP/SFTP/SSH server.

āž• Benefits

1. **Fast**
   1. Updates only changed files.
   2. Deploy faster with parallel deployment processes.
   3. Deploy of 1GB project took about 10 seconds.
2. **Clear**
   1. Only necessary info in you console.
   2. See the process of deployment with progressbar.
3. **Simple**
   1. Only integral options.
   2. Autocompletion for configuration.
   3. Advanced configuration is also available, but hidden deeper in config.

šŸ”— Reference

šŸŽ Examples

šŸ‘ļø Progressbar CLI example

const process = require("process");
const { deploy } = require("../lib/index.js");
const { credentials, folders } = require("./credentials.js");

async function main() {
  await deploy({
    host: "000.00.00.0",
    port: 22,
    protocol: "sftp",
    username: "my-username",
    password: "my-password",

    progress: "bar", // << This option change the view

    localFolder: "./build",
    remoteFolder: "/var/www/my-site.com",
  });
}

main()
  .then(() => process.exit())
  .catch((error) => console.error(error));

Progressbar PFTP

šŸ‘ļø Progress logs CLI example

const process = require("process");
const { deploy } = require("../lib/index.js");
const { credentials, folders } = require("./credentials.js");

async function main() {
  await deploy({
    host: "000.00.00.0",
    port: 22,
    protocol: "sftp",
    username: "my-username",
    password: "my-password",

    progress: "logs", // << This option change the view

    localFolder: "./build",
    remoteFolder: "/var/www/my-site.com",
  });
}

main()
  .then(() => process.exit())
  .catch((error) => console.error(error));

Progress logs PFTP

šŸ Getting Started

Install package:

npm install --save-dev @frylo/pftp
yarn install -D @frylo/pftp
pnpm i -D @frylo/pftp

Create upload script file, e.g. deployment.mjs:

import { deploy, Credentials } from "@frylo/pftp";

/** @type {Credentials} */
const credentials = {
  host: "000.00.00.0",
  port: 22,
  protocol: "sftp",
  username: "my-username",
  password: "my-password",
};

async function main() {
  await deploy({
    ...credentials,
    localFolder: "./build",
    remoteFolder: "/var/www/my-site.com",
    progress: "bar",
  });
}

main.then(() => process.exit());

Run upload script to deploy files:

node ./deployment.mjs

šŸ”‘ Configuration

Configuration schema:

OptionValueDescription
hoststringIP or URL of your host.
portnumberNumber of port, usually 21 for FTP and 22 for SFTP.
protocol'ftp', 'sftp'Protocol for upload. If you are using SSH server, you could simply use SFTP with 22 port.
usernamestringUsername for connection.
passwordstringPassword for connection.
localFolderstringPath to source folder on local machine.
remoteFolderstringPath to target folder on remote machine.
excludeRegExpRegExp[]List of RegExp's to be excluded. Given RegExp's are applied to file and dir names which are in realtive form (relative to cwd). All RegExp's have to be in Egrep format, so flags are not allowed and there are some small difference between JS RegExp and Egrep.
includeForceRegExpRegExp[]Files matching any of this regexp will be uploaded to server no matter has been it changed or not. Given RegExp's are applied to file and dir names which are in realtive form (relative to cwd). All RegExp's have to be in Egrep format, so flags are not allowed and there are some small difference between JS RegExp and Egrep.
progress'bar', 'logs'Customize process loggin.* Bar - show progress bar (useful for manual execution);* Logs - print logs (useful for GitLab CI/CD).
customLftpOptionsCustomLftpOptionsAllows to advancely configure LFTP. Usually you don't need this option. Read more about this options in CustomLftpOptions schema section.

CustomLftpOptions schema:

OptionValueDescription
lftpCommandstringPath to LFTP executable or name of lftp command. Defaults to "lftp".
logLftpCommandbooleanIf true script will log generated LFTP command to console.
beforeOpenstringIn this string you can pass command to lftp that will be ran before "open" command (before connection).Default value: set net:timeout 5; set net:max-retries 3; set net:reconnect-interval-multiplier 1; set net:reconnect-interval-base 5
openCommandOptionsstringHere you can rewrite CLI options for open LFTP command.
beforeMirrorstringIn this string you can pass command to LFTP that will be ran before "mirror" command (then you connected, but mirroring haven't started yet).
mirrorCommandOptionsstringHere you can rewrire CLI options for mirror LFTP command.Default value: --reverse --delete --only-newer --verbose=2 --ignore-time --parallel=10
beforeMirrorForcestringIn this string you can pass command to lftp that will be ran before second "mirror" command that uploads files by force (check includeForceRegExp config options for more info).
mirrorForceCommandOptionsstringOptions for mirror command, that runs at second phase if importForceRegExp option is present.Default value: --reverse --verbose=2 --parallel=10
enaleSslstringBy default SSL option for LFTP is disabled, because usually it bring pain for beginners. You could enable it back with this option.

āš™ļø Package development

Read more about package development here.

1.3.1

4 months ago

1.3.0

4 months ago

1.2.0

4 months ago

1.2.1

4 months ago

1.1.0

4 months ago

1.0.0

4 months ago