UNPKG

@cuba-platform/front-generator

Version:
59 lines 2.55 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const generation_1 = require("../../../common/generation"); const params_1 = require("./params"); exports.params = params_1.entityCardsParams; const cli_options_1 = require("../../../common/cli-options"); exports.options = cli_options_1.polymerElementOptionsConfig; const path = require("path"); const utils_1 = require("../../../common/utils"); class EntityCardsGenerator extends generation_1.BaseGenerator { constructor(args, options) { super(args, options); this.sourceRoot(path.join(__dirname, 'template')); } // noinspection JSUnusedGlobalSymbols prompting() { return __awaiter(this, void 0, void 0, function* () { yield this._promptOrParse(); }); } // noinspection JSUnusedGlobalSymbols writing() { this.log(`Generating to ${this.destinationPath()}`); if (!this.answers) { throw new Error('Answers not provided'); } this.model = entityCardsAnswersToModel(this.answers, this.options.dirShift); this.fs.copyTpl(this.templatePath('entity-cards.html'), this.destinationPath(this.model.componentName + '.html'), this.model); } end() { this.log(`Entity cards have been successfully generated into ${this.destinationRoot()}`); } _getParams() { return params_1.entityCardsParams; } _getAvailableOptions() { return cli_options_1.polymerElementOptionsConfig; } } exports.generator = EntityCardsGenerator; function entityCardsAnswersToModel(answers, dirShift) { return { componentName: answers.componentName, className: utils_1.elementNameToClass(answers.componentName), relDirShift: dirShift || '', entity: answers.entity, view: answers.entityView }; } exports.entityCardsAnswersToModel = entityCardsAnswersToModel; //# sourceMappingURL=index.js.map