New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

comforter-cli

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comforter-cli - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

30

lib/index.js

@@ -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 @@ });

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc