Skip to content

refactor: improve webapp discovery with SFDX project detection @W-21193297@#18

Merged
deepu-mungamuri94 merged 18 commits intomainfrom
refactor-webapp-discovery
Feb 20, 2026
Merged

refactor: improve webapp discovery with SFDX project detection @W-21193297@#18
deepu-mungamuri94 merged 18 commits intomainfrom
refactor-webapp-discovery

Conversation

@deepu-mungamuri94
Copy link
Copy Markdown
Collaborator

@deepu-mungamuri94 deepu-mungamuri94 commented Feb 6, 2026

WI : @W-21193297@

Key Changes

  1. SFDX Project Detection
    Replaced recursive filesystem traversal with deterministic SFDX project detection using SfProject.resolveProjectPath() from @salesforce/core
    Discovery now follows a clear priority: upward search → SFDX project path → standalone webapp
  2. Webapp Identification
    Webapps are now identified by the presence of {name}.webapplication-meta.xml file (required)
    webapplication.json is now optional and only used for dev configuration (command, URL)
  3. --url Flag Enhancement
    Added pre-check: if the provided URL is already reachable, skip dev server startup (proxy-only mode)
    Added mismatch warning: if --url doesn't match the actual dev server URL after startup
  4. --name Flag Conflict Detection
    Added validation when running from inside a webapp directory with a conflicting --name flag
    Provides clear guidance on how to resolve the conflict

What does this PR do?

This PR refactors the webapp discovery algorithm and enhances the sf webapp dev command behavior

  1. Search upward from cwd for "webapplications/" folder
  2. If not found, detect SFDX project root and check "force-app/main/default/webapplications/"
  3. If no webapplications folder, check if cwd itself is a standalone webapp (has .webapplication-meta.xml)
  4. Within webapplications folder, only directories with .webapplication-meta.xml are valid webapps

What issues does this PR fix or reference?

@W-21193297@

