@nmakarov/cli-toolkit 0.61.0 → 0.63.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 +51 -4
- package/dist/cli-runner.cjs.map +1 -1
- package/dist/cli-runner.js +51 -4
- package/dist/cli-runner.js.map +1 -1
- package/dist/db.cjs +16 -3
- package/dist/db.cjs.map +1 -1
- package/dist/db.js +16 -3
- package/dist/db.js.map +1 -1
- package/dist/index.cjs +53 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -4
- package/dist/index.js.map +1 -1
- package/dist/init.cjs +5 -0
- package/dist/init.cjs.map +1 -1
- package/dist/init.js +5 -0
- package/dist/init.js.map +1 -1
- package/dist/logger.cjs +5 -0
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.js +5 -0
- package/dist/logger.js.map +1 -1
- package/dist/tasks.cjs +32 -1
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +31 -1
- package/dist/tasks.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3503,13 +3503,15 @@ var CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
3503
3503
|
"57P02",
|
|
3504
3504
|
"57P03"
|
|
3505
3505
|
]);
|
|
3506
|
-
var CONNECTION_ERROR_MESSAGE_RE = /connection (terminated|ended|closed|destroyed|reset|refused|not open)|Connection terminated unexpectedly|Client has encountered a connection error|server closed the connection|Cannot use a pool after calling end|This socket has been ended|connect ECONNRESET
|
|
3506
|
+
var CONNECTION_ERROR_MESSAGE_RE = /connection (terminated|ended|closed|destroyed|reset|refused|not open)|Connection terminated unexpectedly|Client has encountered a connection error|server closed the connection|Cannot use a pool after calling end|This socket has been ended|connect ECONNRESET/i;
|
|
3507
3507
|
var Db = class _Db {
|
|
3508
3508
|
static async init(context, options = {}) {
|
|
3509
3509
|
const buildConfig = async () => {
|
|
3510
3510
|
const defs = {
|
|
3511
3511
|
dbName: "string",
|
|
3512
|
-
dbProfile: "boolean default false"
|
|
3512
|
+
dbProfile: "boolean default false",
|
|
3513
|
+
/** Cap knex pool size (default 10). Size ≈ expected concurrency + headroom. */
|
|
3514
|
+
dbPoolMax: "number"
|
|
3513
3515
|
};
|
|
3514
3516
|
const discovered = context?.params?.getAllForModule?.("db", defs) ?? {};
|
|
3515
3517
|
const merged = { ...discovered, ...options };
|
|
@@ -3568,12 +3570,23 @@ var Db = class _Db {
|
|
|
3568
3570
|
context?.args?.env,
|
|
3569
3571
|
merged.name
|
|
3570
3572
|
);
|
|
3573
|
+
const poolMaxRaw = merged.dbPoolMax ?? merged.pool?.max;
|
|
3574
|
+
const poolMax = Number(poolMaxRaw);
|
|
3575
|
+
const pool = {
|
|
3576
|
+
...KNEX_DEFAULTS.pool,
|
|
3577
|
+
...merged.pool && typeof merged.pool === "object" ? merged.pool : {}
|
|
3578
|
+
};
|
|
3579
|
+
if (Number.isFinite(poolMax) && poolMax >= 1) {
|
|
3580
|
+
pool.max = Math.floor(poolMax);
|
|
3581
|
+
}
|
|
3571
3582
|
return {
|
|
3572
3583
|
...KNEX_DEFAULTS,
|
|
3573
3584
|
connectionString: dbConnectionString,
|
|
3574
3585
|
name: displayName,
|
|
3575
3586
|
profile: !!dbProfile,
|
|
3576
|
-
logger: context.logger
|
|
3587
|
+
logger: context.logger,
|
|
3588
|
+
pool,
|
|
3589
|
+
...merged.acquireConnectionTimeout != null ? { acquireConnectionTimeout: merged.acquireConnectionTimeout } : {}
|
|
3577
3590
|
};
|
|
3578
3591
|
};
|
|
3579
3592
|
const config2 = context?.params?.runWithModuleAsync ? await context.params.runWithModuleAsync("db", buildConfig) : await buildConfig();
|
|
@@ -5026,6 +5039,9 @@ var Logger = class _Logger {
|
|
|
5026
5039
|
const message = this.inspectChunks([operation, ...chunks]);
|
|
5027
5040
|
this.out({ level: "response", message });
|
|
5028
5041
|
}
|
|
5042
|
+
/**
|
|
5043
|
+
* @returns {boolean} true when the progress line was emitted (not throttled)
|
|
5044
|
+
*/
|
|
5029
5045
|
progress(message, opts) {
|
|
5030
5046
|
const { prefix, count, total } = opts;
|
|
5031
5047
|
const paddedTotal = String(total).length;
|
|
@@ -5059,7 +5075,9 @@ var Logger = class _Logger {
|
|
|
5059
5075
|
if (this.options.progressThrottle && prefix) {
|
|
5060
5076
|
this.lastProgressTimes[prefix] = Date.now();
|
|
5061
5077
|
}
|
|
5078
|
+
return true;
|
|
5062
5079
|
}
|
|
5080
|
+
return false;
|
|
5063
5081
|
}
|
|
5064
5082
|
shouldOutputProgress(prefix, count, total) {
|
|
5065
5083
|
if (!this.options.progressThrottle) {
|
|
@@ -6899,6 +6917,34 @@ async function updateTaskProgress(context, tasksTable, taskId, progress) {
|
|
|
6899
6917
|
progress: typeof progress === "string" ? progress : JSON.stringify(progress)
|
|
6900
6918
|
});
|
|
6901
6919
|
}
|
|
6920
|
+
function createTaskProgressReporter(context, tasksTable, taskId) {
|
|
6921
|
+
let pump = null;
|
|
6922
|
+
let pending = void 0;
|
|
6923
|
+
let hasPending = false;
|
|
6924
|
+
return (progress) => {
|
|
6925
|
+
pending = progress;
|
|
6926
|
+
hasPending = true;
|
|
6927
|
+
if (pump) return pump;
|
|
6928
|
+
pump = (async () => {
|
|
6929
|
+
try {
|
|
6930
|
+
while (hasPending) {
|
|
6931
|
+
hasPending = false;
|
|
6932
|
+
const value = pending;
|
|
6933
|
+
try {
|
|
6934
|
+
await updateTaskProgress(context, tasksTable, taskId, value);
|
|
6935
|
+
} catch (err) {
|
|
6936
|
+
context.logger?.warn?.(
|
|
6937
|
+
`[tasks] progress update failed for ${taskId}: ${err?.message ?? err}`
|
|
6938
|
+
);
|
|
6939
|
+
}
|
|
6940
|
+
}
|
|
6941
|
+
} finally {
|
|
6942
|
+
pump = null;
|
|
6943
|
+
}
|
|
6944
|
+
})();
|
|
6945
|
+
return pump;
|
|
6946
|
+
};
|
|
6947
|
+
}
|
|
6902
6948
|
|
|
6903
6949
|
// src/tasks/servicesRegistry.js
|
|
6904
6950
|
function getDb2(context) {
|
|
@@ -8750,7 +8796,8 @@ async function executeClaimedTask(context, tasksTable, historyTable, row, regist
|
|
|
8750
8796
|
try {
|
|
8751
8797
|
taskInstance = new TaskClass(context, row);
|
|
8752
8798
|
runningTaskInstances.set(row.id, taskInstance);
|
|
8753
|
-
const
|
|
8799
|
+
const reportProgress = createTaskProgressReporter(context, tasksTable, row.id);
|
|
8800
|
+
const runResult = await taskInstance.run(reportProgress);
|
|
8754
8801
|
success = !!runResult?.success;
|
|
8755
8802
|
results = runResult?.results ?? null;
|
|
8756
8803
|
} catch (error) {
|
|
@@ -9297,6 +9344,7 @@ export {
|
|
|
9297
9344
|
controlLaneTaskNames,
|
|
9298
9345
|
convertPattern,
|
|
9299
9346
|
createRelease,
|
|
9347
|
+
createTaskProgressReporter,
|
|
9300
9348
|
defaultFileSynopsisFunction,
|
|
9301
9349
|
defaultTasksRegistry,
|
|
9302
9350
|
defaultVersionSynopsisFunction,
|