Socket
Socket
Sign inDemoInstall

@ionic/cli-framework-output

Package Overview
Dependencies
Maintainers
23
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ionic/cli-framework-output - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

# [2.1.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework-output@2.0.2...@ionic/cli-framework-output@2.1.0) (2020-08-29)
### Features
* **logger:** add createDefaultLogger helper ([6961c33](https://github.com/ionic-team/ionic-cli/commit/6961c3377e88498d86eb0a39e5aef3f776fb3fd3))
* **logger:** add tags option for tagged formatter ([6957104](https://github.com/ionic-team/ionic-cli/commit/695710462178f109d10504e6d9d8b0870eb0541c))
## [2.0.2](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework-output@2.0.1...@ionic/cli-framework-output@2.0.2) (2020-08-28)

@@ -8,0 +20,0 @@

@@ -0,1 +1,3 @@

import { Logger, CreateTaggedFormatterOptions } from './logger';
import { OutputStrategy } from './output';
export * from './colors';

@@ -6,1 +8,17 @@ export * from './format';

export * from './tasks';
export interface CreateDefaultLoggerOptions {
/**
* Specify a custom output strategy to use for the logger.
*
* By default, the logger uses a output strategy with process.stdout and no colors.
*/
output?: OutputStrategy;
/**
* Specify custom logger formatter options.
*/
formatterOptions?: CreateTaggedFormatterOptions;
}
/**
* Creates a logger instance with good defaults.
*/
export declare function createDefaultLogger({ output, formatterOptions }?: CreateDefaultLoggerOptions): Logger;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDefaultLogger = void 0;
const tslib_1 = require("tslib");
const colors_1 = require("./colors");
const logger_1 = require("./logger");
const output_1 = require("./output");
tslib_1.__exportStar(require("./colors"), exports);

@@ -9,1 +13,12 @@ tslib_1.__exportStar(require("./format"), exports);

tslib_1.__exportStar(require("./tasks"), exports);
/**
* Creates a logger instance with good defaults.
*/
function createDefaultLogger({ output = new output_1.StreamOutputStrategy({ colors: colors_1.NO_COLORS, stream: process.stdout }), formatterOptions } = {}) {
const { weak } = output.colors;
const prefix = process.argv.includes('--log-timestamps') ? () => `${weak('[' + new Date().toISOString() + ']')}` : '';
const formatter = logger_1.createTaggedFormatter({ colors: output.colors, prefix, titleize: true, wrap: true, ...formatterOptions });
const handlers = new Set([new logger_1.StreamHandler({ stream: output.stream, formatter })]);
return new logger_1.Logger({ handlers });
}
exports.createDefaultLogger = createDefaultLogger;

3

dist/logger.d.ts

@@ -102,4 +102,5 @@ /// <reference types="node" />

colors?: Colors;
tags?: ReadonlyMap<LoggerLevelWeight, string>;
}
export declare function createTaggedFormatter({ colors, prefix, titleize, wrap }?: CreateTaggedFormatterOptions): LoggerFormatter;
export declare function createTaggedFormatter({ colors, prefix, tags, titleize, wrap }?: CreateTaggedFormatterOptions): LoggerFormatter;
export declare function createPrefixedFormatter(prefix: string | (() => string)): LoggerFormatter;

@@ -160,3 +160,19 @@ "use strict";

exports.Logger = Logger;
function createTaggedFormatter({ colors = colors_1.NO_COLORS, prefix = '', titleize, wrap } = {}) {
function createTaggedFormatter({ colors = colors_1.NO_COLORS, prefix = '', tags, titleize, wrap } = {}) {
const { strong, weak } = colors;
const getLevelTag = (level) => {
if (!level) {
return '';
}
if (tags) {
const tag = tags.get(level);
return tag ? tag : '';
}
const levelName = getLoggerLevelName(level);
if (!levelName) {
return '';
}
const levelColor = getLoggerLevelColor(colors, level);
return `${weak('[')}\x1b[40m${strong(levelColor ? levelColor(levelName) : levelName)}\x1b[49m${weak(']')}`;
};
return ({ msg, level, format }) => {

@@ -166,8 +182,5 @@ if (format === false) {

}
const { strong, weak } = colors;
const [firstLine, ...lines] = msg.split('\n');
const levelName = getLoggerLevelName(level);
const levelColor = getLoggerLevelColor(colors, level);
const tag = ((typeof prefix === 'function' ? prefix() : prefix) +
(levelName ? `${weak('[')}\x1b[40m${strong(levelColor ? levelColor(levelName) : levelName)}\x1b[49m${weak(']')}` : ''));
const tag = (typeof prefix === 'function' ? prefix() : prefix) + getLevelTag(level);
const title = titleize && lines.length > 0 ? `${strong(levelColor ? levelColor(firstLine) : firstLine)}\n` : firstLine;

@@ -174,0 +187,0 @@ const indentation = tag ? format_1.stringWidth(tag) + 1 : 0;

@@ -6,2 +6,3 @@ /// <reference types="node" />

readonly stream: NodeJS.WritableStream;
readonly colors: Colors;
createTaskChain(): TaskChain;

@@ -15,3 +16,3 @@ }

readonly stream: NodeJS.WritableStream;
protected readonly colors: Colors;
readonly colors: Colors;
constructor({ stream, colors }: StreamOutputStrategyOptions);

@@ -26,3 +27,3 @@ createTaskChain(): TaskChain;

readonly stream: NodeJS.WriteStream;
protected readonly colors: Colors;
readonly colors: Colors;
protected readonly redrawer: TTYOutputRedrawer;

@@ -29,0 +30,0 @@ constructor({ stream, colors }?: TTYOutputStrategyOptions);

{
"name": "@ionic/cli-framework-output",
"version": "2.0.2",
"version": "2.1.0",
"description": "The log/tasks/spinners portion of Ionic CLI Framework",

@@ -51,3 +51,3 @@ "homepage": "https://ionicframework.com/",

},
"gitHead": "f85e6db0eba47c8d97181b52d69c687c100f93fb"
"gitHead": "9d14290abb3f55f2f161d425a85187a925992b24"
}
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