UNPKG

@salesforce/plugin-templates

Version:

Commands to create metadata from a default or custom template

69 lines 3.11 kB
/* * 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 */ // tslint:disable:no-unused-expression import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core'; import { TemplateType } from '@salesforce/templates'; import { Messages } from '@salesforce/core'; import { getCustomTemplates, runGenerator } from '../../../utils/templateCommand.js'; import { internalFlag, outputDirFlagLightning } from '../../../utils/flags.js'; const BUNDLE_TYPE = 'Component'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningCmp'); const lightningCommon = Messages.loadMessages('@salesforce/plugin-templates', 'lightning'); export default class LightningComponent extends SfCommand { static summary = messages.getMessage('summary'); static description = messages.getMessage('description'); static examples = messages.getMessages('examples'); static aliases = ['force:lightning:component:create']; static deprecateAliases = true; static flags = { name: Flags.string({ char: 'n', summary: lightningCommon.getMessage('flags.name.summary', [BUNDLE_TYPE]), description: lightningCommon.getMessage('flags.name.description'), required: true, aliases: ['componentname'], deprecateAliases: true, }), template: Flags.option({ char: 't', summary: lightningCommon.getMessage('flags.template.summary'), description: lightningCommon.getMessage('flags.template.description'), default: 'default', // Note: keep this list here and LightningComponentOptions#template in-sync with the // templates/lightningcomponents/[aura|lwc]/* folders options: ['default', 'analyticsDashboard', 'analyticsDashboardWithStep'], })(), 'output-dir': outputDirFlagLightning, 'api-version': orgApiVersionFlagWithDeprecations, type: Flags.option({ summary: messages.getMessage('flags.type.summary'), options: ['aura', 'lwc'], default: 'aura', })(), internal: internalFlag, loglevel, }; async run() { const { flags } = await this.parse(LightningComponent); const flagsAsOptions = { componentname: flags.name, template: flags.template, outputdir: flags['output-dir'], apiversion: flags['api-version'], internal: flags.internal, type: flags.type, }; return runGenerator({ templateType: TemplateType.LightningComponent, opts: flagsAsOptions, ux: new Ux({ jsonEnabled: this.jsonEnabled() }), templates: getCustomTemplates(this.configAggregator), }); } } //# sourceMappingURL=component.js.map