Skip to content

W-12345678: feat: make webapplication.json optional for sf webapp dev command#16

Merged
nrkruk merged 1 commit into
mainfrom
dev-command-optional-webappjson
Feb 6, 2026
Merged

W-12345678: feat: make webapplication.json optional for sf webapp dev command#16
nrkruk merged 1 commit into
mainfrom
dev-command-optional-webappjson

Conversation

@deepu-mungamuri94
Copy link
Copy Markdown
Collaborator

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

WI: @W-21179372@

This change makes the webapplication.json manifest file optional when running the sf webapp dev command. Webapps are now discovered by folder structure within the webapplications/ directory.

Key changes:

  • Webapp discovery now uses folder-based detection within webapplications/ folder (case insensitive)
  • If webapplication.json exists, use manifest values; otherwise use defaults
  • Using default dev command as 'npm run dev' for webapps
  • Auto-select webapp when running from inside a webapp folder
  • ManifestWatcher only enabled when webapplication.json is present
  • Removed strict validation (name, label, version, outputDir not required)
  • Improved error messages for missing dependencies (command not found)
  • Fixed duplicate error/warning messages
  • Enhanced console output formatting with better visual separation
  • Cleaned up unused code (removed loadManifest function from manifest.ts)

What does this PR do?

This removes the mandatory check for webapplication.json file for sf webapp dev command. If not available, the command goes with default values by giving a warning message.

What issues does this PR fix or reference?

@deepu-mungamuri94 deepu-mungamuri94 requested a review from a team as a code owner February 5, 2026 10:08
@deepu-mungamuri94 deepu-mungamuri94 changed the title feat: make webapplication.json optional for sf webapp dev command @W-21179372@ W-12345678: feat: make webapplication.json optional for sf webapp dev command Feb 5, 2026
This change makes the webapplication.json manifest file optional when running
the `sf webapp dev` command. Webapps are now discovered by folder structure
within the `webapplications/` directory.

Key changes:
- Webapp discovery now uses folder-based detection within webapplications/ folder
- If webapplication.json exists, use manifest values; otherwise use defaults
- Default dev command changed from 'npm run build' to 'npm run dev'
- Auto-select webapp when running from inside a webapp folder
- ManifestWatcher only enabled when webapplication.json is present
- Improved error messages for missing dependencies (command not found)

Code cleanup:
- Remove unused ErrorHandler factory methods and inline single-use utilities
- Remove dead code from ProxyServer (unused stats tracking)
- Remove unused exported functions from webappDiscovery

Testing & docs:
- Add comprehensive unit tests for webappDiscovery (39 tests)
- Update developer guide for optional manifest feature
@deepu-mungamuri94 deepu-mungamuri94 force-pushed the dev-command-optional-webappjson branch from 3ab5281 to bcb2414 Compare February 5, 2026 16:18
Copy link
Copy Markdown
Collaborator

@nrkruk nrkruk left a comment

Choose a reason for hiding this comment

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

Changes are fine, just need to address the comments. Can be done in follow up PR, just need to create a work item

Comment thread src/error/ErrorHandler.ts
@@ -1,417 +0,0 @@
/*
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So error handler is no longer used now?

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.

Yeah, we don't need it. After refactoring, there are a couple of functions left & they were moved to the respective files and deleted this file.

* @param dir - Directory to start from
* @returns Object with webapplications folder path and current webapp name, or null if not found
*/
function findWebapplicationsFolderUpward(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This recursive algorithm is way overkill. I think the 3 use cases are:

  1. We are running at the root of an SFDX project (i.e. there is an sfdx-project.json file).
    -- The folder structure underneath will be well defined as to where the webapplications should be (<sfdxproject>/force-app/main/default/webapplications). We don't need to search for it, just check for its existence and assume each directory underneath is a webapplication (if they have a {webappname}.webapplication-meta.xml). The CLI should always prompt the user for which webapplication to run when --name is not specified (even if there is only a single webapplication)
  2. We are running the command from the <sfdxproject>/{...}/webapplications/<webapp> directory
    -- In this case, we assume the user wants to run the dev server for the given web application. We can easily identify this is a web application by checking for the {webappname}.webapplication-meta.xml or checking that the parent directory is named webapplications. If they supply other arguments to the command like --name and that is a different webapp from the current directory we are in, the CLI should error out.
  3. [Optional] We are running the command from outside the context of an sfdx project / directory
    -- Same as number 2, but we just check that there is a {webappname}.webapplication-meta.xml file in existence before starting the proxy server.

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.

Yeah, this makes sense. If we have the proper folder stucture, we can make it better.

I was unsure about this earlier : <sfdxproject>/force-app/main/default/webapplications and thought, the webapplications can reside anywhere as the sf webapp generate command is creating the webapp folder anywhere i wanted. It just asking for the parent folder to be webApplications.

I'll take care of this in next PR.

@@ -80,10 +78,23 @@ export default class WebappDev extends SfCommand<WebAppDevResult> {
* Uses interactive arrow-key selection (standard SF CLI pattern)
*/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The algorithm here should be:

  1. Command is run WITHOUT --name or --url. We always prompt the user which web application to start (even if there is only 1). We then attempt to start the dev server for the webapp.
  2. Command is run with --name. We attempt to start the dev server for the webapp with that name and fail if it doesn't exist or we can't start the server.
  3. Command is run with --url. We check if the given url is already available. If it is, we skip starting the dev server and only start the proxy server. If it is not, we attempt to start the dev server with the given name (or prompt if no name given), and check that the given url matches the actual dev server url (throw a warning/error if this is not the case)

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.

yeah, some of it already handled partially. I'll take care of this in next PR.

@nrkruk nrkruk merged commit 5a35bad into main Feb 6, 2026
15 checks passed
@nrkruk nrkruk deleted the dev-command-optional-webappjson branch February 6, 2026 01:22
@deepu-mungamuri94
Copy link
Copy Markdown
Collaborator Author

Changes are fine, just need to address the comments. Can be done in follow up PR, just need to create a work item

Yeah, I'll take care of these in the next PR, along with the proxy detection from the vite-plugin.

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.

2 participants