comforter-cli
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -7,4 +7,5 @@ #! /usr/bin/env node | ||
var fs = require('fs'); | ||
var zip = require('zip-dir'); | ||
var targz = require('tar.gz'); | ||
var q = require('q'); | ||
var mv = require('mv'); | ||
@@ -16,3 +17,3 @@ var errors = { | ||
lcovFile: 'LCOV file could not be found', | ||
missingRequiredParams: 'Missing one or many of required params (commit, branch, project, host)', | ||
missingRequiredParams: 'Missing one or many of required params (commit, branch, project, host, apiKey)', | ||
zip: 'Coverage folder was not found or could not be zipped' | ||
@@ -36,3 +37,4 @@ }; | ||
project: argv.project, | ||
commit: argv.commit | ||
commit: argv.commit, | ||
apiKey: argv.apiKey | ||
}; | ||
@@ -61,10 +63,16 @@ | ||
fs.accessSync(argv.zip, fs.F_OK); // check for existence of folder | ||
zip(argv.zip, {saveTo: 'coverage.zip'}, function (error) { | ||
if (error) { | ||
return fail(errors.zip, error); | ||
var branchPath = './comforter-tmp/' + argv.branch; | ||
mv(argv.zip, branchPath, {mkdirp: true}, function (err) { | ||
if (err) { | ||
return fail(errors.zip, err); | ||
} | ||
targz().compress(branchPath, 'coverage.zip', function (error) { | ||
if (error) { | ||
return fail(errors.zip, error); | ||
} | ||
var zipSize = fs.statSync('coverage.zip').size; | ||
data.zip = restler.file('coverage.zip', 'coverage.zip', zipSize); | ||
deferred.resolve(); | ||
var zipSize = fs.statSync('coverage.zip').size; | ||
data.zip = restler.file('coverage.zip', 'coverage.zip', zipSize); | ||
deferred.resolve(); | ||
}); | ||
}); | ||
@@ -80,3 +88,3 @@ } catch (err) { | ||
// send multi-part request | ||
restler.post(argv.host + '/api/apps/' + argv.project + '/coverage', { | ||
restler.post(argv.host + '/api/apps/' + argv.project + '/coverage?apiKey=' + data.apiKey, { | ||
multipart: true, | ||
@@ -112,3 +120,3 @@ data: data | ||
} | ||
if (!params.project || !params.branch || !params.commit || !params.host) { | ||
if (!params.project || !params.branch || !params.commit || !params.host || !params.apiKey) { | ||
fail(errors.missingRequiredParams); | ||
@@ -115,0 +123,0 @@ } |
{ | ||
"name": "comforter-cli", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "cli tool for communicating with comforter instance", | ||
"scripts": { | ||
"test": "jshint --reporter=node_modules/jshint-stylish lib/*.js test/ && jscs lib/ test/ && lab -v -m 5000" | ||
"test": "jshint --reporter=node_modules/jshint-stylish lib/*.js test/ && jscs lib/ test/ && lab -v" | ||
}, | ||
@@ -27,5 +27,6 @@ "bin": { | ||
"minimist": "^1.2.0", | ||
"mv": "^2.1.1", | ||
"q": "^1.4.1", | ||
"restler": "^3.4.0", | ||
"zip-dir": "^1.0.0" | ||
"tar.gz": "^1.0.2" | ||
}, | ||
@@ -32,0 +33,0 @@ "devDependencies": { |
@@ -5,3 +5,7 @@ ## Comforter CLI tool | ||
#### Usage | ||
`npm install -g comforter-cli` | ||
`comforter-cli (--path <path-to-lcov-info-file> OR --coverage <coverage%) --branch <branch-name> --project <project-id> --commit <sha> --apiKey <key> [--zip <path-to-html-coverage>]` | ||
* [x] Accept path to generated coverage html and zip and send to Comforter | ||
* [ ] Use `npm cli` to avoid running tests in exec, allowing coverage and better testing (see [jshint](https://github.com/jshint/jshint) repo for examples) |
@@ -24,3 +24,4 @@ 'use strict'; | ||
lab.test('fails when missing lcov file ref or coverage directly', function (done) { | ||
child.exec('node ' + __dirname + '/../lib/index.js --branch branch --project 1 --host a --commit sha > ' + outfile, function (err) { | ||
child.exec('node ' + __dirname + '/../lib/index.js --branch branch --project 1 --host a --commit sha --apiKey key > ' + | ||
outfile, function (err) { | ||
code.expect(err).to.exist(); | ||
@@ -33,3 +34,3 @@ code.expect(err.toString()).to.contain('Missing path to lcov file or generated coverage percentange'); | ||
lab.test('fails if lcov file path doesnt exist', function (done) { | ||
child.exec('node ' + __dirname + '/../lib/index.js --branch branch --project 1 --host a --commit sha --path ' + | ||
child.exec('node ' + __dirname + '/../lib/index.js --branch branch --apiKey key --project 1 --host a --commit sha --path ' + | ||
__dirname + '/../test/lcovv.info > ' + outfile, function (err) { | ||
@@ -36,0 +37,0 @@ code.expect(err).to.exist(); |
@@ -24,31 +24,29 @@ 'use strict'; | ||
lab.test('fails when missing required params', function (done) { | ||
var params = { | ||
host: 'http://localhost/', | ||
branch: 'my-branch', | ||
commit: 'sha', | ||
project: 1, | ||
apiKey: 'key' | ||
}; | ||
var params = { | ||
host: 'http://localhost/', | ||
branch: 'my-branch', | ||
commit: 'sha', | ||
project: 1 | ||
}; | ||
var keys = Object.keys(params); | ||
var keys = Object.keys(params); | ||
var permutations = Combinatorics.permutation(keys).toArray(); | ||
var permutations = Combinatorics.permutation(keys).toArray(); | ||
permutations.forEach(function (permutation, index) { | ||
permutations.forEach(function (permutation, index) { | ||
var string = ''; | ||
permutation.forEach(function (param, index) { | ||
if (index === permutation.length - 1) { | ||
return; // only use 3 | ||
} | ||
string += '--' + param + ' ' + params[param] + ' '; | ||
}); | ||
var string = ''; | ||
permutation.forEach(function (param, index) { | ||
if (index === permutation.length - 1) { | ||
return; // only use 3 | ||
} | ||
string += '--' + param + ' ' + params[param] + ' '; | ||
}); | ||
lab.test('fails when missing required params combo ' + index, function (done) { | ||
child.exec('node ' + __dirname + '/../lib/index.js --coverage 98.8 ' + string + ' > ' + outfile, function (err) { | ||
code.expect(err).to.exist(); | ||
code.expect(err.toString()).to.contain('Missing one or many of required params (commit, branch, project, host)'); | ||
if (index === permutations.length - 1) { | ||
done(); // dont pass err cuz we are expecting err | ||
} | ||
code.expect(err.toString()).to.contain('Missing one or many of required params (commit, branch, project, host, apiKey)'); | ||
done(); | ||
}); | ||
@@ -55,0 +53,0 @@ }); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10736
178
11
2
6
+ Addedmv@^2.1.1
+ Addedtar.gz@^1.0.2
+ Addedbalanced-match@1.0.2(transitive)
+ Addedblock-stream@0.0.9(transitive)
+ Addedbluebird@2.11.0(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedfstream@1.0.12(transitive)
+ Addedglob@6.0.4(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedmout@0.11.1(transitive)
+ Addedmv@2.1.1(transitive)
+ Addedncp@2.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedrimraf@2.4.5(transitive)
+ Addedtar@2.2.2(transitive)
+ Addedtar.gz@1.0.7(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedzip-dir@^1.0.0
- Removedasync@1.5.2(transitive)
- Removedjszip@2.7.0(transitive)
- Removedpako@1.0.11(transitive)
- Removedzip-dir@1.0.2(transitive)