UNPKG

@liferay/generator-js

Version:

Yeoman generators for Liferay DXP and Portal CE JavaScript projects.

66 lines (65 loc) 2.25 kB
"use strict"; /** * SPDX-FileCopyrightText: © 2017 Liferay, Inc. <https://liferay.com> * SPDX-License-Identifier: LGPL-3.0-or-later */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const yeoman_generator_1 = __importDefault(require("yeoman-generator")); const utils_1 = require("../utils"); const npmbuildrc_1 = __importDefault(require("../utils/modifier/npmbuildrc")); const package_json_1 = __importDefault(require("../utils/modifier/package.json")); /** * Generator to add deploy support to projects. */ class default_1 extends yeoman_generator_1.default { /** * Standard Yeoman initialization function */ initializing() { this.sourceRoot(path_1.default.join(__dirname, 'templates')); } /** * Standard Yeoman prompt function */ async prompting() { const answers = await utils_1.promptWithConfig(this, 'facet-deploy', [ { default: true, message: 'Do you have a local installation of Liferay for development?', name: 'liferayPresent', type: 'confirm', }, ]); if (!answers['liferayPresent']) { this.answers = {}; return; } this.answers = await utils_1.promptWithConfig(this, 'facet-deploy', [ { default: '/liferay', message: 'Where is your local installation of Liferay placed?', name: 'liferayDir', type: 'input', validate: utils_1.validateLiferayDir, }, ]); } /** * Standard Yeoman generation function */ writing() { if (!this.answers.liferayDir) { return; } const npmbuildrc = new npmbuildrc_1.default(this); const pkgJson = new package_json_1.default(this); npmbuildrc.setLiferayDir(this.answers.liferayDir); pkgJson.addScript('deploy', 'npm run build && lnbs-deploy'); } } exports.default = default_1; module.exports = exports['default'];