Skip to content

Commit e163efd

Browse files
authored
feat: pull forward 254-patch fixes @W-17682405 (#334)
* feat: 254-patch prerelease @W-15440507@ (#300) * chore(release): 2.8.0 [skip ci] * feat: [sites] add `get-latest` cli parameter / update lwr -> v0.16.2 (includes latest local-dev fixes) (#311) * chore(release): 2.9.0 [skip ci] * feat: add api flags for testing (#319) * chore(release): 2.10.0 [skip ci] * chore: update lwc oss dependency to 8.10.3 to match spring25 @W-17663897 (#320) * chore: update lwc oss dependency to 8.10.3 to match spring25 * fix: pin to same minor version as salesforce core's lwc dependencies * fix: adopt lwr v0.16.3 (#325) - address authentication cookie issues - render commerce b2b store - enable switching between auth / guest user mode * chore(release): 2.10.1 [skip ci] * fix: hot reload not working on windows (#330) * chore(release): 2.10.2 [skip ci]
1 parent accfa2b commit e163efd

File tree

12 files changed

+389
-354
lines changed

12 files changed

+389
-354
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,15 @@ _See code: [src/commands/lightning/dev/app.ts](https://github.com/salesforcecli/
204204

205205
## `sf lightning dev site`
206206

207-
Preview an Experience Builder site locally and in real-time, without deploying it.
207+
[Beta] Preview an Experience Builder site locally and in real-time, without deploying it.
208208

209209
```
210210
USAGE
211-
$ sf lightning dev site -o <value> [--flags-dir <value>] [-n <value>]
211+
$ sf lightning dev site -o <value> [--flags-dir <value>] [-n <value>] [-l]
212212
213213
FLAGS
214+
-l, --get-latest Download the latest version of the specified site from your org, instead of using any local
215+
cache.
214216
-n, --name=<value> Name of the Experience Builder site to preview. It has to match a site name from the current
215217
org.
216218
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
@@ -220,7 +222,7 @@ GLOBAL FLAGS
220222
--flags-dir=<value> Import flag values from a directory.
221223
222224
DESCRIPTION
223-
Preview an Experience Builder site locally and in real-time, without deploying it.
225+
[Beta] Preview an Experience Builder site locally and in real-time, without deploying it.
224226
225227
Enable Local Dev to see local changes to your site in a real-time preview that you don't have to deploy or manually
226228
refresh. To let you quickly iterate on your Lightning web components (LWCs) and pages, your site preview automatically
@@ -239,9 +241,17 @@ DESCRIPTION
239241
For more considerations and limitations, see the Lightning Web Components Developer Guide.
240242
241243
EXAMPLES
244+
Select a site to preview from the org "myOrg":
245+
246+
$ sf lightning dev site --target-org myOrg
247+
242248
Preview the site "Partner Central" from the org "myOrg":
243249
244250
$ sf lightning dev site --name "Partner Central" --target-org myOrg
251+
252+
Get and preview the latest version of the "Partner Central" site from the org "myOrg"
253+
254+
$ sf lightning dev site --name "Partner Central" --target-org myOrg --get-latest
245255
```
246256

247257
_See code: [src/commands/lightning/dev/site.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/3.0.0/src/commands/lightning/dev/site.ts)_

command-snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"alias": [],
1212
"command": "lightning:dev:site",
1313
"flagAliases": [],
14-
"flagChars": ["n", "o"],
15-
"flags": ["flags-dir", "name", "target-org"],
14+
"flagChars": ["l", "n", "o"],
15+
"flags": ["flags-dir", "get-latest", "name", "target-org"],
1616
"plugin": "@salesforce/plugin-lightning-dev"
1717
}
1818
]

messages/lightning.dev.site.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# summary
22

3-
Preview an Experience Builder site locally and in real-time, without deploying it.
3+
[Beta] Preview an Experience Builder site locally and in real-time, without deploying it.
44

55
# description
66

@@ -21,7 +21,15 @@ For more considerations and limitations, see the Lightning Web Components Develo
2121

2222
Name of the Experience Builder site to preview. It has to match a site name from the current org.
2323

24+
# flags.get-latest.summary
25+
26+
Download the latest version of the specified site from your org, instead of using any local cache.
27+
2428
# examples
2529

30+
- Select a site to preview from the org "myOrg":
31+
<%= config.bin %> <%= command.id %> --target-org myOrg
2632
- Preview the site "Partner Central" from the org "myOrg":
2733
<%= config.bin %> <%= command.id %> --name "Partner Central" --target-org myOrg
34+
- Get and preview the latest version of the "Partner Central" site from the org "myOrg"
35+
<%= config.bin %> <%= command.id %> --name "Partner Central" --target-org myOrg --get-latest

messages/prompts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# site.select
22

3-
Select a site
3+
Which Experience Cloud Site would you like to preview (Use arrow keys)
44

55
# site.confirm-update
66

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": "~11.5.0",
1111
"@lwc/sfdc-lwc-compiler": "~11.5.0",
12-
"@lwrjs/api": "0.15.6",
12+
"@lwrjs/api": "0.16.3",
1313
"@oclif/core": "^4.1.0",
1414
"@salesforce/core": "^8.6.2",
1515
"@salesforce/kit": "^3.1.6",

src/commands/lightning/dev/site.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ export default class LightningDevSite extends SfCommand<void> {
2828
char: 'n',
2929
}),
3030
'target-org': Flags.requiredOrg(),
31+
'get-latest': Flags.boolean({
32+
summary: messages.getMessage('flags.get-latest.summary'),
33+
char: 'l',
34+
}),
3135
};
3236

