UNPKG

life-sciences-portal-cli

Version:

A CLI to generate and manage life sciences portals.

82 lines (81 loc) 2.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = require("@oclif/command"); const inquirer = require("inquirer"); const path = require("path"); const schematics_1 = require("@angular-devkit/schematics-cli/bin/schematics"); const child_process_1 = require("child_process"); class New extends command_1.Command { async run() { const { args } = this.parse(New); const portalName = args.portalName; const responses = await inquirer.prompt([ { name: 'portalType', message: 'Select a portal type', type: 'list', choices: [ { name: 'Bare minimum', value: 'basic' }, { name: 'Functioning search system (EBI Search)', value: 'full' }, ], }, { name: 'sitemap', message: 'Do you want to add a sitemap.xml?', type: 'confirm', default: false, }, { name: 'internalCms', message: 'Do you want to add an internal lightweight CMS?', type: 'confirm', default: false, }, { name: 'semanticVersioning', message: 'Do you want to use semantic versioning (standard-version)?', type: 'confirm', default: false, }, ]); const schematicsCollection = path.resolve(__dirname, '..', 'schematics', 'collection.json'); await (0, schematics_1.main)({ args: [ `${schematicsCollection}:lsp-new`, '--no-debug', `--name=${portalName}`, `--portal-type=${responses.portalType}`, this.booleanOpt('sitemap', responses.sitemap), this.booleanOpt('internal-cms', responses.internalCms), this.booleanOpt('semantic-versioning', responses.semanticVersioning), ] }); await this.installPackages(portalName); } booleanOpt(option, value) { return value ? `--${option}` : `--no-${option}`; } installPackages(portalName) { return new Promise((resolve) => { const npmInstall = (0, child_process_1.spawn)('npm', ['install', '--legacy-peer-deps'], { cwd: portalName }); npmInstall.stdout.pipe(process.stdout); npmInstall.stderr.pipe(process.stderr); npmInstall.on('close', (code) => { resolve(code); }); }); } } exports.default = New; New.description = 'Create a new portal'; New.examples = [ '$ life-sciences-portal new test-app', ]; New.flags = { help: command_1.flags.help({ char: 'h' }), }; New.args = [ { name: 'portalName', }, ];