Skip to content

Commit fbdb08a

Browse files
committed
feat: defer component selection
1 parent 43f0093 commit fbdb08a

File tree

4 files changed

+417
-250
lines changed

4 files changed

+417
-250
lines changed

messages/lightning.dev.component.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ See the LWC Development Guide for more information about component development b
2020

2121
Name of a component to preview.
2222

23+
# flags.client-select.summary
24+
25+
Launch component preview without selecting a component
26+
2327
# error.directory
2428

2529
Unable to find components

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@inquirer/select": "^2.4.7",
1010
"@lwc/lwc-dev-server": "~12.3.1",
1111
"@lwc/sfdc-lwc-compiler": "~12.3.1",
12-
"@lwrjs/api": "0.18.1",
12+
"@lwrjs/api": "0.18.3",
1313
"@oclif/core": "^4.1.0",
1414
"@salesforce/core": "^8.6.2",
1515
"@salesforce/kit": "^3.1.6",

src/commands/lightning/dev/component.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export default class LightningDevComponent extends SfCommand<void> {
2727
char: 'n',
2828
requiredOrDefaulted: false,
2929
}),
30+
'client-select': Flags.boolean({
31+
summary: messages.getMessage('flags.client-select.summary'),
32+
char: 'c',
33+
default: false,
34+
}),
3035
// TODO should this be required or optional?
3136
// We don't technically need this if your components are simple / don't need any data from your org
3237
'target-org': Flags.optionalOrg(),
@@ -71,19 +76,21 @@ export default class LightningDevComponent extends SfCommand<void> {
7176
).filter((component) => !!component);
7277

7378
let name = flags.name;
74-
if (name) {
75-
// validate that the component exists before launching the server
76-
const match = components.find((component) => name === component.name || name === component.label);
77-
if (!match) {
78-
throw new Error(messages.getMessage('error.component-not-found', [name]));
79-
}
79+
if (!flags['client-select']) {
80+
if (name) {
81+
// validate that the component exists before launching the server
82+
const match = components.find((component) => name === component.name || name === component.label);
83+
if (!match) {
84+
throw new Error(messages.getMessage('error.component-not-found', [name]));
85+
}
8086

81-
name = match.name;
82-
} else {
83-
// prompt the user for a name if one was not provided
84-
name = await PromptUtils.promptUserToSelectComponent(components);
85-
if (!name) {
86-
throw new Error(messages.getMessage('error.component'));
87+
name = match.name;
88+
} else {
89+
// prompt the user for a name if one was not provided
90+
name = await PromptUtils.promptUserToSelectComponent(components);
91+
if (!name) {
92+
throw new Error(messages.getMessage('error.component'));
93+
}
8794
}
8895
}
8996

@@ -95,7 +102,7 @@ export default class LightningDevComponent extends SfCommand<void> {
95102
rootDir,
96103
mode: 'dev',
97104
port,
98-
name: `c/${name}`,
105+
name: name ? `c/${name}` : undefined,
99106
namespacePaths,
100107
});
101108
}

0 commit comments

Comments
 (0)