@rushstack/terminal
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -106,2 +106,4 @@ /** | ||
static hidden(text: string): string; | ||
static rainbow(text: string): string; | ||
private static _applyColorSequence; | ||
private static _wrapTextInAnsiEscapeCodes; | ||
@@ -126,2 +128,6 @@ } | ||
debugEnabled: boolean; | ||
/** | ||
* {@inheritDoc ITerminalProvider.supportsColor} | ||
*/ | ||
readonly supportsColor: boolean; | ||
constructor(options?: Partial<IConsoleTerminalProviderOptions>); | ||
@@ -136,6 +142,2 @@ /** | ||
get eolCharacter(): string; | ||
/** | ||
* {@inheritDoc ITerminalProvider.supportsColor} | ||
*/ | ||
get supportsColor(): boolean; | ||
} | ||
@@ -142,0 +144,0 @@ |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.39.1" | ||
"packageVersion": "7.40.6" | ||
} | ||
] | ||
} |
@@ -77,4 +77,6 @@ export declare enum SgrParameterAttribute { | ||
static hidden(text: string): string; | ||
static rainbow(text: string): string; | ||
private static _applyColorSequence; | ||
private static _wrapTextInAnsiEscapeCodes; | ||
} | ||
//# sourceMappingURL=Colorize.d.ts.map |
@@ -45,2 +45,10 @@ "use strict"; | ||
})(SgrParameterAttribute || (exports.SgrParameterAttribute = SgrParameterAttribute = {})); | ||
const RAINBOW_SEQUENCE = [ | ||
SgrParameterAttribute.RedForeground, | ||
SgrParameterAttribute.YellowForeground, | ||
SgrParameterAttribute.GreenForeground, | ||
SgrParameterAttribute.CyanForeground, | ||
SgrParameterAttribute.BlueForeground, | ||
SgrParameterAttribute.MagentaForeground | ||
]; | ||
/** | ||
@@ -137,2 +145,13 @@ * The static functions on this class are used to produce colored text | ||
} | ||
static rainbow(text) { | ||
return Colorize._applyColorSequence(text, RAINBOW_SEQUENCE); | ||
} | ||
static _applyColorSequence(text, sequence) { | ||
let result = ''; | ||
const sequenceLength = sequence.length; | ||
for (let i = 0; i < text.length; i++) { | ||
result += AnsiEscape_1.AnsiEscape.getEscapeSequenceForAnsiCode(sequence[i % sequenceLength]) + text[i]; | ||
} | ||
return result + AnsiEscape_1.AnsiEscape.getEscapeSequenceForAnsiCode(SgrParameterAttribute.DefaultForeground); | ||
} | ||
static _wrapTextInAnsiEscapeCodes(startCode, endCode, text) { | ||
@@ -139,0 +158,0 @@ return (AnsiEscape_1.AnsiEscape.getEscapeSequenceForAnsiCode(startCode) + |
@@ -35,2 +35,6 @@ import { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider'; | ||
debugEnabled: boolean; | ||
/** | ||
* {@inheritDoc ITerminalProvider.supportsColor} | ||
*/ | ||
readonly supportsColor: boolean; | ||
constructor(options?: Partial<IConsoleTerminalProviderOptions>); | ||
@@ -45,7 +49,3 @@ /** | ||
get eolCharacter(): string; | ||
/** | ||
* {@inheritDoc ITerminalProvider.supportsColor} | ||
*/ | ||
get supportsColor(): boolean; | ||
} | ||
//# sourceMappingURL=ConsoleTerminalProvider.d.ts.map |
"use strict"; | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConsoleTerminalProvider = void 0; | ||
const os_1 = require("os"); | ||
const safe_1 = require("colors/safe"); | ||
const supports_color_1 = __importDefault(require("supports-color")); | ||
const ITerminalProvider_1 = require("./ITerminalProvider"); | ||
@@ -18,9 +21,5 @@ /** | ||
/** | ||
* If true, verbose-level messages should be written to the console. | ||
* {@inheritDoc ITerminalProvider.supportsColor} | ||
*/ | ||
this.verboseEnabled = false; | ||
/** | ||
* If true, debug-level messages should be written to the console. | ||
*/ | ||
this.debugEnabled = false; | ||
this.supportsColor = ConsoleTerminalProvider.supportsColor; | ||
this.verboseEnabled = !!options.verboseEnabled; | ||
@@ -64,11 +63,5 @@ this.debugEnabled = !!options.debugEnabled; | ||
} | ||
/** | ||
* {@inheritDoc ITerminalProvider.supportsColor} | ||
*/ | ||
get supportsColor() { | ||
return safe_1.enabled; | ||
} | ||
} | ||
exports.ConsoleTerminalProvider = ConsoleTerminalProvider; | ||
ConsoleTerminalProvider.supportsColor = safe_1.enabled; | ||
ConsoleTerminalProvider.supportsColor = !!supports_color_1.default.stdout && !!supports_color_1.default.stderr; | ||
//# sourceMappingURL=ConsoleTerminalProvider.js.map |
{ | ||
"name": "@rushstack/terminal", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "User interface primitives for console applications", | ||
@@ -14,10 +14,11 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"colors": "~1.2.1", | ||
"supports-color": "~8.1.1", | ||
"@rushstack/node-core-library": "4.0.2" | ||
}, | ||
"devDependencies": { | ||
"@rushstack/heft": "0.64.0", | ||
"@rushstack/heft-node-rig": "2.4.0", | ||
"@rushstack/heft": "0.65.4", | ||
"@rushstack/heft-node-rig": "2.4.16", | ||
"@types/heft-jest": "1.0.1", | ||
"@types/node": "18.17.15", | ||
"@types/supports-color": "8.1.3", | ||
"local-eslint-config": "1.0.0" | ||
@@ -24,0 +25,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
360623
4636
6
+ Addedsupports-color@~8.1.1
+ Addedhas-flag@4.0.0(transitive)
+ Addedsupports-color@8.1.1(transitive)
- Removedcolors@~1.2.1
- Removedcolors@1.2.5(transitive)