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
78 lines • 2.12 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractBootstrapConsole = void 0;
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 {
/**
* The console service
*/
service;
/**
* The application container
*/
container;
/**
* The options to bootstrap
*/
options;
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
*/
async useDecorators() {
const consoleModule = this.container.get(module_1.ConsoleModule);
await consoleModule.scan(this.container, this.options.includeModules);
return this;
}
/**
* Public method to activate decorator scanning (call after app.init())
*/
async scanDecorators() {
return this.useDecorators();
}
/**
* Init the console application
*/
async init() {
this.container = await this.create();
this.service = this.container.get(service_1.ConsoleService);
this.service.setContainer(this.container);
// Note: useDecorators should be called after app.init() to ensure all dependencies are resolved
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;
//# sourceMappingURL=abstract.js.map