UNPKG

firmament

Version:

Modularized shell for NodeJS CLI applications

43 lines 1.92 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); const firmament_yargs_1 = require("firmament-yargs"); const _ = require("lodash"); const module_management_command_impl_1 = require("./implementations/commands/module-management-command-impl"); const ModuleManagementImpl_1 = require("./implementations/ModuleManagementImpl"); const package_command_impl_1 = require("./implementations/commands/package-command-impl"); const PackageImpl_1 = require("./implementations/PackageImpl"); const commandLine = firmament_yargs_1.kernel.get('CommandLine'); const allKernels = []; const package_json = require('../package.json'); firmament_yargs_1.kernel.bind('Command').to(module_management_command_impl_1.ModuleManagementCommandImpl); firmament_yargs_1.kernel.bind('Command').to(package_command_impl_1.PackageCommandImpl); firmament_yargs_1.kernel.bind('ModuleManagement').to(ModuleManagementImpl_1.ModuleManagementImpl); firmament_yargs_1.kernel.bind('Package').to(PackageImpl_1.PackageImpl); allKernels.push(firmament_yargs_1.kernel); commandLine.init({ version: () => { return package_json.version; } }); function addCommandsFromKernels(kernels) { kernels.forEach(kernel => { let commands = kernel.getAll('Command'); commands.forEach(command => { commandLine.addCommand(command); }); }); } (function processNpmInfo(npmInfo) { let moduleManagement = firmament_yargs_1.kernel.get('ModuleManagement'); let firmamentModules = Object.getOwnPropertyNames(npmInfo.dependencies).filter(key => { return _.startsWith(key, moduleManagement.modulePrefix); }); firmamentModules.forEach(moduleName => { allKernels.push(require(moduleName).kernel); }); addCommandsFromKernels(allKernels); commandLine.exec(); })(package_json); //# sourceMappingURL=firmament.js.map