@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/tasks.js
CHANGED
|
@@ -463,6 +463,34 @@ async function updateTaskProgress(context, tasksTable, taskId, progress) {
|
|
|
463
463
|
progress: typeof progress === "string" ? progress : JSON.stringify(progress)
|
|
464
464
|
});
|
|
465
465
|
}
|
|
466
|
+
function createTaskProgressReporter(context, tasksTable, taskId) {
|
|
467
|
+
let pump = null;
|
|
468
|
+
let pending = void 0;
|
|
469
|
+
let hasPending = false;
|
|
470
|
+
return (progress) => {
|
|
471
|
+
pending = progress;
|
|
472
|
+
hasPending = true;
|
|
473
|
+
if (pump) return pump;
|
|
474
|
+
pump = (async () => {
|
|
475
|
+
try {
|
|
476
|
+
while (hasPending) {
|
|
477
|
+
hasPending = false;
|
|
478
|
+
const value = pending;
|
|
479
|
+
try {
|
|
480
|
+
await updateTaskProgress(context, tasksTable, taskId, value);
|
|
481
|
+
} catch (err) {
|
|
482
|
+
context.logger?.warn?.(
|
|
483
|
+
`[tasks] progress update failed for ${taskId}: ${err?.message ?? err}`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
} finally {
|
|
488
|
+
pump = null;
|
|
489
|
+
}
|
|
490
|
+
})();
|
|
491
|
+
return pump;
|
|
492
|
+
};
|
|
493
|
+
}
|
|
466
494
|
|
|
467
495
|
// src/tasks/servicesRegistry.js
|
|
468
496
|
function getDb2(context) {
|
|
@@ -3376,7 +3404,8 @@ async function executeClaimedTask(context, tasksTable, historyTable, row, regist
|
|
|
3376
3404
|
try {
|
|
3377
3405
|
taskInstance = new TaskClass(context, row);
|
|
3378
3406
|
runningTaskInstances.set(row.id, taskInstance);
|
|
3379
|
-
const
|
|
3407
|
+
const reportProgress = createTaskProgressReporter(context, tasksTable, row.id);
|
|
3408
|
+
const runResult = await taskInstance.run(reportProgress);
|
|
3380
3409
|
success = !!runResult?.success;
|
|
3381
3410
|
results = runResult?.results ?? null;
|
|
3382
3411
|
} catch (error) {
|
|
@@ -3888,6 +3917,7 @@ export {
|
|
|
3888
3917
|
coerceRuntimeValue,
|
|
3889
3918
|
controlLaneTaskNames,
|
|
3890
3919
|
convertPattern,
|
|
3920
|
+
createTaskProgressReporter,
|
|
3891
3921
|
defaultTasksRegistry,
|
|
3892
3922
|
enqueueStopTask,
|
|
3893
3923
|
enqueueTask,
|