@salesforce/plugin-generate
v1.1.2
Published
Commands to generate Salesforce projects from templates.
Downloads
1,081
Maintainers
Readme
Use the lerna template if you need a library and plugin
This template is useful if the library is already in another repository or the plugin is a wrapper around an API.
plugin-<REPLACE ME>
Change above to <REPLACE_ME> before finalizing
<REPLACE ME DESCRIPTION START>
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
- Clone this repo
- Delete the .git folder
- Replace filler values
a) Every instance of
<REPLACE_ME>
can be directly substitued for the name of the new plugin. However beware, things like github paths are for the salesforcecli Github organization b) Search for case-matchingREPLACE
to find other filler values, such as for the plugin description - Use
git init
to set up the desired git information - Follow the getting started steps below until the
sfdx hello:org
commmand is functioning
<REPLACE ME DESCRIPTION END>
Learn about the plugin-generate
Salesforce CLI plugins are based on the oclif plugin framework. Read the plugin developer guide to learn about Salesforce CLI plugin development.
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the node developer packages used by Salesforce. There is also a default circleci config using the release management orb standards.
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the posttest
script and it is recommended to keep these tests active in your plugin, regardless if you plan to have it bundled.
Everything past here is only a suggestion as to what should be in your specific plugin's description
This plugin is bundled with the Salesforce CLI. For more information on the CLI, read the getting started guide.
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
Install
sfdx plugins:install <REPLACE_ME>@x.y.z
Issues
Please report any issues at https://github.com/forcedotcom/cli/issues
Contributing
- Please read our Code of Conduct
- Create a new issue before starting your project so that we can keep track of what you are trying to add/fix. That way, we can also offer suggestions or let you know if there is already an effort in progress.
- Fork this repository.
- Build the plugin locally
- Create a topic branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
- Edit the code in your fork.
- Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
- Sign CLA (see CLA below).
- Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
CLA
External contributors will be required to sign a Contributor's License Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
Build
To build the plugin locally, make sure to have yarn installed and run the following commands:
# Clone the repository
git clone [email protected]:salesforcecli/plugin-<REPLACE_ME>
# Install the dependencies and compile
yarn install
yarn build
To use your plugin, run using the local ./bin/dev
or ./bin/dev.cmd
file.
# Run using local run file.
./bin/dev <REPLACE_ME>
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
# Link your plugin to the sfdx cli
sfdx plugins:link .
# To verify
sfdx plugins
Commands
sf generate project
Generate a Salesforce DX project.
USAGE
$ sf generate project -n <value> [--json] [-p <value>] [-x] [-s <value>] [-d <value>] [-t standard|empty|analytics]
FLAGS
-d, --output-dir=<value> [default: .] Directory to store the newly created project files.
-n, --name=<value> (required) Name of the generated project.
-p, --default-package-dir=<value> [default: force-app] Default package directory name.
-s, --namespace=<value> Project associated namespace.
-t, --template=<option> [default: standard] Template to use to create the project.
<options: standard|empty|analytics>
-x, --manifest Generate a manifest (package.xml) for change-set based development.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Generate a Salesforce DX project.
A Salesforce DX project has a specific structure and a configuration file (sfdx-project.json) that identifies the
directory as a Salesforce DX project. This command generates the basic scaffolding to get you started.
By default, the generated sfdx-project.json file sets the sourceApiVersion property to the default API version
currently used by Salesforce CLI. To specify a different version, set the apiVersion configuration variable. For
example:
sf config set apiVersion=53.0 --global
EXAMPLES
Generate a project called MyProject:
$ sf generate project --name MyProject
Generate the minimum number of files and directories:
$ sf generate project --name MyProject --template empty
Generate the project in /Users/jdoe/sf-projects rather than the current directory:
$ sf generate project --name MyProject --template empty --output-dir /Users/jdoe/sf-projects
FLAG DESCRIPTIONS
-d, --output-dir=<value> Directory to store the newly created project files.
The location can be an absolute path or relative to the current working directory.
-n, --name=<value> Name of the generated project.
Creates a project directory with this name. Also sets the "name" property in the sfdx-project.json file to this
name.
-p, --default-package-dir=<value> Default package directory name.
The default package directory name. Metadata items such as classes and Lightning bundles are placed inside this
folder.
-s, --namespace=<value> Project associated namespace.
The namespace associated with this project and any connected scratch orgs.
-t, --template=standard|empty|analytics Template to use to create the project.
The template determines the sample configuration files and directories that this command generates. For example, the
empty template provides these files and directory to get you started.
- .forceignore
- config/project-scratch-def.json
- sfdx-project.json
- package.json
- force-app (basic source directory structure)
The standard template provides a complete force-app directory structure so you know where to put your source. It
also provides additional files and scripts, especially useful when using Salesforce Extensions for VS Code. For
example:
- .gitignore: Use Git for version control.
- .prettierrc and .prettierignore: Use Prettier to format your Aura components.
- .vscode/extensions.json: When launched, Visual Studio Code, prompts you to install the recommended extensions for
your project.
- .vscode/launch.json: Configures Replay Debugger.
- .vscode/settings.json: Additional configuration settings.
The analytics template provides similar files and the force-app/main/default/waveTemplates directory.
-x, --manifest Generate a manifest (package.xml) for change-set based development.
Generates a default manifest (package.xml) for fetching Apex, Visualforce, Lightning components, and static
resources.