@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/init.js
CHANGED
|
@@ -2505,7 +2505,8 @@ var LEVEL_COLORS = {
|
|
|
2505
2505
|
silly: chalk.gray,
|
|
2506
2506
|
request: chalk.green,
|
|
2507
2507
|
response: chalk.yellow,
|
|
2508
|
-
|
|
2508
|
+
// Magenta stands out from white info / green request lines.
|
|
2509
|
+
progress: chalk.magentaBright,
|
|
2509
2510
|
results: chalk.magenta
|
|
2510
2511
|
};
|
|
2511
2512
|
var Logger = class _Logger {
|
|
@@ -2524,7 +2525,8 @@ var Logger = class _Logger {
|
|
|
2524
2525
|
this.updateTransport();
|
|
2525
2526
|
}
|
|
2526
2527
|
/**
|
|
2527
|
-
* Configure logger options. Accepts both LoggerOptions shape and flat param names
|
|
2528
|
+
* Configure logger options. Accepts both LoggerOptions shape and flat param names
|
|
2529
|
+
* (levels string, progressWithTimes, progressWithRate, progressThrottleMs).
|
|
2528
2530
|
*/
|
|
2529
2531
|
configure(options) {
|
|
2530
2532
|
if (options.mode !== void 0) {
|
|
@@ -2544,10 +2546,12 @@ var Logger = class _Logger {
|
|
|
2544
2546
|
}
|
|
2545
2547
|
if (options.progress !== void 0) {
|
|
2546
2548
|
if (options.progress.withTimes !== void 0) this.options.progressTimes = options.progress.withTimes;
|
|
2549
|
+
if (options.progress.withRate !== void 0) this.options.progressRate = options.progress.withRate;
|
|
2547
2550
|
if (options.progress.throttleMs !== void 0) this.options.progressThrottle = options.progress.throttleMs;
|
|
2548
2551
|
}
|
|
2549
2552
|
const flat = options;
|
|
2550
2553
|
if (flat.progressWithTimes !== void 0) this.options.progressTimes = flat.progressWithTimes;
|
|
2554
|
+
if (flat.progressWithRate !== void 0) this.options.progressRate = flat.progressWithRate;
|
|
2551
2555
|
if (flat.progressThrottleMs !== void 0) this.options.progressThrottle = flat.progressThrottleMs;
|
|
2552
2556
|
}
|
|
2553
2557
|
/**
|
|
@@ -2564,6 +2568,7 @@ var Logger = class _Logger {
|
|
|
2564
2568
|
timestamp: "boolean default false",
|
|
2565
2569
|
levels: "string",
|
|
2566
2570
|
progressWithTimes: "boolean default false",
|
|
2571
|
+
progressWithRate: "boolean default false",
|
|
2567
2572
|
progressThrottleMs: "number"
|
|
2568
2573
|
};
|
|
2569
2574
|
const discovered = context.params.getAllForModule("logger", paramDefs);
|
|
@@ -2582,6 +2587,7 @@ var Logger = class _Logger {
|
|
|
2582
2587
|
timestamp: false,
|
|
2583
2588
|
levels: DEFAULT_LEVELS,
|
|
2584
2589
|
progressTimes: false,
|
|
2590
|
+
progressRate: false,
|
|
2585
2591
|
progressThrottle: void 0
|
|
2586
2592
|
};
|
|
2587
2593
|
}
|
|
@@ -2647,15 +2653,23 @@ var Logger = class _Logger {
|
|
|
2647
2653
|
if (!this.startTimes[prefix ?? ""]) {
|
|
2648
2654
|
this.startTimes[prefix ?? ""] = Date.now();
|
|
2649
2655
|
}
|
|
2650
|
-
|
|
2656
|
+
const wantTimes = this.options.progressTimes;
|
|
2657
|
+
const wantRate = this.options.progressRate;
|
|
2658
|
+
if (wantTimes || wantRate) {
|
|
2651
2659
|
const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
remaining =
|
|
2660
|
+
const intervals = count > 1 ? count - 1 : 0;
|
|
2661
|
+
const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
|
|
2662
|
+
if (wantTimes) {
|
|
2663
|
+
let remaining = -1;
|
|
2664
|
+
if (itemsPerSec > 0) {
|
|
2665
|
+
remaining = (total - count) / itemsPerSec;
|
|
2666
|
+
}
|
|
2667
|
+
payload.elapsed = this.round(elapsedSeconds, 2);
|
|
2668
|
+
payload.remaining = remaining >= 0 ? this.round(remaining, 2) : remaining;
|
|
2669
|
+
}
|
|
2670
|
+
if (wantRate) {
|
|
2671
|
+
payload.rate = itemsPerSec >= 0 ? this.round(itemsPerSec, 2) : itemsPerSec;
|
|
2656
2672
|
}
|
|
2657
|
-
payload.elapsed = this.round(elapsedSeconds, 2);
|
|
2658
|
-
payload.remaining = remaining >= 0 ? this.round(remaining, 2) : remaining;
|
|
2659
2673
|
}
|
|
2660
2674
|
if (count >= total) {
|
|
2661
2675
|
delete this.startTimes[prefix ?? ""];
|
|
@@ -2720,10 +2734,13 @@ var Logger = class _Logger {
|
|
|
2720
2734
|
parts.push(formatter.bold(struct.message));
|
|
2721
2735
|
}
|
|
2722
2736
|
if (struct.level === "progress") {
|
|
2737
|
+
const formatter = LEVEL_COLORS[struct.level];
|
|
2723
2738
|
if (struct.elapsed !== void 0 && struct.remaining !== void 0) {
|
|
2724
|
-
const formatter = LEVEL_COLORS[struct.level];
|
|
2725
2739
|
parts.push(formatter(`${struct.elapsed}/${struct.remaining}`));
|
|
2726
2740
|
}
|
|
2741
|
+
if (struct.rate !== void 0) {
|
|
2742
|
+
parts.push(formatter(struct.rate >= 0 ? `${struct.rate}/s` : "-/s"));
|
|
2743
|
+
}
|
|
2727
2744
|
}
|
|
2728
2745
|
if (struct.chunks && struct.chunks.length) {
|
|
2729
2746
|
parts.push(this.inspectChunks(struct.chunks));
|