Socket
Socket
Sign inDemoInstall

heroku-cli-util

Package Overview
Dependencies
Maintainers
19
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heroku-cli-util - npm Package Compare versions

Comparing version 5.10.12 to 6.0.0

.nyc_output/15533.json

17

CHANGELOG.md

@@ -0,1 +1,7 @@

5.10.12 / 2016-05-18
====================
* 5.10.12
* added ability to update action message
5.10.11 / 2016-05-16

@@ -179,12 +185,1 @@ ====================

* updated jshintrc
* 5.8.3
* update dependencies
5.8.3 / 2016-03-08
==================
* Merge pull request [#51](https://github.com/heroku/heroku-cli-util/issues/51) from heroku/update-deps
update dependencies
* Merge pull request [#50](https://github.com/heroku/heroku-cli-util/issues/50) from heroku/mocha-junit
added mocha junit reporter for circle ci
* added mocha junit reporter for circle ci
'use strict';
let _ = require('lodash');
let chalk = require('chalk');
const chalk = require('chalk');
const pickBy = require('lodash.pickby');
const mapValues = require('lodash.mapvalues');

@@ -12,7 +13,7 @@ let colors = {

let definedColors = _.pickBy(colors, function(value) {
let definedColors = pickBy(colors, function(value) {
return typeof(chalk[value]) === 'function';
});
let boundColors = _.mapValues(definedColors, v => s => chalk[v](s));
let boundColors = mapValues(definedColors, v => s => chalk[v](s));

@@ -19,0 +20,0 @@ boundColors.release = s => chalk.blue.bold(s);

'use strict';
let stripAnsi = require('..').color.stripColor;
let _ = require('lodash');
let cli = require('..');
const stripAnsi = require('..').color.stripColor;
const cli = require('..');
let defaults = {
colSep: ' ',
after: _.noop,
headerAnsi: _.identity,
printLine: cli.log,
printRow: function(cells) {
this.printLine(cells.join(this.colSep).trimRight());
},
printHeader: function(cells) {
this.printRow(cells.map(_.ary(this.headerAnsi, 1)));
this.printRow(cells.map(function(hdr) { return hdr.replace(/./g, '─'); }));
}
};
let colDefaults = {
format: value => value ? value.toString() : '',
width: 0,
label: function() { return this.key.toString(); },
get: function(row) {
let value;
let path = _.result(this, 'key');
if(!path) {
value = row;
} else {
value = _.get(row, path);
}
return this.format(value, row);
},
};
function calcWidth(cell) {
let lines = stripAnsi(cell).split(/[\r\n]+/);
let lineLengths = lines.map(_.property('length'));
return Math.max.apply(Math, lineLengths);
}
function pad(string, length) {
let visibleLength = stripAnsi(string).length;
let diff = length - visibleLength;
return string + _.repeat(' ', Math.max(0, diff));
}
/**

@@ -75,55 +28,115 @@ * Generates a Unicode table and feeds it into configured printer.

*/
function table(data, options) {
_.defaults(options, defaults);
function table (data, options) {
const ary = require('lodash.ary');
const defaults = require('lodash.defaults');
const get = require('lodash.get');
const identity = require('lodash.identity');
const keys = require('lodash.keys');
const noop = require('lodash.noop');
const partial = require('lodash.partial');
const property = require('lodash.property');
const repeat = require('lodash.repeat');
const result = require('lodash.result');
let columns = options.columns || _.keys(data[0] || {});
let _defaults = {
colSep: ' ',
after: noop,
headerAnsi: identity,
printLine: cli.log,
printRow: function(cells) {
this.printLine(cells.join(this.colSep).trimRight());
},
printHeader: function(cells) {
this.printRow(cells.map(ary(this.headerAnsi, 1)));
this.printRow(cells.map(function(hdr) { return hdr.replace(/./g, '─'); }));
}
};
if(typeof columns[0] === 'string') {
columns = columns.map(function(k) { return {key: k}; });
}
let colDefaults = {
format: value => value ? value.toString() : '',
width: 0,
label: function() { return this.key.toString(); },
let defaultsApplied = false;
for(let row of data) {
row.height = 1;
for(let col of columns) {
if(!defaultsApplied) { _.defaults(col, colDefaults); }
get: function(row) {
let value;
let path = result(this, 'key');
let cell = col.get(row);
if(!path) {
value = row;
} else {
value = get(row, path);
}
col.width = Math.max(
_.result(col, 'label').length,
col.width,
calcWidth(cell)
);
return this.format(value, row);
},
};
row.height = Math.max(
row.height,
cell.split(/[\r\n]+/).length
);
}
defaultsApplied = true;
function calcWidth(cell) {
let lines = stripAnsi(cell).split(/[\r\n]+/);
let lineLengths = lines.map(property('length'));
return Math.max.apply(Math, lineLengths);
}
if (options.printHeader) {
options.printHeader(columns.map(function(col) {
let label = _.result(col, 'label');
return pad(label, col.width || label.length );
}));
}
function pad(string, length) {
let visibleLength = stripAnsi(string).length;
let diff = length - visibleLength;
function getNthLineOfCell(n, row, col) {
// TODO memoize this
let lines = col.get(row).split(/[\r\n]+/);
return pad(lines[n] || '', col.width);
return string + repeat(' ', Math.max(0, diff));
}
for(let row of data) {
for(let i = 0; i < row.height; i++) {
let cells = columns.map(_.partial(getNthLineOfCell, i, row));
options.printRow(cells);
function render () {
let columns = options.columns || keys(data[0] || {});
if(typeof columns[0] === 'string') {
columns = columns.map(function(k) { return {key: k}; });
}
options.after(row, options);
let defaultsApplied = false;
for(let row of data) {
row.height = 1;
for(let col of columns) {
if(!defaultsApplied) { defaults(col, colDefaults); }
let cell = col.get(row);
col.width = Math.max(
result(col, 'label').length,
col.width,
calcWidth(cell)
);
row.height = Math.max(
row.height,
cell.split(/[\r\n]+/).length
);
}
defaultsApplied = true;
}
if (options.printHeader) {
options.printHeader(columns.map(function(col) {
let label = result(col, 'label');
return pad(label, col.width || label.length );
}));
}
function getNthLineOfCell(n, row, col) {
// TODO memoize this
let lines = col.get(row).split(/[\r\n]+/);
return pad(lines[n] || '', col.width);
}
for(let row of data) {
for(let i = 0; i < row.height; i++) {
let cells = columns.map(partial(getNthLineOfCell, i, row));
options.printRow(cells);
}
options.after(row, options);
}
}
defaults(options, _defaults);
render();
}
module.exports = table;
{
"name": "heroku-cli-util",
"description": "Set of helpful CLI utilities",
"version": "5.10.12",
"version": "6.0.0",
"author": "Jeff Dickey (@dickeyxxx)",

@@ -10,12 +10,23 @@ "bugs": {

"dependencies": {
"cardinal": "0.7.1",
"chalk": "1.1.3",
"cli-cursor": "1.0.2",
"co": "4.6.0",
"got": "6.3.0",
"heroku-client": "2.4.3",
"lodash": "4.11.1",
"opn": "3.0.3",
"supports-color": "3.1.2",
"tunnel-agent": "0.4.2"
"cardinal": "^0.7.1",
"chalk": "^1.1.3",
"cli-cursor": "^1.0.2",
"co": "^4.6.0",
"got": "^6.3.0",
"heroku-client": "3.0.0-alpha2",
"lodash.ary": "4.0.1",
"lodash.defaults": "4.0.1",
"lodash.get": "4.3.0",
"lodash.identity": "3.0.0",
"lodash.keys": "4.0.7",
"lodash.mapvalues": "4.4.0",
"lodash.noop": "3.0.1",
"lodash.partial": "4.1.4",
"lodash.pickby": "4.4.0",
"lodash.property": "4.3.0",
"lodash.repeat": "4.0.3",
"lodash.result": "4.4.0",
"opn": "^3.0.3",
"supports-color": "^3.1.2",
"tunnel-agent": "^0.4.3"
},

@@ -32,5 +43,5 @@ "devDependencies": {

"nock": "8.0.0",
"nyc": "6.4.0",
"proxyquire": "1.7.4",
"sinon": "1.17.3",
"nyc": "6.4.4",
"proxyquire": "1.7.9",
"sinon": "1.17.4",
"unexpected": "10.13.2"

@@ -37,0 +48,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