Skip to content

Commit b94bae8

Browse files
authored
Merge pull request #995 from aman06it/feat/rename-ui-embedding
feat: rename lightning embedding command to ui-embedding
2 parents 59aca46 + f470da4 commit b94bae8

6 files changed

Lines changed: 51 additions & 49 deletions

File tree

command-snapshot.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,6 @@
7979
"flags": ["api-version", "flags-dir", "internal", "json", "loglevel", "name", "output-dir", "template", "type"],
8080
"plugin": "@salesforce/plugin-templates"
8181
},
82-
{
83-
"alias": [],
84-
"command": "template:generate:lightning:embedding",
85-
"flagAliases": ["apiversion", "outputdir"],
86-
"flagChars": ["d", "i", "n", "s"],
87-
"flags": [
88-
"api-version",
89-
"flags-dir",
90-
"internal",
91-
"json",
92-
"loglevel",
93-
"name",
94-
"output-dir",
95-
"sandbox",
96-
"shell-title",
97-
"src"
98-
],
99-
"plugin": "@salesforce/plugin-templates"
100-
},
10182
{
10283
"alias": ["force:lightning:event:create", "lightning:generate:event"],
10384
"command": "template:generate:lightning:event",
@@ -159,6 +140,25 @@
159140
"flags": ["api-version", "flags-dir", "json", "label", "name", "output-dir", "template"],
160141
"plugin": "@salesforce/plugin-templates"
161142
},
143+
{
144+
"alias": [],
145+
"command": "template:generate:ui-embedding",
146+
"flagAliases": ["apiversion", "outputdir"],
147+
"flagChars": ["d", "i", "n", "s"],
148+
"flags": [
149+
"api-version",
150+
"flags-dir",
151+
"internal",
152+
"json",
153+
"loglevel",
154+
"name",
155+
"output-dir",
156+
"sandbox",
157+
"shell-title",
158+
"src"
159+
],
160+
"plugin": "@salesforce/plugin-templates"
161+
},
162162
{
163163
"alias": ["force:visualforce:component:create", "visualforce:generate:component"],
164164
"command": "template:generate:visualforce:component",
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
- Generate an embedding wrapper LWC in the current directory:
44

5-
<%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --shell-title "Expense Report Widget"
5+
<%= config.bin %> <%= command.id %> --name MyEmbeddingWrapper --src https://app.example.com --sandbox allow-forms --shell-title "Expense Report Embedding"
66

77
- Generate an embedding wrapper LWC in the "force-app/main/default/lwc" directory with multiple sandbox tokens:
88

9-
<%= 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
9+
<%= 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
1010

1111
# summary
1212

13-
Generate a Lightning Web Component (LWC) bundle that wraps the lightning-embedding base component.
13+
Generate a Lightning Web Component (LWC) bundle that wraps the <lightning-ui-embedding> base component.
1414

1515
# description
1616

17-
The generated LWC bundle consumes the first-party <lightning-embedding> component, which is pre-wired with the three required attributes: the widget URL (src), iframe sandbox tokens, and an accessible iframe title (shell-title).
17+
The generated LWC bundle consumes the first-party <lightning-ui-embedding> component, which is pre-wired with the three required attributes: the embedding URL (src), iframe sandbox tokens, and an accessible iframe title (shell-title).
1818

1919
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".
2020

@@ -32,7 +32,7 @@ Absolute HTTPS URL that the iframe will load.
3232

3333
# flags.src.description
3434

35-
The URL is bound to the <lightning-embedding> "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).
35+
The URL is bound to the <lightning-ui-embedding> "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).
3636

3737
# flags.src.error
3838

@@ -44,12 +44,12 @@ Iframe sandbox token. Specify this flag multiple times to set more than one toke
4444

4545
# flags.sandbox.description
4646

47-
Each token is written into the space-separated "sandbox" attribute on <lightning-embedding>. Only W3C-defined sandbox tokens are accepted.
47+
Each token is written into the space-separated "sandbox" attribute on <lightning-ui-embedding>. Only W3C-defined sandbox tokens are accepted.
4848

4949
# flags.shell-title.summary
5050

5151
Accessible title for the embedded iframe.
5252

5353
# flags.shell-title.description
5454

55-
Written to the "shell-title" attribute on <lightning-embedding> and used as the iframe's accessible name (announced by screen readers).
55+
Written to the "shell-title" attribute on <lightning-ui-embedding> and used as the iframe's accessible name (announced by screen readers).

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
},
8787
"ui-bundle": {
8888
"description": "Generate a UI bundle."
89+
},
90+
"ui-embedding": {
91+
"description": "Generate a UI embedding wrapper LWC."
8992
}
9093
}
9194
}
File renamed without changes.

