Comparing version 0.2.0 to 0.2.1
@@ -189,2 +189,40 @@ 'use strict'; | ||
//Truncate Command | ||
var truncateCmd = cli.command('truncate <project-name>'); | ||
truncateCmd.option('-s, --simulate', 'Simulate for extra safety.') | ||
.description('Truncate 28.io project') | ||
.action(function(projectName){ | ||
cli.matchedCommand = true; | ||
refreshTokens() | ||
.then(function(){ | ||
var projectToken = settings.project_tokens['project_'+projectName]; | ||
if(projectToken) { | ||
var project = API.Project(apiSettings.getProjectAPI(projectName), projectToken); | ||
project.listFiles() | ||
.then(function(list){ | ||
var remote = getRemoteFiles([list]); | ||
Client.truncate( | ||
project, remote, truncateCmd.simulate ? true : false, settings.ignore | ||
) | ||
.then(function(){console.log('Done.');}) | ||
.catch(function(error){ | ||
console.error(error); | ||
}); | ||
}) | ||
.catch(function(error){ | ||
console.error('Server replied with:'); | ||
console.error(error); | ||
}); | ||
} else { | ||
console.error('Project ' + projectToken + ' wasn\'t found.'); | ||
console.error('Run \'28 projects\' for more information.'); | ||
} | ||
}) | ||
.catch(function(error){ | ||
console.error('Server replied with:'); | ||
console.error(error); | ||
}); | ||
}); | ||
//Download Command | ||
@@ -239,3 +277,3 @@ var dlCmd = cli.command('download <project-name>'); | ||
console.error('Project ' + projectToken + ' wasn\'t found.'); | ||
console.error('Run \'28 list projects\' for more information.'); | ||
console.error('Run \'28 projects\' for more information.'); | ||
} | ||
@@ -296,3 +334,3 @@ }).catch(function(error){ | ||
console.error('Project ' + projectToken + ' wasn\'t found.'); | ||
console.error('Run \'28 list projects\' for more information.'); | ||
console.error('Run \'28 projects\' for more information.'); | ||
} | ||
@@ -299,0 +337,0 @@ }).catch(function(error){ |
@@ -94,6 +94,6 @@ 'use strict'; | ||
var sync = function(project, from, to, overwrite, deleteOrphaned, simulate, fromOrigin, toOrigin){ | ||
var promises = []; | ||
var asyncPromises = []; | ||
var sequentialPromises = []; | ||
Object.keys(from).forEach(function(file){ | ||
var fromFile = { | ||
@@ -112,4 +112,4 @@ path: file, | ||
}; | ||
promises.push(function() { | ||
var promise = function() { | ||
var deferred = Q.defer(); | ||
@@ -142,3 +142,8 @@ performAction(fromFile, toFile, overwrite).then(function(result){ | ||
return deferred.promise; | ||
}); | ||
}; | ||
if(toFile.exists === true && overwrite === that.OVERWRITE_ASK) { | ||
sequentialPromises.push(promise); | ||
} else { | ||
asyncPromises.push(promise()); | ||
} | ||
}); | ||
@@ -149,3 +154,3 @@ | ||
if(!from[file]) { | ||
promises.push(function(){ | ||
var promise = function(){ | ||
var deferred = Q.defer(); | ||
@@ -169,8 +174,10 @@ console.log('Delete ' + '<' + toOrigin + '>/' + file); | ||
return deferred.promise; | ||
}); | ||
}; | ||
asyncPromises.push(promise()); | ||
} | ||
}); | ||
} | ||
return promises.reduce(Q.when, Q()); | ||
sequentialPromises.push(function(){ return Q.all(asyncPromises); }); | ||
return sequentialPromises.reduce(Q.when, Q()); | ||
}; | ||
@@ -220,4 +227,12 @@ | ||
}; | ||
this.truncate = function(project, remote, simulate, ignore){ | ||
remote = filterList(remote, ignore); | ||
return sync( | ||
project, {}, remote, this.OVERWRITE_ALWAYS, | ||
true, simulate, 'local', 'remote' | ||
); | ||
}; | ||
}; | ||
module.exports = new Client(); | ||
module.exports = new Client(); |
@@ -9,3 +9,3 @@ { | ||
"description": "Command line utility to download and upload 28.io queries.", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"keywords": [ | ||
@@ -60,3 +60,9 @@ "jsoniq", | ||
"bin": "./bin" | ||
} | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "Apache 2", | ||
"url": "https://github.com/28msec/28/blob/master/LICENSE" | ||
} | ||
] | ||
} |
@@ -1,2 +0,2 @@ | ||
28.io CLI Tool: Getting Started | ||
28.io CLI [![Build Status](https://travis-ci.org/28msec/28.png?branch=master)](https://travis-ci.org/28msec/28) | ||
============ | ||
@@ -62,3 +62,14 @@ | ||
### Truncate Project | ||
``` | ||
$28 truncate <project name> [-s, --simulate] | ||
``` | ||
Options: | ||
* `-h, --help` output usage information. | ||
* `-s, --simulate` Simulate for extra safety. | ||
## Synchronizing | ||
@@ -109,6 +120,15 @@ | ||
## ChangeLog | ||
Version 0.2.1 | ||
* New truncate command. | ||
* Execute request asynchronously if an automatic overwrite option is set. | ||
Version 0.2.0 | ||
* Bug fix for Windows clients. | ||
* Improvements in the CLI error handling. | ||
Version 0.1.9 | ||
* Bug fixes: [#1](https://github.com/28msec/28/issues/1), [#2](https://github.com/28msec/28/issues/2), [#3](https://github.com/28msec/28/issues/3). |
Sorry, the diff of this file is not supported yet
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
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
44865
0
758
133