template generate project

<!-- prettier-ignore-start -->

Generate a Salesforce DX project.

Description for template generate 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 necessary configuration files and directories 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=57.0 --global".

Aliases for template generate project

force:project:create

project:generate

Flags

Flag Name (Long) Flag Name (Short) Description
<code>‑‑api‑version</code> N/A Type: Value<br><br>Will set this version as sourceApiVersion in the sfdx-project.json file<br><br>Override the api version used for api requests made by this command
<code>‑‑default‑package‑dir</code> <code>‑p</code> Type: Value<br>Default value: force-app<br><br>Default package directory name.<br><br>Metadata items such as classes and Lightning bundles are placed inside this folder.
<code>‑‑flags‑dir</code> N/A Type: Value<br><br>Import flag values from a directory.
<code>‑‑json</code> N/A Type: Boolean<br><br>Format output as json.
<code>‑‑lwc‑language</code> N/A Type: Value<br>Valid Values: javascript, typescript<br><br>Language of the Lightning Web Components. If not specified, "javascript" is used.<br><br>When set to 'typescript', generates TypeScript configuration files (tsconfig.json, package.json with TypeScript dependencies, and TypeScript-aware ESLint config). When you deploy the TypeScript-based Lightning Web Components, the TypeScript files are first compiled locally for validation and then the .ts files are deployed to your org for server-side type stripping.
<code>‑‑manifest</code> <code>‑x</code> Type: Boolean<br><br>Generate a manifest (package.xml) for change-set based development.<br><br>Generates a default manifest (package.xml) for fetching Apex, Visualforce, Lightning components, and static resources.
<code>‑‑name</code> <code>‑n</code> Type: Value<br>Required<br><br>Name of the generated project.<br><br>Generates a project directory with this name; any valid directory name is accepted. Also sets the "name" property in the sfdx-project.json file to this name.
<code>‑‑namespace</code> <code>‑s</code> Type: Value<br><br>Namespace associated with this project and any connected scratch orgs.
<code>‑‑output‑dir</code> <code>‑d</code> Type: Value<br>Default value: .<br><br>Directory for saving the created files.<br><br>The location can be an absolute path or relative to the current working directory. The default is the current directory.
<code>‑‑template</code> <code>‑t</code> Type: Value<br>Valid Values: standard, empty, analytics, reactinternalapp, reactexternalapp, angularinternalapp, angularexternalapp, agent<br>Default value: standard<br><br>Template to use for project creation.<br><br>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.<br><br><ul><li>.forceignore</li><li>config/project-scratch-def.json</li><li>sfdx-project.json</li><li>package.json</li><li>force-app (basic source directory structure)</li></ul><br><br>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:<br><br><ul><li>.gitignore: Use Git for version control.</li><li>.prettierrc and .prettierignore: Use Prettier to format your Aura components.</li><li>.vscode/extensions.json: When launched, Visual Studio Code, prompts you to install the recommended extensions for your project.</li><li>.vscode/launch.json: Configures Replay Debugger.</li><li>.vscode/settings.json: Additional configuration settings.</li></ul><br><br>The analytics template provides similar files and the force-app/main/default/waveTemplates directory.<br><br>The reactinternalapp and reactexternalapp templates provide React-based project scaffolding for internal and external UI bundle use cases.<br><br>The angularinternalapp and angularexternalapp templates provide Angular-based project scaffolding for internal and external UI bundle use cases.<br><br>The agent template provides project scaffolding for building Agentforce agents and includes a sample agent called Local Info Agent.

Examples for template generate project

Generate a project called "mywork":

sf template generate project --name mywork

Similar to previous example, but generate the files in a directory called "myapp":

sf template generate project --name mywork --default-package-dir myapp

Similar to prevoius example, but also generate a default package.xml manifest file:

sf template generate project --name mywork --default-package-dir myapp --manifest

Generate a project with the minimum files and directories:

sf template generate project --name mywork --template empty

Generate a project in which the Lightning Web Components use TypeScript rather than the default JavaScript:

sf template generate project --name mywork --lwc-language typescript
<!-- prettier-ignore-end -->