UNPKG

@athenna/core

Version:

One foundation for multiple applications.

73 lines (72 loc) 3.02 kB
/** * @athenna/core * * (c) João Lenon <lenon@athenna.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ 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); }; import { File, Module, Path } from '@athenna/common'; import { Argument, BaseCommand, Option } from '@athenna/artisan'; export class InstallCommand extends BaseCommand { static signature() { return 'install'; } static description() { return 'Install libraries and automatically run the configurer if it exist.'; } async handle() { this.logger.simple('({bold,green} [ INSTALLING LIBRARIES ])\n'); const task = this.logger.task(); task.addPromise(`Installing ${this.libraries.join(', ')} libraries`, () => { return this.npm.install(this.libraries, { registry: Config.get('rc.commands.install.registry', this.registry), dev: this.isDev }); }); await task.run(); console.log(); this.logger.success(`Successfully installed ${this.libraries.join(', ')} libraries`); for (const library of this.libraries) { const path = Path.nodeModules(`${library}/configurer/index.js`); if (!(await File.exists(path))) { continue; } this.logger.simple(`\n({bold,green} [ CONFIGURING ${library} ])\n`); const Configurer = await Module.getFrom(path); await new Configurer().setPath(path).configure(); } } } __decorate([ Argument({ signature: 'libraries...', description: 'The libraries to install in your project.' }), __metadata("design:type", Array) ], InstallCommand.prototype, "libraries", void 0); __decorate([ Option({ signature: '--registry', description: 'Change the package manager that will be used to install the libraries', default: 'npm' }), __metadata("design:type", String) ], InstallCommand.prototype, "registry", void 0); __decorate([ Option({ signature: '-D, --save-dev', description: 'Install libraries as devDependencies.', default: false }), __metadata("design:type", Boolean) ], InstallCommand.prototype, "isDev", void 0);