UNPKG

@salesforce/templates

Version:

Salesforce JS library for templates

47 lines 2.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); /* * Copyright (c) 2019, salesforce.com, inc. * All rights reserved. * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ const path = require("path"); const i18n_1 = require("../i18n"); const utils_1 = require("../utils"); const baseGenerator_1 = require("./baseGenerator"); class LightningAppGenerator extends baseGenerator_1.BaseGenerator { constructor(options) { super(options); } validateOptions() { utils_1.CreateUtil.checkInputs(this.options.appname); utils_1.CreateUtil.checkInputs(this.options.template); const fileparts = path.resolve(this.outputdir).split(path.sep); if (!fileparts.includes('aura') && !this.options.internal) { throw new Error(i18n_1.nls.localize('MissingAuraDir')); } } generate() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const { template, appname, internal } = this.options; this.sourceRootWithPartialPath('lightningapp'); if (!internal) { yield this.render(this.templatePath('_auradefinitionbundle.app-meta.xml'), this.destinationPath(path.join(this.outputdir, appname, `${appname}.app-meta.xml`)), { apiVersion: this.apiversion, description: i18n_1.nls.localize('LightningAppBundle'), }); } yield this.render(this.templatePath(`${template}.app`), this.destinationPath(path.join(this.outputdir, appname, `${appname}.app`)), {}), yield this.render(this.templatePath('DefaultLightningAuradoc.auradoc'), this.destinationPath(path.join(this.outputdir, appname, `${appname}.auradoc`)), {}), yield this.render(this.templatePath('DefaultLightningController.js'), this.destinationPath(path.join(this.outputdir, appname, `${appname}Controller.js`)), {}), yield this.render(this.templatePath('DefaultLightningCss.css'), this.destinationPath(path.join(this.outputdir, appname, `${appname}.css`)), {}), yield this.render(this.templatePath('DefaultLightningHelper.js'), this.destinationPath(path.join(this.outputdir, appname, `${appname}Helper.js`)), {}), yield this.render(this.templatePath('DefaultLightningRenderer.js'), this.destinationPath(path.join(this.outputdir, appname, `${appname}Renderer.js`)), {}), yield this.render(this.templatePath('DefaultLightningSVG.svg'), this.destinationPath(path.join(this.outputdir, appname, `${appname}.svg`)), {}); }); } } exports.default = LightningAppGenerator; //# sourceMappingURL=lightningAppGenerator.js.map