@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
78 lines • 3.81 kB
JavaScript
// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
import { inject, injectable } from 'tsyringe-neo';
import { Listr, } from 'listr2';
import { InjectTokens } from '../dependency-injection/inject-tokens.js';
import { patchInject } from '../dependency-injection/container-helper.js';
let DefaultTaskList = class DefaultTaskList {
logger;
constructor(logger) {
this.logger = logger;
this.logger = patchInject(this.logger, InjectTokens.SoloLogger, this.constructor.name);
}
newOneShotSingleDeployTaskList(task, options, parentTask) {
return new Listr(task, options, parentTask);
}
newOneShotSingleDestroyTaskList(task, options, parentTask) {
return new Listr(task, options, parentTask);
}
// Queue of pending parent task wrappers keyed by command name. A queue is
// required because the same command can be invoked concurrently.
parentTaskListMap = new Map();
newTaskList(task, options, parentTask, commandName) {
if (commandName && this.parentTaskListMap.has(commandName)) {
// Consume exactly one queued parent node for this invocation. Using
// `shift()` keeps FIFO pairing with the enqueue point in
// `subTaskSoloCommand()`, avoiding cross-assignment of child tasks.
const pendingParentTaskLists = this.parentTaskListMap.get(commandName) ?? [];
const parentTaskList = pendingParentTaskLists.shift();
if (pendingParentTaskLists.length === 0) {
this.parentTaskListMap.delete(commandName);
}
if (parentTaskList) {
parentTaskList.children = parentTaskList.taskListWrapper.newListr(task, options);
return parentTaskList.children;
}
}
return new Listr(task, options, parentTask);
}
trailingCloseFunctions = [];
registerCloseFunction(trailingCloseFunction) {
this.trailingCloseFunctions.push(trailingCloseFunction);
}
async callCloseFunctions() {
for (const closeFunction of this.trailingCloseFunctions) {
try {
await closeFunction()
.then()
.catch((error) => {
// Log the error or handle it as needed
this.logger.error('Error during trailing close function:', error);
});
}
catch (error) {
// Log the error or handle it as needed
this.logger.error('Error during trailing close function:', error);
}
}
this.trailingCloseFunctions = []; // Clear the functions after execution
}
};
DefaultTaskList = __decorate([
injectable(),
__param(0, inject(InjectTokens.SoloLogger)),
__metadata("design:paramtypes", [Object])
], DefaultTaskList);
export { DefaultTaskList };
//# sourceMappingURL=default-task-list.js.map