src/commands/template/generate/lightning/embedding.ts renamed to src/commands/template/generate/ui-embedding/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import { getCustomTemplates, runGenerator } from '../../../../utils/templateComm
1818
import { internalFlag, outputDirFlagLightning } from '../../../../utils/flags.js';
1919

2020
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
21-
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'lightningEmbedding');
21+
const messages = Messages.loadMessages('@salesforce/plugin-templates', 'uiEmbedding');
2222

23-
export default class LightningEmbedding extends SfCommand<CreateOutput> {
23+
export default class UIEmbedding extends SfCommand<CreateOutput> {
2424
public static readonly summary = messages.getMessage('summary');
2525
public static readonly description = messages.getMessage('description');
2626
public static readonly examples = messages.getMessages('examples');
@@ -65,7 +65,7 @@ export default class LightningEmbedding extends SfCommand<CreateOutput> {
6565
};
6666

6767
public async run(): Promise<CreateOutput> {
68-
const { flags } = await this.parse(LightningEmbedding);
68+
const { flags } = await this.parse(UIEmbedding);
6969

7070
const flagsAsOptions: UIEmbeddingOptions = {
7171
componentname: flags.name,

test/commands/template/generate/lightning/embedding.nut.ts renamed to test/commands/template/generate/ui-embedding/index.nut.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import assert from 'yeoman-assert';
1111

1212
config.truncateThreshold = 0;
1313

14-
describe('template generate lightning embedding:', () => {
14+
describe('template generate ui-embedding:', () => {
1515
let session: TestSession;
1616
before(async () => {
1717
session = await TestSession.create({
@@ -29,22 +29,22 @@ describe('template generate lightning embedding:', () => {
2929
return ['.html', '.js', '.css', '.js-meta.xml'].map((suffix) => path.join(lwcDir(), camel, camel + suffix));
3030
};
3131

32-
describe('Check lightning embedding creation', () => {
32+
describe('Check ui-embedding creation', () => {
3333
const name = 'MyEmbedding';
3434
const src = 'https://app.example.com';
3535
const shellTitle = 'Demo Embedding';
3636

3737
it('should scaffold an embedding LWC bundle with all four files', () => {
3838
execCmd(
39-
`template generate lightning embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
39+
`template generate ui-embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
4040
{ ensureExitCode: 0 }
4141
);
4242
assert.file(bundleFiles(name));
4343
});
4444

45-
it('should emit a <lightning-embedding> element in the generated html', () => {
45+
it('should emit a <lightning-ui-embedding> element in the generated html', () => {
4646
execCmd(
47-
`template generate lightning embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
47+
`template generate ui-embedding --name ${name} --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
4848
{ ensureExitCode: 0 }
4949
);
5050
const camel = name.charAt(0).toLowerCase() + name.slice(1);
@@ -53,7 +53,7 @@ describe('template generate lightning embedding:', () => {
5353

5454
it('should join multiple --sandbox tokens into a single space-separated attribute', () => {
5555
execCmd(
56-
`template generate lightning embedding --name MultiSandbox --src ${src} --sandbox allow-forms --sandbox allow-scripts --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
56+
`template generate ui-embedding --name MultiSandbox --src ${src} --sandbox allow-forms --sandbox allow-scripts --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
5757
{ ensureExitCode: 0 }
5858
);
5959
assert.fileContent(
@@ -64,84 +64,83 @@ describe('template generate lightning embedding:', () => {
6464

6565
it('should bind the src URL into the generated js as a reactive property', () => {
6666
execCmd(
67-
`template generate lightning embedding --name SrcBinding --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
67+
`template generate ui-embedding --name SrcBinding --src ${src} --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
6868
{ ensureExitCode: 0 }
6969
);
7070
assert.fileContent(path.join(lwcDir(), 'srcBinding', 'srcBinding.js'), src);
7171
});
7272

7373
it('should accept http URLs on localhost for local development', () => {
7474
execCmd(
75-
`template generate lightning embedding --name LocalDev --src http://localhost:3000 --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
75+
`template generate ui-embedding --name LocalDev --src http://localhost:3000 --sandbox allow-forms --shell-title "${shellTitle}" --output-dir ${lwcDir()}`,
7676
{ ensureExitCode: 0 }
7777
);
7878
assert.fileContent(path.join(lwcDir(), 'localDev', 'localDev.js'), 'http://localhost:3000');
7979
});
8080
});
8181

82-
describe('lightning embedding failures', () => {
82+
describe('ui-embedding failures', () => {
8383
const baseFlags = '--name Foo --sandbox allow-forms --shell-title "Demo"';
8484

8585
it('should throw missing --name error', () => {
8686
const stderr = execCmd(
87-
'template generate lightning embedding --src https://app.example.com --sandbox allow-forms --shell-title "Demo"'
87+
'template generate ui-embedding --src https://app.example.com --sandbox allow-forms --shell-title "Demo"'
8888
).shellOutput.stderr;
8989
expect(stderr).to.contain('Missing required flag');
9090
});
9191

9292
it('should throw missing --src error', () => {
93-
const stderr = execCmd(
94-
'template generate lightning embedding --name Foo --sandbox allow-forms --shell-title "Demo"'
95-
).shellOutput.stderr;
93+
const stderr = execCmd('template generate ui-embedding --name Foo --sandbox allow-forms --shell-title "Demo"')
94+
.shellOutput.stderr;
9695
expect(stderr).to.contain('Missing required flag');
9796
});
9897

9998
it('should throw missing --sandbox error', () => {
10099
const stderr = execCmd(
101-
'template generate lightning embedding --name Foo --src https://app.example.com --shell-title "Demo"'
100+
'template generate ui-embedding --name Foo --src https://app.example.com --shell-title "Demo"'
102101
).shellOutput.stderr;
103102
expect(stderr).to.contain('Missing required flag');
104103
});
105104

106105
it('should throw missing --shell-title error (no fallback to --name)', () => {
107106
const stderr = execCmd(
108-
'template generate lightning embedding --name Foo --src https://app.example.com --sandbox allow-forms'
107+
'template generate ui-embedding --name Foo --src https://app.example.com --sandbox allow-forms'
109108
).shellOutput.stderr;
110109
expect(stderr).to.contain('Missing required flag');
111110
});
112111

113112
it('should reject http src on a non-localhost host', () => {
114113
const stderr = execCmd(
115-
`template generate lightning embedding --name Foo --src http://attacker.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}`
114+
`template generate ui-embedding --name Foo --src http://attacker.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}`
116115
).shellOutput.stderr;
117116
expect(stderr).to.contain('HTTPS URL');
118117
});
119118

120119
it('should reject non-http(s) protocols', () => {
121120
const stderr = execCmd(
122-
`template generate lightning embedding --name Foo --src ftp://example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}`
121+
`template generate ui-embedding --name Foo --src ftp://example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}`
123122
).shellOutput.stderr;
124123
expect(stderr).to.contain('HTTPS URL');
125124
});
126125

127126
it('should reject malformed --src input', () => {
128127
const stderr = execCmd(
129-
`template generate lightning embedding --name Foo --src not-a-url --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}`
128+
`template generate ui-embedding --name Foo --src not-a-url --sandbox allow-forms --shell-title "Demo" --output-dir ${lwcDir()}`
130129
).shellOutput.stderr;
131130
expect(stderr).to.contain('HTTPS URL');
132131
});
133132

134133
it('should reject an unknown sandbox token', () => {
135134
const stderr = execCmd(
136-
`template generate lightning embedding ${baseFlags} --src https://app.example.com --sandbox allow-everything --output-dir ${lwcDir()}`,
135+
`template generate ui-embedding ${baseFlags} --src https://app.example.com --sandbox allow-everything --output-dir ${lwcDir()}`,
137136
{ ensureExitCode: 'nonZero' }
138137
).shellOutput.stderr;
139138
expect(stderr).to.contain('Expected --sandbox');
140139
});
141140

142141
it('should throw missing lwc parent folder error when output-dir is not under lwc/', () => {
143142
const stderr = execCmd(
144-
`template generate lightning embedding --name Foo --src https://app.example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${path.join(
143+
`template generate ui-embedding --name Foo --src https://app.example.com --sandbox allow-forms --shell-title "Demo" --output-dir ${path.join(
145144
session.project.dir,
146145
'somewhere-else'
147146
)}`

0 commit comments

Comments
 (0)