Comparing version 0.3.5 to 0.4.0
@@ -6,4 +6,6 @@ var utils = require('../utils'), | ||
argParse = require('../args').parse, | ||
ProgressBar = require('progress'), | ||
async = require('async'), | ||
util = require('util'); | ||
util = require('util'), | ||
_ = require('underscore')._; | ||
@@ -24,3 +26,5 @@ | ||
'Options:\n' + | ||
' --push Use push instead of pull replication'; | ||
' --push Use push instead of pull replication\n' + | ||
' --create Create target database if it doesn\'t exist\n' + | ||
' --progress Display progress bar'; | ||
@@ -30,3 +34,5 @@ | ||
var a = argParse(args, { | ||
'push': {match: ['--push']} | ||
'push': {match: ['--push']}, | ||
'create_target': {match: ['--create']}, | ||
'progress': {match: ['--progress']} | ||
}); | ||
@@ -101,8 +107,43 @@ | ||
source: source, | ||
target: target | ||
target: target, | ||
create_target: options.create_target || false | ||
}; | ||
var db = couchdb(replicator); | ||
console.log('Replicating...'); | ||
db.client('POST', '/_replicate', data, callback); | ||
if (options.progress) { | ||
var bar = new ProgressBar('Replicating [:bar] :percent', { | ||
total: 100, | ||
width: 30 | ||
}); | ||
// report progress | ||
var t = setInterval(function () { | ||
db.client('GET', '/_active_tasks', {}, function (err, data, res) { | ||
if (!err) { | ||
var task = _.detect(data, function (t) { | ||
return ( | ||
t.source === source.replace(/\/$/, '') + '/' && | ||
t.target === target.replace(/\/$/, '') + '/' | ||
); | ||
}); | ||
if (task) { | ||
bar.tick(task.progress - bar.curr); | ||
if (bar.complete) { | ||
clearInterval(t); | ||
} | ||
} | ||
} | ||
}); | ||
}, 3000); | ||
} | ||
else { | ||
console.log('Replicating...'); | ||
} | ||
// start replication | ||
db.client('POST', '/_replicate', data, function (err, data, res) { | ||
if (options.progress) { | ||
bar.tick(100); | ||
clearInterval(t); | ||
} | ||
return callback.apply(this, arguments); | ||
}); | ||
}); | ||
}; |
{ | ||
"name": "kanso", | ||
"description": "The surprisingly simple way to write CouchApps", | ||
"maintainers": [ | ||
{"name": "Caolan McMahon", "web": "https://github.com/caolan"}, | ||
{"name": "Ryan Ramage", "web": "https://github.com/ryanramage"}, | ||
{"name": "Milan Andric", "web": "https://github.com/mandric"} | ||
], | ||
"dependencies": { | ||
"async": "0.1.15", | ||
"mime": "1.2.4", | ||
"semver": "1.0.9", | ||
"csv": "0.0.9", | ||
"parser": "0.1.2", | ||
"underscore": "1.1.7", | ||
"prompt": "0.1.11" | ||
"name": "kanso", | ||
"description": "The surprisingly simple way to write CouchApps", | ||
"maintainers": [ | ||
{ | ||
"name": "Caolan McMahon", | ||
"web": "https://github.com/caolan" | ||
}, | ||
"devDependencies": { | ||
"nodelint": "0.5.2", | ||
"nodeunit": "0.6.4" | ||
{ | ||
"name": "Ryan Ramage", | ||
"web": "https://github.com/ryanramage" | ||
}, | ||
"version": "0.3.5", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kanso/kanso.git" | ||
}, | ||
"engines": {"node": "~0.6.6 || ~0.8.0 || ~0.10.0"}, | ||
"bugs": {"url": "https://github.com/kanso/kanso/issues"}, | ||
"bin": { | ||
"kanso": "./bin/kanso", | ||
"kanso_completions": "./scripts/autocomp.js" | ||
}, | ||
"scripts": { | ||
"test": "node_modules/nodeunit/bin/nodeunit test" | ||
{ | ||
"name": "Milan Andric", | ||
"web": "https://github.com/mandric" | ||
} | ||
], | ||
"dependencies": { | ||
"async": "0.1.15", | ||
"csv": "0.0.9", | ||
"mime": "1.2.4", | ||
"parser": "0.1.2", | ||
"progress": "^1.1.8", | ||
"prompt": "0.1.11", | ||
"semver": "1.0.9", | ||
"underscore": "1.1.7" | ||
}, | ||
"devDependencies": { | ||
"nodelint": "0.5.2", | ||
"nodeunit": "0.6.4" | ||
}, | ||
"version": "0.4.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kanso/kanso.git" | ||
}, | ||
"engines": { | ||
"node": "~0.6.6 || ~0.8.0 || ~0.10.0" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/kanso/kanso/issues" | ||
}, | ||
"bin": { | ||
"kanso": "./bin/kanso", | ||
"kanso_completions": "./scripts/autocomp.js" | ||
}, | ||
"scripts": { | ||
"test": "node_modules/nodeunit/bin/nodeunit test" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
922389
21489
8
+ Addedprogress@^1.1.8
+ Addedprogress@1.1.8(transitive)