Skip to content

feat: add guest flag @W-17731639 #396

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"command": "lightning:dev:site",
"flagAliases": [],
"flagChars": ["l", "n", "o"],
"flags": ["flags-dir", "get-latest", "name", "target-org"],
"flags": ["flags-dir", "get-latest", "guest", "name", "target-org"],
"plugin": "@salesforce/plugin-lightning-dev"
}
]
4 changes: 4 additions & 0 deletions messages/lightning.dev.site.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Name of the Experience Builder site to preview. It has to match a site name from

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

# flags.guest.summary

Preview the site as a guest user (rather than an authenticated user).

# examples

- Select a site to preview from the org "myOrg":
Expand Down
7 changes: 6 additions & 1 deletion src/commands/lightning/dev/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default class LightningDevSite extends SfCommand<void> {
summary: messages.getMessage('flags.get-latest.summary'),
char: 'l',
}),
guest: Flags.boolean({
summary: messages.getMessage('flags.guest.summary'),
default: false,
}),
};

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

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

// Establish a valid access token for this site
const authToken = await selectedSite.setupAuth();
const authToken = guest ? '' : await selectedSite.setupAuth();

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