UNPKG

generator-liferay-js

Version:

Yeoman generators for Liferay DXP and Portal CE JavaScript projects.

99 lines (98 loc) 4.03 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 ProjectAnalyzer_1 = __importDefault(require("../utils/ProjectAnalyzer")); const configuration_json_1 = __importDefault(require("../utils/modifier/features/configuration.json")); const Language_properties_1 = __importDefault(require("../utils/modifier/features/localization/Language.properties")); /** * */ class default_1 { /** * @param {Generator} generator */ constructor(generator) { this._generator = generator; } /** * */ generate() { const projectAnalyzer = new ProjectAnalyzer_1.default(this._generator); if (projectAnalyzer.hasConfiguration) { const configurationJson = new configuration_json_1.default(this._generator); if (projectAnalyzer.hasLocalization) { // Add system configuration description configurationJson.addField(configuration_json_1.default.Section.SYSTEM, 'fruit', 'string', { name: 'fruit', description: 'fruit-help', required: false, defaultValue: 'orange', options: { orange: 'an-orange', pear: 'a-pear', apple: 'an-apple', }, }); // Add portletInstance configuration description configurationJson.addField(configuration_json_1.default.Section.PORTLET_INSTANCE, 'drink', 'string', { name: 'drink', description: 'drink-help', required: false, defaultValue: 'water', options: { water: 'water', wine: 'wine', beer: 'beer', }, }); // Add configuration localization new Language_properties_1.default(this._generator).addProperties({ 'fruit': 'Favorite fruit', 'fruit-help': 'Choose the fruit you like the most', 'an-orange': 'An orange', 'a-pear': 'A pear', 'an-apple': 'An apple', 'drink': 'Favorite drink', 'drink-help': 'Choose the drink you like the most', 'water': 'Water', 'wine': 'Wine', 'beer': 'Beer', }); } else { // Add system configuration description configurationJson.addField(configuration_json_1.default.Section.SYSTEM, 'fruit', 'string', { name: 'Favorite fruit', description: 'Choose the fruit you like the most', required: false, defaultValue: 'orange', options: { orange: 'An orange', pear: 'A pear', apple: 'An apple', }, }); // Add portletInstance configuration description configurationJson.addField(configuration_json_1.default.Section.PORTLET_INSTANCE, 'drink', 'string', { name: 'Favorite drink', description: 'Choose the drink you like the most', required: false, defaultValue: 'water', options: { water: 'Water', wine: 'Wine', beer: 'Beer', }, }); } } } } exports.default = default_1;