3337
public async run(): Promise<void> {
3438
const { flags } = await this.parse(LightningDevSite);
3539

3640
try {
3741
const org = flags['target-org'];
42+
const getLatest = flags['get-latest'];
3843
let siteName = flags.name;
3944

4045
const connection = org.getConnection(undefined);
@@ -55,26 +60,27 @@ export default class LightningDevSite extends SfCommand<void> {
5560
const selectedSite = new ExperienceSite(org, siteName);
5661
let siteZip: string | undefined;
5762

58-
if (!selectedSite.isSiteSetup()) {
59-
this.log(`[local-dev] initializing: ${siteName}`);
63+
// If the site is not setup / is not based on the current release / or get-latest is requested ->
64+
// generate and download a new site bundle from the org based on latest builder metadata
65+
if (!selectedSite.isSiteSetup() || getLatest) {
66+
const startTime = Date.now();
67+
this.log(`[local-dev] Initializing: ${siteName}`);
68+
this.spinner.start('[local-dev] Downloading site (this may take a few minutes)');
6069
siteZip = await selectedSite.downloadSite();
61-
} else {
62-
// If local-dev is already setup, check if an updated site has been published to download
63-
const updateAvailable = await selectedSite.isUpdateAvailable();
64-
if (updateAvailable) {
65-
const shouldUpdate = await PromptUtils.promptUserToConfirmUpdate(siteName);
66-
if (shouldUpdate) {
67-
this.log(`[local-dev] updating: ${siteName}`);
68-
siteZip = await selectedSite.downloadSite();
69-
// delete oldSitePath recursive
70-
const oldSitePath = selectedSite.getExtractDirectory();
71-
if (fs.existsSync(oldSitePath)) {
72-
fs.rmdirSync(oldSitePath, { recursive: true });
73-
}
74-
}
70+
71+
// delete oldSitePath recursive
72+
const oldSitePath = selectedSite.getExtractDirectory();
73+
if (fs.existsSync(oldSitePath)) {
74+
fs.rmSync(oldSitePath, { recursive: true });
7575
}
76+
const endTime = Date.now();
77+
const duration = (endTime - startTime) / 1000; // Convert to seconds
78+
this.spinner.stop('done.');
79+
this.log(`[local-dev] Site setup completed in ${duration.toFixed(2)} seconds.`);
7680
}
7781

82+
this.log(`[local-dev] launching browser preview for: ${siteName}`);
83+
7884
// Establish a valid access token for this site
7985
const authToken = await selectedSite.setupAuth();
8086

@@ -94,10 +100,13 @@ export default class LightningDevSite extends SfCommand<void> {
94100
// Environment variable used to setup the site rather than setup & start server
95101
if (process.env.SETUP_ONLY === 'true') {
96102
await setupDev(startupParams);
103+
this.log('[local-dev] setup complete!');
97104
} else {
98105
await expDev(startupParams);
106+
this.log('[local-dev] watching for file changes... (CTRL-C to stop)');
99107
}
100108
} catch (e) {
109+
this.spinner.stop('failed.');
101110
this.log('Local Development setup failed', e);
102111
}
103112
}

src/lwc-dev-server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function createLWCServerConfig(
3030
const { namespace } = projectJson;
3131

3232
// e.g. lwc folders in force-app/main/default/lwc, package-dir/lwc
33-
const namespacePaths = (await Promise.all(packageDirs.map((dir) => glob(`${dir.fullPath}/**/lwc`)))).flat();
33+
const namespacePaths = (await Promise.all(packageDirs.map((dir) => glob(`${dir.fullPath}/**/lwc`, { absolute: true })))).flat();
3434

3535
const ports = serverPorts ??
3636
(await ConfigUtils.getLocalDevServerPorts()) ?? {

0 commit comments

Comments
 (0)