Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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 1.1.0 to 2.0.0

22

CHANGELOG.md

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

# [2.0.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework-output@1.1.0...@ionic/cli-framework-output@2.0.0) (2020-08-27)
### Bug Fixes
* **output:** newlines in stream output strategy ([4f9a7c9](https://github.com/ionic-team/ionic-cli/commit/4f9a7c988a0a63b21bf2a80eef065155c78545d0))
* **output:** stream is optional ([df3e949](https://github.com/ionic-team/ionic-cli/commit/df3e949ebb092c92b84717a83bd662e283463e37))
### Code Refactoring
* **output:** replace log-update ([a90005c](https://github.com/ionic-team/ionic-cli/commit/a90005cd048a68252456da8409dedacaab54b505))
### BREAKING CHANGES
* **output:** `LogUpdateOutputStrategy` removed in favor of `TTYOutputStrategy`
# [1.1.0](https://github.com/ionic-team/ionic-cli/compare/@ionic/cli-framework-output@1.0.1...@ionic/cli-framework-output@1.1.0) (2020-08-26)

@@ -8,0 +30,0 @@

30

dist/output.d.ts
/// <reference types="node" />
import { LogUpdate } from 'log-update';
import { Colors } from './colors';

@@ -9,7 +8,4 @@ import { TaskChain } from './tasks';

}
export interface RedrawLine {
redrawLine(msg?: string): void;
}
export interface StreamOutputStrategyOptions {
readonly stream: NodeJS.WritableStream;
readonly stream?: NodeJS.WritableStream;
readonly colors?: Colors;

@@ -23,13 +19,23 @@ }

}
export interface LogUpdateOutputStrategyOptions {
readonly stream?: NodeJS.WritableStream;
export interface TTYOutputStrategyOptions {
readonly stream?: NodeJS.WriteStream;
readonly colors?: Colors;
}
export declare class LogUpdateOutputStrategy implements OutputStrategy, RedrawLine {
readonly stream: NodeJS.WritableStream;
export declare class TTYOutputStrategy implements OutputStrategy {
readonly stream: NodeJS.WriteStream;
protected readonly colors: Colors;
protected readonly logUpdate: LogUpdate;
constructor({ stream, colors }?: LogUpdateOutputStrategyOptions);
redrawLine(msg?: string): void;
protected readonly redrawer: TTYOutputRedrawer;
constructor({ stream, colors }?: TTYOutputStrategyOptions);
createTaskChain(): TaskChain;
}
export interface TTYOutputRedrawerOptions {
readonly stream?: NodeJS.WriteStream;
}
export declare class TTYOutputRedrawer {
readonly stream: NodeJS.WriteStream;
constructor({ stream }: TTYOutputRedrawerOptions);
get width(): number;
redraw(msg: string): void;
clear(): void;
end(): void;
}

40

dist/output.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const logUpdate = require("log-update");
const utils_terminal_1 = require("@ionic/utils-terminal");
const colors_1 = require("./colors");

@@ -18,6 +18,6 @@ const tasks_1 = require("./tasks");

if (result.success) {
this.stream.write(`${success(tasks_1.ICON_SUCCESS)} ${task.msg} ${weak(`in ${utils_1.formatHrTime(result.elapsedTime)}`)}`);
this.stream.write(`${success(tasks_1.ICON_SUCCESS)} ${task.msg} ${weak(`in ${utils_1.formatHrTime(result.elapsedTime)}`)}\n`);
}
else {
this.stream.write(`${failure(tasks_1.ICON_FAILURE)} ${task.msg} ${failure(weak('- failed!'))}`);
this.stream.write(`${failure(tasks_1.ICON_FAILURE)} ${task.msg} ${failure(weak('- failed!'))}\n`);
}

@@ -30,11 +30,8 @@ });

exports.StreamOutputStrategy = StreamOutputStrategy;
class LogUpdateOutputStrategy {
class TTYOutputStrategy {
constructor({ stream = process.stdout, colors = colors_1.NO_COLORS } = {}) {
this.stream = stream;
this.colors = colors;
this.logUpdate = logUpdate.create(stream);
this.redrawer = new TTYOutputRedrawer({ stream });
}
redrawLine(msg = '') {
this.logUpdate(msg);
}
createTaskChain() {

@@ -56,10 +53,10 @@ const { failure, strong, success, weak } = this.colors;

const frame = spinner.frame();
this.redrawLine(`${strong(frame)} ${task.msg}${progress ? ' (' + strong(String(progress) + '%') + ')' : ''} `);
this.redrawer.redraw(`${strong(frame)} ${task.msg}${progress ? ' (' + strong(String(progress) + '%') + ')' : ''} `);
});
task.on('clear', () => {
this.logUpdate.clear();
this.redrawer.clear();
});
});
chain.on('end', () => {
this.logUpdate.done();
this.redrawer.end();
});

@@ -69,2 +66,21 @@ return chain;

}
exports.LogUpdateOutputStrategy = LogUpdateOutputStrategy;
exports.TTYOutputStrategy = TTYOutputStrategy;
class TTYOutputRedrawer {
constructor({ stream = process.stdout }) {
this.stream = stream;
}
get width() {
return this.stream.columns || 80;
}
redraw(msg) {
utils_terminal_1.Cursor.hide();
this.stream.write(utils_terminal_1.EscapeCode.eraseLines(1) + utils_1.enforceSingleLF(msg));
}
clear() {
this.stream.write(utils_terminal_1.EscapeCode.eraseLines(1));
}
end() {
utils_terminal_1.Cursor.show();
}
}
exports.TTYOutputRedrawer = TTYOutputRedrawer;
export declare function identity<T>(v: T): T;
export declare function enforceLF(str: string): string;
export declare function enforceSingleLF(str: string): string;
export declare function dropWhile<T>(array: readonly T[], predicate?: (item: T) => boolean): T[];
export declare function formatHrTime(hrtime: [number, number]): string;

@@ -11,2 +11,6 @@ "use strict";

exports.enforceLF = enforceLF;
function enforceSingleLF(str) {
return str.replace(/[\r\n]+$/, '') + '\n';
}
exports.enforceSingleLF = enforceSingleLF;
function dropWhile(array, predicate = v => !!v) {

@@ -13,0 +17,0 @@ let done = false;

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

@@ -27,4 +27,5 @@ "homepage": "https://ionicframework.com/",

"dependencies": {
"@ionic/utils-terminal": "2.2.0",
"debug": "^4.0.0",
"log-update": "^4.0.0",
"signal-exit": "^3.0.3",
"slice-ansi": "^4.0.0",

@@ -42,2 +43,3 @@ "string-width": "^4.1.0",

"@types/node": "~10.17.13",
"@types/signal-exit": "^3.0.0",
"@types/slice-ansi": "^4.0.0",

@@ -52,3 +54,3 @@ "@types/wrap-ansi": "^3.0.0",

},
"gitHead": "8ed8f6bdee185d324e4183ff75d643a57c47b9b6"
"gitHead": "f6712a9508b37de0a8e202072bb14d75ee81c8bf"
}
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