@nmakarov/cli-toolkit 0.77.0 → 0.79.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/init.js CHANGED
@@ -2515,6 +2515,8 @@ var Logger = class _Logger {
2515
2515
  options;
2516
2516
  transport;
2517
2517
  startTimes = {};
2518
+ /** Count at the first progress sample for each prefix (rate baseline). */
2519
+ startCounts = {};
2518
2520
  lastProgressTimes = {};
2519
2521
  constructor(context, options = {}) {
2520
2522
  this.context = context;
@@ -2650,15 +2652,17 @@ var Logger = class _Logger {
2650
2652
  total,
2651
2653
  prefix
2652
2654
  };
2653
- if (!this.startTimes[prefix ?? ""]) {
2654
- this.startTimes[prefix ?? ""] = Date.now();
2655
+ const key = prefix ?? "";
2656
+ if (this.startTimes[key] === void 0) {
2657
+ this.startTimes[key] = Date.now();
2658
+ this.startCounts[key] = count;
2655
2659
  }
2656
2660
  const wantTimes = this.options.progressTimes;
2657
2661
  const wantRate = this.options.progressRate;
2658
2662
  if (wantTimes || wantRate) {
2659
- const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
2660
- const intervals = count > 1 ? count - 1 : 0;
2661
- const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
2663
+ const elapsedSeconds = (Date.now() - this.startTimes[key]) / 1e3;
2664
+ const done = count - (this.startCounts[key] ?? count);
2665
+ const itemsPerSec = done > 0 && elapsedSeconds > 0 ? done / elapsedSeconds : -1;
2662
2666
  if (wantTimes) {
2663
2667
  let remaining = -1;
2664
2668
  if (itemsPerSec > 0) {
@@ -2672,8 +2676,9 @@ var Logger = class _Logger {
2672
2676
  }
2673
2677
  }
2674
2678
  if (count >= total) {
2675
- delete this.startTimes[prefix ?? ""];
2676
- delete this.lastProgressTimes[prefix ?? ""];
2679
+ delete this.startTimes[key];
2680
+ delete this.startCounts[key];
2681
+ delete this.lastProgressTimes[key];
2677
2682
  }
2678
2683
  if (this.shouldOutputProgress(prefix ?? "", count, total)) {
2679
2684
  this.out(payload);