Socket
Socket
Sign inDemoInstall

ftpsync

Package Overview
Dependencies
22
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.3 to 0.1.4

LICENSE-MIT

110

lib/ftpsync.js
// Design Notes
// ----------------------------------------------------------------------------
// TODO:
// - add try/catch logic to sync.setup()
// - add verify() function

@@ -9,3 +8,2 @@ // - add touch() function

// - fix time comparison on isModified
// - improve error handling

@@ -18,3 +16,7 @@ // Setup

var async = require('async');
var config = require(process.cwd() + '/config.json');
var minimatch = require("minimatch");
var config = {};
if (fs.existsSync(process.cwd() + '/config.json')) {
config = require(process.cwd() + '/config.json');
}

@@ -50,12 +52,17 @@ var settings;

console.log('-------------------------------------------------------------');
if (!settings.host) { callback("Host name not set"); }
if (!settings.user) { callback("User name not set"); }
if (!settings.pass && settings.pass !== '') { callback("Password not set"); }
console.log('Settings:');
console.dir(settings);
ftp = new jsftp({
host: settings.host,
port: settings.port,
user: settings.user,
pass: settings.pass
});
console.log();
try {
ftp = new jsftp({
host: settings.host,
port: settings.port,
user: settings.user,
pass: settings.pass
});
}
catch(err) { callback(err, 'setup failed'); }
callback(null, 'setup complete');

