diff --git a/command-snapshot.json b/command-snapshot.json index 4d758847..6feaf042 100644 --- a/command-snapshot.json +++ b/command-snapshot.json @@ -154,8 +154,8 @@ "name", "output-dir", "sandbox", - "shell-title", - "src" + "src", + "title" ], "plugin": "@salesforce/plugin-templates" }, diff --git a/messages/uiEmbedding.md b/messages/uiEmbedding.md index 7a149025..24775c19 100644 --- a/messages/uiEmbedding.md +++ b/messages/uiEmbedding.md @@ -2,11 +2,11 @@ - 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 Embedding" + <%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --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 Embedding" --output-dir force-app/main/default/lwc + <%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --sandbox allow-scripts --title "Expense Report Embedding" --output-dir force-app/main/default/lwc # summary @@ -14,7 +14,7 @@ Generate a Lightning Web Component (LWC) bundle that wraps the 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 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 (--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". @@ -46,10 +46,10 @@ Iframe sandbox token. Specify this flag multiple times to set more than one toke Each token is written into the space-separated "sandbox" attribute on . Only W3C-defined sandbox tokens are accepted. -# flags.shell-title.summary +# flags.title.summary Accessible title for the embedded iframe. -# flags.shell-title.description +# flags.title.description 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 4e534b0b..f28a3619 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dependencies": { "@salesforce/core": "^9.1.9", "@salesforce/sf-plugins-core": "^13.0.4", - "@salesforce/templates": "^66.14.0" + "@salesforce/templates": "^66.15.0" }, "devDependencies": { "@oclif/plugin-command-snapshot": "^6.0.0", diff --git a/src/commands/template/generate/ui-embedding/index.ts b/src/commands/template/generate/ui-embedding/index.ts index c2384a51..1b3fdec5 100644 --- a/src/commands/template/generate/ui-embedding/index.ts +++ b/src/commands/template/generate/ui-embedding/index.ts @@ -60,9 +60,9 @@ export default class UIEmbedding extends SfCommand { multiple: true, required: true, })(), - 'shell-title': Flags.string({ - summary: messages.getMessage('flags.shell-title.summary'), - description: messages.getMessage('flags.shell-title.description'), + title: Flags.string({ + summary: messages.getMessage('flags.title.summary'), + description: messages.getMessage('flags.title.description'), required: true, }), 'output-dir': outputDirFlagLightning, @@ -78,7 +78,7 @@ export default class UIEmbedding extends SfCommand { componentname: flags.name, src: flags.src, sandbox: flags.sandbox.join(' '), - shellTitle: flags['shell-title'], + title: flags.title, outputdir: flags['output-dir'], apiversion: flags['api-version'], internal: flags.internal, diff --git a/test/commands/template/generate/ui-embedding/index.nut.ts b/test/commands/template/generate/ui-embedding/index.nut.ts index 0b5bcd68..b5a5c5ee 100644 --- a/test/commands/template/generate/ui-embedding/index.nut.ts +++ b/test/commands/template/generate/ui-embedding/index.nut.ts @@ -45,7 +45,7 @@ describe('template generate ui-embedding:', () => { it('should scaffold an embedding LWC bundle with all four files', () => { execCmd( - `template generate ui-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 --title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.file(bundleFiles(name)); @@ -53,7 +53,7 @@ describe('template generate ui-embedding:', () => { it('should emit a element in the generated html', () => { execCmd( - `template generate ui-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 --title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); const camel = name.charAt(0).toLowerCase() + name.slice(1); @@ -62,7 +62,7 @@ describe('template generate ui-embedding:', () => { it('should join multiple --sandbox tokens into a single space-separated attribute', () => { execCmd( - `template generate ui-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 --title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.fileContent( @@ -73,7 +73,7 @@ describe('template generate ui-embedding:', () => { it('should bind the src URL into the generated js as a reactive property', () => { execCmd( - `template generate ui-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 --title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.fileContent(path.join(lwcDir(), 'srcBinding', 'srcBinding.js'), src); @@ -81,7 +81,7 @@ describe('template generate ui-embedding:', () => { it('should accept http URLs on localhost for local development', () => { execCmd( - `template generate ui-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 --title "${shellTitle}" --output-dir ${lwcDir()}`, { ensureExitCode: 0 } ); assert.fileContent(path.join(lwcDir(), 'localDev', 'localDev.js'), 'http://localhost:3000'); @@ -89,29 +89,29 @@ describe('template generate ui-embedding:', () => { }); describe('ui-embedding failures', () => { - const baseFlags = '--name Foo --sandbox allow-forms --shell-title "Demo"'; + const baseFlags = '--name Foo --sandbox allow-forms --title "Demo"'; it('should throw missing --name error', () => { const stderr = execCmd( - 'template generate ui-embedding --src https://app.example.com --sandbox allow-forms --shell-title "Demo"' + 'template generate ui-embedding --src https://app.example.com --sandbox allow-forms --title "Demo"' ).shellOutput.stderr; expect(stderr).to.contain('Missing required flag'); }); it('should throw missing --src error', () => { - const stderr = execCmd('template generate ui-embedding --name Foo --sandbox allow-forms --shell-title "Demo"') + const stderr = execCmd('template generate ui-embedding --name Foo --sandbox allow-forms --title "Demo"') .shellOutput.stderr; expect(stderr).to.contain('Missing required flag'); }); it('should throw missing --sandbox error', () => { const stderr = execCmd( - 'template generate ui-embedding --name Foo --src https://app.example.com --shell-title "Demo"' + 'template generate ui-embedding --name Foo --src https://app.example.com --title "Demo"' ).shellOutput.stderr; expect(stderr).to.contain('Missing required flag'); }); - it('should throw missing --shell-title error (no fallback to --name)', () => { + it('should throw missing --title error (no fallback to --name)', () => { const stderr = execCmd( 'template generate ui-embedding --name Foo --src https://app.example.com --sandbox allow-forms' ).shellOutput.stderr; @@ -120,21 +120,21 @@ describe('template generate ui-embedding:', () => { it('should reject http src on a non-localhost host', () => { const stderr = execCmd( - `template generate ui-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 --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 ui-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 --title "Demo" --output-dir ${lwcDir()}` ).shellOutput.stderr; expect(stderr).to.contain('HTTPS URL'); }); it('should reject malformed --src input', () => { const stderr = execCmd( - `template generate ui-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 --title "Demo" --output-dir ${lwcDir()}` ).shellOutput.stderr; expect(stderr).to.contain('HTTPS URL'); }); @@ -149,7 +149,7 @@ describe('template generate ui-embedding:', () => { it('should throw missing lwc parent folder error when output-dir is not under lwc/', () => { const stderr = execCmd( - `template generate ui-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 --title "Demo" --output-dir ${path.join( session.project.dir, 'somewhere-else' )}` diff --git a/yarn.lock b/yarn.lock index 341e9ec5..ba3dd8cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1436,10 +1436,10 @@ cli-progress "^3.12.0" terminal-link "^3.0.0" -"@salesforce/templates@^66.14.0": - version "66.14.0" - resolved "https://registry.yarnpkg.com/@salesforce/templates/-/templates-66.14.0.tgz#9ce7e15419094841116500922129554164b28366" - integrity sha512-4tmVFM3/9GefMXmhAoVA43qC4Zq6ir3rWQ8fEJimGizCo6qjsNs9gn1e3nQKldXSgXlt1T6SB0tgnMgsZnp2og== +"@salesforce/templates@^66.15.0": + version "66.15.0" + resolved "https://registry.yarnpkg.com/@salesforce/templates/-/templates-66.15.0.tgz#2b64727feaac1cc947fd8f7eff87f22cc2d9cdb3" + integrity sha512-wOFos8lh/xsswuRs7z3o6D8pCtmScC0LJ0Jzbzz6SxZGxYKoI09NpgXwvCOzZkLRqyCYNUknQi0UplOP2PaIOw== dependencies: "@salesforce/kit" "^4.0.0" ejs "^3.1.10"