@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.js
CHANGED
|
@@ -5171,7 +5171,8 @@ var LEVEL_COLORS = {
|
|
|
5171
5171
|
silly: chalk.gray,
|
|
5172
5172
|
request: chalk.green,
|
|
5173
5173
|
response: chalk.yellow,
|
|
5174
|
-
|
|
5174
|
+
// Magenta stands out from white info / green request lines.
|
|
5175
|
+
progress: chalk.magentaBright,
|
|
5175
5176
|
results: chalk.magenta
|
|
5176
5177
|
};
|
|
5177
5178
|
var Logger = class _Logger {
|
|
@@ -5190,7 +5191,8 @@ var Logger = class _Logger {
|
|
|
5190
5191
|
this.updateTransport();
|
|
5191
5192
|
}
|
|
5192
5193
|
/**
|
|
5193
|
-
* Configure logger options. Accepts both LoggerOptions shape and flat param names
|
|
5194
|
+
* Configure logger options. Accepts both LoggerOptions shape and flat param names
|
|
5195
|
+
* (levels string, progressWithTimes, progressWithRate, progressThrottleMs).
|
|
5194
5196
|
*/
|
|
5195
5197
|
configure(options) {
|
|
5196
5198
|
if (options.mode !== void 0) {
|
|
@@ -5210,10 +5212,12 @@ var Logger = class _Logger {
|
|
|
5210
5212
|
}
|
|
5211
5213
|
if (options.progress !== void 0) {
|
|
5212
5214
|
if (options.progress.withTimes !== void 0) this.options.progressTimes = options.progress.withTimes;
|
|
5215
|
+
if (options.progress.withRate !== void 0) this.options.progressRate = options.progress.withRate;
|
|
5213
5216
|
if (options.progress.throttleMs !== void 0) this.options.progressThrottle = options.progress.throttleMs;
|
|
5214
5217
|
}
|
|
5215
5218
|
const flat = options;
|
|
5216
5219
|
if (flat.progressWithTimes !== void 0) this.options.progressTimes = flat.progressWithTimes;
|
|
5220
|
+
if (flat.progressWithRate !== void 0) this.options.progressRate = flat.progressWithRate;
|
|
5217
5221
|
if (flat.progressThrottleMs !== void 0) this.options.progressThrottle = flat.progressThrottleMs;
|
|
5218
5222
|
}
|
|
5219
5223
|
/**
|
|
@@ -5230,6 +5234,7 @@ var Logger = class _Logger {
|
|
|
5230
5234
|
timestamp: "boolean default false",
|
|
5231
5235
|
levels: "string",
|
|
5232
5236
|
progressWithTimes: "boolean default false",
|
|
5237
|
+
progressWithRate: "boolean default false",
|
|
5233
5238
|
progressThrottleMs: "number"
|
|
5234
5239
|
};
|
|
5235
5240
|
const discovered = context.params.getAllForModule("logger", paramDefs);
|
|
@@ -5248,6 +5253,7 @@ var Logger = class _Logger {
|
|
|
5248
5253
|
timestamp: false,
|
|
5249
5254
|
levels: DEFAULT_LEVELS,
|
|
5250
5255
|
progressTimes: false,
|
|
5256
|
+
progressRate: false,
|
|
5251
5257
|
progressThrottle: void 0
|
|
5252
5258
|
};
|
|
5253
5259
|
}
|
|
@@ -5313,15 +5319,23 @@ var Logger = class _Logger {
|
|
|
5313
5319
|
if (!this.startTimes[prefix ?? ""]) {
|
|
5314
5320
|
this.startTimes[prefix ?? ""] = Date.now();
|
|
5315
5321
|
}
|
|
5316
|
-
|
|
5322
|
+
const wantTimes = this.options.progressTimes;
|
|
5323
|
+
const wantRate = this.options.progressRate;
|
|
5324
|
+
if (wantTimes || wantRate) {
|
|
5317
5325
|
const elapsedSeconds = (Date.now() - this.startTimes[prefix ?? ""]) / 1e3;
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
remaining =
|
|
5326
|
+
const intervals = count > 1 ? count - 1 : 0;
|
|
5327
|
+
const itemsPerSec = intervals > 0 && elapsedSeconds > 0 ? intervals / elapsedSeconds : -1;
|
|
5328
|
+
if (wantTimes) {
|
|
5329
|
+
let remaining = -1;
|
|
5330
|
+
if (itemsPerSec > 0) {
|
|
5331
|
+
remaining = (total - count) / itemsPerSec;
|
|
5332
|
+
}
|
|
5333
|
+
payload.elapsed = this.round(elapsedSeconds, 2);
|
|
5334
|
+
payload.remaining = remaining >= 0 ? this.round(remaining, 2) : remaining;
|
|
5335
|
+
}
|
|
5336
|
+
if (wantRate) {
|
|
5337
|
+
payload.rate = itemsPerSec >= 0 ? this.round(itemsPerSec, 2) : itemsPerSec;
|
|
5322
5338
|
}
|
|
5323
|
-
payload.elapsed = this.round(elapsedSeconds, 2);
|
|
5324
|
-
payload.remaining = remaining >= 0 ? this.round(remaining, 2) : remaining;
|
|
5325
5339
|
}
|
|
5326
5340
|
if (count >= total) {
|
|
5327
5341
|
delete this.startTimes[prefix ?? ""];
|
|
@@ -5386,10 +5400,13 @@ var Logger = class _Logger {
|
|
|
5386
5400
|
parts.push(formatter.bold(struct.message));
|
|
5387
5401
|
}
|
|
5388
5402
|
if (struct.level === "progress") {
|
|
5403
|
+
const formatter = LEVEL_COLORS[struct.level];
|
|
5389
5404
|
if (struct.elapsed !== void 0 && struct.remaining !== void 0) {
|
|
5390
|
-
const formatter = LEVEL_COLORS[struct.level];
|
|
5391
5405
|
parts.push(formatter(`${struct.elapsed}/${struct.remaining}`));
|
|
5392
5406
|
}
|
|
5407
|
+
if (struct.rate !== void 0) {
|
|
5408
|
+
parts.push(formatter(struct.rate >= 0 ? `${struct.rate}/s` : "-/s"));
|
|
5409
|
+
}
|
|
5393
5410
|
}
|
|
5394
5411
|
if (struct.chunks && struct.chunks.length) {
|
|
5395
5412
|
parts.push(this.inspectChunks(struct.chunks));
|
|
@@ -8360,6 +8377,7 @@ var LOGGER_RUNTIME_KEYS = [
|
|
|
8360
8377
|
"route",
|
|
8361
8378
|
"prefix",
|
|
8362
8379
|
"progressWithTimes",
|
|
8380
|
+
"progressWithRate",
|
|
8363
8381
|
"progressThrottleMs"
|
|
8364
8382
|
];
|
|
8365
8383
|
var DEFAULT_RUNTIME_PARAM_SPECS = [
|
|
@@ -8471,6 +8489,7 @@ function coerceRuntimeValue(key, value) {
|
|
|
8471
8489
|
case "showLevel":
|
|
8472
8490
|
case "timestamp":
|
|
8473
8491
|
case "progressWithTimes":
|
|
8492
|
+
case "progressWithRate":
|
|
8474
8493
|
if (typeof value === "boolean") return value;
|
|
8475
8494
|
if (value === "true" || value === "1") return true;
|
|
8476
8495
|
if (value === "false" || value === "0") return false;
|