@@ -75,2 +82,4 @@ },

], function(err, results) {
if (err) { callback(err, 'collection failed'); }
sync.local = results[0];

@@ -221,2 +230,3 @@ sync.remote = results[1];

function(err, results) {
if (err) { callback(err, 'commit failed'); }
// log the results

@@ -272,3 +282,3 @@ console.log(results);

fs.readdir(dir, function(err, list) {
if (err) return callback(err);
if (err) return callback('ReadDir Failed ' + err);
var i = 0;

@@ -279,10 +289,11 @@ (function next() {

if (!file) return callback(null, { 'dirs':dirs,'files':files });
// get file/dir name/stats
var path = dir + '/' + file;
// skip ignore files
if (settings.ignore.indexOf(file) != -1) {
if (helpers.isIgnored(helpers.trimPathRoot(settings.local, path))) {
next();
return;
}
// get file/dir name/stats
var path = dir + '/' + file;
fs.stat(path, function(err, stat) {
if (err) return callback('FS STAT Failed: ' + err);
// handle directories

@@ -322,3 +333,3 @@ if (stat.isDirectory()) {

ftp.ls(dir, function(err, list) {
if (err) return callback(err);
if (err) return callback('FTP LS Failed: ' + err);
var i = 0;

@@ -329,9 +340,9 @@ (function next() {

if (!file) return callback(null, { 'dirs':dirs, 'files':files });
// get file/dir name/stats
var path = dir + '/' + file.name;
// skip ignore files
if (settings.ignore.indexOf(file.name) != -1) {
if (helpers.isIgnored(helpers.trimPathRoot(settings.remote, path))) {
next();
return;
}
// get file/dir name/stats
var path = dir + '/' + file.name;
// handle directories

@@ -367,12 +378,6 @@ if (file.type == 1) {

mkdir: function(dir, callback) {
var dir = settings.remote + dir;
ftp.raw.mkd(dir, function(err, data) {
if (err) {
console.error(err);
callback(err);
}
else {
console.log(dir + " - created successfuly");
callback();
}
if (err) { callback('MKDIR Failed: ' + err); }
console.log(dir + " - created successfuly");
callback();
});

@@ -382,12 +387,6 @@ },

rmdir: function(dir, callback) {
var dir = settings.remote + dir;
ftp.raw.rmd(dir, function(err, data) {
if (err) {
console.error(err);
callback(err);
}
else {
console.log(dir + " - deleted successfuly");
callback();
}
if (err) { callback('RMDIR Failed: ' + err); }
console.log(dir + " - deleted successfuly");
callback();
});

@@ -407,16 +406,8 @@ },

fs.readFile(local, function(err, buffer) {
if(err) {
console.error(err);
callback(err);
}
if(err) { callback('ReadFile Failed: ' + err); }
else {
ftp.put(buffer, remote, function(err) {
if (err) {
console.error(err);
callback(err);
}
else {
console.log(file + " - uploaded successfuly");
callback();
}
if (err) { callback('FTP PUT Failed: ' + err); }
console.log(file + " - uploaded successfuly");
callback();
});

@@ -430,10 +421,5 @@ }

ftp.raw.dele(file, function(err, data) {
if (err) {
console.error(err);
callback(err);
}
else {
console.log(file + " - deleted successfuly");
callback();
}
if (err) { callback('Remove Failed: ' + err); }
console.log(file + " - deleted successfuly");
callback();
});

@@ -499,2 +485,14 @@ }

//console.log('rTime: ' + rtime);
},
isIgnored: function(path) {
// skip if no ignores are defined
if (settings.ignore.length == 0) { return false; }
// should the path be ignored?
for(var i = 0, len = settings.ignore.length; i < len; i++) {
if (minimatch(path, settings.ignore[i], {matchBase: true})) {
return true;
}
}
return false;
}

@@ -501,0 +499,0 @@ }

{
"name": "ftpsync",
"version": "0.1.3",
"description": "Intelligent file syncronization over FTP",
"version": "0.1.4",
"homepage": "http://github.com/evanplaice/node-ftpsync",

@@ -9,23 +9,23 @@ "author": {

"email": "evanplaice@gmail.com",
"url": "https://plus.google.com/u/0/112882755236529658404/about"
"url": "http://plus.google.com/+evanplaice"
},
"repository": {
"type": "git",
"url": "http://github.com/evanplaice/node-ftpsync.git"
},
"bugs": {
"url": "https://github.com/evanplaice/node-ftpsync/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/evanplaice/grunt-ftp-deploy/blob/master/LICENSE-MIT"
"url": "https://github.com/evanplaice/node-ftpsync/blob/master/LICENSE-MIT"
}
],
"main": "lib/ftpsync.js",
"bin":"bin/ftpsync",
"preferGlobal":true,
"repository": {
"type": "git",
"url": "git://github.com/evanplaice/node-ftpsync.git"
"bin": "bin/ftpsync",
"preferGlobal": true,
"engines": {
"node": ">=0.8.0"
},
"bugs": {
"url": "https://github.com/evanplaice/node-ftpsync/issues"
},
"engines": {
"node" : ">=0.8.0"
},
"dependencies": {

@@ -35,8 +35,5 @@ "async": ">=0.2.9",

"touch": ">=0.0.2",
"commander": ">=2.1.0"
"commander": ">=2.1.0",
"minimatch": "~0.2.12"
},
"repository" : {
"type": "git",
"url": "http://github.com/evanplaice/node-ftpsync.git"
},
"keywords": [

@@ -48,3 +45,3 @@ "ftp",

"synchronise"
]
}
]
}

@@ -95,5 +95,6 @@ An FTP synchronization app for NodeJS based on [jsftp](https://npmjs.org/package/jsftp). With an emphasis on speed and simplicity ftpsync aims to fulfull your one-click file deployment needs.

- `connections` - the max number of concurrent ftp connections (default `1`).
- `lTimeOffset` - the local hosts timezone offset (autodetected).
- `rTimeOffset` - the remoge ftp server's timezone offset (autodetected).
- `ignore` - the list of file patterns to ignore.
*Note: Ignore patterns can be defined as a filename, file path, or glob match.*
#### ftpsync.local{}

@@ -213,5 +214,3 @@

- Implement timestamp file comparisons on updates
- Improve error handling
- Improve logging
- Implement glob matching on ignore files

@@ -218,0 +217,0 @@ ### Long Term

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc