Skip to content

Commit 48b4c7c

Browse files
committed
feat: add flag for getting the latest version of a experience site / bug fixes
1 parent 5fdb5c0 commit 48b4c7c

File tree

8 files changed

+260
-241
lines changed

8 files changed

+260
-241
lines changed

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2024, Salesforce.com, Inc.
1+
Copyright (c) 2025, Salesforce.com, Inc.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

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.1.0",
1111
"@lwc/sfdc-lwc-compiler": "^11.1.0",
12-
"@lwrjs/api": "0.15.6",
12+
"@lwrjs/api": "0.16.2",
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ 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> {
@@ -69,7 +73,7 @@ export default class LightningDevSite extends SfCommand<void> {
6973
// delete oldSitePath recursive
7074
const oldSitePath = selectedSite.getExtractDirectory();
7175
if (fs.existsSync(oldSitePath)) {
72-
fs.rmdirSync(oldSitePath, { recursive: true });
76+
fs.rmSync(oldSitePath, { recursive: true });
7377
}
7478
}
7579
}

src/shared/experience/expSite.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ export class ExperienceSite {
289289
}
290290
const resourcePath = this.getSiteZipPath(metadata);
291291
try {
292-
const apiUrl = `${instanceUrl}/services/data/v63.0/sites/${siteIdMinus3}/preview`;
292+
// Limit API to published sites for now until we have a patch for the issues with unpublished sites
293+
// TODO set the api version dynamically based on CLI input
294+
const apiUrl = `${instanceUrl}/services/data/v63.0/sites/${siteIdMinus3}/preview?published`;
293295
const response = await axios.get(apiUrl, {
294296
headers: {
295297
Authorization: `Bearer ${accessToken}`,

src/shared/promptUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'prom
2121

2222
export class PromptUtils {
2323
public static async promptUserToSelectSite(sites: string[]): Promise<string> {
24-
const choices = sites.map((site) => ({ value: site }));
24+
const choices = sites.sort((a, b) => a.localeCompare(b)).map((site) => ({ value: site }));
2525
const response = await select({
2626
message: messages.getMessage('site.select'),
2727
choices,

0 commit comments

Comments
 (0)