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

58 lines 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConsoleModule = void 0; const tslib_1 = require("tslib"); /** * @module ConsoleModule */ const common_1 = require("@nestjs/common"); const constants_1 = require("./constants"); const scanner_1 = require("./scanner"); const service_1 = require("./service"); const cliProvider = { provide: constants_1.CLI_SERVICE_TOKEN, useFactory: () => service_1.ConsoleService.createCli(), }; let ConsoleModule = class ConsoleModule { service; scanner = new scanner_1.ConsoleScanner(); constructor(service) { this.service = service; } async scan(app, includedModules) { const scanResponse = await this.scanner.scan(app, includedModules); const cli = this.service.getRootCli(); scanResponse.forEach(({ methods, instance, metadata }) => { let parent; let subCli = this.service.getCli(metadata.command); if (subCli !== undefined) { parent = subCli; } else { const commandNames = metadata.command.split('.'); if (commandNames.length > 1) { commandNames.pop(); subCli = this.service.getCli(commandNames.join('.')); } if (subCli === undefined) { parent = this.service.createGroupCommand(metadata, cli); } else { parent = this.service.createGroupCommand(metadata, subCli); } } for (const method of methods) { this.service.createCommand(method.metadata, { instance, methodName: method.name }, parent); } }); } }; exports.ConsoleModule = ConsoleModule; exports.ConsoleModule = ConsoleModule = tslib_1.__decorate([ (0, common_1.Module)({ providers: [cliProvider, service_1.ConsoleService], exports: [service_1.ConsoleService], }), tslib_1.__metadata("design:paramtypes", [service_1.ConsoleService]) ], ConsoleModule); //# sourceMappingURL=module.js.map