UNPKG

@liferay/generator-js

Version:

Yeoman generators for Liferay DXP and Portal CE JavaScript projects.

99 lines (98 loc) 4.02 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', { defaultValue: 'orange', description: 'fruit-help', name: 'fruit', options: { apple: 'an-apple', orange: 'an-orange', pear: 'a-pear', }, required: false, }); // Add portletInstance configuration description configurationJson.addField(configuration_json_1.default.Section.PORTLET_INSTANCE, 'drink', 'string', { defaultValue: 'water', description: 'drink-help', name: 'drink', options: { beer: 'beer', water: 'water', wine: 'wine', }, required: false, }); // Add configuration localization new Language_properties_1.default(this._generator).addProperties({ 'a-pear': 'A pear', 'an-apple': 'An apple', 'an-orange': 'An orange', beer: 'Beer', drink: 'Favorite drink', 'drink-help': 'Choose the drink you like the most', fruit: 'Favorite fruit', 'fruit-help': 'Choose the fruit you like the most', water: 'Water', wine: 'Wine', }); } else { // Add system configuration description configurationJson.addField(configuration_json_1.default.Section.SYSTEM, 'fruit', 'string', { defaultValue: 'orange', description: 'Choose the fruit you like the most', name: 'Favorite fruit', options: { apple: 'An apple', orange: 'An orange', pear: 'A pear', }, required: false, }); // Add portletInstance configuration description configurationJson.addField(configuration_json_1.default.Section.PORTLET_INSTANCE, 'drink', 'string', { defaultValue: 'water', description: 'Choose the drink you like the most', name: 'Favorite drink', options: { beer: 'Beer', water: 'Water', wine: 'Wine', }, required: false, }); } } } } exports.default = default_1;