Skip to content

Commit b4c8924

Browse files
authored
fix: @ W-17818313 add base components and support label selection (#379)
* fix: add base components and support label selection * chore: upgrade lwr
1 parent ddc8c87 commit b4c8924

File tree

5 files changed

+776
-566
lines changed

5 files changed

+776
-566
lines changed

lwc.config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"modules": [
3+
{
4+
"npm": "lightning-base-components"
5+
}
6+
]
7+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
"@inquirer/select": "^2.4.7",
1010
"@lwc/lwc-dev-server": "~11.5.0",
1111
"@lwc/sfdc-lwc-compiler": "~11.5.0",
12-
"@lwrjs/api": "0.16.10",
12+
"@lwrjs/api": "0.18.1",
1313
"@oclif/core": "^4.1.0",
1414
"@salesforce/core": "^8.6.2",
1515
"@salesforce/kit": "^3.1.6",
1616
"@salesforce/lwc-dev-mobile-core": "4.0.0-alpha.9",
1717
"@salesforce/sf-plugins-core": "^11.2.4",
1818
"axios": "^1.7.9",
1919
"glob": "^10.4.5",
20+
"lightning-base-components": "1.27.2-alpha",
2021
"lwc": "~8.12.5",
2122
"node-fetch": "^3.3.2",
2223
"xml2js": "^0.6.2"

src/commands/lightning/dev/component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import path from 'node:path';
9+
import url from 'node:url';
910
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
1011
import { Messages, SfProject } from '@salesforce/core';
1112
import { cmpDev } from '@lwrjs/api';
@@ -72,9 +73,12 @@ export default class LightningDevComponent extends SfCommand<void> {
7273
let name = flags.name;
7374
if (name) {
7475
// validate that the component exists before launching the server
75-
if (!components.find((component) => name === component.name)) {
76+
const match = components.find((component) => name === component.name || name === component.label);
77+
if (!match) {
7678
throw new Error(messages.getMessage('error.component-not-found', [name]));
7779
}
80+
81+
name = match.name;
7882
} else {
7983
// prompt the user for a name if one was not provided
8084
name = await PromptUtils.promptUserToSelectComponent(components);
@@ -83,12 +87,16 @@ export default class LightningDevComponent extends SfCommand<void> {
8387
}
8488
}
8589

90+
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
91+
const rootDir = path.resolve(dirname, '../../../..');
8692
const port = parseInt(process.env.PORT ?? '3000', 10);
8793

8894
await cmpDev({
95+
rootDir,
8996
mode: 'dev',
9097
port,
9198
name: `c/${name}`,
99+
namespacePaths,
92100
});
93101
}
94102
}

src/shared/componentUtils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,31 @@ export class ComponentUtils {
5757
return undefined;
5858
}
5959

60+
if (parsedData.LightningComponentBundle) {
61+
parsedData.LightningComponentBundle.masterLabel = this.normalizeMetaProperty(
62+
parsedData.LightningComponentBundle.masterLabel
63+
);
64+
parsedData.LightningComponentBundle.description = this.normalizeMetaProperty(
65+
parsedData.LightningComponentBundle.description
66+
);
67+
}
68+
6069
return parsedData;
6170
}
6271

6372
private static isLwcMetadata(obj: unknown): obj is LwcMetadata {
6473
return (obj && typeof obj === 'object' && 'LightningComponentBundle' in obj) === true;
6574
}
75+
76+
private static normalizeMetaProperty(prop: string[] | string | undefined): string | undefined {
77+
if (!prop || typeof prop === 'string') {
78+
return prop;
79+
}
80+
81+
if (Array.isArray(prop) && prop.length > 0) {
82+
return prop[0];
83+
}
84+
85+
return undefined;
86+
}
6687
}

0 commit comments

Comments
 (0)