From ddb6784f732cccca0a7a19c1bba15413af4ff066 Mon Sep 17 00:00:00 2001 From: AMAN SINGH Date: Tue, 21 Jul 2026 21:19:46 +0530 Subject: [PATCH 1/2] feat: rename lightning embedding command to ui-embedding Rename the `template generate lightning embedding` command to `template generate ui-embedding`. Update command class, messages, tests, package.json topic, and command snapshot. Remove "widget" terminology and standardize angle-bracket usage in help text (). @W-23468815@ @W-23301022@ @W-23301024@ --- command-snapshot.json | 38 ++++++++--------- .../{lightningEmbedding.md => uiEmbedding.md} | 14 +++---- package.json | 3 ++ .../embedding.ts => ui-embedding/index.ts} | 20 ++++----- .../index.nut.ts} | 41 +++++++++---------- 5 files changed, 59 insertions(+), 57 deletions(-) rename messages/{lightningEmbedding.md => uiEmbedding.md} (62%) rename src/commands/template/generate/{lightning/embedding.ts => ui-embedding/index.ts} (84%) rename test/commands/template/generate/{lightning/embedding.nut.ts => ui-embedding/index.nut.ts} (63%) diff --git a/command-snapshot.json b/command-snapshot.json index fa7af857..4d758847 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -79,25 +79,6 @@ "flags": ["api-version", "flags-dir", "internal", "json", "loglevel", "name", "output-dir", "template", "type"], "plugin": "@salesforce/plugin-templates" }, - { - "alias": [], - "command": "template:generate:lightning:embedding", - "flagAliases": ["apiversion", "outputdir"], - "flagChars": ["d", "i", "n", "s"], - "flags": [ - "api-version", - "flags-dir", - "internal", - "json", - "loglevel", - "name", - "output-dir", - "sandbox", - "shell-title", - "src" - ], - "plugin": "@salesforce/plugin-templates" - }, { "alias": ["force:lightning:event:create", "lightning:generate:event"], "command": "template:generate:lightning:event", @@ -159,6 +140,25 @@ "flags": ["api-version", "flags-dir", "json", "label", "name", "output-dir", "template"], "plugin": "@salesforce/plugin-templates" }, + { + "alias": [], + "command": "template:generate:ui-embedding", + "flagAliases": ["apiversion", "outputdir"], + "flagChars": ["d", "i", "n", "s"], + "flags": [ + "api-version", + "flags-dir", + "internal", + "json", + "loglevel", + "name", + "output-dir", + "sandbox", + "shell-title", + "src" + ], + "plugin": "@salesforce/plugin-templates" + }, { "alias": ["force:visualforce:component:create", "visualforce:generate:component"], "command": "template:generate:visualforce:component", diff --git a/messages/lightningEmbedding.md b/messages/uiEmbedding.md similarity index 62% rename from messages/lightningEmbedding.md rename to messages/uiEmbedding.md index e549668b..7a149025 100644 --- a/messages/lightningEmbedding.md +++ b/messages/uiEmbedding.md @@ -2,19 +2,19 @@ - Generate an embedding wrapper LWC in the current directory: - <%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --shell-title "Expense Report Widget" + <%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --shell-title "Expense Report Embedding" - Generate an embedding wrapper LWC in the "force-app/main/default/lwc" directory with multiple sandbox tokens: - <%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --sandbox allow-scripts --shell-title "Expense Report Widget" --output-dir force-app/main/default/lwc + <%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --sandbox allow-scripts --shell-title "Expense Report Embedding" --output-dir force-app/main/default/lwc # summary -Generate a Lightning Web Component (LWC) bundle that wraps the lightning-embedding base component. +Generate a Lightning Web Component (LWC) bundle that wraps the base component. # description -The generated LWC bundle consumes the first-party component, which is pre-wired with the three required attributes: the widget URL (src), iframe sandbox tokens, and an accessible iframe title (shell-title). +The generated LWC bundle consumes the first-party component, which is pre-wired with the three required attributes: the embedding URL (src), iframe sandbox tokens, and an accessible iframe title (shell-title). The generated LWC bundle contains four files (.html, .js, .js-meta.xml, .css) in a directory named with the camelCased component name. The bundle must live under a parent folder named "lwc". @@ -32,7 +32,7 @@ Absolute HTTPS URL that the iframe will load. # flags.src.description -The URL is bound to the "src" attribute as a reactive property in the generated LWC. Must use HTTPS; plain HTTP is allowed only for localhost or 127.0.0.1 (for local development). +The URL is bound to the "src" attribute as a reactive property in the generated LWC. Must use HTTPS; plain HTTP is allowed only for localhost or 127.0.0.1 (for local development). # flags.src.error @@ -44,7 +44,7 @@ Iframe sandbox token. Specify this flag multiple times to set more than one toke # flags.sandbox.description -Each token is written into the space-separated "sandbox" attribute on . Only W3C-defined sandbox tokens are accepted. +Each token is written into the space-separated "sandbox" attribute on . Only W3C-defined sandbox tokens are accepted. # flags.shell-title.summary @@ -52,4 +52,4 @@ Accessible title for the embedded iframe. # flags.shell-title.description -Written to the "shell-title" attribute on and used as the iframe's accessible name (announced by screen readers). +Written to the "shell-title" attribute on and used as the iframe's accessible name (announced by screen readers). diff --git a/package.json b/package.json index e6b987c4..6bfe8602 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,9 @@ }, "ui-bundle": { "description": "Generate a UI bundle." + }, + "ui-embedding": { + "description": "Generate a UI embedding wrapper LWC." } } } diff --git a/src/commands/template/generate/lightning/embedding.ts b/src/commands/template/generate/ui-embedding/index.ts similarity index 84% rename from src/commands/template/generate/lightning/embedding.ts rename to src/commands/template/generate/ui-embedding/index.ts index 2a206395..811d72c5 100644 --- a/src/commands/template/generate/lightning/embedding.ts +++ b/src/commands/template/generate/ui-embedding/index.ts @@ -8,9 +8,9 @@ import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, Ux } from '@salesforce/sf-plugins-core'; import { CreateOutput, - isAllowedLightningEmbeddingSrcUrl, - LIGHTNING_EMBEDDING_SANDBOX_TOKENS, - LightningEmbeddingOptions, + isAllowedUIEmbeddingSrcUrl, + UI_EMBEDDING_SANDBOX_TOKENS, + UIEmbeddingOptions, TemplateType, } from '@salesforce/templates'; import { Messages } from '@salesforce/core'; @@ -18,9 +18,9 @@ import { getCustomTemplates, runGenerator } from '../../../../utils/templateComm import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); -const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningEmbedding'); +const messages = Messages.loadMessages('@salesforce/plugin-templates', 'uiEmbedding'); -export default class LightningEmbedding extends SfCommand { +export default class UIEmbedding extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); public static readonly examples = messages.getMessages('examples'); @@ -40,7 +40,7 @@ export default class LightningEmbedding extends SfCommand { description: messages.getMessage('flags.src.description'), required: true, parse: (input: string) => { - if (!isAllowedLightningEmbeddingSrcUrl(input)) { + if (!isAllowedUIEmbeddingSrcUrl(input)) { throw new Error(messages.getMessage('flags.src.error')); } return Promise.resolve(input); @@ -49,7 +49,7 @@ export default class LightningEmbedding extends SfCommand { sandbox: Flags.option({ summary: messages.getMessage('flags.sandbox.summary'), description: messages.getMessage('flags.sandbox.description'), - options: LIGHTNING_EMBEDDING_SANDBOX_TOKENS, + options: UI_EMBEDDING_SANDBOX_TOKENS, multiple: true, required: true, })(), @@ -65,9 +65,9 @@ export default class LightningEmbedding extends SfCommand { }; public async run(): Promise { - const { flags } = await this.parse(LightningEmbedding); + const { flags } = await this.parse(UIEmbedding); - const flagsAsOptions: LightningEmbeddingOptions = { + const flagsAsOptions: UIEmbeddingOptions = { componentname: flags.name, src: flags.src, sandbox: flags.sandbox.join(' '), @@ -78,7 +78,7 @@ export default class LightningEmbedding extends SfCommand { }; return runGenerator({ - templateType: TemplateType.LightningEmbedding, + templateType: TemplateType.UIEmbedding, opts: flagsAsOptions, ux: new Ux({ jsonEnabled: this.jsonEnabled() }), templates: getCustomTemplates(this.configAggregator), diff --git a/test/commands/template/generate/lightning/embedding.nut.ts b/test/commands/template/generate/ui-embedding/index.nut.ts similarity index 63% rename from test/commands/template/generate/lightning/embedding.nut.ts rename to test/commands/template/generate/ui-embedding/index.nut.ts index 61935abf..0fd969f4 100644 --- a/test/commands/template/generate/lightning/embedding.nut.ts +++ b/test/commands/template/generate/ui-embedding/index.nut.ts @@ -11,7 +11,7 @@ import assert from 'yeoman-assert'; config.truncateThreshold = 0; -describe('template generate lightning embedding:', () => { +describe('template generate ui-embedding:', () => { let session: TestSession; before(async () => { session = await TestSession.create({ @@ -29,31 +29,31 @@ describe('template generate lightning embedding:', () => { return ['.html', '.js', '.css', '.js-meta.xml'].map((suffix) => path.join(lwcDir(), camel, camel + suffix)); }; - describe('Check lightning embedding creation', () => { + describe('Check ui-embedding creation', () => { const name = 'MyEmbedding'; const src = 'https://app.example.com'; const shellTitle = 'Demo Embedding'; it('should scaffold an embedding LWC bundle with all four files', () => { execCmd( - `template generate lightning embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, + `template generate ui-embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.file(bundleFiles(name)); }); - it('should emit a element in the generated html', () => { + it('should emit a element in the generated html', () => { execCmd( - `template generate lightning embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, + `template generate ui-embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); const camel = name.charAt(0).toLowerCase() + name.slice(1); - assert.fileContent(path.join(lwcDir(), camel, `${camel}.html`), ' { execCmd( - `template generate lightning embedding --name MultiSandbox --src ${src} --sandbox allow-forms --sandbox allow-scripts --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, + `template generate ui-embedding --name MultiSandbox --src ${src} --sandbox allow-forms --sandbox allow-scripts --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.fileContent( @@ -64,7 +64,7 @@ describe('template generate lightning embedding:', () => { it('should bind the src URL into the generated js as a reactive property', () => { execCmd( - `template generate lightning embedding --name SrcBinding --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, + `template generate ui-embedding --name SrcBinding --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.fileContent(path.join(lwcDir(), 'srcBinding', 'srcBinding.js'), src); @@ -72,68 +72,67 @@ describe('template generate lightning embedding:', () => { it('should accept http URLs on localhost for local development', () => { execCmd( - `template generate lightning embedding --name LocalDev --src http://localhost:3000 --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, + `template generate ui-embedding --name LocalDev --src http://localhost:3000 --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.fileContent(path.join(lwcDir(), 'localDev', 'localDev.js'), 'http://localhost:3000'); }); }); - describe('lightning embedding failures', () => { + describe('ui-embedding failures', () => { const baseFlags = '--name Foo --sandbox allow-forms --shell-title "Demo"'; it('should throw missing --name error', () => { const stderr = execCmd( - 'template generate lightning embedding --src https://app.example.com --sandbox allow-forms --shell-title "Demo"' + 'template generate ui-embedding --src https://app.example.com --sandbox allow-forms --shell-title "Demo"' ).shellOutput.stderr; expect(stderr).to.contain('Missing required flag'); }); it('should throw missing --src error', () => { - const stderr = execCmd( - 'template generate lightning embedding --name Foo --sandbox allow-forms --shell-title "Demo"' - ).shellOutput.stderr; + const stderr = execCmd('template generate ui-embedding --name Foo --sandbox allow-forms --shell-title "Demo"') + .shellOutput.stderr; expect(stderr).to.contain('Missing required flag'); }); it('should throw missing --sandbox error', () => { const stderr = execCmd( - 'template generate lightning embedding --name Foo --src https://app.example.com --shell-title "Demo"' + 'template generate ui-embedding --name Foo --src https://app.example.com --shell-title "Demo"' ).shellOutput.stderr; expect(stderr).to.contain('Missing required flag'); }); it('should throw missing --shell-title error (no fallback to --name)', () => { const stderr = execCmd( - 'template generate lightning embedding --name Foo --src https://app.example.com --sandbox allow-forms' + 'template generate ui-embedding --name Foo --src https://app.example.com --sandbox allow-forms' ).shellOutput.stderr; expect(stderr).to.contain('Missing required flag'); }); it('should reject http src on a non-localhost host', () => { const stderr = execCmd( - `template generate lightning embedding --name Foo --src http://attacker.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}` + `template generate ui-embedding --name Foo --src http://attacker.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}` ).shellOutput.stderr; expect(stderr).to.contain('HTTPS URL'); }); it('should reject non-http(s) protocols', () => { const stderr = execCmd( - `template generate lightning embedding --name Foo --src ftp://example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}` + `template generate ui-embedding --name Foo --src ftp://example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}` ).shellOutput.stderr; expect(stderr).to.contain('HTTPS URL'); }); it('should reject malformed --src input', () => { const stderr = execCmd( - `template generate lightning embedding --name Foo --src not-a-url --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}` + `template generate ui-embedding --name Foo --src not-a-url --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}` ).shellOutput.stderr; expect(stderr).to.contain('HTTPS URL'); }); it('should reject an unknown sandbox token', () => { const stderr = execCmd( - `template generate lightning embedding ${baseFlags} --src https://app.example.com --sandbox allow-everything --output-dir ${lwcDir()}`, + `template generate ui-embedding ${baseFlags} --src https://app.example.com --sandbox allow-everything --output-dir ${lwcDir()}`, { ensureExitCode: 'nonZero' } ).shellOutput.stderr; expect(stderr).to.contain('Expected --sandbox'); @@ -141,7 +140,7 @@ describe('template generate lightning embedding:', () => { it('should throw missing lwc parent folder error when output-dir is not under lwc/', () => { const stderr = execCmd( - `template generate lightning embedding --name Foo --src https://app.example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${path.join( + `template generate ui-embedding --name Foo --src https://app.example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${path.join( session.project.dir, 'somewhere-else' )}` From 4814161fd82771c30fa25fa6c809e08b54417eae Mon Sep 17 00:00:00 2001 From: AMAN SINGH Date: Wed, 22 Jul 2026 09:31:48 +0530 Subject: [PATCH 2/2] chore: rename schema file for ui-embedding command --- ...htning-embedding.json => template-generate-ui__embedding.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename schemas/{template-generate-lightning-embedding.json => template-generate-ui__embedding.json} (100%) diff --git a/schemas/template-generate-lightning-embedding.json b/schemas/template-generate-ui__embedding.json similarity index 100% rename from schemas/template-generate-lightning-embedding.json rename to schemas/template-generate-ui__embedding.json