Skip to content

@W-20178308 feat: add webapp generate command#818

Merged
iowillhoit merged 12 commits intosalesforcecli:mainfrom
Shinoni:feat/webapp-generate-command
Dec 16, 2025
Merged

@W-20178308 feat: add webapp generate command#818
iowillhoit merged 12 commits intosalesforcecli:mainfrom
Shinoni:feat/webapp-generate-command

Conversation

@Shinoni
Copy link
Copy Markdown
Contributor

@Shinoni Shinoni commented Dec 8, 2025

Add new command to generate web app scaffolding from templates.

What does this PR do?

Scaffolds a new command to get the app template.

What issues does this PR fix or reference?

@Shinoni Shinoni requested a review from a team as a code owner December 8, 2025 19:17
@Shinoni Shinoni force-pushed the feat/webapp-generate-command branch from 4576d8a to 715265d Compare December 8, 2025 19:26
@Shinoni Shinoni marked this pull request as draft December 8, 2025 22:20
Add new command to generate web app scaffolding from templates.

Features:
- Clone from template repositories (react-basic, lwc-basic)
- Default to webapp-basic template when none specified
- Support --force flag to overwrite existing directories
- JSON and text output modes
- Spinner feedback during template cloning

Files:
- src/commands/webapp/generate.ts - main command implementation
- messages/webapp.md - externalized user-facing strings
- test/commands/webapp/generate.nut.ts - integration tests (16)
- test/commands/webapp/generate.test.ts - unit tests (11)

Dependencies:
- simple-git: Git operations
- fs-extra: File system operations
- esmock: ESM module mocking for tests
- Replace git clone approach with @salesforce/templates library
- Remove --force flag (not needed with template approach)
- Make label optional (auto-derived from name)
- Use webApplication.md for messages
- Remove fs-extra and simple-git dependencies
- Simplify tests to use NUT tests only
- Add hidden = true to hide command until GA
- Remove unused getCustomTemplates (not supported by generator)
- Hide webapp topic in package.json
- Clean up unused imports
@Shinoni Shinoni force-pushed the feat/webapp-generate-command branch from 6c1bfda to e0176af Compare December 11, 2025 22:30
@Shinoni Shinoni marked this pull request as ready for review December 11, 2025 22:30
@Shinoni Shinoni marked this pull request as draft December 12, 2025 01:00
@Shinoni Shinoni marked this pull request as ready for review December 12, 2025 21:22
Copy link
Copy Markdown
Contributor

@jshackell-sfdc jshackell-sfdc left a comment

Choose a reason for hiding this comment

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

Messages lgtm. Note I reviewed only messages, not code!

Comment thread src/commands/webapp/generate.ts Outdated
summary: messages.getMessage('flags.name.summary'),
description: messages.getMessage('flags.name.description'),
required: true,
aliases: ['webappname'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

webappname doesn't follow the flag name style guide, see:
https://developer.salesforce.com/docs/platform/salesforce-cli-plugin/guide/flags.html

Given the command name, it seems --name should be enough for the user to know it's the name of a the web app to be generated, what do you think? flag aliases aren't required and might confuse users, most of our commands do have deprecated aliases with this style only for backward compatibility with the old sfdx CLI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

bah, I just saw it's marked as deprecated right in the next line 😁
ditto, since it's a new command you don't need to add it

Comment thread src/commands/webapp/generate.ts Outdated
description: messages.getMessage('flags.label.description'),
}),
'output-dir': outputDirFlag,
'api-version': orgApiVersionFlagWithDeprecations,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto, new commands shouldn't add flag with deprecated aliases.
You can use the standard api-version flag from sf-plugins-core like this:
https://github.com/salesforcecli/plugin-org/blob/85721af5642f5faf894db9df24db258dd909a96a/src/commands/org/open/agent.ts#L24

Comment thread src/commands/webapp/generate.ts Outdated
}),
'output-dir': outputDirFlag,
'api-version': orgApiVersionFlagWithDeprecations,
loglevel,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

loglevel is a deprecated flag and shouldn't be used

Comment thread src/commands/webapp/generate.ts Outdated
summary: messages.getMessage('flags.label.summary'),
description: messages.getMessage('flags.label.description'),
}),
'output-dir': outputDirFlag,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this flag is re-using deprecated aliases in its definition:

export const outputDirFlag = Flags.string({

let's an exact copy of that flag def in the same file but skip the deprecated alias, the new one should be named outputDirFlag and the existing one renamed to outputDirFlagWithDeprecations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Instead of refactoring the shared flags, I defined a new inline flag with Flags.directory() that has no deprecated aliases and a dynamic default as it reads sfdx-project.json and defaults to {defaultPackageDir}/main/default/webApplications. Let me know if you'd still prefer the refactor approach instead.

@cristiand391
Copy link
Copy Markdown
Member

@Shinoni left a few small requests but overall looks good 👍🏼

question about --output-dir:

I see the default value would be ., if webapps are expected to be always inside the package dir wouldn't it be better for the output dir default to the one defined in the sfdx-project.json?

example:

projects usually set their default project folder like this:
https://github.com/trailheadapps/dreamhouse-lwc/blob/15cfc6fffcd17d2bf23e7a6bd70bfce4738cb44a/sfdx-project.json#L5

sfdx-core has some classes to access that file's content:
https://forcedotcom.github.io/sfdx-core/classes/sfProject.SfProjectJson.html

@iowillhoit iowillhoit merged commit 5d3302b into salesforcecli:main Dec 16, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants