Skip to content

Commit 60a8098

Browse files
authored
feat: add --guest flag for experience sites @W-17731639 (#396)
1 parent 66df0fc commit 60a8098

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

command-snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"command": "lightning:dev:site",
2121
"flagAliases": [],
2222
"flagChars": ["l", "n", "o"],
23-
"flags": ["flags-dir", "get-latest", "name", "target-org"],
23+
"flags": ["flags-dir", "get-latest", "guest", "name", "target-org"],
2424
"plugin": "@salesforce/plugin-lightning-dev"
2525
}
2626
]

messages/lightning.dev.site.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Name of the Experience Builder site to preview. It has to match a site name from
2525

2626
Download the latest version of the specified site from your org, instead of using any local cache.
2727

28+
# flags.guest.summary
29+
30+
Preview the site as a guest user (rather than an authenticated user).
31+
2832
# examples
2933

3034
- Select a site to preview from the org "myOrg":

src/commands/lightning/dev/site.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export default class LightningDevSite extends SfCommand<void> {
3232
summary: messages.getMessage('flags.get-latest.summary'),
3333
char: 'l',
3434
}),
35+
guest: Flags.boolean({
36+
summary: messages.getMessage('flags.guest.summary'),
37+
default: false,
38+
}),
3539
};
3640

3741
public async run(): Promise<void> {
@@ -40,6 +44,7 @@ export default class LightningDevSite extends SfCommand<void> {
4044
try {
4145
const org = flags['target-org'];
4246
const getLatest = flags['get-latest'];
47+
const guest = flags.guest;
4348
let siteName = flags.name;
4449

4550
const connection = org.getConnection(undefined);
@@ -82,7 +87,7 @@ export default class LightningDevSite extends SfCommand<void> {
8287
this.log(`[local-dev] launching browser preview for: ${siteName}`);
8388

8489
// Establish a valid access token for this site
85-
const authToken = await selectedSite.setupAuth();
90+
const authToken = guest ? '' : await selectedSite.setupAuth();
8691

8792
// Start the dev server
8893
const port = parseInt(process.env.PORT ?? '3000', 10);

0 commit comments

Comments
 (0)