@nice-move/cli 0.10.14 → 0.11.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/dist/cli.mjs +10467 -1
- package/dist/node_modules_cli-truncate_index_js.mjs +298 -0
- package/dist/node_modules_commitlint_rules_lib_trailer-exists_js.mjs +18 -0
- package/dist/node_modules_lint-staged_lib_loadConfig_js.mjs +23 -0
- package/dist/node_modules_listr2_node_modules_wrap-ansi_index_js.mjs +236 -0
- package/dist/vendors-node_modules_ansi-styles_index_js-node_modules_string-width_index_js.mjs +703 -0
- package/dist/vendors-node_modules_commitlint_format_lib_index_js.mjs +2108 -0
- package/dist/vendors-node_modules_commitlint_lint_lib_lint_js.mjs +8268 -0
- package/dist/vendors-node_modules_lint-staged_lib_index_js.mjs +12063 -0
- package/dist/vendors-node_modules_log-update_index_js.mjs +1124 -0
- package/package.json +6 -6
- package/dist/138.mjs +0 -1
- package/dist/246.mjs +0 -1
- package/dist/402.mjs +0 -1
- package/dist/586.mjs +0 -1
- package/dist/777.mjs +0 -1
- package/dist/794.mjs +0 -1
- package/dist/841.mjs +0 -1
- package/dist/931.mjs +0 -1
- package/dist/976.mjs +0 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
export const id = "node_modules_cli-truncate_index_js";
|
|
2
|
+
export const ids = ["node_modules_cli-truncate_index_js"];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ "../../node_modules/cli-truncate/index.js":
|
|
6
|
+
/*!************************************************!*\
|
|
7
|
+
!*** ../../node_modules/cli-truncate/index.js ***!
|
|
8
|
+
\************************************************/
|
|
9
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
10
|
+
|
|
11
|
+
__webpack_require__.r(__webpack_exports__);
|
|
12
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
/* harmony export */ "default": () => (/* binding */ cliTruncate)
|
|
14
|
+
/* harmony export */ });
|
|
15
|
+
/* harmony import */ var slice_ansi__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! slice-ansi */ "../../node_modules/slice-ansi/index.js");
|
|
16
|
+
/* harmony import */ var string_width__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! string-width */ "../../node_modules/string-width/index.js");
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
|
|
21
|
+
if (string.charAt(wantedIndex) === ' ') {
|
|
22
|
+
return wantedIndex;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (let index = 1; index <= 3; index++) {
|
|
26
|
+
if (shouldSearchRight) {
|
|
27
|
+
if (string.charAt(wantedIndex + index) === ' ') {
|
|
28
|
+
return wantedIndex + index;
|
|
29
|
+
}
|
|
30
|
+
} else if (string.charAt(wantedIndex - index) === ' ') {
|
|
31
|
+
return wantedIndex - index;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return wantedIndex;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function cliTruncate(text, columns, options) {
|
|
39
|
+
options = {
|
|
40
|
+
position: 'end',
|
|
41
|
+
preferTruncationOnSpace: false,
|
|
42
|
+
truncationCharacter: '…',
|
|
43
|
+
...options,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const {position, space, preferTruncationOnSpace} = options;
|
|
47
|
+
let {truncationCharacter} = options;
|
|
48
|
+
|
|
49
|
+
if (typeof text !== 'string') {
|
|
50
|
+
throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (typeof columns !== 'number') {
|
|
54
|
+
throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (columns < 1) {
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (columns === 1) {
|
|
62
|
+
return truncationCharacter;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const length = (0,string_width__WEBPACK_IMPORTED_MODULE_1__["default"])(text);
|
|
66
|
+
|
|
67
|
+
if (length <= columns) {
|
|
68
|
+
return text;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (position === 'start') {
|
|
72
|
+
if (preferTruncationOnSpace) {
|
|
73
|
+
const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
|
|
74
|
+
return truncationCharacter + (0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, nearestSpace, length).trim();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (space === true) {
|
|
78
|
+
truncationCharacter += ' ';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return truncationCharacter + (0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, length - columns + (0,string_width__WEBPACK_IMPORTED_MODULE_1__["default"])(truncationCharacter), length);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (position === 'middle') {
|
|
85
|
+
if (space === true) {
|
|
86
|
+
truncationCharacter = ` ${truncationCharacter} `;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const half = Math.floor(columns / 2);
|
|
90
|
+
|
|
91
|
+
if (preferTruncationOnSpace) {
|
|
92
|
+
const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
|
|
93
|
+
const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + 1, true);
|
|
94
|
+
return (0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + (0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, spaceNearSecondBreakPoint, length).trim();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
(0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, 0, half)
|
|
99
|
+
+ truncationCharacter
|
|
100
|
+
+ (0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, length - (columns - half) + (0,string_width__WEBPACK_IMPORTED_MODULE_1__["default"])(truncationCharacter), length)
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (position === 'end') {
|
|
105
|
+
if (preferTruncationOnSpace) {
|
|
106
|
+
const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
|
|
107
|
+
return (0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, 0, nearestSpace) + truncationCharacter;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (space === true) {
|
|
111
|
+
truncationCharacter = ` ${truncationCharacter}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (0,slice_ansi__WEBPACK_IMPORTED_MODULE_0__["default"])(text, 0, columns - (0,string_width__WEBPACK_IMPORTED_MODULE_1__["default"])(truncationCharacter)) + truncationCharacter;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
throw new Error(`Expected \`options.position\` to be either \`start\`, \`middle\` or \`end\`, got ${position}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
/***/ }),
|
|
122
|
+
|
|
123
|
+
/***/ "../../node_modules/is-fullwidth-code-point/index.js":
|
|
124
|
+
/*!***********************************************************!*\
|
|
125
|
+
!*** ../../node_modules/is-fullwidth-code-point/index.js ***!
|
|
126
|
+
\***********************************************************/
|
|
127
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
128
|
+
|
|
129
|
+
__webpack_require__.r(__webpack_exports__);
|
|
130
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
131
|
+
/* harmony export */ "default": () => (/* binding */ isFullwidthCodePoint)
|
|
132
|
+
/* harmony export */ });
|
|
133
|
+
/* eslint-disable yoda */
|
|
134
|
+
|
|
135
|
+
function isFullwidthCodePoint(codePoint) {
|
|
136
|
+
if (!Number.isInteger(codePoint)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Code points are derived from:
|
|
141
|
+
// https://unicode.org/Public/UNIDATA/EastAsianWidth.txt
|
|
142
|
+
return codePoint >= 0x1100 && (
|
|
143
|
+
codePoint <= 0x115F || // Hangul Jamo
|
|
144
|
+
codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
|
|
145
|
+
codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
|
|
146
|
+
// CJK Radicals Supplement .. Enclosed CJK Letters and Months
|
|
147
|
+
(0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) ||
|
|
148
|
+
// Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
|
|
149
|
+
(0x3250 <= codePoint && codePoint <= 0x4DBF) ||
|
|
150
|
+
// CJK Unified Ideographs .. Yi Radicals
|
|
151
|
+
(0x4E00 <= codePoint && codePoint <= 0xA4C6) ||
|
|
152
|
+
// Hangul Jamo Extended-A
|
|
153
|
+
(0xA960 <= codePoint && codePoint <= 0xA97C) ||
|
|
154
|
+
// Hangul Syllables
|
|
155
|
+
(0xAC00 <= codePoint && codePoint <= 0xD7A3) ||
|
|
156
|
+
// CJK Compatibility Ideographs
|
|
157
|
+
(0xF900 <= codePoint && codePoint <= 0xFAFF) ||
|
|
158
|
+
// Vertical Forms
|
|
159
|
+
(0xFE10 <= codePoint && codePoint <= 0xFE19) ||
|
|
160
|
+
// CJK Compatibility Forms .. Small Form Variants
|
|
161
|
+
(0xFE30 <= codePoint && codePoint <= 0xFE6B) ||
|
|
162
|
+
// Halfwidth and Fullwidth Forms
|
|
163
|
+
(0xFF01 <= codePoint && codePoint <= 0xFF60) ||
|
|
164
|
+
(0xFFE0 <= codePoint && codePoint <= 0xFFE6) ||
|
|
165
|
+
// Kana Supplement
|
|
166
|
+
(0x1B000 <= codePoint && codePoint <= 0x1B001) ||
|
|
167
|
+
// Enclosed Ideographic Supplement
|
|
168
|
+
(0x1F200 <= codePoint && codePoint <= 0x1F251) ||
|
|
169
|
+
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
|
|
170
|
+
(0x20000 <= codePoint && codePoint <= 0x3FFFD)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
/***/ }),
|
|
176
|
+
|
|
177
|
+
/***/ "../../node_modules/slice-ansi/index.js":
|
|
178
|
+
/*!**********************************************!*\
|
|
179
|
+
!*** ../../node_modules/slice-ansi/index.js ***!
|
|
180
|
+
\**********************************************/
|
|
181
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
182
|
+
|
|
183
|
+
__webpack_require__.r(__webpack_exports__);
|
|
184
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
185
|
+
/* harmony export */ "default": () => (/* binding */ sliceAnsi)
|
|
186
|
+
/* harmony export */ });
|
|
187
|
+
/* harmony import */ var is_fullwidth_code_point__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! is-fullwidth-code-point */ "../../node_modules/is-fullwidth-code-point/index.js");
|
|
188
|
+
/* harmony import */ var ansi_styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ansi-styles */ "../../node_modules/ansi-styles/index.js");
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
const astralRegex = /^[\uD800-\uDBFF][\uDC00-\uDFFF]$/;
|
|
193
|
+
|
|
194
|
+
const ESCAPES = [
|
|
195
|
+
'\u001B',
|
|
196
|
+
'\u009B'
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
const wrapAnsi = code => `${ESCAPES[0]}[${code}m`;
|
|
200
|
+
|
|
201
|
+
const checkAnsi = (ansiCodes, isEscapes, endAnsiCode) => {
|
|
202
|
+
let output = [];
|
|
203
|
+
ansiCodes = [...ansiCodes];
|
|
204
|
+
|
|
205
|
+
for (let ansiCode of ansiCodes) {
|
|
206
|
+
const ansiCodeOrigin = ansiCode;
|
|
207
|
+
if (ansiCode.includes(';')) {
|
|
208
|
+
ansiCode = ansiCode.split(';')[0][0] + '0';
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const item = ansi_styles__WEBPACK_IMPORTED_MODULE_1__["default"].codes.get(Number.parseInt(ansiCode, 10));
|
|
212
|
+
if (item) {
|
|
213
|
+
const indexEscape = ansiCodes.indexOf(item.toString());
|
|
214
|
+
if (indexEscape === -1) {
|
|
215
|
+
output.push(wrapAnsi(isEscapes ? item : ansiCodeOrigin));
|
|
216
|
+
} else {
|
|
217
|
+
ansiCodes.splice(indexEscape, 1);
|
|
218
|
+
}
|
|
219
|
+
} else if (isEscapes) {
|
|
220
|
+
output.push(wrapAnsi(0));
|
|
221
|
+
break;
|
|
222
|
+
} else {
|
|
223
|
+
output.push(wrapAnsi(ansiCodeOrigin));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (isEscapes) {
|
|
228
|
+
output = output.filter((element, index) => output.indexOf(element) === index);
|
|
229
|
+
|
|
230
|
+
if (endAnsiCode !== undefined) {
|
|
231
|
+
const fistEscapeCode = wrapAnsi(ansi_styles__WEBPACK_IMPORTED_MODULE_1__["default"].codes.get(Number.parseInt(endAnsiCode, 10)));
|
|
232
|
+
// TODO: Remove the use of `.reduce` here.
|
|
233
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
234
|
+
output = output.reduce((current, next) => next === fistEscapeCode ? [next, ...current] : [...current, next], []);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return output.join('');
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
function sliceAnsi(string, begin, end) {
|
|
242
|
+
const characters = [...string];
|
|
243
|
+
const ansiCodes = [];
|
|
244
|
+
|
|
245
|
+
let stringEnd = typeof end === 'number' ? end : characters.length;
|
|
246
|
+
let isInsideEscape = false;
|
|
247
|
+
let ansiCode;
|
|
248
|
+
let visible = 0;
|
|
249
|
+
let output = '';
|
|
250
|
+
|
|
251
|
+
for (const [index, character] of characters.entries()) {
|
|
252
|
+
let leftEscape = false;
|
|
253
|
+
|
|
254
|
+
if (ESCAPES.includes(character)) {
|
|
255
|
+
const code = /\d[^m]*/.exec(string.slice(index, index + 18));
|
|
256
|
+
ansiCode = code && code.length > 0 ? code[0] : undefined;
|
|
257
|
+
|
|
258
|
+
if (visible < stringEnd) {
|
|
259
|
+
isInsideEscape = true;
|
|
260
|
+
|
|
261
|
+
if (ansiCode !== undefined) {
|
|
262
|
+
ansiCodes.push(ansiCode);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} else if (isInsideEscape && character === 'm') {
|
|
266
|
+
isInsideEscape = false;
|
|
267
|
+
leftEscape = true;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (!isInsideEscape && !leftEscape) {
|
|
271
|
+
visible++;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (!astralRegex.test(character) && (0,is_fullwidth_code_point__WEBPACK_IMPORTED_MODULE_0__["default"])(character.codePointAt())) {
|
|
275
|
+
visible++;
|
|
276
|
+
|
|
277
|
+
if (typeof end !== 'number') {
|
|
278
|
+
stringEnd++;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (visible > begin && visible <= stringEnd) {
|
|
283
|
+
output += character;
|
|
284
|
+
} else if (visible === begin && !isInsideEscape && ansiCode !== undefined) {
|
|
285
|
+
output = checkAnsi(ansiCodes);
|
|
286
|
+
} else if (visible >= stringEnd) {
|
|
287
|
+
output += checkAnsi(ansiCodes, true, ansiCode);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return output;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
/***/ })
|
|
297
|
+
|
|
298
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const id = "node_modules_commitlint_rules_lib_trailer-exists_js";
|
|
2
|
+
export const ids = ["node_modules_commitlint_rules_lib_trailer-exists_js"];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ "../../node_modules/@commitlint/rules/lib/trailer-exists.js":
|
|
6
|
+
/*!******************************************************************!*\
|
|
7
|
+
!*** ../../node_modules/@commitlint/rules/lib/trailer-exists.js ***!
|
|
8
|
+
\******************************************************************/
|
|
9
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.trailerExists = undefined;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/***/ })
|
|
17
|
+
|
|
18
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const id = "node_modules_lint-staged_lib_loadConfig_js";
|
|
2
|
+
export const ids = ["node_modules_lint-staged_lib_loadConfig_js"];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ "../../node_modules/lint-staged/lib/loadConfig.js":
|
|
6
|
+
/*!********************************************************!*\
|
|
7
|
+
!*** ../../node_modules/lint-staged/lib/loadConfig.js ***!
|
|
8
|
+
\********************************************************/
|
|
9
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
10
|
+
|
|
11
|
+
__webpack_require__.r(__webpack_exports__);
|
|
12
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
/* harmony export */ loadConfig: () => (/* binding */ loadConfig),
|
|
14
|
+
/* harmony export */ searchPlaces: () => (/* binding */ searchPlaces)
|
|
15
|
+
/* harmony export */ });
|
|
16
|
+
const loadConfig = async () => {};
|
|
17
|
+
|
|
18
|
+
const searchPlaces = [];
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/***/ })
|
|
22
|
+
|
|
23
|
+
};
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
export const id = "node_modules_listr2_node_modules_wrap-ansi_index_js";
|
|
2
|
+
export const ids = ["node_modules_listr2_node_modules_wrap-ansi_index_js"];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ "../../node_modules/listr2/node_modules/wrap-ansi/index.js":
|
|
6
|
+
/*!*****************************************************************!*\
|
|
7
|
+
!*** ../../node_modules/listr2/node_modules/wrap-ansi/index.js ***!
|
|
8
|
+
\*****************************************************************/
|
|
9
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
10
|
+
|
|
11
|
+
__webpack_require__.r(__webpack_exports__);
|
|
12
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
/* harmony export */ "default": () => (/* binding */ wrapAnsi)
|
|
14
|
+
/* harmony export */ });
|
|
15
|
+
/* harmony import */ var string_width__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! string-width */ "../../node_modules/string-width/index.js");
|
|
16
|
+
/* harmony import */ var strip_ansi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! strip-ansi */ "../../node_modules/strip-ansi/index.js");
|
|
17
|
+
/* harmony import */ var ansi_styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ansi-styles */ "../../node_modules/ansi-styles/index.js");
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const ESCAPES = new Set([
|
|
23
|
+
'\u001B',
|
|
24
|
+
'\u009B',
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const END_CODE = 39;
|
|
28
|
+
const ANSI_ESCAPE_BELL = '\u0007';
|
|
29
|
+
const ANSI_CSI = '[';
|
|
30
|
+
const ANSI_OSC = ']';
|
|
31
|
+
const ANSI_SGR_TERMINATOR = 'm';
|
|
32
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
33
|
+
|
|
34
|
+
const wrapAnsiCode = code => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
35
|
+
const wrapAnsiHyperlink = uri => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${uri}${ANSI_ESCAPE_BELL}`;
|
|
36
|
+
|
|
37
|
+
// Calculate the length of words split on ' ', ignoring
|
|
38
|
+
// the extra characters added by ansi escape codes
|
|
39
|
+
const wordLengths = string => string.split(' ').map(character => (0,string_width__WEBPACK_IMPORTED_MODULE_0__["default"])(character));
|
|
40
|
+
|
|
41
|
+
// Wrap a long word across multiple rows
|
|
42
|
+
// Ansi escape codes do not count towards length
|
|
43
|
+
const wrapWord = (rows, word, columns) => {
|
|
44
|
+
const characters = [...word];
|
|
45
|
+
|
|
46
|
+
let isInsideEscape = false;
|
|
47
|
+
let isInsideLinkEscape = false;
|
|
48
|
+
let visible = (0,string_width__WEBPACK_IMPORTED_MODULE_0__["default"])((0,strip_ansi__WEBPACK_IMPORTED_MODULE_1__["default"])(rows[rows.length - 1]));
|
|
49
|
+
|
|
50
|
+
for (const [index, character] of characters.entries()) {
|
|
51
|
+
const characterLength = (0,string_width__WEBPACK_IMPORTED_MODULE_0__["default"])(character);
|
|
52
|
+
|
|
53
|
+
if (visible + characterLength <= columns) {
|
|
54
|
+
rows[rows.length - 1] += character;
|
|
55
|
+
} else {
|
|
56
|
+
rows.push(character);
|
|
57
|
+
visible = 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (ESCAPES.has(character)) {
|
|
61
|
+
isInsideEscape = true;
|
|
62
|
+
isInsideLinkEscape = characters.slice(index + 1).join('').startsWith(ANSI_ESCAPE_LINK);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (isInsideEscape) {
|
|
66
|
+
if (isInsideLinkEscape) {
|
|
67
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
68
|
+
isInsideEscape = false;
|
|
69
|
+
isInsideLinkEscape = false;
|
|
70
|
+
}
|
|
71
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
72
|
+
isInsideEscape = false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
visible += characterLength;
|
|
79
|
+
|
|
80
|
+
if (visible === columns && index < characters.length - 1) {
|
|
81
|
+
rows.push('');
|
|
82
|
+
visible = 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// It's possible that the last row we copy over is only
|
|
87
|
+
// ansi escape characters, handle this edge-case
|
|
88
|
+
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
|
|
89
|
+
rows[rows.length - 2] += rows.pop();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Trims spaces from a string ignoring invisible sequences
|
|
94
|
+
const stringVisibleTrimSpacesRight = string => {
|
|
95
|
+
const words = string.split(' ');
|
|
96
|
+
let last = words.length;
|
|
97
|
+
|
|
98
|
+
while (last > 0) {
|
|
99
|
+
if ((0,string_width__WEBPACK_IMPORTED_MODULE_0__["default"])(words[last - 1]) > 0) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
last--;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (last === words.length) {
|
|
107
|
+
return string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode
|
|
114
|
+
//
|
|
115
|
+
// 'hard' will never allow a string to take up more than columns characters
|
|
116
|
+
//
|
|
117
|
+
// 'soft' allows long words to expand past the column length
|
|
118
|
+
const exec = (string, columns, options = {}) => {
|
|
119
|
+
if (options.trim !== false && string.trim() === '') {
|
|
120
|
+
return '';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let returnValue = '';
|
|
124
|
+
let escapeCode;
|
|
125
|
+
let escapeUrl;
|
|
126
|
+
|
|
127
|
+
const lengths = wordLengths(string);
|
|
128
|
+
let rows = [''];
|
|
129
|
+
|
|
130
|
+
for (const [index, word] of string.split(' ').entries()) {
|
|
131
|
+
if (options.trim !== false) {
|
|
132
|
+
rows[rows.length - 1] = rows[rows.length - 1].trimStart();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let rowLength = (0,string_width__WEBPACK_IMPORTED_MODULE_0__["default"])(rows[rows.length - 1]);
|
|
136
|
+
|
|
137
|
+
if (index !== 0) {
|
|
138
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
139
|
+
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
|
140
|
+
rows.push('');
|
|
141
|
+
rowLength = 0;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (rowLength > 0 || options.trim === false) {
|
|
145
|
+
rows[rows.length - 1] += ' ';
|
|
146
|
+
rowLength++;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
|
|
151
|
+
if (options.hard && lengths[index] > columns) {
|
|
152
|
+
const remainingColumns = (columns - rowLength);
|
|
153
|
+
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
|
154
|
+
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
|
155
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
156
|
+
rows.push('');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
wrapWord(rows, word, columns);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
|
164
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
165
|
+
wrapWord(rows, word, columns);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
rows.push('');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
|
173
|
+
wrapWord(rows, word, columns);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
rows[rows.length - 1] += word;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (options.trim !== false) {
|
|
181
|
+
rows = rows.map(row => stringVisibleTrimSpacesRight(row));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const pre = [...rows.join('\n')];
|
|
185
|
+
|
|
186
|
+
for (const [index, character] of pre.entries()) {
|
|
187
|
+
returnValue += character;
|
|
188
|
+
|
|
189
|
+
if (ESCAPES.has(character)) {
|
|
190
|
+
const {groups} = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(pre.slice(index).join('')) || {groups: {}};
|
|
191
|
+
if (groups.code !== undefined) {
|
|
192
|
+
const code = Number.parseFloat(groups.code);
|
|
193
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
194
|
+
} else if (groups.uri !== undefined) {
|
|
195
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const code = ansi_styles__WEBPACK_IMPORTED_MODULE_2__["default"].codes.get(Number(escapeCode));
|
|
200
|
+
|
|
201
|
+
if (pre[index + 1] === '\n') {
|
|
202
|
+
if (escapeUrl) {
|
|
203
|
+
returnValue += wrapAnsiHyperlink('');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (escapeCode && code) {
|
|
207
|
+
returnValue += wrapAnsiCode(code);
|
|
208
|
+
}
|
|
209
|
+
} else if (character === '\n') {
|
|
210
|
+
if (escapeCode && code) {
|
|
211
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (escapeUrl) {
|
|
215
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return returnValue;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// For each newline, invoke the method separately
|
|
224
|
+
function wrapAnsi(string, columns, options) {
|
|
225
|
+
return String(string)
|
|
226
|
+
.normalize()
|
|
227
|
+
.replace(/\r\n/g, '\n')
|
|
228
|
+
.split('\n')
|
|
229
|
+
.map(line => exec(line, columns, options))
|
|
230
|
+
.join('\n');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
/***/ })
|
|
235
|
+
|
|
236
|
+
};
|