@deepu-mungamuri94 deepu-mungamuri94 requested a review from a team as a code owner February 6, 2026 05:38
- Add SFDX project detection for webapp discovery
- Simplify webapplications folder detection logic
- Condense warning messages, remove verbose JSON examples
- Add help tip for configuration options
@deepu-mungamuri94 deepu-mungamuri94 force-pushed the refactor-webapp-discovery branch from f015bfc to a8579b1 Compare February 6, 2026 16:44
Comment thread messages/webapp.dev.md
Comment thread messages/webapp.dev.md Outdated
Comment thread messages/webapp.dev.md
Comment thread messages/webapp.dev.md Outdated
Comment thread src/commands/webapp/dev.ts
Comment thread src/commands/webapp/dev.ts
ankitsinghkuntal09 and others added 7 commits February 13, 2026 20:12
…experimental/proxy (#22)

* feat: consume error-page template from @salesforce/webapp-experimental/proxy @W-21111977@

Update plugin-webapp to import the error page HTML template from the
@salesforce/webapp-experimental proxy package instead of bundling it locally.

Migration changes:
- ErrorPageRenderer now uses getErrorPageTemplate() from @salesforce/webapp-experimental/proxy
- Removed local error-page.html template (now lives in webapps package)
- Removed scripts/copy-templates.cjs (no longer needed)
- Removed postbuild script from package.json
- Bumped @salesforce/webapp-experimental dependency to ^1.17.0

Bug fixes included:
- DevServerManager: emit DevServerError directly instead of wrapping in SfError,
  so the proxy can display the "Dev Server Error" page when dev server crashes
- ProxyServer: add socket error handler to prevent ECONNRESET from crashing the
  proxy when dev server dies mid-connection

Depends on: salesforce-experience-platform-emu/webapps PR for @W-21111977@

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: W-21111977 consume error-page template from @salesforce/webapp-experimental/proxy

Update plugin-webapp to import the error page HTML template from the
@salesforce/webapp-experimental proxy package (v1.23.0) instead of
bundling it locally.

Migration changes:
- ErrorPageRenderer now uses getErrorPageTemplate() from
  @salesforce/webapp-experimental/proxy (direct import, no workarounds)
- Removed local error-page.html template (now lives in webapps package)
- Removed scripts/copy-templates.cjs (no longer needed)
- Removed postbuild script from package.json
- Bumped @salesforce/webapp-experimental dependency to ^1.23.0

Bug fixes included:
- DevServerManager: emit DevServerError directly instead of wrapping
  in SfError, so the proxy can display the "Dev Server Error" page
  when dev server crashes
- ProxyServer: add socket error handler to prevent ECONNRESET from
  crashing the proxy when dev server dies mid-connection
- ProxyServer: remove label/version from fallback manifest (not in type)

Depends on: salesforce-experience-platform-emu/webapps#86 (merged)

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Ankit Singh <singhankit@singhank-ltmg4lv.internal.salesforce.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- messages: specify 'proxy server' in Ctrl+C stop message
- ProxyServer: add label and version to fallback WebAppManifest
- ErrorPageRenderer: use local template (getErrorPageTemplate not in package)
- tests: add label and version to WebAppManifest fixtures

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep only the messages change: 'Press Ctrl+C to stop the proxy server'.
Revert ErrorPageRenderer, ProxyServer, and test changes - will address separately.

Co-authored-by: Cursor <cursoragent@cursor.com>
- no-manifest: log applied defaults (dev command, proxy port) at info level
- ready-for-development: show only URL to open in browser (proxy URL)
- flags.url: add dev server URL precedence to help text

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/config/webappDiscovery.ts
Comment thread src/config/webappDiscovery.ts Outdated
Comment thread src/commands/webapp/dev.ts
Comment thread src/config/webappDiscovery.ts Outdated
Comment thread src/config/webappDiscovery.ts
Comment thread src/commands/webapp/dev.ts Outdated
deepu-mungamuri94 and others added 2 commits February 18, 2026 11:48
…tive (#23)

* feat: add Vite proxy detection and TTY-aware messaging

- Detect Vite WebApp proxy via health check, skip standalone proxy when active
- Use getErrorPageTemplate from @salesforce/webapp-experimental/proxy
- TTY-aware stop message (Ctrl+C in terminal vs VS Code command palette)
- Add info.ready-for-development-vite for Vite proxy case
- Simplify ready-for-development to show only URL to open
- Resolve PR review comments on messaging

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: remove label/version to match @salesforce/webapp-experimental 1.x type

- Run yarn install to resolve 1.23.0+ (was 0.2.0 from stale lock)
- ProxyServer: use minimal fallback { name, outputDir } per PR #22
- Tests: remove label/version from manifest fixtures
- ManifestWatcher tests: fix assertions for simplified type

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: group ready-for-development messages, simplify Vite message format

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: update server-running message - remove bold, add quotes

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
…timeout

- Add comprehensive tests for devServerUrl vs actualDevServerUrl mismatch
  combinations (explicit URL match/mismatch, manifest, skipDevServer cases)
- Warn when multiple .webapplication-meta.xml files found in directory;
  use first match for backward compatibility
- Increase dev server startup timeout from 30 to 60 seconds to align with
  VS Code extension and support slower dev server startups

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread SF_WEBAPP_DEV_GUIDE.md
> - **Manifest watching**: Disabled
> - `{name}.webapplication-meta.xml` is **required** to identify a valid webapp
> - `webapplication.json` is optional for dev configuration. If not present, defaults to:
> - **Name**: From meta.xml filename or folder name
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a property in webapplication.json

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.. Updated doc.

Comment thread SF_WEBAPP_DEV_GUIDE.md Outdated
Comment thread SF_WEBAPP_DEV_GUIDE.md Outdated
Comment thread SF_WEBAPP_DEV_GUIDE.md Outdated
deepu-mungamuri94 and others added 6 commits February 20, 2026 07:46
Co-authored-by: Brian Buchanan <5377888+bpbuch@users.noreply.github.com>
Co-authored-by: Brian Buchanan <5377888+bpbuch@users.noreply.github.com>
Co-authored-by: Brian Buchanan <5377888+bpbuch@users.noreply.github.com>
…mmand

- Remove name, label from --name option (matches folder name)
- Simplify picker format, remove label references
- Remove Full Configuration example (name, label, version, outputDir)
- Add Dev + Routing example with only dev and routing
- Update troubleshooting: --name matches folder name only

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@deepu-mungamuri94 deepu-mungamuri94 merged commit e743427 into main Feb 20, 2026
15 checks passed
@deepu-mungamuri94 deepu-mungamuri94 deleted the refactor-webapp-discovery branch February 20, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants