# @frylo/pftp

> Progressive FTP deployment

Latest version **1.5.0** (published 2024-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @frylo/pftp
pnpm add @frylo/pftp
yarn add @frylo/pftp
bun add @frylo/pftp
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2024-07-25 |
| First published | 2024-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 150.7 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | frylo |
| Maintainers | frylo |
| Keywords | ftp, sftp, lftp, sync, deploy, deployment, ci, rsync, upload |

## Links

- npm: https://www.npmjs.com/package/@frylo/pftp
- Repository: https://github.com/frylo-d-ts/pftp
- Homepage: https://github.com/frylo-d-ts/pftp#readme
- Issues: https://github.com/frylo-d-ts/pftp/issues
- npm.io page: https://npm.io/package/@frylo/pftp

## Dependencies (6)

- [zod](https://npm.io/package/zod.md) ^3.22.4
- [glob](https://npm.io/package/glob.md) ^10.3.10
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [cli-progress](https://npm.io/package/cli-progress.md) ^3.12.0
- [command-exists](https://npm.io/package/command-exists.md) ^1.2.9
- [humanize-duration](https://npm.io/package/humanize-duration.md) ^3.31.0

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2024-07-25
- 1.4.0 — 2024-05-15
- 1.3.1 — 2024-01-18
- 1.3.0 — 2024-01-18
- 1.2.1 — 2024-01-04
- 1.2.0 — 2024-01-04
- 1.1.0 — 2024-01-04
- 1.0.0 — 2024-01-04

## README

# 🚀 @frylo/pftp - Progressive FTP

This package using [LFTP](https://lftp.yar.ru/) to deploy your code to FTP/SFTP/SSH server.

➕ **Benefits**

```md
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](#-examples)
  - [👁️ Progressbar CLI example](#️-progressbar-cli-example)
  - [👁️ Progress logs CLI example](#️-progress-logs-cli-example)
- [🏁 Getting Started](#-getting-started)
- [🔑 Configuration](#-configuration)
- [⚙️ Package development](#️-package-development)
- [📜 LFTP docs](#-lftp-docs)

## 🎁 Examples

### 👁️ Progressbar CLI example

<details><summary>Code of example</summary>

```js
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));
```

</details>

![Progressbar PFTP](./readme/progress-bar.png)

### 👁️ Progress logs CLI example

<details><summary>Code of example</summary>

```js
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));
```

</details>

![Progress logs PFTP](./readme/progress-logs.png)

## 🏁 Getting Started

Install package:

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

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

```js
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:

```bash
node ./deployment.mjs
```

## 🔑 Configuration

**Configuration** schema:

| Option             | Value             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| host               | string            | IP or URL of your host.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| port               | number            | Number 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| username           | string            | Username for connection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| password           | string            | Password for connection.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| localFolder        | string            | Path to source folder on local machine.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| remoteFolder       | string            | Path to target folder on remote machine.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| excludeRegExp      | RegExp[]          | 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](https://www.gnu.org/software/findutils/manual/html_node/find_html/posix_002degrep-regular-expression-syntax.html) format, so **flags are not allowed** and there are some **small difference between JS RegExp and Egrep**.                                                                                                                                                  |
| includeForceRegExp | RegExp[]          | Files matching any of this regexp will be uploaded to server no matter has been it changed or not. Given RegExp's are applied only to file names which are in realtive form (relative to cwd). All RegExp's have to be in [Egrep](https://www.gnu.org/software/findutils/manual/html_node/find_html/posix_002degrep-regular-expression-syntax.html) format, so **flags are not allowed** and there are some **small difference between JS RegExp and Egrep**. All files mathcing RegExp will be uploaded to server using `mput` lftp command. |
| progress           | 'bar', 'logs'     | Customize process loggin.<br />\* Bar - show progress bar (useful for manual execution);<br />\* Logs - print logs (useful for GitLab CI/CD).                                                                                                                                                                                                                                                                                                                                                                                                           |
| customLftpOptions  | CustomLftpOptions | Allows to advancely configure LFTP. Usually you don't need this option. Read more about this options in CustomLftpOptions schema section.                                                                                                                                                                                                                                                                                                                                                                                                               |

**CustomLftpOptions** schema:

| Option               | Value   | Description                                                                                                                                                                                                                                                    |
| -------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| lftpCommand          | string  | Path to LFTP executable or name of lftp command. Defaults to "lftp".                                                                                                                                                                                           |
| logLftpCommand       | boolean | If true script will log generated LFTP command to console.                                                                                                                                                                                                     |
| beforeOpen           | string  | In this string you can pass command to lftp that will be ran before "open" command (before connection).<br />**Default value**: `set net:timeout 5; set net:max-retries 3; set net:reconnect-interval-multiplier 1; set net:reconnect-interval-base 5` |
| openCommandOptions   | string  | Here you can rewrite CLI options for [open LFTP command](https://lftp.yar.ru/lftp-man.html).                                                                                                                                                                       |
| beforeMirror         | string  | In this string you can pass command to LFTP that will be ran before "mirror" command (then you connected, but mirroring haven't started yet).                                                                                                                  |
| mirrorCommandOptions | string  | Here you can rewrire CLI options for mirror LFTP command.<br />**Default value**: `--reverse --delete --only-newer --verbose=2 --ignore-time --parallel=10`                                                                                            |
| beforeMput           | string  | In this string you can pass command to lftp that will be ran before "mput" set of commands (this set will run only if you use `includeForceRegExp` option).                                                                                                  |
| mputCommandOptions   | string  | Options for mput set of commands, that runs at second phase if `importForceRegExp` option is present.<br />**Default value**: `-d`                                                                                                                   |
| enaleSsl             | string  | By 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](./readme/package-development.md).

## 📜 LFTP docs

[Read here](readme/lftp-docs.md).

---
_Source: https://npm.io/package/@frylo/pftp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
