UNPKG

@salesforce/plugin-templates

Version:

Commands to create metadata from a default or custom template

75 lines 3.26 kB
/* * Copyright (c) 2026, 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 */ import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core'; import { isAllowedLightningEmbeddingSrcUrl, LIGHTNING_EMBEDDING_SANDBOX_TOKENS, TemplateType, } from '@salesforce/templates'; import { Messages } from '@salesforce/core'; import { getCustomTemplates, runGenerator } from '../../../../utils/templateCommand.js'; import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningEmbedding'); export default class LightningEmbedding extends SfCommand { static summary = messages.getMessage('summary'); static description = messages.getMessage('description'); static examples = messages.getMessages('examples'); static state = 'beta'; static hidden = true; static flags = { name: Flags.string({ char: 'n', summary: messages.getMessage('flags.name.summary'), description: messages.getMessage('flags.name.description'), required: true, }), src: Flags.string({ char: 's', summary: messages.getMessage('flags.src.summary'), description: messages.getMessage('flags.src.description'), required: true, parse: (input) => { if (!isAllowedLightningEmbeddingSrcUrl(input)) { throw new Error(messages.getMessage('flags.src.error')); } return Promise.resolve(input); }, }), sandbox: Flags.option({ summary: messages.getMessage('flags.sandbox.summary'), description: messages.getMessage('flags.sandbox.description'), options: LIGHTNING_EMBEDDING_SANDBOX_TOKENS, multiple: true, required: true, })(), 'shell-title': Flags.string({ summary: messages.getMessage('flags.shell-title.summary'), description: messages.getMessage('flags.shell-title.description'), required: true, }), 'output-dir': outputDirFlagLightning, 'api-version': orgApiVersionFlagWithDeprecations, internal: internalFlag, loglevel, }; async run() { const { flags } = await this.parse(LightningEmbedding); const flagsAsOptions = { componentname: flags.name, src: flags.src, sandbox: flags.sandbox.join(' '), shellTitle: flags['shell-title'], outputdir: flags['output-dir'], apiversion: flags['api-version'], internal: flags.internal, }; return runGenerator({ templateType: TemplateType.LightningEmbedding, opts: flagsAsOptions, ux: new Ux({ jsonEnabled: this.jsonEnabled() }), templates: getCustomTemplates(this.configAggregator), }); } } //# sourceMappingURL=embedding.js.map