@rushstack/terminal 0.13.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +29 -0
- package/CHANGELOG.md +13 -1
- package/dist/terminal.d.ts +5 -1
- package/lib/PrintUtilities.d.ts.map +1 -1
- package/lib/PrintUtilities.js +2 -1
- package/lib/PrintUtilities.js.map +1 -1
- package/lib/StringBufferTerminalProvider.d.ts +5 -1
- package/lib/StringBufferTerminalProvider.d.ts.map +1 -1
- package/lib/StringBufferTerminalProvider.js +7 -1
- package/lib/StringBufferTerminalProvider.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/terminal",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.14.0",
|
|
6
|
+
"tag": "@rushstack/terminal_v0.14.0",
|
|
7
|
+
"date": "Wed, 21 Aug 2024 05:43:04 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Create a new instance function called `getVerboseOutput` on `StringBufferTerminalProvider` and mark `getVerbose` as deprecated."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/node-core-library\" to `5.7.0`"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"version": "0.13.4",
|
|
23
|
+
"tag": "@rushstack/terminal_v0.13.4",
|
|
24
|
+
"date": "Mon, 12 Aug 2024 22:16:04 GMT",
|
|
25
|
+
"comments": {
|
|
26
|
+
"dependency": [
|
|
27
|
+
{
|
|
28
|
+
"comment": "Updating dependency \"@rushstack/node-core-library\" to `5.6.0`"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
4
33
|
{
|
|
5
34
|
"version": "0.13.3",
|
|
6
35
|
"tag": "@rushstack/terminal_v0.13.3",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Change Log - @rushstack/terminal
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 21 Aug 2024 05:43:04 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.14.0
|
|
6
|
+
Wed, 21 Aug 2024 05:43:04 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Create a new instance function called `getVerboseOutput` on `StringBufferTerminalProvider` and mark `getVerbose` as deprecated.
|
|
11
|
+
|
|
12
|
+
## 0.13.4
|
|
13
|
+
Mon, 12 Aug 2024 22:16:04 GMT
|
|
14
|
+
|
|
15
|
+
_Version update only_
|
|
4
16
|
|
|
5
17
|
## 0.13.3
|
|
6
18
|
Sat, 27 Jul 2024 00:10:27 GMT
|
package/dist/terminal.d.ts
CHANGED
|
@@ -898,9 +898,13 @@ export declare class StringBufferTerminalProvider implements ITerminalProvider {
|
|
|
898
898
|
*/
|
|
899
899
|
getOutput(options?: IStringBufferOutputOptions): string;
|
|
900
900
|
/**
|
|
901
|
-
*
|
|
901
|
+
* @deprecated - use {@link StringBufferTerminalProvider.getVerboseOutput}
|
|
902
902
|
*/
|
|
903
903
|
getVerbose(options?: IStringBufferOutputOptions): string;
|
|
904
|
+
/**
|
|
905
|
+
* Get everything that has been written at verbose-level severity.
|
|
906
|
+
*/
|
|
907
|
+
getVerboseOutput(options?: IStringBufferOutputOptions): string;
|
|
904
908
|
/**
|
|
905
909
|
* Get everything that has been written at debug-level severity.
|
|
906
910
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrintUtilities.d.ts","sourceRoot":"","sources":["../src/PrintUtilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":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.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.PrintUtilities = exports.DEFAULT_CONSOLE_WIDTH = void 0;
|
|
6
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
6
7
|
/**
|
|
7
8
|
* A sensible fallback column width for consoles.
|
|
8
9
|
*
|
|
@@ -47,7 +48,7 @@ class PrintUtilities {
|
|
|
47
48
|
}
|
|
48
49
|
// Apply word wrapping and the provided line prefix, while also respecting existing newlines
|
|
49
50
|
// and prefix spaces that may exist in the text string already.
|
|
50
|
-
const lines =
|
|
51
|
+
const lines = node_core_library_1.Text.splitByNewLines(text);
|
|
51
52
|
const wrappedLines = [];
|
|
52
53
|
for (const line of lines) {
|
|
53
54
|
if (line.length + linePrefixLength <= maxLineLength) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrintUtilities.js","sourceRoot":"","sources":["../src/PrintUtilities.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D;;;;GAIG;AACU,QAAA,qBAAqB,GAAW,EAAE,CAAC;AAEhD;;;;GAIG;AACH,MAAa,cAAc;IACzB;;OAEG;IACI,MAAM,CAAC,eAAe;;QAC3B,OAAO,MAAA,OAAO,CAAC,MAAM,0CAAE,OAAO,CAAC;IACjC,CAAC;IA2BM,MAAM,CAAC,SAAS,CACrB,IAAY,EACZ,aAAsB,EACtB,kBAAoC;QAEpC,MAAM,YAAY,GAAa,cAAc,CAAC,gBAAgB,CAC5D,IAAI,EACJ,aAAa,EACb,kBAAwC,CAAC,kCAAkC;SAC5E,CAAC;QACF,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IA+BM,MAAM,CAAC,gBAAgB,CAC5B,IAAY,EACZ,aAAsB,EACtB,kBAAoC;;QAEpC,IAAI,UAAkB,CAAC;QACvB,Q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AAgB;YAChB,gBAAgB;YAChB,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YACrD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;gBACvC,MAAM,OAAO,GAAW,QAAQ,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;gBAC1D,MAAM,WAAW,GAAW,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;gBACpD,MAAM,YAAY,GAAW,OAAO,GAAG,WAAW,CAAC;gBACnD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAC/F,CAAC;YACD,QAAQ,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AArND,wCAqNC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ITerminal } from './ITerminal';\n\n/**\n * A sensible fallback column width for consoles.\n *\n * @public\n */\nexport const DEFAULT_CONSOLE_WIDTH: number = 80;\n\n/**\n * A collection of utilities for printing messages to the console.\n *\n * @public\n */\nexport class PrintUtilities {\n /**\n * Returns the width of the console, measured in columns\n */\n public static getConsoleWidth(): number | undefined {\n return process.stdout?.columns;\n }\n\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWords(text: string, maxLineLength?: number, indent?: number): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWords(text: string, maxLineLength?: number, linePrefix?: string): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWords(text: string, maxLineLength?: number, indentOrLinePrefix?: number | string): string;\n public static wrapWords(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string {\n const wrappedLines: string[] = PrintUtilities.wrapWordsToLines(\n text,\n maxLineLength,\n indentOrLinePrefix as string | undefined // TS is confused by the overloads\n );\n return wrappedLines.join('\\n');\n }\n\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, indent?: number): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, linePrefix?: string): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[];\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[] {\n let linePrefix: string;\n switch (typeof indentOrLinePrefix) {\n case 'number':\n linePrefix = ' '.repeat(indentOrLinePrefix);\n break;\n case 'string':\n linePrefix = indentOrLinePrefix;\n break;\n default:\n linePrefix = '';\n break;\n }\n\n const linePrefixLength: number = linePrefix.length;\n\n if (!maxLineLength) {\n maxLineLength = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n }\n\n // Apply word wrapping and the provided line prefix, while also respecting existing newlines\n // and prefix spaces that may exist in the text string already.\n const lines: string[] = text.split(/\\r?\\n/);\n\n const wrappedLines: string[] = [];\n for (const line of lines) {\n if (line.length + linePrefixLength <= maxLineLength) {\n wrappedLines.push(linePrefix + line);\n } else {\n const lineAdditionalPrefix: string = line.match(/^\\s*/)?.[0] || '';\n const whitespaceRegexp: RegExp = /\\s+/g;\n let currentWhitespaceMatch: RegExpExecArray | null = null;\n let previousWhitespaceMatch: RegExpExecArray | undefined;\n let currentLineStartIndex: number = lineAdditionalPrefix.length;\n let previousBreakRanOver: boolean = false;\n while ((currentWhitespaceMatch = whitespaceRegexp.exec(line)) !== null) {\n if (currentWhitespaceMatch.index + linePrefixLength - currentLineStartIndex > maxLineLength) {\n let whitespaceToSplitAt: RegExpExecArray | undefined;\n if (\n !previousWhitespaceMatch ||\n // Handle the case where there are two words longer than the maxLineLength in a row\n previousBreakRanOver\n ) {\n whitespaceToSplitAt = currentWhitespaceMatch;\n } else {\n whitespaceToSplitAt = previousWhitespaceMatch;\n }\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n previousBreakRanOver = whitespaceToSplitAt.index - currentLineStartIndex > maxLineLength;\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n } else {\n previousBreakRanOver = false;\n }\n\n previousWhitespaceMatch = currentWhitespaceMatch;\n }\n\n if (\n previousWhitespaceMatch &&\n line.length + linePrefixLength - currentLineStartIndex > maxLineLength\n ) {\n const whitespaceToSplitAt: RegExpExecArray = previousWhitespaceMatch;\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n }\n\n if (currentLineStartIndex < line.length) {\n wrappedLines.push(linePrefix + lineAdditionalPrefix + line.substring(currentLineStartIndex));\n }\n }\n }\n\n return wrappedLines;\n }\n\n /**\n * Displays a message in the console wrapped in a box UI.\n *\n * @param message - The message to display.\n * @param terminal - The terminal to write the message to.\n * @param boxWidth - The width of the box, defaults to half of the console width.\n */\n public static printMessageInBox(message: string, terminal: ITerminal, boxWidth?: number): void {\n if (!boxWidth) {\n const consoleWidth: number = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n boxWidth = Math.floor(consoleWidth / 2);\n }\n\n const maxLineLength: number = boxWidth - 10;\n const wrappedMessageLines: string[] = PrintUtilities.wrapWordsToLines(message, maxLineLength);\n let longestLineLength: number = 0;\n const trimmedLines: string[] = [];\n for (const line of wrappedMessageLines) {\n const trimmedLine: string = line.trim();\n trimmedLines.push(trimmedLine);\n longestLineLength = Math.max(longestLineLength, trimmedLine.length);\n }\n\n if (longestLineLength > boxWidth - 2) {\n // If the longest line is longer than the box, print bars above and below the message\n // ═════════════\n // Message\n // ═════════════\n const headerAndFooter: string = ` ${'═'.repeat(boxWidth)}`;\n terminal.writeLine(headerAndFooter);\n for (const line of wrappedMessageLines) {\n terminal.writeLine(` ${line}`);\n }\n\n terminal.writeLine(headerAndFooter);\n } else {\n // ╔═══════════╗\n // ║ Message ║\n // ╚═══════════╝\n terminal.writeLine(` ╔${'═'.repeat(boxWidth - 2)}╗`);\n for (const trimmedLine of trimmedLines) {\n const padding: number = boxWidth - trimmedLine.length - 2;\n const leftPadding: number = Math.floor(padding / 2);\n const rightPadding: number = padding - leftPadding;\n terminal.writeLine(` ║${' '.repeat(leftPadding)}${trimmedLine}${' '.repeat(rightPadding)}║`);\n }\n terminal.writeLine(` ╚${'═'.repeat(boxWidth - 2)}╝`);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PrintUtilities.js","sourceRoot":"","sources":["../src/PrintUtilities.ts"],"names":[],"mappings":";AAAA,4F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;IACH,CAAC;CACF;AArND,wCAqNC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text } from '@rushstack/node-core-library';\nimport type { ITerminal } from './ITerminal';\n\n/**\n * A sensible fallback column width for consoles.\n *\n * @public\n */\nexport const DEFAULT_CONSOLE_WIDTH: number = 80;\n\n/**\n * A collection of utilities for printing messages to the console.\n *\n * @public\n */\nexport class PrintUtilities {\n /**\n * Returns the width of the console, measured in columns\n */\n public static getConsoleWidth(): number | undefined {\n return process.stdout?.columns;\n }\n\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWords(text: string, maxLineLength?: number, indent?: number): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWords(text: string, maxLineLength?: number, linePrefix?: string): string;\n /**\n * Applies word wrapping.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWords(text: string, maxLineLength?: number, indentOrLinePrefix?: number | string): string;\n public static wrapWords(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string {\n const wrappedLines: string[] = PrintUtilities.wrapWordsToLines(\n text,\n maxLineLength,\n indentOrLinePrefix as string | undefined // TS is confused by the overloads\n );\n return wrappedLines.join('\\n');\n }\n\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indent - The number of spaces to indent the wrapped lines, defaults to 0\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, indent?: number): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param linePrefix - The string to prefix each line with, defaults to ''\n */\n public static wrapWordsToLines(text: string, maxLineLength?: number, linePrefix?: string): string[];\n /**\n * Applies word wrapping and returns an array of lines.\n *\n * @param text - The text to wrap\n * @param maxLineLength - The maximum length of a line, defaults to the console width\n * @param indentOrLinePrefix - The number of spaces to indent the wrapped lines or the string to prefix\n * each line with, defaults to no prefix\n */\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[];\n public static wrapWordsToLines(\n text: string,\n maxLineLength?: number,\n indentOrLinePrefix?: number | string\n ): string[] {\n let linePrefix: string;\n switch (typeof indentOrLinePrefix) {\n case 'number':\n linePrefix = ' '.repeat(indentOrLinePrefix);\n break;\n case 'string':\n linePrefix = indentOrLinePrefix;\n break;\n default:\n linePrefix = '';\n break;\n }\n\n const linePrefixLength: number = linePrefix.length;\n\n if (!maxLineLength) {\n maxLineLength = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n }\n\n // Apply word wrapping and the provided line prefix, while also respecting existing newlines\n // and prefix spaces that may exist in the text string already.\n const lines: string[] = Text.splitByNewLines(text);\n\n const wrappedLines: string[] = [];\n for (const line of lines) {\n if (line.length + linePrefixLength <= maxLineLength) {\n wrappedLines.push(linePrefix + line);\n } else {\n const lineAdditionalPrefix: string = line.match(/^\\s*/)?.[0] || '';\n const whitespaceRegexp: RegExp = /\\s+/g;\n let currentWhitespaceMatch: RegExpExecArray | null = null;\n let previousWhitespaceMatch: RegExpExecArray | undefined;\n let currentLineStartIndex: number = lineAdditionalPrefix.length;\n let previousBreakRanOver: boolean = false;\n while ((currentWhitespaceMatch = whitespaceRegexp.exec(line)) !== null) {\n if (currentWhitespaceMatch.index + linePrefixLength - currentLineStartIndex > maxLineLength) {\n let whitespaceToSplitAt: RegExpExecArray | undefined;\n if (\n !previousWhitespaceMatch ||\n // Handle the case where there are two words longer than the maxLineLength in a row\n previousBreakRanOver\n ) {\n whitespaceToSplitAt = currentWhitespaceMatch;\n } else {\n whitespaceToSplitAt = previousWhitespaceMatch;\n }\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n previousBreakRanOver = whitespaceToSplitAt.index - currentLineStartIndex > maxLineLength;\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n } else {\n previousBreakRanOver = false;\n }\n\n previousWhitespaceMatch = currentWhitespaceMatch;\n }\n\n if (\n previousWhitespaceMatch &&\n line.length + linePrefixLength - currentLineStartIndex > maxLineLength\n ) {\n const whitespaceToSplitAt: RegExpExecArray = previousWhitespaceMatch;\n\n wrappedLines.push(\n linePrefix +\n lineAdditionalPrefix +\n line.substring(currentLineStartIndex, whitespaceToSplitAt.index)\n );\n currentLineStartIndex = whitespaceToSplitAt.index + whitespaceToSplitAt[0].length;\n }\n\n if (currentLineStartIndex < line.length) {\n wrappedLines.push(linePrefix + lineAdditionalPrefix + line.substring(currentLineStartIndex));\n }\n }\n }\n\n return wrappedLines;\n }\n\n /**\n * Displays a message in the console wrapped in a box UI.\n *\n * @param message - The message to display.\n * @param terminal - The terminal to write the message to.\n * @param boxWidth - The width of the box, defaults to half of the console width.\n */\n public static printMessageInBox(message: string, terminal: ITerminal, boxWidth?: number): void {\n if (!boxWidth) {\n const consoleWidth: number = PrintUtilities.getConsoleWidth() || DEFAULT_CONSOLE_WIDTH;\n boxWidth = Math.floor(consoleWidth / 2);\n }\n\n const maxLineLength: number = boxWidth - 10;\n const wrappedMessageLines: string[] = PrintUtilities.wrapWordsToLines(message, maxLineLength);\n let longestLineLength: number = 0;\n const trimmedLines: string[] = [];\n for (const line of wrappedMessageLines) {\n const trimmedLine: string = line.trim();\n trimmedLines.push(trimmedLine);\n longestLineLength = Math.max(longestLineLength, trimmedLine.length);\n }\n\n if (longestLineLength > boxWidth - 2) {\n // If the longest line is longer than the box, print bars above and below the message\n // ═════════════\n // Message\n // ═════════════\n const headerAndFooter: string = ` ${'═'.repeat(boxWidth)}`;\n terminal.writeLine(headerAndFooter);\n for (const line of wrappedMessageLines) {\n terminal.writeLine(` ${line}`);\n }\n\n terminal.writeLine(headerAndFooter);\n } else {\n // ╔═══════════╗\n // ║ Message ║\n // ╚═══════════╝\n terminal.writeLine(` ╔${'═'.repeat(boxWidth - 2)}╗`);\n for (const trimmedLine of trimmedLines) {\n const padding: number = boxWidth - trimmedLine.length - 2;\n const leftPadding: number = Math.floor(padding / 2);\n const rightPadding: number = padding - leftPadding;\n terminal.writeLine(` ║${' '.repeat(leftPadding)}${trimmedLine}${' '.repeat(rightPadding)}║`);\n }\n terminal.writeLine(` ╚${'═'.repeat(boxWidth - 2)}╝`);\n }\n }\n}\n"]}
|
|
@@ -43,9 +43,13 @@ export declare class StringBufferTerminalProvider implements ITerminalProvider {
|
|
|
43
43
|
*/
|
|
44
44
|
getOutput(options?: IStringBufferOutputOptions): string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* @deprecated - use {@link StringBufferTerminalProvider.getVerboseOutput}
|
|
47
47
|
*/
|
|
48
48
|
getVerbose(options?: IStringBufferOutputOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* Get everything that has been written at verbose-level severity.
|
|
51
|
+
*/
|
|
52
|
+
getVerboseOutput(options?: IStringBufferOutputOptions): string;
|
|
49
53
|
/**
|
|
50
54
|
* Get everything that has been written at debug-level severity.
|
|
51
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringBufferTerminalProvider.d.ts","sourceRoot":"","sources":["../src/StringBufferTerminalProvider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAGvF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,0BAA0B,EAAE,OAAO,CAAC;CAC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OAAO,CAAC,YAAY,CAAsC;IAC1D,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,YAAY,CAAsC;IAE1D,OAAO,CAAC,cAAc,CAAU;gBAEb,aAAa,GAAE,OAAe;IAIjD;;OAEG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,wBAAwB,GAAG,IAAI;IA8BpE;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;OAEG;IACH,IAAW,aAAa,IAAI,OAAO,CAElC;IAED;;OAEG;IACI,SAAS,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAI9D;;OAEG;IACI,UAAU,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAI/D;;OAEG;IACI,gBAAgB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAIrE;;OAEG;IACI,cAAc,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAInE;;OAEG;IACI,cAAc,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAInE;;OAEG;IACI,gBAAgB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,MAAM;IAIrE,OAAO,CAAC,gBAAgB;CAezB"}
|
|
@@ -69,9 +69,15 @@ class StringBufferTerminalProvider {
|
|
|
69
69
|
return this._normalizeOutput(this._standardBuffer.toString(), options);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* @deprecated - use {@link StringBufferTerminalProvider.getVerboseOutput}
|
|
73
73
|
*/
|
|
74
74
|
getVerbose(options) {
|
|
75
|
+
return this.getVerboseOutput(options);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get everything that has been written at verbose-level severity.
|
|
79
|
+
*/
|
|
80
|
+
getVerboseOutput(options) {
|
|
75
81
|
return this._normalizeOutput(this._verboseBuffer.toString(), options);
|
|
76
82
|
}
|
|
77
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringBufferTerminalProvider.js","sourceRoot":"","sources":["../src/StringBufferTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAmE;AACnE,2DAAuF;AACvF,6CAA0C;AAe1C;;;;;;GAMG;AACH,MAAa,4BAA4B;IASvC,YAAmB,gBAAyB,KAAK;QARzC,oBAAe,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACrD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAClD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAKxD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAY,EAAE,QAAkC;QAC3D,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACjC,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC/B,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACjC,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC/B,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,GAAG,CAAC;YAClC,OAAO,CAAC,CAAC,CAAC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OAAO,uBAAU,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"StringBufferTerminalProvider.js","sourceRoot":"","sources":["../src/StringBufferTerminalProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAmE;AACnE,2DAAuF;AACvF,6CAA0C;AAe1C;;;;;;GAMG;AACH,MAAa,4BAA4B;IASvC,YAAmB,gBAAyB,KAAK;QARzC,oBAAe,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACrD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAClD,mBAAc,GAAkB,IAAI,iCAAa,EAAE,CAAC;QACpD,iBAAY,GAAkB,IAAI,iCAAa,EAAE,CAAC;QAKxD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,IAAY,EAAE,QAAkC;QAC3D,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACjC,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAC/B,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,OAAO,CAAC,CAAC,CAAC;gBACtC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACjC,MAAM;YACR,CAAC;YAED,KAAK,4CAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBACpC,IAAI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xE,CAAC;IAEO,gBAAgB,CAAC,CAAS,EAAE,OAA+C;QACjF,OAAO,mBACL,0BAA0B,EAAE,IAAI,IAE7B,CAAC,OAAO,IAAI,EAAE,CAAC,CACnB,CAAC;QAEF,CAAC,GAAG,wBAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAExB,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;YACvC,OAAO,uBAAU,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF;AArHD,oEAqHC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { StringBuilder, Text } from '@rushstack/node-core-library';\nimport { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalProvider';\nimport { AnsiEscape } from './AnsiEscape';\n\n/**\n * @beta\n */\nexport interface IStringBufferOutputOptions {\n /**\n * If set to true, special characters like \\\\n, \\\\r, and the \\\\u001b character\n * in color control tokens will get normalized to [-n-], [-r-], and [-x-] respectively\n *\n * This option defaults to `true`\n */\n normalizeSpecialCharacters: boolean;\n}\n\n/**\n * Terminal provider that stores written data in buffers separated by severity.\n * This terminal provider is designed to be used when code that prints to a terminal\n * is being unit tested.\n *\n * @beta\n */\nexport class StringBufferTerminalProvider implements ITerminalProvider {\n private _standardBuffer: StringBuilder = new StringBuilder();\n private _verboseBuffer: StringBuilder = new StringBuilder();\n private _debugBuffer: StringBuilder = new StringBuilder();\n private _warningBuffer: StringBuilder = new StringBuilder();\n private _errorBuffer: StringBuilder = new StringBuilder();\n\n private _supportsColor: boolean;\n\n public constructor(supportsColor: boolean = false) {\n this._supportsColor = supportsColor;\n }\n\n /**\n * {@inheritDoc ITerminalProvider.write}\n */\n public write(data: string, severity: TerminalProviderSeverity): void {\n switch (severity) {\n case TerminalProviderSeverity.warning: {\n this._warningBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.error: {\n this._errorBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.verbose: {\n this._verboseBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.debug: {\n this._debugBuffer.append(data);\n break;\n }\n\n case TerminalProviderSeverity.log:\n default: {\n this._standardBuffer.append(data);\n break;\n }\n }\n }\n\n /**\n * {@inheritDoc ITerminalProvider.eolCharacter}\n */\n public get eolCharacter(): string {\n return '\\n';\n }\n\n /**\n * {@inheritDoc ITerminalProvider.supportsColor}\n */\n public get supportsColor(): boolean {\n return this._supportsColor;\n }\n\n /**\n * Get everything that has been written at log-level severity.\n */\n public getOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._standardBuffer.toString(), options);\n }\n\n /**\n * @deprecated - use {@link StringBufferTerminalProvider.getVerboseOutput}\n */\n public getVerbose(options?: IStringBufferOutputOptions): string {\n return this.getVerboseOutput(options);\n }\n\n /**\n * Get everything that has been written at verbose-level severity.\n */\n public getVerboseOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._verboseBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at debug-level severity.\n */\n public getDebugOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._debugBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at error-level severity.\n */\n public getErrorOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._errorBuffer.toString(), options);\n }\n\n /**\n * Get everything that has been written at warning-level severity.\n */\n public getWarningOutput(options?: IStringBufferOutputOptions): string {\n return this._normalizeOutput(this._warningBuffer.toString(), options);\n }\n\n private _normalizeOutput(s: string, options: IStringBufferOutputOptions | undefined): string {\n options = {\n normalizeSpecialCharacters: true,\n\n ...(options || {})\n };\n\n s = Text.convertToLf(s);\n\n if (options.normalizeSpecialCharacters) {\n return AnsiEscape.formatForTests(s, { encodeNewlines: true });\n } else {\n return s;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/terminal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "User interface primitives for console applications",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "dist/terminal.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"supports-color": "~8.1.1",
|
|
15
|
-
"@rushstack/node-core-library": "5.
|
|
15
|
+
"@rushstack/node-core-library": "5.7.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@rushstack/heft": "0.66.17",
|