@soybeanjs/changelog 0.3.25 → 0.4.0-beta.1
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/index.d.ts +93 -91
- package/dist/index.js +530 -1642
- package/package.json +8 -8
- package/dist/index.cjs +0 -2543
- package/dist/index.d.cts +0 -139
- package/dist/prompt-BN7TR4PR.js +0 -756
package/dist/index.js
CHANGED
|
@@ -1,1720 +1,608 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import { Presets, SingleBar } from "cli-progress";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import process2 from "process";
|
|
6
|
-
import { readFile } from "fs/promises";
|
|
7
|
-
|
|
8
|
-
// src/git.ts
|
|
9
|
-
import { ofetch } from "ofetch";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
10
4
|
import dayjs from "dayjs";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var LogLevels = {
|
|
14
|
-
silent: Number.NEGATIVE_INFINITY,
|
|
15
|
-
fatal: 0,
|
|
16
|
-
error: 0,
|
|
17
|
-
warn: 1,
|
|
18
|
-
log: 2,
|
|
19
|
-
info: 3,
|
|
20
|
-
success: 3,
|
|
21
|
-
fail: 3,
|
|
22
|
-
ready: 3,
|
|
23
|
-
start: 3,
|
|
24
|
-
box: 3,
|
|
25
|
-
debug: 4,
|
|
26
|
-
trace: 5,
|
|
27
|
-
verbose: Number.POSITIVE_INFINITY
|
|
28
|
-
};
|
|
29
|
-
var LogTypes = {
|
|
30
|
-
// Silent
|
|
31
|
-
silent: {
|
|
32
|
-
level: -1
|
|
33
|
-
},
|
|
34
|
-
// Level 0
|
|
35
|
-
fatal: {
|
|
36
|
-
level: LogLevels.fatal
|
|
37
|
-
},
|
|
38
|
-
error: {
|
|
39
|
-
level: LogLevels.error
|
|
40
|
-
},
|
|
41
|
-
// Level 1
|
|
42
|
-
warn: {
|
|
43
|
-
level: LogLevels.warn
|
|
44
|
-
},
|
|
45
|
-
// Level 2
|
|
46
|
-
log: {
|
|
47
|
-
level: LogLevels.log
|
|
48
|
-
},
|
|
49
|
-
// Level 3
|
|
50
|
-
info: {
|
|
51
|
-
level: LogLevels.info
|
|
52
|
-
},
|
|
53
|
-
success: {
|
|
54
|
-
level: LogLevels.success
|
|
55
|
-
},
|
|
56
|
-
fail: {
|
|
57
|
-
level: LogLevels.fail
|
|
58
|
-
},
|
|
59
|
-
ready: {
|
|
60
|
-
level: LogLevels.info
|
|
61
|
-
},
|
|
62
|
-
start: {
|
|
63
|
-
level: LogLevels.info
|
|
64
|
-
},
|
|
65
|
-
box: {
|
|
66
|
-
level: LogLevels.info
|
|
67
|
-
},
|
|
68
|
-
// Level 4
|
|
69
|
-
debug: {
|
|
70
|
-
level: LogLevels.debug
|
|
71
|
-
},
|
|
72
|
-
// Level 5
|
|
73
|
-
trace: {
|
|
74
|
-
level: LogLevels.trace
|
|
75
|
-
},
|
|
76
|
-
// Verbose
|
|
77
|
-
verbose: {
|
|
78
|
-
level: LogLevels.verbose
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
function isPlainObject$1(value) {
|
|
82
|
-
if (value === null || typeof value !== "object") {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
const prototype = Object.getPrototypeOf(value);
|
|
86
|
-
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
if (Symbol.iterator in value) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
if (Symbol.toStringTag in value) {
|
|
93
|
-
return Object.prototype.toString.call(value) === "[object Module]";
|
|
94
|
-
}
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
98
|
-
if (!isPlainObject$1(defaults)) {
|
|
99
|
-
return _defu(baseObject, {}, namespace, merger);
|
|
100
|
-
}
|
|
101
|
-
const object = Object.assign({}, defaults);
|
|
102
|
-
for (const key in baseObject) {
|
|
103
|
-
if (key === "__proto__" || key === "constructor") {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const value = baseObject[key];
|
|
107
|
-
if (value === null || value === void 0) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (merger && merger(object, key, value, namespace)) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
114
|
-
object[key] = [...value, ...object[key]];
|
|
115
|
-
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
116
|
-
object[key] = _defu(
|
|
117
|
-
value,
|
|
118
|
-
object[key],
|
|
119
|
-
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
120
|
-
merger
|
|
121
|
-
);
|
|
122
|
-
} else {
|
|
123
|
-
object[key] = value;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return object;
|
|
127
|
-
}
|
|
128
|
-
function createDefu(merger) {
|
|
129
|
-
return (...arguments_) => (
|
|
130
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
131
|
-
arguments_.reduce((p, c2) => _defu(p, c2, "", merger), {})
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
var defu = createDefu();
|
|
135
|
-
function isPlainObject(obj) {
|
|
136
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
137
|
-
}
|
|
138
|
-
function isLogObj(arg) {
|
|
139
|
-
if (!isPlainObject(arg)) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
if (!arg.message && !arg.args) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
if (arg.stack) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
var paused = false;
|
|
151
|
-
var queue = [];
|
|
152
|
-
var Consola = class _Consola {
|
|
153
|
-
options;
|
|
154
|
-
_lastLog;
|
|
155
|
-
_mockFn;
|
|
156
|
-
/**
|
|
157
|
-
* Creates an instance of Consola with specified options or defaults.
|
|
158
|
-
*
|
|
159
|
-
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
160
|
-
*/
|
|
161
|
-
constructor(options = {}) {
|
|
162
|
-
const types = options.types || LogTypes;
|
|
163
|
-
this.options = defu(
|
|
164
|
-
{
|
|
165
|
-
...options,
|
|
166
|
-
defaults: { ...options.defaults },
|
|
167
|
-
level: _normalizeLogLevel(options.level, types),
|
|
168
|
-
reporters: [...options.reporters || []]
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
types: LogTypes,
|
|
172
|
-
throttle: 1e3,
|
|
173
|
-
throttleMin: 5,
|
|
174
|
-
formatOptions: {
|
|
175
|
-
date: true,
|
|
176
|
-
colors: false,
|
|
177
|
-
compact: true
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
);
|
|
181
|
-
for (const type in types) {
|
|
182
|
-
const defaults = {
|
|
183
|
-
type,
|
|
184
|
-
...this.options.defaults,
|
|
185
|
-
...types[type]
|
|
186
|
-
};
|
|
187
|
-
this[type] = this._wrapLogFn(defaults);
|
|
188
|
-
this[type].raw = this._wrapLogFn(
|
|
189
|
-
defaults,
|
|
190
|
-
true
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
if (this.options.mockFn) {
|
|
194
|
-
this.mockTypes();
|
|
195
|
-
}
|
|
196
|
-
this._lastLog = {};
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Gets the current log level of the Consola instance.
|
|
200
|
-
*
|
|
201
|
-
* @returns {number} The current log level.
|
|
202
|
-
*/
|
|
203
|
-
get level() {
|
|
204
|
-
return this.options.level;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Sets the minimum log level that will be output by the instance.
|
|
208
|
-
*
|
|
209
|
-
* @param {number} level - The new log level to set.
|
|
210
|
-
*/
|
|
211
|
-
set level(level) {
|
|
212
|
-
this.options.level = _normalizeLogLevel(
|
|
213
|
-
level,
|
|
214
|
-
this.options.types,
|
|
215
|
-
this.options.level
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Displays a prompt to the user and returns the response.
|
|
220
|
-
* Throw an error if `prompt` is not supported by the current configuration.
|
|
221
|
-
*
|
|
222
|
-
* @template T
|
|
223
|
-
* @param {string} message - The message to display in the prompt.
|
|
224
|
-
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
225
|
-
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
226
|
-
*/
|
|
227
|
-
prompt(message, opts) {
|
|
228
|
-
if (!this.options.prompt) {
|
|
229
|
-
throw new Error("prompt is not supported!");
|
|
230
|
-
}
|
|
231
|
-
return this.options.prompt(message, opts);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
235
|
-
*
|
|
236
|
-
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
237
|
-
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
238
|
-
*/
|
|
239
|
-
create(options) {
|
|
240
|
-
const instance = new _Consola({
|
|
241
|
-
...this.options,
|
|
242
|
-
...options
|
|
243
|
-
});
|
|
244
|
-
if (this._mockFn) {
|
|
245
|
-
instance.mockTypes(this._mockFn);
|
|
246
|
-
}
|
|
247
|
-
return instance;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Creates a new Consola instance with the specified default log object properties.
|
|
251
|
-
*
|
|
252
|
-
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
253
|
-
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
254
|
-
*/
|
|
255
|
-
withDefaults(defaults) {
|
|
256
|
-
return this.create({
|
|
257
|
-
...this.options,
|
|
258
|
-
defaults: {
|
|
259
|
-
...this.options.defaults,
|
|
260
|
-
...defaults
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
266
|
-
*
|
|
267
|
-
* @param {string} tag - The tag to include in each log of the new instance.
|
|
268
|
-
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
269
|
-
*/
|
|
270
|
-
withTag(tag) {
|
|
271
|
-
return this.withDefaults({
|
|
272
|
-
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Adds a custom reporter to the Consola instance.
|
|
277
|
-
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
278
|
-
*
|
|
279
|
-
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
280
|
-
* @returns {Consola} The current Consola instance.
|
|
281
|
-
*/
|
|
282
|
-
addReporter(reporter) {
|
|
283
|
-
this.options.reporters.push(reporter);
|
|
284
|
-
return this;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Removes a custom reporter from the Consola instance.
|
|
288
|
-
* If no reporter is specified, all reporters will be removed.
|
|
289
|
-
*
|
|
290
|
-
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
291
|
-
* @returns {Consola} The current Consola instance.
|
|
292
|
-
*/
|
|
293
|
-
removeReporter(reporter) {
|
|
294
|
-
if (reporter) {
|
|
295
|
-
const i2 = this.options.reporters.indexOf(reporter);
|
|
296
|
-
if (i2 !== -1) {
|
|
297
|
-
return this.options.reporters.splice(i2, 1);
|
|
298
|
-
}
|
|
299
|
-
} else {
|
|
300
|
-
this.options.reporters.splice(0);
|
|
301
|
-
}
|
|
302
|
-
return this;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
306
|
-
*
|
|
307
|
-
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
308
|
-
* @returns {Consola} The current Consola instance.
|
|
309
|
-
*/
|
|
310
|
-
setReporters(reporters) {
|
|
311
|
-
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
312
|
-
return this;
|
|
313
|
-
}
|
|
314
|
-
wrapAll() {
|
|
315
|
-
this.wrapConsole();
|
|
316
|
-
this.wrapStd();
|
|
317
|
-
}
|
|
318
|
-
restoreAll() {
|
|
319
|
-
this.restoreConsole();
|
|
320
|
-
this.restoreStd();
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Overrides console methods with Consola logging methods for consistent logging.
|
|
324
|
-
*/
|
|
325
|
-
wrapConsole() {
|
|
326
|
-
for (const type in this.options.types) {
|
|
327
|
-
if (!console["__" + type]) {
|
|
328
|
-
console["__" + type] = console[type];
|
|
329
|
-
}
|
|
330
|
-
console[type] = this[type].raw;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Restores the original console methods, removing Consola overrides.
|
|
335
|
-
*/
|
|
336
|
-
restoreConsole() {
|
|
337
|
-
for (const type in this.options.types) {
|
|
338
|
-
if (console["__" + type]) {
|
|
339
|
-
console[type] = console["__" + type];
|
|
340
|
-
delete console["__" + type];
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Overrides standard output and error streams to redirect them through Consola.
|
|
346
|
-
*/
|
|
347
|
-
wrapStd() {
|
|
348
|
-
this._wrapStream(this.options.stdout, "log");
|
|
349
|
-
this._wrapStream(this.options.stderr, "log");
|
|
350
|
-
}
|
|
351
|
-
_wrapStream(stream, type) {
|
|
352
|
-
if (!stream) {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
if (!stream.__write) {
|
|
356
|
-
stream.__write = stream.write;
|
|
357
|
-
}
|
|
358
|
-
stream.write = (data) => {
|
|
359
|
-
this[type].raw(String(data).trim());
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
364
|
-
*/
|
|
365
|
-
restoreStd() {
|
|
366
|
-
this._restoreStream(this.options.stdout);
|
|
367
|
-
this._restoreStream(this.options.stderr);
|
|
368
|
-
}
|
|
369
|
-
_restoreStream(stream) {
|
|
370
|
-
if (!stream) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
if (stream.__write) {
|
|
374
|
-
stream.write = stream.__write;
|
|
375
|
-
delete stream.__write;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Pauses logging, queues incoming logs until resumed.
|
|
380
|
-
*/
|
|
381
|
-
pauseLogs() {
|
|
382
|
-
paused = true;
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Resumes logging, processing any queued logs.
|
|
386
|
-
*/
|
|
387
|
-
resumeLogs() {
|
|
388
|
-
paused = false;
|
|
389
|
-
const _queue = queue.splice(0);
|
|
390
|
-
for (const item of _queue) {
|
|
391
|
-
item[0]._logFn(item[1], item[2]);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Replaces logging methods with mocks if a mock function is provided.
|
|
396
|
-
*
|
|
397
|
-
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
398
|
-
*/
|
|
399
|
-
mockTypes(mockFn) {
|
|
400
|
-
const _mockFn = mockFn || this.options.mockFn;
|
|
401
|
-
this._mockFn = _mockFn;
|
|
402
|
-
if (typeof _mockFn !== "function") {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
for (const type in this.options.types) {
|
|
406
|
-
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
407
|
-
this[type].raw = this[type];
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
_wrapLogFn(defaults, isRaw) {
|
|
411
|
-
return (...args) => {
|
|
412
|
-
if (paused) {
|
|
413
|
-
queue.push([this, defaults, args, isRaw]);
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
return this._logFn(defaults, args, isRaw);
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
_logFn(defaults, args, isRaw) {
|
|
420
|
-
if ((defaults.level || 0) > this.level) {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
const logObj = {
|
|
424
|
-
date: /* @__PURE__ */ new Date(),
|
|
425
|
-
args: [],
|
|
426
|
-
...defaults,
|
|
427
|
-
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
428
|
-
};
|
|
429
|
-
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
430
|
-
Object.assign(logObj, args[0]);
|
|
431
|
-
} else {
|
|
432
|
-
logObj.args = [...args];
|
|
433
|
-
}
|
|
434
|
-
if (logObj.message) {
|
|
435
|
-
logObj.args.unshift(logObj.message);
|
|
436
|
-
delete logObj.message;
|
|
437
|
-
}
|
|
438
|
-
if (logObj.additional) {
|
|
439
|
-
if (!Array.isArray(logObj.additional)) {
|
|
440
|
-
logObj.additional = logObj.additional.split("\n");
|
|
441
|
-
}
|
|
442
|
-
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
443
|
-
delete logObj.additional;
|
|
444
|
-
}
|
|
445
|
-
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
446
|
-
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
447
|
-
const resolveLog = (newLog = false) => {
|
|
448
|
-
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
449
|
-
if (this._lastLog.object && repeated > 0) {
|
|
450
|
-
const args2 = [...this._lastLog.object.args];
|
|
451
|
-
if (repeated > 1) {
|
|
452
|
-
args2.push(`(repeated ${repeated} times)`);
|
|
453
|
-
}
|
|
454
|
-
this._log({ ...this._lastLog.object, args: args2 });
|
|
455
|
-
this._lastLog.count = 1;
|
|
456
|
-
}
|
|
457
|
-
if (newLog) {
|
|
458
|
-
this._lastLog.object = logObj;
|
|
459
|
-
this._log(logObj);
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
clearTimeout(this._lastLog.timeout);
|
|
463
|
-
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
464
|
-
this._lastLog.time = logObj.date;
|
|
465
|
-
if (diffTime < this.options.throttle) {
|
|
466
|
-
try {
|
|
467
|
-
const serializedLog = JSON.stringify([
|
|
468
|
-
logObj.type,
|
|
469
|
-
logObj.tag,
|
|
470
|
-
logObj.args
|
|
471
|
-
]);
|
|
472
|
-
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
473
|
-
this._lastLog.serialized = serializedLog;
|
|
474
|
-
if (isSameLog) {
|
|
475
|
-
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
476
|
-
if (this._lastLog.count > this.options.throttleMin) {
|
|
477
|
-
this._lastLog.timeout = setTimeout(
|
|
478
|
-
resolveLog,
|
|
479
|
-
this.options.throttle
|
|
480
|
-
);
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
} catch {
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
resolveLog(true);
|
|
488
|
-
}
|
|
489
|
-
_log(logObj) {
|
|
490
|
-
for (const reporter of this.options.reporters) {
|
|
491
|
-
reporter.log(logObj, {
|
|
492
|
-
options: this.options
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
498
|
-
if (input === void 0) {
|
|
499
|
-
return defaultLevel;
|
|
500
|
-
}
|
|
501
|
-
if (typeof input === "number") {
|
|
502
|
-
return input;
|
|
503
|
-
}
|
|
504
|
-
if (types[input] && types[input].level !== void 0) {
|
|
505
|
-
return types[input].level;
|
|
506
|
-
}
|
|
507
|
-
return defaultLevel;
|
|
508
|
-
}
|
|
509
|
-
Consola.prototype.add = Consola.prototype.addReporter;
|
|
510
|
-
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
511
|
-
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
512
|
-
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
513
|
-
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
514
|
-
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
515
|
-
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
516
|
-
function createConsola(options = {}) {
|
|
517
|
-
return new Consola(options);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
|
|
521
|
-
import { formatWithOptions } from "util";
|
|
522
|
-
import { sep } from "path";
|
|
523
|
-
function parseStack(stack, message) {
|
|
524
|
-
const cwd = process.cwd() + sep;
|
|
525
|
-
const lines = stack.split("\n").splice(message.split("\n").length).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
|
|
526
|
-
return lines;
|
|
527
|
-
}
|
|
528
|
-
function writeStream(data, stream) {
|
|
529
|
-
const write = stream.__write || stream.write;
|
|
530
|
-
return write.call(stream, data);
|
|
531
|
-
}
|
|
532
|
-
var bracket = (x) => x ? `[${x}]` : "";
|
|
533
|
-
var BasicReporter = class {
|
|
534
|
-
formatStack(stack, message, opts) {
|
|
535
|
-
const indent = " ".repeat(((opts == null ? void 0 : opts.errorLevel) || 0) + 1);
|
|
536
|
-
return indent + parseStack(stack, message).join(`
|
|
537
|
-
${indent}`);
|
|
538
|
-
}
|
|
539
|
-
formatError(err, opts) {
|
|
540
|
-
const message = err.message ?? formatWithOptions(opts, err);
|
|
541
|
-
const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
|
|
542
|
-
const level = (opts == null ? void 0 : opts.errorLevel) || 0;
|
|
543
|
-
const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
|
|
544
|
-
const causedError = err.cause ? "\n\n" + this.formatError(err.cause, { ...opts, errorLevel: level + 1 }) : "";
|
|
545
|
-
return causedPrefix + message + "\n" + stack + causedError;
|
|
546
|
-
}
|
|
547
|
-
formatArgs(args, opts) {
|
|
548
|
-
const _args = args.map((arg) => {
|
|
549
|
-
if (arg && typeof arg.stack === "string") {
|
|
550
|
-
return this.formatError(arg, opts);
|
|
551
|
-
}
|
|
552
|
-
return arg;
|
|
553
|
-
});
|
|
554
|
-
return formatWithOptions(opts, ..._args);
|
|
555
|
-
}
|
|
556
|
-
formatDate(date, opts) {
|
|
557
|
-
return opts.date ? date.toLocaleTimeString() : "";
|
|
558
|
-
}
|
|
559
|
-
filterAndJoin(arr) {
|
|
560
|
-
return arr.filter(Boolean).join(" ");
|
|
561
|
-
}
|
|
562
|
-
formatLogObj(logObj, opts) {
|
|
563
|
-
const message = this.formatArgs(logObj.args, opts);
|
|
564
|
-
if (logObj.type === "box") {
|
|
565
|
-
return "\n" + [
|
|
566
|
-
bracket(logObj.tag),
|
|
567
|
-
logObj.title && logObj.title,
|
|
568
|
-
...message.split("\n")
|
|
569
|
-
].filter(Boolean).map((l2) => " > " + l2).join("\n") + "\n";
|
|
570
|
-
}
|
|
571
|
-
return this.filterAndJoin([
|
|
572
|
-
bracket(logObj.type),
|
|
573
|
-
bracket(logObj.tag),
|
|
574
|
-
message
|
|
575
|
-
]);
|
|
576
|
-
}
|
|
577
|
-
log(logObj, ctx) {
|
|
578
|
-
const line = this.formatLogObj(logObj, {
|
|
579
|
-
columns: ctx.options.stdout.columns || 0,
|
|
580
|
-
...ctx.options.formatOptions
|
|
581
|
-
});
|
|
582
|
-
return writeStream(
|
|
583
|
-
line + "\n",
|
|
584
|
-
logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout
|
|
585
|
-
);
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
// node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
590
|
-
import g$1 from "process";
|
|
591
|
-
|
|
592
|
-
// node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
|
|
593
|
-
import * as tty from "tty";
|
|
594
|
-
var {
|
|
595
|
-
env = {},
|
|
596
|
-
argv = [],
|
|
597
|
-
platform = ""
|
|
598
|
-
} = typeof process === "undefined" ? {} : process;
|
|
599
|
-
var isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
|
|
600
|
-
var isForced = "FORCE_COLOR" in env || argv.includes("--color");
|
|
601
|
-
var isWindows = platform === "win32";
|
|
602
|
-
var isDumbTerminal = env.TERM === "dumb";
|
|
603
|
-
var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
|
|
604
|
-
var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
605
|
-
var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
606
|
-
function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
|
|
607
|
-
return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
608
|
-
}
|
|
609
|
-
function clearBleed(index, string, open, close, replace) {
|
|
610
|
-
return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
|
|
611
|
-
}
|
|
612
|
-
function filterEmpty(open, close, replace = open, at = open.length + 1) {
|
|
613
|
-
return (string) => string || !(string === "" || string === void 0) ? clearBleed(
|
|
614
|
-
("" + string).indexOf(close, at),
|
|
615
|
-
string,
|
|
616
|
-
open,
|
|
617
|
-
close,
|
|
618
|
-
replace
|
|
619
|
-
) : "";
|
|
620
|
-
}
|
|
621
|
-
function init(open, close, replace) {
|
|
622
|
-
return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
|
|
623
|
-
}
|
|
624
|
-
var colorDefs = {
|
|
625
|
-
reset: init(0, 0),
|
|
626
|
-
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
627
|
-
dim: init(2, 22, "\x1B[22m\x1B[2m"),
|
|
628
|
-
italic: init(3, 23),
|
|
629
|
-
underline: init(4, 24),
|
|
630
|
-
inverse: init(7, 27),
|
|
631
|
-
hidden: init(8, 28),
|
|
632
|
-
strikethrough: init(9, 29),
|
|
633
|
-
black: init(30, 39),
|
|
634
|
-
red: init(31, 39),
|
|
635
|
-
green: init(32, 39),
|
|
636
|
-
yellow: init(33, 39),
|
|
637
|
-
blue: init(34, 39),
|
|
638
|
-
magenta: init(35, 39),
|
|
639
|
-
cyan: init(36, 39),
|
|
640
|
-
white: init(37, 39),
|
|
641
|
-
gray: init(90, 39),
|
|
642
|
-
bgBlack: init(40, 49),
|
|
643
|
-
bgRed: init(41, 49),
|
|
644
|
-
bgGreen: init(42, 49),
|
|
645
|
-
bgYellow: init(43, 49),
|
|
646
|
-
bgBlue: init(44, 49),
|
|
647
|
-
bgMagenta: init(45, 49),
|
|
648
|
-
bgCyan: init(46, 49),
|
|
649
|
-
bgWhite: init(47, 49),
|
|
650
|
-
blackBright: init(90, 39),
|
|
651
|
-
redBright: init(91, 39),
|
|
652
|
-
greenBright: init(92, 39),
|
|
653
|
-
yellowBright: init(93, 39),
|
|
654
|
-
blueBright: init(94, 39),
|
|
655
|
-
magentaBright: init(95, 39),
|
|
656
|
-
cyanBright: init(96, 39),
|
|
657
|
-
whiteBright: init(97, 39),
|
|
658
|
-
bgBlackBright: init(100, 49),
|
|
659
|
-
bgRedBright: init(101, 49),
|
|
660
|
-
bgGreenBright: init(102, 49),
|
|
661
|
-
bgYellowBright: init(103, 49),
|
|
662
|
-
bgBlueBright: init(104, 49),
|
|
663
|
-
bgMagentaBright: init(105, 49),
|
|
664
|
-
bgCyanBright: init(106, 49),
|
|
665
|
-
bgWhiteBright: init(107, 49)
|
|
666
|
-
};
|
|
667
|
-
function createColors(useColor = isColorSupported) {
|
|
668
|
-
return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
|
|
669
|
-
}
|
|
670
|
-
var colors = createColors();
|
|
671
|
-
function getColor(color, fallback = "reset") {
|
|
672
|
-
return colors[color] || colors[fallback];
|
|
673
|
-
}
|
|
674
|
-
var ansiRegex = [
|
|
675
|
-
String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,
|
|
676
|
-
String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`
|
|
677
|
-
].join("|");
|
|
678
|
-
function stripAnsi(text) {
|
|
679
|
-
return text.replace(new RegExp(ansiRegex, "g"), "");
|
|
680
|
-
}
|
|
681
|
-
var boxStylePresets = {
|
|
682
|
-
solid: {
|
|
683
|
-
tl: "\u250C",
|
|
684
|
-
tr: "\u2510",
|
|
685
|
-
bl: "\u2514",
|
|
686
|
-
br: "\u2518",
|
|
687
|
-
h: "\u2500",
|
|
688
|
-
v: "\u2502"
|
|
689
|
-
},
|
|
690
|
-
double: {
|
|
691
|
-
tl: "\u2554",
|
|
692
|
-
tr: "\u2557",
|
|
693
|
-
bl: "\u255A",
|
|
694
|
-
br: "\u255D",
|
|
695
|
-
h: "\u2550",
|
|
696
|
-
v: "\u2551"
|
|
697
|
-
},
|
|
698
|
-
doubleSingle: {
|
|
699
|
-
tl: "\u2553",
|
|
700
|
-
tr: "\u2556",
|
|
701
|
-
bl: "\u2559",
|
|
702
|
-
br: "\u255C",
|
|
703
|
-
h: "\u2500",
|
|
704
|
-
v: "\u2551"
|
|
705
|
-
},
|
|
706
|
-
doubleSingleRounded: {
|
|
707
|
-
tl: "\u256D",
|
|
708
|
-
tr: "\u256E",
|
|
709
|
-
bl: "\u2570",
|
|
710
|
-
br: "\u256F",
|
|
711
|
-
h: "\u2500",
|
|
712
|
-
v: "\u2551"
|
|
713
|
-
},
|
|
714
|
-
singleThick: {
|
|
715
|
-
tl: "\u250F",
|
|
716
|
-
tr: "\u2513",
|
|
717
|
-
bl: "\u2517",
|
|
718
|
-
br: "\u251B",
|
|
719
|
-
h: "\u2501",
|
|
720
|
-
v: "\u2503"
|
|
721
|
-
},
|
|
722
|
-
singleDouble: {
|
|
723
|
-
tl: "\u2552",
|
|
724
|
-
tr: "\u2555",
|
|
725
|
-
bl: "\u2558",
|
|
726
|
-
br: "\u255B",
|
|
727
|
-
h: "\u2550",
|
|
728
|
-
v: "\u2502"
|
|
729
|
-
},
|
|
730
|
-
singleDoubleRounded: {
|
|
731
|
-
tl: "\u256D",
|
|
732
|
-
tr: "\u256E",
|
|
733
|
-
bl: "\u2570",
|
|
734
|
-
br: "\u256F",
|
|
735
|
-
h: "\u2550",
|
|
736
|
-
v: "\u2502"
|
|
737
|
-
},
|
|
738
|
-
rounded: {
|
|
739
|
-
tl: "\u256D",
|
|
740
|
-
tr: "\u256E",
|
|
741
|
-
bl: "\u2570",
|
|
742
|
-
br: "\u256F",
|
|
743
|
-
h: "\u2500",
|
|
744
|
-
v: "\u2502"
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
var defaultStyle = {
|
|
748
|
-
borderColor: "white",
|
|
749
|
-
borderStyle: "rounded",
|
|
750
|
-
valign: "center",
|
|
751
|
-
padding: 2,
|
|
752
|
-
marginLeft: 1,
|
|
753
|
-
marginTop: 1,
|
|
754
|
-
marginBottom: 1
|
|
755
|
-
};
|
|
756
|
-
function box(text, _opts = {}) {
|
|
757
|
-
const opts = {
|
|
758
|
-
..._opts,
|
|
759
|
-
style: {
|
|
760
|
-
...defaultStyle,
|
|
761
|
-
..._opts.style
|
|
762
|
-
}
|
|
763
|
-
};
|
|
764
|
-
const textLines = text.split("\n");
|
|
765
|
-
const boxLines = [];
|
|
766
|
-
const _color = getColor(opts.style.borderColor);
|
|
767
|
-
const borderStyle = {
|
|
768
|
-
...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle
|
|
769
|
-
};
|
|
770
|
-
if (_color) {
|
|
771
|
-
for (const key in borderStyle) {
|
|
772
|
-
borderStyle[key] = _color(
|
|
773
|
-
borderStyle[key]
|
|
774
|
-
);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
|
|
778
|
-
const height = textLines.length + paddingOffset;
|
|
779
|
-
const width = Math.max(
|
|
780
|
-
...textLines.map((line) => stripAnsi(line).length),
|
|
781
|
-
opts.title ? stripAnsi(opts.title).length : 0
|
|
782
|
-
) + paddingOffset;
|
|
783
|
-
const widthOffset = width + paddingOffset;
|
|
784
|
-
const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
|
|
785
|
-
if (opts.style.marginTop > 0) {
|
|
786
|
-
boxLines.push("".repeat(opts.style.marginTop));
|
|
787
|
-
}
|
|
788
|
-
if (opts.title) {
|
|
789
|
-
const title = _color ? _color(opts.title) : opts.title;
|
|
790
|
-
const left = borderStyle.h.repeat(
|
|
791
|
-
Math.floor((width - stripAnsi(opts.title).length) / 2)
|
|
792
|
-
);
|
|
793
|
-
const right = borderStyle.h.repeat(
|
|
794
|
-
width - stripAnsi(opts.title).length - stripAnsi(left).length + paddingOffset
|
|
795
|
-
);
|
|
796
|
-
boxLines.push(
|
|
797
|
-
`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`
|
|
798
|
-
);
|
|
799
|
-
} else {
|
|
800
|
-
boxLines.push(
|
|
801
|
-
`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`
|
|
802
|
-
);
|
|
803
|
-
}
|
|
804
|
-
const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
|
|
805
|
-
for (let i2 = 0; i2 < height; i2++) {
|
|
806
|
-
if (i2 < valignOffset || i2 >= valignOffset + textLines.length) {
|
|
807
|
-
boxLines.push(
|
|
808
|
-
`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`
|
|
809
|
-
);
|
|
810
|
-
} else {
|
|
811
|
-
const line = textLines[i2 - valignOffset];
|
|
812
|
-
const left = " ".repeat(paddingOffset);
|
|
813
|
-
const right = " ".repeat(width - stripAnsi(line).length);
|
|
814
|
-
boxLines.push(
|
|
815
|
-
`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`
|
|
816
|
-
);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
boxLines.push(
|
|
820
|
-
`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`
|
|
821
|
-
);
|
|
822
|
-
if (opts.style.marginBottom > 0) {
|
|
823
|
-
boxLines.push("".repeat(opts.style.marginBottom));
|
|
824
|
-
}
|
|
825
|
-
return boxLines.join("\n");
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
// node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
|
|
829
|
-
import "util";
|
|
830
|
-
import "path";
|
|
831
|
-
import "tty";
|
|
832
|
-
var r = /* @__PURE__ */ Object.create(null);
|
|
833
|
-
var i = (e) => {
|
|
834
|
-
var _a8, _b5;
|
|
835
|
-
return ((_a8 = globalThis.process) == null ? void 0 : _a8.env) || import.meta.env || ((_b5 = globalThis.Deno) == null ? void 0 : _b5.env.toObject()) || globalThis.__env__ || (e ? r : globalThis);
|
|
836
|
-
};
|
|
837
|
-
var o = new Proxy(r, { get(e, s2) {
|
|
838
|
-
return i()[s2] ?? r[s2];
|
|
839
|
-
}, has(e, s2) {
|
|
840
|
-
const E = i();
|
|
841
|
-
return s2 in E || s2 in r;
|
|
842
|
-
}, set(e, s2, E) {
|
|
843
|
-
const B = i(true);
|
|
844
|
-
return B[s2] = E, true;
|
|
845
|
-
}, deleteProperty(e, s2) {
|
|
846
|
-
if (!s2) return false;
|
|
847
|
-
const E = i(true);
|
|
848
|
-
return delete E[s2], true;
|
|
849
|
-
}, ownKeys() {
|
|
850
|
-
const e = i(true);
|
|
851
|
-
return Object.keys(e);
|
|
852
|
-
} });
|
|
853
|
-
var t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
|
|
854
|
-
var f = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
|
|
855
|
-
function b() {
|
|
856
|
-
var _a8, _b5, _c, _d, _e, _f;
|
|
857
|
-
if ((_a8 = globalThis.process) == null ? void 0 : _a8.env) for (const e of f) {
|
|
858
|
-
const s2 = e[1] || e[0];
|
|
859
|
-
if ((_b5 = globalThis.process) == null ? void 0 : _b5.env[s2]) return { name: e[0].toLowerCase(), ...e[2] };
|
|
860
|
-
}
|
|
861
|
-
return ((_d = (_c = globalThis.process) == null ? void 0 : _c.env) == null ? void 0 : _d.SHELL) === "/bin/jsh" && ((_f = (_e = globalThis.process) == null ? void 0 : _e.versions) == null ? void 0 : _f.webcontainer) ? { name: "stackblitz", ci: false } : { name: "", ci: false };
|
|
862
|
-
}
|
|
863
|
-
var l = b();
|
|
864
|
-
l.name;
|
|
865
|
-
function n(e) {
|
|
866
|
-
return e ? e !== "false" : false;
|
|
867
|
-
}
|
|
868
|
-
var _a;
|
|
869
|
-
var I = ((_a = globalThis.process) == null ? void 0 : _a.platform) || "";
|
|
870
|
-
var T = n(o.CI) || l.ci !== false;
|
|
871
|
-
var _a2, _b;
|
|
872
|
-
var a = n(((_a2 = globalThis.process) == null ? void 0 : _a2.stdout) && ((_b = globalThis.process) == null ? void 0 : _b.stdout.isTTY));
|
|
873
|
-
var g = n(o.DEBUG);
|
|
874
|
-
var R = t === "test" || n(o.TEST);
|
|
875
|
-
n(o.MINIMAL) || T || R || !a;
|
|
876
|
-
var A = /^win/i.test(I);
|
|
877
|
-
!n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM !== "dumb" || T);
|
|
878
|
-
var _a3, _b2;
|
|
879
|
-
var C = (((_b2 = (_a3 = globalThis.process) == null ? void 0 : _a3.versions) == null ? void 0 : _b2.node) || "").replace(/^v/, "") || null;
|
|
880
|
-
Number(C == null ? void 0 : C.split(".")[0]) || null;
|
|
881
|
-
var y = globalThis.process || /* @__PURE__ */ Object.create(null);
|
|
882
|
-
var _ = { versions: {} };
|
|
883
|
-
new Proxy(y, { get(e, s2) {
|
|
884
|
-
if (s2 === "env") return o;
|
|
885
|
-
if (s2 in e) return e[s2];
|
|
886
|
-
if (s2 in _) return _[s2];
|
|
887
|
-
} });
|
|
888
|
-
var _a4, _b3;
|
|
889
|
-
var c = ((_b3 = (_a4 = globalThis.process) == null ? void 0 : _a4.release) == null ? void 0 : _b3.name) === "node";
|
|
890
|
-
var _a5, _b4;
|
|
891
|
-
var O = !!globalThis.Bun || !!((_b4 = (_a5 = globalThis.process) == null ? void 0 : _a5.versions) == null ? void 0 : _b4.bun);
|
|
892
|
-
var D = !!globalThis.Deno;
|
|
893
|
-
var L = !!globalThis.fastly;
|
|
894
|
-
var S = !!globalThis.Netlify;
|
|
895
|
-
var u = !!globalThis.EdgeRuntime;
|
|
896
|
-
var _a6;
|
|
897
|
-
var N = ((_a6 = globalThis.navigator) == null ? void 0 : _a6.userAgent) === "Cloudflare-Workers";
|
|
898
|
-
var F = [[S, "netlify"], [u, "edge-light"], [N, "workerd"], [L, "fastly"], [D, "deno"], [O, "bun"], [c, "node"]];
|
|
899
|
-
function G() {
|
|
900
|
-
const e = F.find((s2) => s2[0]);
|
|
901
|
-
if (e) return { name: e[1] };
|
|
902
|
-
}
|
|
903
|
-
var P = G();
|
|
904
|
-
(P == null ? void 0 : P.name) || "";
|
|
905
|
-
function ansiRegex2({ onlyFirst = false } = {}) {
|
|
906
|
-
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
907
|
-
const pattern = [
|
|
908
|
-
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
909
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
910
|
-
].join("|");
|
|
911
|
-
return new RegExp(pattern, onlyFirst ? void 0 : "g");
|
|
912
|
-
}
|
|
913
|
-
var regex = ansiRegex2();
|
|
914
|
-
function stripAnsi2(string) {
|
|
915
|
-
if (typeof string !== "string") {
|
|
916
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
917
|
-
}
|
|
918
|
-
return string.replace(regex, "");
|
|
919
|
-
}
|
|
920
|
-
function isAmbiguous(x) {
|
|
921
|
-
return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
|
|
922
|
-
}
|
|
923
|
-
function isFullWidth(x) {
|
|
924
|
-
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
925
|
-
}
|
|
926
|
-
function isWide(x) {
|
|
927
|
-
return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
|
|
928
|
-
}
|
|
929
|
-
function validate(codePoint) {
|
|
930
|
-
if (!Number.isSafeInteger(codePoint)) {
|
|
931
|
-
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
|
|
935
|
-
validate(codePoint);
|
|
936
|
-
if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
|
|
937
|
-
return 2;
|
|
938
|
-
}
|
|
939
|
-
return 1;
|
|
940
|
-
}
|
|
941
|
-
var emojiRegex = () => {
|
|
942
|
-
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
943
|
-
};
|
|
944
|
-
var _a7;
|
|
945
|
-
var segmenter = ((_a7 = globalThis.Intl) == null ? void 0 : _a7.Segmenter) ? new Intl.Segmenter() : { segment: (str) => str.split("") };
|
|
946
|
-
var defaultIgnorableCodePointRegex = new RegExp("^\\p{Default_Ignorable_Code_Point}$", "u");
|
|
947
|
-
function stringWidth$1(string, options = {}) {
|
|
948
|
-
if (typeof string !== "string" || string.length === 0) {
|
|
949
|
-
return 0;
|
|
950
|
-
}
|
|
951
|
-
const {
|
|
952
|
-
ambiguousIsNarrow = true,
|
|
953
|
-
countAnsiEscapeCodes = false
|
|
954
|
-
} = options;
|
|
955
|
-
if (!countAnsiEscapeCodes) {
|
|
956
|
-
string = stripAnsi2(string);
|
|
957
|
-
}
|
|
958
|
-
if (string.length === 0) {
|
|
959
|
-
return 0;
|
|
960
|
-
}
|
|
961
|
-
let width = 0;
|
|
962
|
-
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
963
|
-
for (const { segment: character } of segmenter.segment(string)) {
|
|
964
|
-
const codePoint = character.codePointAt(0);
|
|
965
|
-
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
966
|
-
continue;
|
|
967
|
-
}
|
|
968
|
-
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
|
|
969
|
-
continue;
|
|
970
|
-
}
|
|
971
|
-
if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) {
|
|
972
|
-
continue;
|
|
973
|
-
}
|
|
974
|
-
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
975
|
-
continue;
|
|
976
|
-
}
|
|
977
|
-
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
978
|
-
continue;
|
|
979
|
-
}
|
|
980
|
-
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
981
|
-
continue;
|
|
982
|
-
}
|
|
983
|
-
if (emojiRegex().test(character)) {
|
|
984
|
-
width += 2;
|
|
985
|
-
continue;
|
|
986
|
-
}
|
|
987
|
-
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
988
|
-
}
|
|
989
|
-
return width;
|
|
990
|
-
}
|
|
991
|
-
function isUnicodeSupported() {
|
|
992
|
-
const { env: env2 } = g$1;
|
|
993
|
-
const { TERM, TERM_PROGRAM } = env2;
|
|
994
|
-
if (g$1.platform !== "win32") {
|
|
995
|
-
return TERM !== "linux";
|
|
996
|
-
}
|
|
997
|
-
return Boolean(env2.WT_SESSION) || Boolean(env2.TERMINUS_SUBLIME) || env2.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env2.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
998
|
-
}
|
|
999
|
-
var TYPE_COLOR_MAP = {
|
|
1000
|
-
info: "cyan",
|
|
1001
|
-
fail: "red",
|
|
1002
|
-
success: "green",
|
|
1003
|
-
ready: "green",
|
|
1004
|
-
start: "magenta"
|
|
1005
|
-
};
|
|
1006
|
-
var LEVEL_COLOR_MAP = {
|
|
1007
|
-
0: "red",
|
|
1008
|
-
1: "yellow"
|
|
1009
|
-
};
|
|
1010
|
-
var unicode = isUnicodeSupported();
|
|
1011
|
-
var s = (c2, fallback) => unicode ? c2 : fallback;
|
|
1012
|
-
var TYPE_ICONS = {
|
|
1013
|
-
error: s("\u2716", "\xD7"),
|
|
1014
|
-
fatal: s("\u2716", "\xD7"),
|
|
1015
|
-
ready: s("\u2714", "\u221A"),
|
|
1016
|
-
warn: s("\u26A0", "\u203C"),
|
|
1017
|
-
info: s("\u2139", "i"),
|
|
1018
|
-
success: s("\u2714", "\u221A"),
|
|
1019
|
-
debug: s("\u2699", "D"),
|
|
1020
|
-
trace: s("\u2192", "\u2192"),
|
|
1021
|
-
fail: s("\u2716", "\xD7"),
|
|
1022
|
-
start: s("\u25D0", "o"),
|
|
1023
|
-
log: ""
|
|
1024
|
-
};
|
|
1025
|
-
function stringWidth(str) {
|
|
1026
|
-
const hasICU = typeof Intl === "object";
|
|
1027
|
-
if (!hasICU || !Intl.Segmenter) {
|
|
1028
|
-
return stripAnsi(str).length;
|
|
1029
|
-
}
|
|
1030
|
-
return stringWidth$1(str);
|
|
1031
|
-
}
|
|
1032
|
-
var FancyReporter = class extends BasicReporter {
|
|
1033
|
-
formatStack(stack, message, opts) {
|
|
1034
|
-
const indent = " ".repeat(((opts == null ? void 0 : opts.errorLevel) || 0) + 1);
|
|
1035
|
-
return `
|
|
1036
|
-
${indent}` + parseStack(stack, message).map(
|
|
1037
|
-
(line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_2, m) => `(${colors.cyan(m)})`)
|
|
1038
|
-
).join(`
|
|
1039
|
-
${indent}`);
|
|
1040
|
-
}
|
|
1041
|
-
formatType(logObj, isBadge, opts) {
|
|
1042
|
-
const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
|
|
1043
|
-
if (isBadge) {
|
|
1044
|
-
return getBgColor(typeColor)(
|
|
1045
|
-
colors.black(` ${logObj.type.toUpperCase()} `)
|
|
1046
|
-
);
|
|
1047
|
-
}
|
|
1048
|
-
const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
|
|
1049
|
-
return _type ? getColor2(typeColor)(_type) : "";
|
|
1050
|
-
}
|
|
1051
|
-
formatLogObj(logObj, opts) {
|
|
1052
|
-
const [message, ...additional] = this.formatArgs(logObj.args, opts).split(
|
|
1053
|
-
"\n"
|
|
1054
|
-
);
|
|
1055
|
-
if (logObj.type === "box") {
|
|
1056
|
-
return box(
|
|
1057
|
-
characterFormat(
|
|
1058
|
-
message + (additional.length > 0 ? "\n" + additional.join("\n") : "")
|
|
1059
|
-
),
|
|
1060
|
-
{
|
|
1061
|
-
title: logObj.title ? characterFormat(logObj.title) : void 0,
|
|
1062
|
-
style: logObj.style
|
|
1063
|
-
}
|
|
1064
|
-
);
|
|
1065
|
-
}
|
|
1066
|
-
const date = this.formatDate(logObj.date, opts);
|
|
1067
|
-
const coloredDate = date && colors.gray(date);
|
|
1068
|
-
const isBadge = logObj.badge ?? logObj.level < 2;
|
|
1069
|
-
const type = this.formatType(logObj, isBadge, opts);
|
|
1070
|
-
const tag = logObj.tag ? colors.gray(logObj.tag) : "";
|
|
1071
|
-
let line;
|
|
1072
|
-
const left = this.filterAndJoin([type, characterFormat(message)]);
|
|
1073
|
-
const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
|
|
1074
|
-
const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
|
|
1075
|
-
line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
|
|
1076
|
-
line += characterFormat(
|
|
1077
|
-
additional.length > 0 ? "\n" + additional.join("\n") : ""
|
|
1078
|
-
);
|
|
1079
|
-
if (logObj.type === "trace") {
|
|
1080
|
-
const _err = new Error("Trace: " + logObj.message);
|
|
1081
|
-
line += this.formatStack(_err.stack || "", _err.message);
|
|
1082
|
-
}
|
|
1083
|
-
return isBadge ? "\n" + line + "\n" : line;
|
|
1084
|
-
}
|
|
1085
|
-
};
|
|
1086
|
-
function characterFormat(str) {
|
|
1087
|
-
return str.replace(/`([^`]+)`/gm, (_2, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_2, m) => ` ${colors.underline(m)} `);
|
|
1088
|
-
}
|
|
1089
|
-
function getColor2(color = "white") {
|
|
1090
|
-
return colors[color] || colors.white;
|
|
1091
|
-
}
|
|
1092
|
-
function getBgColor(color = "bgWhite") {
|
|
1093
|
-
return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
|
|
1094
|
-
}
|
|
1095
|
-
function createConsola2(options = {}) {
|
|
1096
|
-
let level = _getDefaultLogLevel();
|
|
1097
|
-
if (process.env.CONSOLA_LEVEL) {
|
|
1098
|
-
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
1099
|
-
}
|
|
1100
|
-
const consola2 = createConsola({
|
|
1101
|
-
level,
|
|
1102
|
-
defaults: { level },
|
|
1103
|
-
stdout: process.stdout,
|
|
1104
|
-
stderr: process.stderr,
|
|
1105
|
-
prompt: (...args) => import("./prompt-BN7TR4PR.js").then((m) => m.prompt(...args)),
|
|
1106
|
-
reporters: options.reporters || [
|
|
1107
|
-
options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()
|
|
1108
|
-
],
|
|
1109
|
-
...options
|
|
1110
|
-
});
|
|
1111
|
-
return consola2;
|
|
1112
|
-
}
|
|
1113
|
-
function _getDefaultLogLevel() {
|
|
1114
|
-
if (g) {
|
|
1115
|
-
return LogLevels.debug;
|
|
1116
|
-
}
|
|
1117
|
-
if (R) {
|
|
1118
|
-
return LogLevels.warn;
|
|
1119
|
-
}
|
|
1120
|
-
return LogLevels.info;
|
|
1121
|
-
}
|
|
1122
|
-
var consola = createConsola2();
|
|
1123
|
-
|
|
1124
|
-
// src/git.ts
|
|
5
|
+
import { ofetch } from "ofetch";
|
|
6
|
+
import { consola } from "consola";
|
|
1125
7
|
import semver from "semver";
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { convert } from "convert-gitmoji";
|
|
1126
10
|
|
|
1127
|
-
|
|
11
|
+
//#region src/shared.ts
|
|
1128
12
|
async function execCommand(cmd, args, options) {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
return ((_a8 = res == null ? void 0 : res.stdout) == null ? void 0 : _a8.trim()) || "";
|
|
13
|
+
const { execa } = await import("execa");
|
|
14
|
+
const res = await execa(cmd, args, options);
|
|
15
|
+
return (res?.stdout)?.trim() || "";
|
|
1133
16
|
}
|
|
1134
17
|
function notNullish(v) {
|
|
1135
|
-
|
|
18
|
+
return v !== null && v !== void 0;
|
|
1136
19
|
}
|
|
1137
20
|
function partition(array, ...filters) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
21
|
+
const result = Array.from({ length: filters.length + 1 }).fill(null).map(() => []);
|
|
22
|
+
array.forEach((e, idx, arr) => {
|
|
23
|
+
let i = 0;
|
|
24
|
+
for (const filter of filters) {
|
|
25
|
+
if (filter(e, idx, arr)) {
|
|
26
|
+
result[i].push(e);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
i += 1;
|
|
30
|
+
}
|
|
31
|
+
result[i].push(e);
|
|
32
|
+
});
|
|
33
|
+
return result;
|
|
1151
34
|
}
|
|
1152
35
|
function groupBy(items, key, groups = {}) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
const v = item[key];
|
|
38
|
+
groups[v] ||= [];
|
|
39
|
+
groups[v].push(item);
|
|
40
|
+
}
|
|
41
|
+
return groups;
|
|
1159
42
|
}
|
|
1160
43
|
function capitalize(str) {
|
|
1161
|
-
|
|
44
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1162
45
|
}
|
|
1163
46
|
function join(array, glue = ", ", finalGlue = " and ") {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
47
|
+
if (!array || array.length === 0) return "";
|
|
48
|
+
if (array.length === 1) return array[0];
|
|
49
|
+
if (array.length === 2) return array.join(finalGlue);
|
|
50
|
+
return `${array.slice(0, -1).join(glue)}${finalGlue}${array.slice(-1)}`;
|
|
1168
51
|
}
|
|
1169
52
|
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/constant.ts
|
|
55
|
+
const VERSION_REG = /^v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
56
|
+
const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?]/g;
|
|
57
|
+
const VERSION_WITH_RELEASE = /release\sv\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
1174
58
|
|
|
1175
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/git.ts
|
|
61
|
+
/** Get the total git tags */
|
|
1176
62
|
async function getTotalGitTags() {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
63
|
+
const tagStr = await execCommand("git", [
|
|
64
|
+
"--no-pager",
|
|
65
|
+
"tag",
|
|
66
|
+
"-l",
|
|
67
|
+
"--sort=v:refname"
|
|
68
|
+
]);
|
|
69
|
+
const tags = tagStr.split("\n");
|
|
70
|
+
const filtered = tags.filter((tag) => VERSION_REG.test(tag));
|
|
71
|
+
return semver.sort(filtered);
|
|
72
|
+
}
|
|
73
|
+
/** Get map of the git tag and date */
|
|
1182
74
|
async function getTagDateMap() {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
75
|
+
const tagDateStr = await execCommand("git", [
|
|
76
|
+
"--no-pager",
|
|
77
|
+
"log",
|
|
78
|
+
"--tags",
|
|
79
|
+
"--simplify-by-decoration",
|
|
80
|
+
"--pretty=format:%ci %d"
|
|
81
|
+
]);
|
|
82
|
+
const TAG_MARK = "tag: ";
|
|
83
|
+
const map = /* @__PURE__ */ new Map();
|
|
84
|
+
const dates = tagDateStr.split("\n").filter((item) => item.includes(TAG_MARK));
|
|
85
|
+
dates.forEach((item) => {
|
|
86
|
+
const [dateStr, tagStr] = item.split(TAG_MARK);
|
|
87
|
+
const date = dayjs(dateStr).format("YYYY-MM-DD");
|
|
88
|
+
const tag = tagStr.match(VERSION_REG)?.[0];
|
|
89
|
+
if (tag && date) map.set(tag.trim(), date);
|
|
90
|
+
});
|
|
91
|
+
return map;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the git tags by formatting from-to style
|
|
95
|
+
*
|
|
96
|
+
* @param tags Git tags
|
|
97
|
+
*/
|
|
1204
98
|
function getFromToTags(tags) {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
99
|
+
const result = [];
|
|
100
|
+
if (tags.length < 2) return result;
|
|
101
|
+
const releaseTags = tags.filter((tag) => !isPrerelease(tag));
|
|
102
|
+
const reversedTags = [...tags].reverse();
|
|
103
|
+
reversedTags.forEach((tag, index) => {
|
|
104
|
+
if (index < reversedTags.length - 1) {
|
|
105
|
+
const to = tag;
|
|
106
|
+
let from = reversedTags[index + 1];
|
|
107
|
+
if (!isPrerelease(to)) {
|
|
108
|
+
const toIndex = releaseTags.indexOf(to);
|
|
109
|
+
from = releaseTags[toIndex - 1];
|
|
110
|
+
}
|
|
111
|
+
result.push({
|
|
112
|
+
from,
|
|
113
|
+
to
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return result.reverse();
|
|
1223
118
|
}
|
|
1224
119
|
async function getGitMainBranchName() {
|
|
1225
|
-
|
|
1226
|
-
|
|
120
|
+
const main = await execCommand("git", [
|
|
121
|
+
"rev-parse",
|
|
122
|
+
"--abbrev-ref",
|
|
123
|
+
"HEAD"
|
|
124
|
+
]);
|
|
125
|
+
return main;
|
|
1227
126
|
}
|
|
1228
127
|
async function getCurrentGitBranch() {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
128
|
+
const tag = await execCommand("git", [
|
|
129
|
+
"tag",
|
|
130
|
+
"--points-at",
|
|
131
|
+
"HEAD"
|
|
132
|
+
]);
|
|
133
|
+
const main = getGitMainBranchName();
|
|
134
|
+
return tag || main;
|
|
1232
135
|
}
|
|
1233
136
|
async function getGitHubRepo() {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
137
|
+
const url = await execCommand("git", [
|
|
138
|
+
"config",
|
|
139
|
+
"--get",
|
|
140
|
+
"remote.origin.url"
|
|
141
|
+
]);
|
|
142
|
+
const match = url.match(/github\.com[/:]([\w\d._-]+?)\/([\w\d._-]+?)(\.git)?$/i);
|
|
143
|
+
if (!match) throw new Error(`Can not parse GitHub repo from url ${url}`);
|
|
144
|
+
return `${match[1]}/${match[2]}`;
|
|
1240
145
|
}
|
|
1241
146
|
function isPrerelease(version) {
|
|
1242
|
-
|
|
1243
|
-
|
|
147
|
+
const REG = /^[^.]*[\d.]+$/;
|
|
148
|
+
return !REG.test(version);
|
|
1244
149
|
}
|
|
1245
150
|
function getFirstGitCommit() {
|
|
1246
|
-
|
|
151
|
+
return execCommand("git", [
|
|
152
|
+
"rev-list",
|
|
153
|
+
"--max-parents=0",
|
|
154
|
+
"HEAD"
|
|
155
|
+
]);
|
|
1247
156
|
}
|
|
1248
157
|
async function getGitDiff(from, to = "HEAD") {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
158
|
+
const rawGit = await execCommand("git", [
|
|
159
|
+
"--no-pager",
|
|
160
|
+
"log",
|
|
161
|
+
`${from ? `${from}...` : ""}${to}`,
|
|
162
|
+
"--pretty=\"----%n%s|%h|%an|%ae%n%b\"",
|
|
163
|
+
"--name-status"
|
|
164
|
+
]);
|
|
165
|
+
const rwaGitLines = rawGit.split("----\n").splice(1);
|
|
166
|
+
const gitCommits = rwaGitLines.map((line) => {
|
|
167
|
+
const [firstLine, ...body] = line.split("\n");
|
|
168
|
+
const [message, shortHash, authorName, authorEmail] = firstLine.split("|");
|
|
169
|
+
const gitCommit = {
|
|
170
|
+
message,
|
|
171
|
+
shortHash,
|
|
172
|
+
author: {
|
|
173
|
+
name: authorName,
|
|
174
|
+
email: authorEmail
|
|
175
|
+
},
|
|
176
|
+
body: body.join("\n")
|
|
177
|
+
};
|
|
178
|
+
return gitCommit;
|
|
179
|
+
});
|
|
180
|
+
return gitCommits;
|
|
1269
181
|
}
|
|
1270
182
|
function parseGitCommit(commit) {
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
183
|
+
const ConventionalCommitRegex = /(?<type>[a-z]+)(\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
184
|
+
const CoAuthoredByRegex = /co-authored-by:\s*(?<name>.+)(<(?<email>.+)>)/gim;
|
|
185
|
+
const PullRequestRE = /\([a-z]*(#\d+)\s*\)/gm;
|
|
186
|
+
const IssueRE = /(#\d+)/gm;
|
|
187
|
+
const match = commit.message.match(ConventionalCommitRegex);
|
|
188
|
+
if (!match?.groups) return null;
|
|
189
|
+
const type = match.groups.type;
|
|
190
|
+
const scope = match.groups.scope || "";
|
|
191
|
+
const isBreaking = Boolean(match.groups.breaking);
|
|
192
|
+
let description = match.groups.description;
|
|
193
|
+
const references = [];
|
|
194
|
+
for (const m of description.matchAll(PullRequestRE)) references.push({
|
|
195
|
+
type: "pull-request",
|
|
196
|
+
value: m[1]
|
|
197
|
+
});
|
|
198
|
+
for (const m of description.matchAll(IssueRE)) if (!references.some((i) => i.value === m[1])) references.push({
|
|
199
|
+
type: "issue",
|
|
200
|
+
value: m[1]
|
|
201
|
+
});
|
|
202
|
+
references.push({
|
|
203
|
+
value: commit.shortHash,
|
|
204
|
+
type: "hash"
|
|
205
|
+
});
|
|
206
|
+
description = description.replace(PullRequestRE, "").trim();
|
|
207
|
+
const authors = [commit.author];
|
|
208
|
+
const matches = commit.body.matchAll(CoAuthoredByRegex);
|
|
209
|
+
for (const $match of matches) {
|
|
210
|
+
const { name = "", email = "" } = $match.groups || {};
|
|
211
|
+
const author = {
|
|
212
|
+
name: name.trim(),
|
|
213
|
+
email: email.trim()
|
|
214
|
+
};
|
|
215
|
+
authors.push(author);
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
...commit,
|
|
219
|
+
authors,
|
|
220
|
+
resolvedAuthors: [],
|
|
221
|
+
description,
|
|
222
|
+
type,
|
|
223
|
+
scope,
|
|
224
|
+
references,
|
|
225
|
+
isBreaking
|
|
226
|
+
};
|
|
1314
227
|
}
|
|
1315
228
|
async function getGitCommits(from, to = "HEAD") {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
229
|
+
const rwaGitCommits = await getGitDiff(from, to);
|
|
230
|
+
const commits = rwaGitCommits.map((commit) => parseGitCommit(commit)).filter(notNullish);
|
|
231
|
+
return commits;
|
|
1319
232
|
}
|
|
1320
233
|
function getHeaders(githubToken) {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
234
|
+
return {
|
|
235
|
+
accept: "application/vnd.github.v3+json",
|
|
236
|
+
authorization: `token ${githubToken}`
|
|
237
|
+
};
|
|
1325
238
|
}
|
|
1326
239
|
async function getResolvedAuthorLogin(github, commitHashes, email) {
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}
|
|
1352
|
-
if (login) {
|
|
1353
|
-
return login;
|
|
1354
|
-
}
|
|
1355
|
-
try {
|
|
1356
|
-
const data = await ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`, {
|
|
1357
|
-
headers: getHeaders(token)
|
|
1358
|
-
});
|
|
1359
|
-
login = data.items[0].login;
|
|
1360
|
-
} catch (e) {
|
|
1361
|
-
consola.log("e: ", e);
|
|
1362
|
-
}
|
|
1363
|
-
return login;
|
|
240
|
+
let login = "";
|
|
241
|
+
try {
|
|
242
|
+
const data = await ofetch(`https://ungh.cc/users/find/${email}`);
|
|
243
|
+
login = data?.user?.username || "";
|
|
244
|
+
} catch (e) {
|
|
245
|
+
consola.log("e: ", e);
|
|
246
|
+
}
|
|
247
|
+
if (login) return login;
|
|
248
|
+
const { repo, token } = github;
|
|
249
|
+
if (!token) return login;
|
|
250
|
+
if (commitHashes.length) try {
|
|
251
|
+
const data = await ofetch(`https://api.github.com/repos/${repo}/commits/${commitHashes[0]}`, { headers: getHeaders(token) });
|
|
252
|
+
login = data?.author?.login || "";
|
|
253
|
+
} catch (e) {
|
|
254
|
+
consola.log("e: ", e);
|
|
255
|
+
}
|
|
256
|
+
if (login) return login;
|
|
257
|
+
try {
|
|
258
|
+
const data = await ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`, { headers: getHeaders(token) });
|
|
259
|
+
login = data.items[0].login;
|
|
260
|
+
} catch (e) {
|
|
261
|
+
consola.log("e: ", e);
|
|
262
|
+
}
|
|
263
|
+
return login;
|
|
1364
264
|
}
|
|
1365
265
|
async function getGitCommitsAndResolvedAuthors(commits, github, resolvedLogins) {
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
};
|
|
266
|
+
const resultCommits = [];
|
|
267
|
+
const map = /* @__PURE__ */ new Map();
|
|
268
|
+
for await (const commit of commits) {
|
|
269
|
+
const resolvedAuthors = [];
|
|
270
|
+
for await (const [index, author] of commit.authors.entries()) {
|
|
271
|
+
const { email, name } = author;
|
|
272
|
+
if (email && name) {
|
|
273
|
+
const commitHashes = [];
|
|
274
|
+
if (index === 0) commitHashes.push(commit.shortHash);
|
|
275
|
+
const resolvedAuthor = {
|
|
276
|
+
name,
|
|
277
|
+
email,
|
|
278
|
+
commits: commitHashes,
|
|
279
|
+
login: ""
|
|
280
|
+
};
|
|
281
|
+
if (!resolvedLogins?.has(email)) {
|
|
282
|
+
const login = await getResolvedAuthorLogin(github, commitHashes, email);
|
|
283
|
+
resolvedAuthor.login = login;
|
|
284
|
+
resolvedLogins?.set(email, login);
|
|
285
|
+
} else {
|
|
286
|
+
const login = resolvedLogins?.get(email) || "";
|
|
287
|
+
resolvedAuthor.login = login;
|
|
288
|
+
}
|
|
289
|
+
resolvedAuthors.push(resolvedAuthor);
|
|
290
|
+
if (!map.has(email)) map.set(email, resolvedAuthor);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const resultCommit = {
|
|
294
|
+
...commit,
|
|
295
|
+
resolvedAuthors
|
|
296
|
+
};
|
|
297
|
+
resultCommits.push(resultCommit);
|
|
298
|
+
}
|
|
299
|
+
return {
|
|
300
|
+
commits: resultCommits,
|
|
301
|
+
contributors: Array.from(map.values())
|
|
302
|
+
};
|
|
1404
303
|
}
|
|
1405
304
|
|
|
1406
|
-
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region src/options.ts
|
|
1407
307
|
function createDefaultOptions() {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
};
|
|
1442
|
-
return options;
|
|
308
|
+
const cwd = process.cwd();
|
|
309
|
+
const options = {
|
|
310
|
+
cwd,
|
|
311
|
+
types: {
|
|
312
|
+
feat: "🚀 Features",
|
|
313
|
+
fix: "🐞 Bug Fixes",
|
|
314
|
+
perf: "🔥 Performance",
|
|
315
|
+
optimize: "🛠 Optimizations",
|
|
316
|
+
refactor: "💅 Refactors",
|
|
317
|
+
docs: "📖 Documentation",
|
|
318
|
+
build: "📦 Build",
|
|
319
|
+
types: "🌊 Types",
|
|
320
|
+
chore: "🏡 Chore",
|
|
321
|
+
examples: "🏀 Examples",
|
|
322
|
+
test: "✅ Tests",
|
|
323
|
+
style: "🎨 Styles",
|
|
324
|
+
ci: "🤖 CI"
|
|
325
|
+
},
|
|
326
|
+
github: {
|
|
327
|
+
repo: "",
|
|
328
|
+
token: process.env.GITHUB_TOKEN || ""
|
|
329
|
+
},
|
|
330
|
+
from: "",
|
|
331
|
+
to: "",
|
|
332
|
+
tags: [],
|
|
333
|
+
tagDateMap: /* @__PURE__ */ new Map(),
|
|
334
|
+
capitalize: false,
|
|
335
|
+
emoji: true,
|
|
336
|
+
titles: { breakingChanges: "🚨 Breaking Changes" },
|
|
337
|
+
output: "CHANGELOG.md",
|
|
338
|
+
regenerate: false
|
|
339
|
+
};
|
|
340
|
+
return options;
|
|
1443
341
|
}
|
|
1444
342
|
async function getVersionFromPkgJson(cwd) {
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
return {
|
|
1453
|
-
newVersion
|
|
1454
|
-
};
|
|
343
|
+
let newVersion = "";
|
|
344
|
+
try {
|
|
345
|
+
const pkgJson = await readFile(`${cwd}/package.json`, "utf-8");
|
|
346
|
+
const pkg = JSON.parse(pkgJson);
|
|
347
|
+
newVersion = pkg?.version || "";
|
|
348
|
+
} catch {}
|
|
349
|
+
return { newVersion };
|
|
1455
350
|
}
|
|
1456
351
|
async function createOptions(options) {
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
return opts;
|
|
352
|
+
const opts = createDefaultOptions();
|
|
353
|
+
Object.assign(opts, options);
|
|
354
|
+
const { newVersion } = await getVersionFromPkgJson(opts.cwd);
|
|
355
|
+
opts.github.repo ||= await getGitHubRepo();
|
|
356
|
+
const tags = await getTotalGitTags();
|
|
357
|
+
opts.tags = tags;
|
|
358
|
+
opts.from ||= tags[tags.length - 1];
|
|
359
|
+
opts.to ||= `v${newVersion}`;
|
|
360
|
+
if (opts.to === opts.from) {
|
|
361
|
+
const lastTag = tags[tags.length - 2];
|
|
362
|
+
const firstCommit = await getFirstGitCommit();
|
|
363
|
+
opts.from = lastTag || firstCommit;
|
|
364
|
+
}
|
|
365
|
+
opts.tagDateMap = await getTagDateMap();
|
|
366
|
+
opts.prerelease ||= isPrerelease(opts.to);
|
|
367
|
+
const isFromPrerelease = isPrerelease(opts.from);
|
|
368
|
+
if (!isPrerelease(newVersion) && isFromPrerelease) {
|
|
369
|
+
const allReleaseTags = opts.tags.filter((tag) => !isPrerelease(tag) && tag !== opts.to);
|
|
370
|
+
opts.from = allReleaseTags[allReleaseTags.length - 1];
|
|
371
|
+
}
|
|
372
|
+
return opts;
|
|
1479
373
|
}
|
|
1480
374
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
import { readFile as readFile2, writeFile } from "fs/promises";
|
|
1484
|
-
import dayjs2 from "dayjs";
|
|
1485
|
-
import { convert } from "convert-gitmoji";
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/markdown.ts
|
|
1486
377
|
function formatReferences(references, githubRepo, type) {
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
return referencesString;
|
|
378
|
+
const refs = references.filter((i) => {
|
|
379
|
+
if (type === "issues") return i.type === "issue" || i.type === "pull-request";
|
|
380
|
+
return i.type === "hash";
|
|
381
|
+
}).map((ref) => {
|
|
382
|
+
if (!githubRepo) return ref.value;
|
|
383
|
+
if (ref.type === "pull-request" || ref.type === "issue") return `https://github.com/${githubRepo}/issues/${ref.value.slice(1)}`;
|
|
384
|
+
return `[<samp>(${ref.value.slice(0, 5)})</samp>](https://github.com/${githubRepo}/commit/${ref.value})`;
|
|
385
|
+
});
|
|
386
|
+
const referencesString = join(refs).trim();
|
|
387
|
+
if (type === "issues") return referencesString && `in ${referencesString}`;
|
|
388
|
+
return referencesString;
|
|
1499
389
|
}
|
|
1500
390
|
function formatLine(commit, options) {
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
391
|
+
const prRefs = formatReferences(commit.references, options.github.repo, "issues");
|
|
392
|
+
const hashRefs = formatReferences(commit.references, options.github.repo, "hash");
|
|
393
|
+
let authors = join([...new Set(commit.resolvedAuthors.map((i) => i.login ? `@${i.login}` : `**${i.name}**`))]).trim();
|
|
394
|
+
if (authors) authors = `by ${authors}`;
|
|
395
|
+
let refs = [
|
|
396
|
+
authors,
|
|
397
|
+
prRefs,
|
|
398
|
+
hashRefs
|
|
399
|
+
].filter((i) => i?.trim()).join(" ");
|
|
400
|
+
if (refs) refs = ` - ${refs}`;
|
|
401
|
+
const description = options.capitalize ? capitalize(commit.description) : commit.description;
|
|
402
|
+
return [description, refs].filter((i) => i?.trim()).join(" ");
|
|
1513
403
|
}
|
|
1514
404
|
function formatTitle(name, options) {
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
}
|
|
1520
|
-
return `### ${formatName}`;
|
|
405
|
+
const emojisRE = /([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g;
|
|
406
|
+
let formatName = name.trim();
|
|
407
|
+
if (!options.emoji) formatName = name.replace(emojisRE, "").trim();
|
|
408
|
+
return `### ${formatName}`;
|
|
1521
409
|
}
|
|
1522
410
|
function formatSection(commits, sectionName, options) {
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
411
|
+
if (!commits.length) return [];
|
|
412
|
+
const lines = [
|
|
413
|
+
"",
|
|
414
|
+
formatTitle(sectionName, options),
|
|
415
|
+
""
|
|
416
|
+
];
|
|
417
|
+
const scopes = groupBy(commits, "scope");
|
|
418
|
+
let useScopeGroup = true;
|
|
419
|
+
if (!Object.entries(scopes).some(([k, v]) => k && v.length > 1)) useScopeGroup = false;
|
|
420
|
+
Object.keys(scopes).sort().forEach((scope) => {
|
|
421
|
+
let padding = "";
|
|
422
|
+
let prefix = "";
|
|
423
|
+
const scopeText = `**${scope}**`;
|
|
424
|
+
if (scope && useScopeGroup) {
|
|
425
|
+
lines.push(`- ${scopeText}:`);
|
|
426
|
+
padding = " ";
|
|
427
|
+
} else if (scope) prefix = `${scopeText}: `;
|
|
428
|
+
lines.push(...scopes[scope].reverse().map((commit) => `${padding}- ${prefix}${formatLine(commit, options)}`));
|
|
429
|
+
});
|
|
430
|
+
return lines;
|
|
1543
431
|
}
|
|
1544
432
|
function getUserGithub(userName) {
|
|
1545
|
-
|
|
1546
|
-
|
|
433
|
+
const githubUrl = `https://github.com/${userName}`;
|
|
434
|
+
return githubUrl;
|
|
1547
435
|
}
|
|
1548
436
|
function getGitUserAvatar(userName) {
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
437
|
+
const githubUrl = getUserGithub(userName);
|
|
438
|
+
const avatarUrl = `${githubUrl}.png?size=48`;
|
|
439
|
+
return avatarUrl;
|
|
1552
440
|
}
|
|
1553
441
|
function createContributorLine(contributors) {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
});
|
|
1575
|
-
return `${loginLine}
|
|
1576
|
-
${unLoginLine}`;
|
|
442
|
+
let loginLine = "";
|
|
443
|
+
let unLoginLine = "";
|
|
444
|
+
const contributorMap = /* @__PURE__ */ new Map();
|
|
445
|
+
contributors.forEach((contributor) => {
|
|
446
|
+
contributorMap.set(contributor.email, contributor);
|
|
447
|
+
});
|
|
448
|
+
const filteredContributors = Array.from(contributorMap.values());
|
|
449
|
+
filteredContributors.forEach((contributor, index) => {
|
|
450
|
+
const { name, email, login } = contributor;
|
|
451
|
+
if (!login) {
|
|
452
|
+
let line = `[${name}](mailto:${email})`;
|
|
453
|
+
if (index < contributors.length - 1) line += ", ";
|
|
454
|
+
unLoginLine += line;
|
|
455
|
+
} else {
|
|
456
|
+
const githubUrl = getUserGithub(login);
|
|
457
|
+
const avatar = getGitUserAvatar(login);
|
|
458
|
+
loginLine += `[](${githubUrl}) `;
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
return `${loginLine}\n${unLoginLine}`;
|
|
1577
462
|
}
|
|
1578
463
|
function generateMarkdown(params) {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
lines.push("", "### \u2764\uFE0F Contributors", "");
|
|
1606
|
-
const contributorLine = createContributorLine(contributors);
|
|
1607
|
-
lines.push(contributorLine);
|
|
1608
|
-
}
|
|
1609
|
-
const md = convert(lines.join("\n").trim(), true);
|
|
1610
|
-
return md;
|
|
464
|
+
const { options, showTitle, contributors } = params;
|
|
465
|
+
const commits = params.commits.filter((commit) => commit.description.match(VERSION_WITH_RELEASE) === null);
|
|
466
|
+
const lines = [];
|
|
467
|
+
const url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.to}`;
|
|
468
|
+
if (showTitle) {
|
|
469
|
+
const date = options.tagDateMap.get(options.to) || dayjs().format("YYYY-MM-DD");
|
|
470
|
+
let title = `## [${options.to}](${url})`;
|
|
471
|
+
if (date) title += ` (${date})`;
|
|
472
|
+
lines.push(title);
|
|
473
|
+
}
|
|
474
|
+
const [breaking, changes] = partition(commits, (c) => c.isBreaking);
|
|
475
|
+
const group = groupBy(changes, "type");
|
|
476
|
+
lines.push(...formatSection(breaking, options.titles.breakingChanges, options));
|
|
477
|
+
for (const type of Object.keys(options.types)) {
|
|
478
|
+
const items = group[type] || [];
|
|
479
|
+
lines.push(...formatSection(items, options.types[type], options));
|
|
480
|
+
}
|
|
481
|
+
if (!lines.length) lines.push("*No significant changes*");
|
|
482
|
+
if (!showTitle) lines.push("", `##### [View changes on GitHub](${url})`);
|
|
483
|
+
if (showTitle) {
|
|
484
|
+
lines.push("", "### ❤️ Contributors", "");
|
|
485
|
+
const contributorLine = createContributorLine(contributors);
|
|
486
|
+
lines.push(contributorLine);
|
|
487
|
+
}
|
|
488
|
+
const md = convert(lines.join("\n").trim(), true);
|
|
489
|
+
return md;
|
|
1611
490
|
}
|
|
1612
491
|
async function isVersionInMarkdown(newVersion, mdPath) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
return isIn;
|
|
492
|
+
let isIn = false;
|
|
493
|
+
let md = "";
|
|
494
|
+
try {
|
|
495
|
+
md = await readFile(mdPath, "utf8");
|
|
496
|
+
} catch {}
|
|
497
|
+
if (md) {
|
|
498
|
+
const matches = md.match(VERSION_REG_OF_MARKDOWN);
|
|
499
|
+
if (matches?.length) {
|
|
500
|
+
const versionInMarkdown = `## [${newVersion}]`;
|
|
501
|
+
isIn = matches.includes(versionInMarkdown);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
return isIn;
|
|
1627
505
|
}
|
|
1628
506
|
async function writeMarkdown(md, mdPath, regenerate = false) {
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
}
|
|
1639
|
-
if (!changelogMD.startsWith(changelogPrefix)) {
|
|
1640
|
-
changelogMD = `${changelogPrefix}
|
|
1641
|
-
|
|
1642
|
-
${changelogMD}`;
|
|
1643
|
-
}
|
|
1644
|
-
const lastEntry = changelogMD.match(/^###?\s+.*$/m);
|
|
1645
|
-
if (lastEntry) {
|
|
1646
|
-
changelogMD = `${changelogMD.slice(0, lastEntry.index) + md}
|
|
1647
|
-
|
|
1648
|
-
${changelogMD.slice(lastEntry.index)}`;
|
|
1649
|
-
} else {
|
|
1650
|
-
changelogMD += `
|
|
1651
|
-
${md}
|
|
1652
|
-
|
|
1653
|
-
`;
|
|
1654
|
-
}
|
|
1655
|
-
await writeFile(mdPath, changelogMD);
|
|
507
|
+
let changelogMD = "";
|
|
508
|
+
const changelogPrefix = "# Changelog";
|
|
509
|
+
if (!existsSync(mdPath)) await writeFile(mdPath, `${changelogPrefix}\n\n`, "utf8");
|
|
510
|
+
if (!regenerate) changelogMD = await readFile(mdPath, "utf8");
|
|
511
|
+
if (!changelogMD.startsWith(changelogPrefix)) changelogMD = `${changelogPrefix}\n\n${changelogMD}`;
|
|
512
|
+
const lastEntry = changelogMD.match(/^###?\s+.*$/m);
|
|
513
|
+
if (lastEntry) changelogMD = `${changelogMD.slice(0, lastEntry.index) + md}\n\n${changelogMD.slice(lastEntry.index)}`;
|
|
514
|
+
else changelogMD += `\n${md}\n\n`;
|
|
515
|
+
await writeFile(mdPath, changelogMD);
|
|
1656
516
|
}
|
|
1657
517
|
|
|
1658
|
-
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/index.ts
|
|
520
|
+
/**
|
|
521
|
+
* Get the changelog markdown by two git tags
|
|
522
|
+
*
|
|
523
|
+
* @param options The changelog options
|
|
524
|
+
* @param showTitle Whither show the title
|
|
525
|
+
*/
|
|
1659
526
|
async function getChangelogMarkdown(options, showTitle = true) {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
527
|
+
const opts = await createOptions(options);
|
|
528
|
+
const current = await getCurrentGitBranch();
|
|
529
|
+
const to = opts.tags.includes(opts.to) ? opts.to : current;
|
|
530
|
+
const gitCommits = await getGitCommits(opts.from, to);
|
|
531
|
+
const resolvedLogins = /* @__PURE__ */ new Map();
|
|
532
|
+
const { commits, contributors } = await getGitCommitsAndResolvedAuthors(gitCommits, opts.github, resolvedLogins);
|
|
533
|
+
const markdown = generateMarkdown({
|
|
534
|
+
commits,
|
|
535
|
+
options: opts,
|
|
536
|
+
showTitle,
|
|
537
|
+
contributors
|
|
538
|
+
});
|
|
539
|
+
return {
|
|
540
|
+
markdown,
|
|
541
|
+
commits,
|
|
542
|
+
options: opts
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Get the changelog markdown by the total git tags
|
|
547
|
+
*
|
|
548
|
+
* @param options The changelog options
|
|
549
|
+
* @param showProgress Whither show the progress bar
|
|
550
|
+
*/
|
|
1673
551
|
async function getTotalChangelogMarkdown(options, showProgress = true) {
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
552
|
+
const opts = await createOptions(options);
|
|
553
|
+
let bar = null;
|
|
554
|
+
if (showProgress) bar = new SingleBar({ format: "generate total changelog: [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}" }, Presets.shades_classic);
|
|
555
|
+
const tags = getFromToTags(opts.tags);
|
|
556
|
+
if (tags.length === 0) {
|
|
557
|
+
const { markdown: markdown$1 } = await getChangelogMarkdown(opts);
|
|
558
|
+
return markdown$1;
|
|
559
|
+
}
|
|
560
|
+
bar?.start(tags.length, 0);
|
|
561
|
+
let markdown = "";
|
|
562
|
+
const resolvedLogins = /* @__PURE__ */ new Map();
|
|
563
|
+
for await (const [index, tag] of tags.entries()) {
|
|
564
|
+
const { from, to } = tag;
|
|
565
|
+
const gitCommits = await getGitCommits(from, to);
|
|
566
|
+
const { commits, contributors } = await getGitCommitsAndResolvedAuthors(gitCommits, opts.github, resolvedLogins);
|
|
567
|
+
const nextMd = generateMarkdown({
|
|
568
|
+
commits,
|
|
569
|
+
options: {
|
|
570
|
+
...opts,
|
|
571
|
+
from,
|
|
572
|
+
to
|
|
573
|
+
},
|
|
574
|
+
showTitle: true,
|
|
575
|
+
contributors
|
|
576
|
+
});
|
|
577
|
+
markdown = `${nextMd}\n\n${markdown}`;
|
|
578
|
+
bar?.update(index + 1);
|
|
579
|
+
}
|
|
580
|
+
bar?.stop();
|
|
581
|
+
return markdown;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Generate the changelog markdown by two git tags
|
|
585
|
+
*
|
|
586
|
+
* @param options The changelog options
|
|
587
|
+
*/
|
|
1703
588
|
async function generateChangelog(options) {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
}
|
|
589
|
+
const opts = await createOptions(options);
|
|
590
|
+
const existContent = await isVersionInMarkdown(opts.to, opts.output);
|
|
591
|
+
if (!opts.regenerate && existContent) return;
|
|
592
|
+
const { markdown } = await getChangelogMarkdown(opts);
|
|
593
|
+
await writeMarkdown(markdown, opts.output, opts.regenerate);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Generate the changelog markdown by the total git tags
|
|
597
|
+
*
|
|
598
|
+
* @param options The changelog options
|
|
599
|
+
* @param showProgress Whither show the progress bar
|
|
600
|
+
*/
|
|
1710
601
|
async function generateTotalChangelog(options, showProgress = true) {
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
602
|
+
const opts = await createOptions(options);
|
|
603
|
+
const markdown = await getTotalChangelogMarkdown(opts, showProgress);
|
|
604
|
+
await writeMarkdown(markdown, opts.output, true);
|
|
1714
605
|
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
getChangelogMarkdown,
|
|
1719
|
-
getTotalChangelogMarkdown
|
|
1720
|
-
};
|
|
606
|
+
|
|
607
|
+
//#endregion
|
|
608
|
+
export { generateChangelog, generateTotalChangelog, getChangelogMarkdown, getTotalChangelogMarkdown };
|