cnys
v1.0.0
Published
Synchronization between remote server on change !
Downloads
8
Maintainers
Readme
cnys
cnys main feature allow developers to synchronize files between remote server on change !, what it does:
- ssh/sftp ! :globe_with_meridians:
- Server hoping (netcat) :lock:
- Copy/delete file/folder ! :eyeglasses:
- Queue / concurrency :train:
- Ready to use :fire:
If something doesn’t work, please file an issue :bug:.
Quick Start
Install
$ npm install or yarn install
Then use it like this :
const cnys = require('cnys');
const config = {
url: '192.168.30.2',
source: 'sync',
destination: '/home/user/sync',
username: 'your_username',
privateKey: true
};
cnys(config);
Which is the same as :
$ cnys remote 'sync' '192.168.30.2' '/home/user/sync' --username 'your_username' --privateKey true
Commands
Start cnys on a local folder to a local destination :
$ cyns local [source=<sourcePath>] [destination=<destinationpath>]
| Options | Description | aliases | type | default | | ------- | ----------------------------------------------------- | ------- | ----------------------------------------------------- | ----------------- | | verbose | Output action logs. | --v | boolean | false | | debug | Output debug logs. | --d | boolean | false | | remove | Enable delete file from destination. | --rm | boolean | true | | ignored | A glob, regex, function, or array of any combination. | --i | filePattern | null | | events | An array of event used as liteners. | --e | array | Events |
$ cyns remote [source=<sourcePath>] [url=<urlString>] [destination=<destinationpath>]
| Options | Description | aliases | type | default | | ----------- | ----------------------------------------------------- | ------- | ----------------------------------------------------- | ----------------- | | verbose | Output action logs. | --v | boolean | false | | debug | Output debug logs. | --d | boolean | false | | concurrency | Number of task that can be done in parallel. | --c | number | 5 | | remove | Enable delete file from destination. | --rm | boolean | true | | ignored | A glob, regex, function, or array of any combination. | --i | filePattern | null | | ncUrl | A netcat url for ssh. (this is your destination). | --nc | string | null | | username | A username to connect for ssh. | --u | string | null | | password | A password to connect for ssh. | --pwd | string | null | | privateKey | Will look for your pka file under ~/.ssh. | --ppk | boolean | false | | events | An array of event used as liteners. | --e | array | Events |
Events
You may want to look at chokidar, to see what kind of events you could start watching, by default cnys use all events.
Example of use :
$ cnys local 'sync' 'sync2' --v true --ignored '.git*' '*.yml'
The example above will start watching file on a folder name sync and copying file into folder sync2
$ cnys remote 'sync' '192.168.30.2' '/home/user/sync' --ncUrl '192.168.30.3' --username 'your_username' --privateKey true
The example above will start watching file on a folder name sync and copying file to '192.168.30.3' at '/home/user/test'
Test
Use npm test
to start testing your file. By default it read test file named *.test.js
under /test
.
You can easily add your own config by editing package.json
It also has a built-in coverage with npm run coverage
Credits
chokidar, a powerfull watcher
Jest, a testing framework
Thanks to Alexandre for the idea.