flex-plugins-utils-logger
Advanced tools
Comparing version 0.16.3-alpha.0 to 0.17.0
@@ -13,2 +13,3 @@ declare const boxen: { | ||
export { default as inquirer, confirm, prompt, choose, Question } from './lib/inquirer'; | ||
export { default as columnify } from './lib/columnify'; | ||
export { boxen }; |
@@ -51,2 +51,4 @@ "use strict"; | ||
Object.defineProperty(exports, "choose", { enumerable: true, get: function () { return inquirer_1.choose; } }); | ||
var columnify_1 = require("./lib/columnify"); | ||
Object.defineProperty(exports, "columnify", { enumerable: true, get: function () { return columnify_1.default; } }); | ||
//# sourceMappingURL=index.js.map |
import chalk from 'chalk'; | ||
interface ColumnsOptions { | ||
indent?: boolean; | ||
} | ||
export declare type LogLevels = 'debug' | 'info' | 'warning' | 'error' | 'trace' | 'success'; | ||
@@ -34,2 +37,3 @@ interface LoggerOptions { | ||
notice: (...args: any[]) => void; | ||
columns: (lines: string[][], options?: ColumnsOptions | undefined) => void; | ||
newline: (lines?: number) => void; | ||
@@ -60,2 +64,3 @@ installInfo: (command: string, ...args: string[]) => void; | ||
}) => string; | ||
columns: (lines: string[][], options?: ColumnsOptions | undefined) => void; | ||
colors: chalk.Chalk & chalk.ChalkFunction & { | ||
@@ -62,0 +67,0 @@ supportsColor: false | chalk.ColorSupport; |
@@ -32,2 +32,4 @@ "use strict"; | ||
var flex_plugins_utils_env_1 = __importDefault(require("flex-plugins-utils-env")); | ||
var string_width_1 = __importDefault(require("string-width")); | ||
var columnify_1 = __importDefault(require("./columnify")); | ||
var DefaultWrapOptions = { hard: true }; | ||
@@ -104,2 +106,31 @@ exports.coloredStrings = { | ||
}; | ||
this.columns = function (lines, options) { | ||
var minWidths = Array(lines[0].length).fill(0); | ||
lines.forEach(function (line) { | ||
line.forEach(function (entry, index) { | ||
minWidths[index] = Math.max(minWidths[index], string_width_1.default(entry)); | ||
}); | ||
}); | ||
var data = lines.map(function (line) { | ||
return line.reduce(function (accum, entry, index) { | ||
accum["entry" + index] = entry; | ||
return accum; | ||
}, {}); | ||
}); | ||
var config = minWidths.reduce(function (accum, minWidth, index) { | ||
if (index < minWidths.length - 1) { | ||
minWidth += 5; | ||
} | ||
accum["entry" + index] = { minWidth: minWidth }; | ||
return accum; | ||
}, {}); | ||
var cols = columnify_1.default(data, { showHeaders: false, config: config }); | ||
if (options === null || options === void 0 ? void 0 : options.indent) { | ||
cols = cols | ||
.split('\n') | ||
.map(function (entry) { return "\t" + entry; }) | ||
.join('\n'); | ||
} | ||
_this._log({ level: 'info', args: [cols] }); | ||
}; | ||
this.newline = function (lines) { | ||
@@ -226,3 +257,3 @@ if (lines === void 0) { lines = 1; } | ||
exports._logger = new Logger(); | ||
var debug = exports._logger.debug, info = exports._logger.info, warning = exports._logger.warning, error = exports._logger.error, trace = exports._logger.trace, success = exports._logger.success, newline = exports._logger.newline, notice = exports._logger.notice, installInfo = exports._logger.installInfo, clearTerminal = exports._logger.clearTerminal, markdown = exports._logger.markdown; | ||
var debug = exports._logger.debug, info = exports._logger.info, warning = exports._logger.warning, error = exports._logger.error, trace = exports._logger.trace, success = exports._logger.success, newline = exports._logger.newline, notice = exports._logger.notice, installInfo = exports._logger.installInfo, clearTerminal = exports._logger.clearTerminal, markdown = exports._logger.markdown, columns = exports._logger.columns; | ||
exports.default = { | ||
@@ -241,2 +272,3 @@ debug: debug, | ||
wrap: wrap, | ||
columns: columns, | ||
colors: chalk_1.default, | ||
@@ -243,0 +275,0 @@ coloredStrings: exports.coloredStrings, |
{ | ||
"name": "flex-plugins-utils-logger", | ||
"version": "0.16.3-alpha.0", | ||
"version": "0.17.0", | ||
"description": "Flex Plugins Logger", | ||
@@ -46,10 +46,19 @@ "keywords": [ | ||
"chalk": "^4.1.0", | ||
"flex-plugins-utils-env": "^0.16.3-alpha.0", | ||
"columnify": "^1.5.4", | ||
"flex-plugins-utils-env": "^0.17.0", | ||
"inquirer": "7.3.3", | ||
"log-symbols": "^3.0.0", | ||
"ora": "^4.0.5", | ||
"string-width": "^4.2.0", | ||
"table": "^5.4.6", | ||
"wrap-ansi": "^4.0.0" | ||
}, | ||
"gitHead": "63d6fa56390ce850c5a4d4da451efc44b0410347" | ||
"devDependencies": { | ||
"@types/columnify": "^1.5.0", | ||
"@types/inquirer": "^7.3.1", | ||
"@types/string-width": "^4.0.1", | ||
"@types/table": "^4.0.7", | ||
"@types/wrap-ansi": "^3.0.0" | ||
}, | ||
"gitHead": "07f7b72a310704d5abc7e41fde1a8eabeaec9213" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55466
27
814
11
5
+ Addedcolumnify@^1.5.4
+ Addedstring-width@^4.2.0
+ Added@types/lodash@4.17.13(transitive)
+ Added@types/lodash.get@4.4.9(transitive)
+ Addedcolumnify@1.6.0(transitive)
+ Addedflex-plugins-utils-env@0.17.2(transitive)
- Removedflex-plugins-utils-env@0.16.3-alpha.0(transitive)