Socket
Socket
Sign inDemoInstall

cac

Package Overview
Dependencies
Maintainers
3
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cac - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

221

dist/cac.js

@@ -5,4 +5,6 @@ 'use strict';

var stripAnsi = _interopDefault(require('strip-ansi'));
var table = _interopDefault(require('text-table'));
var stringWidth = _interopDefault(require('string-width'));
var chalk = _interopDefault(require('chalk'));
var redent = _interopDefault(require('redent'));
var path = _interopDefault(require('path'));

@@ -13,168 +15,2 @@ var EventEmitter = _interopDefault(require('events'));

var textTable = function (rows_, opts) {
if (!opts) opts = {};
var hsep = opts.hsep === undefined ? ' ' : opts.hsep;
var align = opts.align || [];
var stringLength = opts.stringLength
|| function (s) { return String(s).length; }
;
var dotsizes = reduce(rows_, function (acc, row) {
forEach(row, function (c, ix) {
var n = dotindex(c);
if (!acc[ix] || n > acc[ix]) acc[ix] = n;
});
return acc;
}, []);
var rows = map(rows_, function (row) {
return map(row, function (c_, ix) {
var c = String(c_);
if (align[ix] === '.') {
var index = dotindex(c);
var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2)
- (stringLength(c) - index)
;
return c + Array(size).join(' ');
}
else return c;
});
});
var sizes = reduce(rows, function (acc, row) {
forEach(row, function (c, ix) {
var n = stringLength(c);
if (!acc[ix] || n > acc[ix]) acc[ix] = n;
});
return acc;
}, []);
return map(rows, function (row) {
return map(row, function (c, ix) {
var n = (sizes[ix] - stringLength(c)) || 0;
var s = Array(Math.max(n + 1, 1)).join(' ');
if (align[ix] === 'r' || align[ix] === '.') {
return s + c;
}
if (align[ix] === 'c') {
return Array(Math.ceil(n / 2 + 1)).join(' ')
+ c + Array(Math.floor(n / 2 + 1)).join(' ')
;
}
return c + s;
}).join(hsep).replace(/\s+$/, '');
}).join('\n');
};
function dotindex (c) {
var m = /\.[^.]*$/.exec(c);
return m ? m.index + 1 : c.length;
}
function reduce (xs, f, init) {
if (xs.reduce) return xs.reduce(f, init);
var i = 0;
var acc = arguments.length >= 3 ? init : xs[i++];
for (; i < xs.length; i++) {
f(acc, xs[i], i);
}
return acc;
}
function forEach (xs, f) {
if (xs.forEach) return xs.forEach(f);
for (var i = 0; i < xs.length; i++) {
f.call(xs, xs[i], i);
}
}
function map (xs, f) {
if (xs.map) return xs.map(f);
var res = [];
for (var i = 0; i < xs.length; i++) {
res.push(f.call(xs, xs[i], i));
}
return res;
}
/* eslint-disable yoda */
var isFullwidthCodePoint = x => {
if (Number.isNaN(x)) {
return false;
}
// code points are derived from:
// http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
if (
x >= 0x1100 && (
x <= 0x115f || // Hangul Jamo
x === 0x2329 || // LEFT-POINTING ANGLE BRACKET
x === 0x232a || // RIGHT-POINTING ANGLE BRACKET
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
(0x2e80 <= x && x <= 0x3247 && x !== 0x303f) ||
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
(0x3250 <= x && x <= 0x4dbf) ||
// CJK Unified Ideographs .. Yi Radicals
(0x4e00 <= x && x <= 0xa4c6) ||
// Hangul Jamo Extended-A
(0xa960 <= x && x <= 0xa97c) ||
// Hangul Syllables
(0xac00 <= x && x <= 0xd7a3) ||
// CJK Compatibility Ideographs
(0xf900 <= x && x <= 0xfaff) ||
// Vertical Forms
(0xfe10 <= x && x <= 0xfe19) ||
// CJK Compatibility Forms .. Small Form Variants
(0xfe30 <= x && x <= 0xfe6b) ||
// Halfwidth and Fullwidth Forms
(0xff01 <= x && x <= 0xff60) ||
(0xffe0 <= x && x <= 0xffe6) ||
// Kana Supplement
(0x1b000 <= x && x <= 0x1b001) ||
// Enclosed Ideographic Supplement
(0x1f200 <= x && x <= 0x1f251) ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
(0x20000 <= x && x <= 0x3fffd)
)
) {
return true;
}
return false;
};
var stringWidth = str => {
if (typeof str !== 'string' || str.length === 0) {
return 0;
}
str = stripAnsi(str);
let width = 0;
for (let i = 0; i < str.length; i++) {
const code = str.codePointAt(i);
// Ignore control characters
if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) {
continue;
}
// Ignore combining characters
if (code >= 0x300 && code <= 0x36F) {
continue;
}
// Surrogates
if (code > 0xFFFF) {
i++;
}
width += isFullwidthCodePoint(code) ? 2 : 1;
}
return width;
};
class CacError extends Error {

@@ -192,4 +28,4 @@ constructor(message) {

}
function textTable$1(data) {
return textTable(data, {
function textTable(data) {
return table(data, {
stringLength: stringWidth

@@ -256,3 +92,3 @@ });

toString() {
return textTable$1(this.options.map(option => {
return textTable(this.options.map(option => {
const extra = [];

@@ -296,45 +132,2 @@ if (typeof option.default !== 'undefined') {

var stripIndent = str => {
const match = str.match(/^[ \t]*(?=\S)/gm);
if (!match) {
return str;
}
// TODO: use spread operator when targeting Node.js 6
const indent = Math.min.apply(Math, match.map(x => x.length)); // eslint-disable-line
const re = new RegExp(`^[ \\t]{${indent}}`, 'gm');
return indent > 0 ? str.replace(re, '') : str;
};
var indentString = (str, count, opts) => {
// Support older versions: use the third parameter as options.indent
// TODO: Remove the workaround in the next major version
const options = typeof opts === 'object' ? Object.assign({indent: ' '}, opts) : {indent: opts || ' '};
count = count === undefined ? 1 : count;
if (typeof str !== 'string') {
throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``);
}
if (typeof count !== 'number') {
throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof count}\``);
}
if (typeof options.indent !== 'string') {
throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\``);
}
if (count === 0) {
return str;
}
const regex = options.includeEmptyLines ? /^/mg : /^(?!\s*$)/mg;
return str.replace(regex, options.indent.repeat(count));
}
;
var redent = (str, count, indent) => indentString(stripIndent(str), count || 0, indent);
class Help {

@@ -536,3 +329,3 @@ constructor(root, command, opts) {

commandsToString() {
return textTable$1(this.commands.map(({ command }) => {
return textTable(this.commands.map(({ command }) => {
return [

@@ -539,0 +332,0 @@ command.names.map(v => chalk.magenta(v)).join(', '),

10

package.json
{
"name": "cac",
"version": "5.0.0",
"version": "5.0.1",
"description": "Command-line queen.",

@@ -45,3 +45,6 @@ "repository": {

"minimost": "^1.1.0",
"read-pkg-up": "^2.0.0"
"read-pkg-up": "^2.0.0",
"redent": "^2.0.0",
"string-width": "^2.1.1",
"text-table": "^0.2.0"
},

@@ -60,7 +63,4 @@ "devDependencies": {

"markdown-toc": "^1.1.0",
"redent": "^2.0.0",
"rollup-plugin-typescript2": "^0.13.0",
"string-width": "^2.1.1",
"strip-ansi": "^4.0.0",
"text-table": "^0.2.0",
"ts-jest": "^22.4.3",

@@ -67,0 +67,0 @@ "typedoc": "^0.11.1",

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