@W-20178308 feat: add webapp generate command#818
@W-20178308 feat: add webapp generate command#818iowillhoit merged 12 commits intosalesforcecli:mainfrom
Conversation
4576d8a to
715265d
Compare
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
6c1bfda to
e0176af
Compare
| summary: messages.getMessage('flags.name.summary'), | ||
| description: messages.getMessage('flags.name.description'), | ||
| required: true, | ||
| aliases: ['webappname'], |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| description: messages.getMessage('flags.label.description'), | ||
| }), | ||
| 'output-dir': outputDirFlag, | ||
| 'api-version': orgApiVersionFlagWithDeprecations, |
There was a problem hiding this comment.
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
| }), | ||
| 'output-dir': outputDirFlag, | ||
| 'api-version': orgApiVersionFlagWithDeprecations, | ||
| loglevel, |
There was a problem hiding this comment.
loglevel is a deprecated flag and shouldn't be used
| summary: messages.getMessage('flags.label.summary'), | ||
| description: messages.getMessage('flags.label.description'), | ||
| }), | ||
| 'output-dir': outputDirFlag, |
There was a problem hiding this comment.
this flag is re-using deprecated aliases in its definition:
plugin-templates/src/utils/flags.ts
Line 16 in b7cbb2c
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.
There was a problem hiding this comment.
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.
|
@Shinoni left a few small requests but overall looks good 👍🏼 question about I see the default value would be example: projects usually set their default project folder like this: sfdx-core has some classes to access that file's content: |
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?