UNPKG

rucken

Version:

Console tools and scripts for nx and not only that I (EndyKaufman) use to automate the workflow and speed up the development process

67 lines (66 loc) 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AbstractBootstrapConsole = void 0; const tslib_1 = require("tslib"); const module_1 = require("../module"); const service_1 = require("../service"); /** * An abstract class to boot a nest application * @param A The type of nest application * @param O The options */ class AbstractBootstrapConsole { constructor(options) { this.options = options; if (!this.options.contextOptions) { this.options.contextOptions = {}; } if (!this.options.contextOptions.logger) { this.options.contextOptions.logger = ['error']; } } /** * Activate the decorators scanner */ useDecorators() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const consoleModule = this.container.get(module_1.ConsoleModule); yield consoleModule.scan(this.container, this.options.includeModules); return this; }); } /** * Init the console application */ init() { return tslib_1.__awaiter(this, void 0, void 0, function* () { this.container = yield this.create(); this.service = this.container.get(service_1.ConsoleService); this.service.setContainer(this.container); if (this.options.useDecorators) { yield this.useDecorators(); } return this.container; }); } /** * Get the console service */ getService() { return this.service; } /** * Get the options */ getOptions() { return this.options; } /** * Boot the console * @param argv The list of arguments to pass to the cli, default are process.argv */ boot(argv = process.argv) { return this.service.init(argv); } } exports.AbstractBootstrapConsole = AbstractBootstrapConsole;