Skip to content

feat: @W-18182827@ defer component selection #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"alias": [],
"command": "lightning:dev:component",
"flagAliases": [],
"flagChars": ["n", "o"],
"flags": ["flags-dir", "json", "name", "target-org"],
"flagChars": ["c", "n", "o"],
"flags": ["client-select", "flags-dir", "json", "name", "target-org"],
"plugin": "@salesforce/plugin-lightning-dev"
},
{
Expand Down
4 changes: 4 additions & 0 deletions messages/lightning.dev.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ See the LWC Development Guide for more information about component development b

Name of a component to preview.

# flags.client-select.summary

Launch component preview without selecting a component

# error.directory

Unable to find components
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@inquirer/select": "^2.4.7",
"@lwc/lwc-dev-server": "~12.3.1",
"@lwc/sfdc-lwc-compiler": "~12.3.1",
"@lwrjs/api": "0.18.1",
"@lwrjs/api": "0.18.3",
"@oclif/core": "^4.1.0",
"@salesforce/core": "^8.6.2",
"@salesforce/kit": "^3.1.6",
Expand Down
33 changes: 20 additions & 13 deletions src/commands/lightning/dev/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export default class LightningDevComponent extends SfCommand<void> {
char: 'n',
requiredOrDefaulted: false,
}),
'client-select': Flags.boolean({
summary: messages.getMessage('flags.client-select.summary'),
char: 'c',
default: false,
}),
// TODO should this be required or optional?
// We don't technically need this if your components are simple / don't need any data from your org
'target-org': Flags.optionalOrg(),
Expand Down Expand Up @@ -71,19 +76,21 @@ export default class LightningDevComponent extends SfCommand<void> {
).filter((component) => !!component);

let name = flags.name;
if (name) {
// validate that the component exists before launching the server
const match = components.find((component) => name === component.name || name === component.label);
if (!match) {
throw new Error(messages.getMessage('error.component-not-found', [name]));
}
if (!flags['client-select']) {
if (name) {
// validate that the component exists before launching the server
const match = components.find((component) => name === component.name || name === component.label);
if (!match) {
throw new Error(messages.getMessage('error.component-not-found', [name]));
}

name = match.name;
} else {
// prompt the user for a name if one was not provided
name = await PromptUtils.promptUserToSelectComponent(components);
if (!name) {
throw new Error(messages.getMessage('error.component'));
name = match.name;
} else {
// prompt the user for a name if one was not provided
name = await PromptUtils.promptUserToSelectComponent(components);
if (!name) {
throw new Error(messages.getMessage('error.component'));
}
}
}

Expand All @@ -95,7 +102,7 @@ export default class LightningDevComponent extends SfCommand<void> {
rootDir,
mode: 'dev',
port,
name: `c/${name}`,
name: name ? `c/${name}` : undefined,
namespacePaths,
});
}
Expand Down
Loading
Loading