Comparing version 0.1.9 to 0.2.0
112
lib/cli.js
@@ -40,3 +40,3 @@ 'use strict'; | ||
var settingFile = path.join(process.env.HOME, '.28.json'); | ||
var settingFile = path.join(process.env.HOME || process.env.USERPROFILE || '', '.28.json'); | ||
var localSettingFile = process.cwd() + '/.28.json'; | ||
@@ -98,2 +98,3 @@ if(fs.existsSync(localSettingFile)) { | ||
cli.matchedCommand = false; | ||
@@ -105,2 +106,3 @@ //Login Command | ||
.action(function(email) { | ||
cli.matchedCommand = true; | ||
@@ -133,2 +135,3 @@ if(!email) { | ||
.action(function(){ | ||
cli.matchedCommand = true; | ||
refreshTokens() | ||
@@ -149,2 +152,43 @@ .then(function(body){ | ||
var overwriteCoercion = function(value, cmd){ | ||
value = value.toLowerCase(); | ||
if(value === 'yes' || value === 'all' || value === 'always') { | ||
return Client.OVERWRITE_ALWAYS; | ||
}else if(value === 'no' || value === 'none' || value === 'never') { | ||
return Client.OVERWRITE_NEVER; | ||
} else if(value === 'ask') { | ||
return Client.OVERWRITE_ASK; | ||
} else if(value === 'if-newer') { | ||
return Client.OVERWRITE_IF_NEWER; | ||
} else { | ||
console.error('Invalid option value for overwrite.'); | ||
cmd.help(); | ||
} | ||
}; | ||
var getRemoteFiles = function(lists){ | ||
return objectConcat(objectConcat(lists[0][0], lists[0][1]), lists[0][2]); | ||
}; | ||
var getLocalFiles = function(lists) { | ||
var local = []; | ||
lists[1].forEach(function(path){ | ||
local[path] = { | ||
//TODO: remove String conversion | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
lists[2].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
lists[3].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
return local; | ||
}; | ||
//Download Command | ||
@@ -156,14 +200,3 @@ var dlCmd = cli.command('download <project-name>'); | ||
function(value){ | ||
if(value === 'yes') { | ||
return Client.OVERWRITE_ALWAYS; | ||
}else if(value === 'no') { | ||
return Client.OVERWRITE_NEVER; | ||
} else if(value === 'ask') { | ||
return Client.OVERWRITE_ASK; | ||
} else if(value === 'if-newer') { | ||
return Client.OVERWRITE_IF_NEWER; | ||
} else { | ||
//TODO: error | ||
return undefined; | ||
} | ||
return overwriteCoercion(value, dlCmd); | ||
} | ||
@@ -175,2 +208,3 @@ ) | ||
.action(function(projectName){ | ||
cli.matchedCommand = true; | ||
refreshTokens() | ||
@@ -191,19 +225,4 @@ .then(function(){ | ||
.then(function(lists){ | ||
var remote = objectConcat(objectConcat(lists[0][0], lists[0][1]), lists[0][2]); | ||
var local = []; | ||
lists[1].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
lists[2].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
lists[3].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
var remote = getRemoteFiles(lists); | ||
var local = getLocalFiles(lists); | ||
Client.download( | ||
@@ -240,14 +259,3 @@ project, remote, local, | ||
function(value){ | ||
if(value === 'yes') { | ||
return Client.OVERWRITE_ALWAYS; | ||
}else if(value === 'no') { | ||
return Client.OVERWRITE_NEVER; | ||
} else if(value === 'ask') { | ||
return Client.OVERWRITE_ASK; | ||
} else if(value === 'if-newer') { | ||
return Client.OVERWRITE_IF_NEWER; | ||
} else { | ||
//TODO: error | ||
return undefined; | ||
} | ||
return overwriteCoercion(value, upCmd); | ||
} | ||
@@ -259,2 +267,3 @@ ) | ||
.action(function(projectName){ | ||
cli.matchedCommand = true; | ||
refreshTokens() | ||
@@ -275,19 +284,4 @@ .then(function(){ | ||
.then(function(lists){ | ||
var remote = objectConcat(objectConcat(lists[0][0], lists[0][1]), lists[0][2]); | ||
var local = []; | ||
lists[1].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
lists[2].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
lists[3].forEach(function(path){ | ||
local[path] = { | ||
lastModified: new Date(fs.statSync(path).mtime).toISOString() | ||
}; | ||
}); | ||
var remote = getRemoteFiles(lists); | ||
var local = getLocalFiles(lists); | ||
Client.upload( | ||
@@ -294,0 +288,0 @@ project, remote, local, |
@@ -7,4 +7,4 @@ 'use strict'; | ||
.parse(process.argv); | ||
if (!cli.args.length) { | ||
if (!cli.args.length || !cli.matchedCommand) { | ||
cli.help(); | ||
} |
@@ -9,3 +9,3 @@ { | ||
"description": "Command line utility to download and upload 28.io queries.", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"keywords": [ | ||
@@ -55,3 +55,3 @@ "jsoniq", | ||
"scripts": { | ||
"test": "node ./node_modules/vows/bin/vows --spec" | ||
"test": "grunt" | ||
}, | ||
@@ -58,0 +58,0 @@ "directories": { |
@@ -108,3 +108,6 @@ 28.io CLI Tool: Getting Started | ||
## ChangeLog | ||
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). |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
var vows = require('vows'); | ||
@@ -16,2 +18,2 @@ //var assert = require('assert'); | ||
} | ||
}).export(module); | ||
}).export(module); |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
32190
13
113
706
5