@nmakarov/cli-toolkit 0.75.0 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-runner.cjs +29 -10
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +29 -10
- package/dist/cli-runner.js.map +1 -1
- package/dist/index.cjs +29 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -10
- package/dist/index.js.map +1 -1
- package/dist/init.cjs +27 -10
- package/dist/init.cjs.map +1 -1
- package/dist/init.js +27 -10
- package/dist/init.js.map +1 -1
- package/dist/logger.cjs +27 -10
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.js +27 -10
- package/dist/logger.js.map +1 -1
- package/dist/tasks.cjs +2 -0
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +2 -0
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5356,7 +5356,8 @@ var LEVEL_COLORS = {
|
|
|
5356
5356
|
silly: import_chalk.default.gray,
|
|
5357
5357
|
request: import_chalk.default.green,
|
|
5358
5358
|
response: import_chalk.default.yellow,
|
|
5359
|
-
|
|
5359
|
+
// Magenta stands out from white info / green request lines.
|
|
5360
|
+
progress: import_chalk.default.magentaBright,
|
|
5360
5361
|
results: import_chalk.default.magenta
|
|
5361
5362
|
};
|
|
5362
5363
|
var Logger = class _Logger {
|
|
@@ -5375,7 +5376,8 @@ var Logger = class _Logger {
|
|
|
5375
5376
|
this.updateTransport();
|
|
5376
5377
|
}
|
|
5377
5378
|
/**
|
|
5378
|
-
* Configure logger options. Accepts both LoggerOptions shape and flat param names
|
|
5379
|
+
* Configure logger options. Accepts both LoggerOptions shape and flat param names
|
|
5380
|
+
* (levels string, progressWithTimes, progressWithRate, progressThrottleMs).
|
|
5379
5381
|
*/
|
|
5380
5382
|
configure(options) {
|
|
5381
5383
|
if (options.mode !== void 0) {
|
|
@@ -5395,10 +5397,12 @@ var Logger = class _Logger {
|
|
|
5395
5397
|
}
|
|
5396
5398
|
if (options.progress !== void 0) {
|
|
5397
5399
|
if (options.progress.withTimes !== void 0) this.options.progressTimes = options.progress.withTimes;
|
|
5400
|
+
if (options.progress.withRate !== void 0) this.options.progressRate = options.progress.withRate;
|
|
5398
5401
|
if (options.progress.throttleMs !== void 0) this.options.progressThrottle = options.progress.throttleMs;
|
|
5399
5402
|
}
|
|
5400
5403
|
const flat = options;
|
|
5401
5404
|
if (flat.progressWithTimes !== void 0) this.options.progressTimes = flat.progressWithTimes;
|
|
5405
|
+
if (flat.progressWithRate !== void 0) this.options.progressRate = flat.progressWithRate;
|
|
5402
5406
|
if (flat.progressThrottleMs !== void 0) this.options.progressThrottle = flat.progressThrottleMs;
|
|
5403
5407
|
}
|
|
5404
5408
|
/**
|
|
@@ -5415,6 +5419,7 @@ var Logger = class _Logger {
|
|
|
5415
5419
|
timestamp: "boolean default false",
|
|
5416
5420
|
levels: "string",
|
|
5417
5421
|
progressWithTimes: "boolean default false",
|
|
5422
|
+
progressWithRate: "boolean default false",
|
|
5418
5423
|
progressThrottleMs: "number"
|
|
5419
5424
|
};
|
|
5420
5425
|
const discovered = context.params.getAllForModule("logger", paramDefs);
|
|
@@ -5433,6 +5438,7 @@ var Logger = class _Logger {
|
|
|
5433
5438
|
timestamp: false,
|
|
5434
5439
|
levels: DEFAULT_LEVELS,
|
|
5435
5440
|
progressTimes: false,
|
|
5441
|
+
progressRate: false,
|
|
5436
5442
|
progressThrottle: void 0
|
|
5437
5443
|
};
|
|
5438
5444
|
}
|
|
@@ -5498,15 +5504,23 @@ var Logger = class _Logger {
|
|
|
5498
5504
|
if (!this.startTimes[prefix ?? ""]) {
|
|
5499
5505
|
this.startTimes[prefix ?? ""] = Date.now();
|
|
5500
5506
|
}
|
|
5501
|
-
|
|
5507
|
+
const wantTimes = this.options.progressTimes;
|
|
5508
|
+
const wantRate = this.options.progressRate;
|
|
5509
|
+
if (wantTimes || wantRate) {
|
|
5502
5510
|
const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
remaining =
|
|
5511
|
+
const intervals = count > 1 ? count - 1 : 0;
|
|
5512
|
+
const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
|
|
5513
|
+
if (wantTimes) {
|
|
5514
|
+
let remaining = -1;
|
|
5515
|
+
if (itemsPerSec > 0) {
|
|
5516
|
+
remaining = (total - count) / itemsPerSec;
|
|
5517
|
+
}
|
|
5518
|
+
payload.elapsed = this.round(elapsedSeconds, 2);
|
|
5519
|
+
payload.remaining = remaining >= 0 ? this.round(remaining, 2) : remaining;
|
|
5520
|
+
}
|
|
5521
|
+
if (wantRate) {
|
|
5522
|
+
payload.rate = itemsPerSec >= 0 ? this.round(itemsPerSec, 2) : itemsPerSec;
|
|
5507
5523
|
}
|
|
5508
|
-
payload.elapsed = this.round(elapsedSeconds, 2);
|
|
5509
|
-
payload.remaining = remaining >= 0 ? this.round(remaining, 2) : remaining;
|
|
5510
5524
|
}
|
|
5511
5525
|
if (count >= total) {
|
|
5512
5526
|
delete this.startTimes[prefix ?? ""];
|
|
@@ -5571,10 +5585,13 @@ var Logger = class _Logger {
|
|
|
5571
5585
|
parts.push(formatter.bold(struct.message));
|
|
5572
5586
|
}
|
|
5573
5587
|
if (struct.level === "progress") {
|
|
5588
|
+
const formatter = LEVEL_COLORS[struct.level];
|
|
5574
5589
|
if (struct.elapsed !== void 0 && struct.remaining !== void 0) {
|
|
5575
|
-
const formatter = LEVEL_COLORS[struct.level];
|
|
5576
5590
|
parts.push(formatter(`${struct.elapsed}/${struct.remaining}`));
|
|
5577
5591
|
}
|
|
5592
|
+
if (struct.rate !== void 0) {
|
|
5593
|
+
parts.push(formatter(struct.rate >= 0 ? `${struct.rate}/s` : "-/s"));
|
|
5594
|
+
}
|
|
5578
5595
|
}
|
|
5579
5596
|
if (struct.chunks && struct.chunks.length) {
|
|
5580
5597
|
parts.push(this.inspectChunks(struct.chunks));
|
|
@@ -8545,6 +8562,7 @@ var LOGGER_RUNTIME_KEYS = [
|
|
|
8545
8562
|
"route",
|
|
8546
8563
|
"prefix",
|
|
8547
8564
|
"progressWithTimes",
|
|
8565
|
+
"progressWithRate",
|
|
8548
8566
|
"progressThrottleMs"
|
|
8549
8567
|
];
|
|
8550
8568
|
var DEFAULT_RUNTIME_PARAM_SPECS = [
|
|
@@ -8656,6 +8674,7 @@ function coerceRuntimeValue(key, value) {
|
|
|
8656
8674
|
case "showLevel":
|
|
8657
8675
|
case "timestamp":
|
|
8658
8676
|
case "progressWithTimes":
|
|
8677
|
+
case "progressWithRate":
|
|
8659
8678
|
if (typeof value === "boolean") return value;
|
|
8660
8679
|
if (value === "true" || value === "1") return true;
|
|
8661
8680
|
if (value === "false" || value === "0") return false;
|