Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dobbydog/sftp-sync-deploy
[Node.js] Sync local files to remote using SFTP.
https://github.com/dobbydog/sftp-sync-deploy
Last synced: 18 days ago
JSON representation
[Node.js] Sync local files to remote using SFTP.
- Host: GitHub
- URL: https://github.com/dobbydog/sftp-sync-deploy
- Owner: dobbydog
- License: mit
- Created: 2016-12-07T09:07:19.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T11:35:23.000Z (over 1 year ago)
- Last Synced: 2024-10-11T21:01:43.724Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 51.8 KB
- Stars: 25
- Watchers: 1
- Forks: 17
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sftp-sync-deploy
Sync local files to remote using SFTP.
## Usage
### Javscript
```js
const { deploy } = require('sftp-sync-deploy');let config = {
host: 'example.com', // Required.
port: 22, // Optional, Default to 22.
username: 'user', // Required.
password: 'password', // Optional.
privateKey: '/path/to/key.pem', // Optional.
passphrase: 'passphrase', // Optional.
agent: '/path/to/agent.sock', // Optional, path to the ssh-agent socket.
localDir: 'dist', // Required, Absolute or relative to cwd.
remoteDir: '/path/to/dest' // Required, Absolute path only.
};let options = {
dryRun: false, // Enable dry-run mode. Default to false
exclude: [ // exclude patterns (glob)
'node_modules',
'src/**/*.spec.ts'
],
excludeMode: 'remove', // Behavior for excluded files ('remove' or 'ignore'), Default to 'remove'.
forceUpload: false, // Force uploading all files, Default to false(upload only newer files).
concurrency: 100 // Max number of SFTP tasks processed concurrently. Default to 100.
};deploy(config, options).then(() => {
console.log('success!');
}).catch(err => {
console.error('error! ', err);
});
```### TypeScript
```ts
import { deploy, SftpSyncConfig, SftpSyncOptions } from 'sftp-sync-deploy';let config: SftpSyncConfig = {...};
let options: SftpSyncOptions = {...};deploy(config, options);
```## Dry run mode
```js
deploy(config, {dryRun: true});
```Outputs the tasks to be done for each file in following format. Any changes of the files will not be performed.
```
[ (local file status) | (remote file status) ] (file path)
-> (task)
```### Output example
```
# Local is a file (upload the file)
[ F | F ] index.html
-> upload# Local is a directory (sync recursively)
[ D | D ] lib
-> sync# Remote exists and local doesn't (remove the remote file or directory)
[ | F ] index.html.bak
-> remove remote# Excluded (do nothing)
[ X | ] node_modules
-> ignore# Excluded and remote exists (operation depends on excludeMode option)
[ X | D ] .bin
-> remove remote # if excludeMode is 'remove'
-> ignore # if excludeMode is 'ignore'# Local and remote have the same name but different types (remove remote then upload local)
[ F | D ] test
-> remove remote and upload# Permission error on a remote server (ignored)
[ F | ! ] secret.txt
-> denied
```