npm package: @salesforce/plugin-templates
Description: Commands to create metadata from a default or custom template
Author: Salesforce
Latest version: 56.15.5

# plugin-templates

This repository provides a series of commands, templates, and generators for various metadata types, including support for TypeScript Lightning Web Components.

[![Known Vulnerabilities](https://snyk.io/test/github/salesforcecli/plugin-templates/badge.svg)](https://snyk.io/test/github/salesforcecli/plugin-templates)
[![License](https://img.shields.io/npm/l/@salesforce/plugin-templates.svg)](https://github.com/salesforcecli/plugin-templates/blob/master/package.json)

# Getting Started

To use, install the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli) and run the following commands.

```
Verify the CLI is installed
  $ sfdx (-v | --version)
Install the @salesforce/plugin-templates plugin
  $ sfdx plugins:install @salesforce/plugin-templates
To run a command
  $ sfdx [command]
```

## Install

1. Clone the repository, and `cd` into it.

```sh
git clone git@github.com:salesforcecli/plugin-templates.git
```

2. Ensure you have [Yarn](https://yarnpkg.com/) installed and run the following to build:

```
yarn install
yarn build
```

## Issues

Please report any issues to https://github.com/salesforcecli/plugin-templates/issues or https://github.com/forcedotcom/cli/issues.

## Contributing

1. Familiarize yourself with the codebase by reading the docs and the templates [library](https://github.com/salesforcecli/plugin-templates).
   - If you're adding a new template generator, see the [Development Guide](./DEVELOPMENT.md) for detailed instructions.
1. Create a new issue before starting your project so that we can keep track of
   what you're trying to add/fix. That way, we can also offer suggestions or
   let you know if there is already an effort in progress.
1. Fork this repository.
1. The [build](#build) section has details on how to set up your environment.
1. Create a _topic_ branch in your fork based on the correct branch (usually the **main** branch). Note: this step is recommended but technically not required if contributing using a fork.
1. Edit the code in your fork.
1. Sign CLA (see [CLA](#cla)).
1. Send us a pull request when you're done. We'll review your code, suggest any
   needed changes, and merge it in.

## Pull Requests

### Committing

1. We enforce commit message format using [commitizen](https://github.com/commitizen/cz-cli). To ensure correct formatting, use our VS Code Task `Commit`. with `yarn run commit`.
1. The commit message format that we expect is: `type: commit message`. Valid types are: feat, fix, improvement, docs, style, refactor, perf, test, build, ci, chore and revert.
1. Before commit and push, Husky runs several hooks to ensure the commit message is in the correct format and that everything lints and compiles properly.

## 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

## Developing Plugin

To test plugin locally, use `bin/dev` in place of `sfdx`. For example:

```sh
./bin/dev force:apex:class:create --classname 'TestClass' --template 'DefaultApexClass' --outputdir ./testsoutput/myApex/
```

Link your plugin to Salesforce CLI:

```sh
sfdx plugins:link .
```

Verify plugin is linked:

```sh
sfdx plugins
```

To test plugin locally with Salesforce CLI, add `"@salesforce/plugin-templates": "file://path/to/plugin-templates"` to the plugin's `package.json`.

## Debugging Your Plugin

We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the `.vscode` directory of this plugin is a `launch.json` config file, which allows you to attach a debugger to the node process when running your commands.

To debug the `hello:org` command:

1. If you linked your plugin to the Salesforce CLI, call your command with the `dev-suspend` switch:

```sh-session
$ sfdx hello:org -u myOrg@example.com --dev-suspend
```

Alternatively, to call your command using the `bin/dev` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:

```sh-session
$ NODE_OPTIONS=--inspect-brk ./bin/dev force:apex:class:create --classname 'TestClass' --template 'DefaultApexClass' --outputdir ./testsoutput/myApex/
```

2. Set some breakpoints in your command code.
3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration is selected.
5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program.
6. Hit the green play button at the top middle of VS Code (this play button is to the right of the play button that you clicked in step #5).

Congrats, you are debugging!

# Commands

<!-- commands -->

- [`sf template generate analytics template`](#sf-template-generate-analytics-template)
- [`sf template generate apex class`](#sf-template-generate-apex-class)
- [`sf template generate apex trigger`](#sf-template-generate-apex-trigger)
- [`sf template generate digital-experience site`](#sf-template-generate-digital-experience-site)
- [`sf template generate flexipage`](#sf-template-generate-flexipage)
- [`sf template generate lightning app`](#sf-template-generate-lightning-app)
- [`sf template generate lightning component`](#sf-template-generate-lightning-component)
- [`sf template generate lightning event`](#sf-template-generate-lightning-event)
- [`sf template generate lightning interface`](#sf-template-generate-lightning-interface)
- [`sf template generate lightning test`](#sf-template-generate-lightning-test)
- [`sf template generate project`](#sf-template-generate-project)
- [`sf template generate static-resource`](#sf-template-generate-static-resource)
- [`sf template generate ui-bundle`](#sf-template-generate-ui-bundle)
- [`sf template generate visualforce component`](#sf-template-generate-visualforce-component)
- [`sf template generate visualforce page`](#sf-template-generate-visualforce-page)

## `sf template generate analytics template`

Generate a simple Analytics template.

```
USAGE
  $ sf template generate analytics template -n <value> [--json] [--flags-dir <value>] [-d <value>] [--api-version
  <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the Analytics template.
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a simple Analytics template.

  The metadata files associated with the Analytics template must be contained in a parent directory called
  "waveTemplates" in your package directory. Either run this command from an existing directory of this name, or use the
  --output-dir flag to generate one or point to an existing one.

ALIASES
  $ sf force analytics template create
  $ sf analytics generate template

EXAMPLES
  Generate the metadata files for a simple Analytics template file called myTemplate in the
  force-app/main/default/waveTemplates directory:

    $ sf template generate analytics template --name myTemplate --output-dir force-app/main/default/waveTemplates

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.
```

_See code: [src/commands/template/generate/analytics/template.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/analytics/template.ts)_

## `sf template generate apex class`

Generate an Apex class.

```
USAGE
  $ sf template generate apex class -n <value> [--json] [--flags-dir <value>] [-t
    ApexException|ApexUnitTest|BasicUnitTest|DefaultApexClass|InboundEmailService] [-d <value>] [--api-version <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the generated Apex class.
  -t, --template=<option>    [default: DefaultApexClass] Template to use for file creation.
                             <options: ApexException|ApexUnitTest|BasicUnitTest|DefaultApexClass|InboundEmailService>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate an Apex class.

  Generates the Apex *.cls file and associated metadata file. These files must be contained in a parent directory called
  "classes" in your package directory. Either run this command from an existing directory of this name, or use the
  --output-dir flag to generate one or point to an existing one.

ALIASES
  $ sf force apex class create
  $ sf apex generate class

EXAMPLES
  Generate two metadata files associated with the MyClass Apex class (MyClass.cls and MyClass.cls-meta.xml) in the
  current directory:

    $ sf template generate apex class --name MyClass

  Similar to previous example, but generates the files in the "force-app/main/default/classes" directory:

    $ sf template generate apex class --name MyClass --output-dir force-app/main/default/classes

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Apex class.

    The name can be up to 40 characters and must start with a letter.

  -t, --template=ApexException|ApexUnitTest|BasicUnitTest|DefaultApexClass|InboundEmailService

    Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template.
```

_See code: [src/commands/template/generate/apex/class.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/apex/class.ts)_

## `sf template generate apex trigger`

Generate an Apex trigger.

```
USAGE
  $ sf template generate apex trigger -n <value> [--json] [--flags-dir <value>] [-t ApexTrigger] [-d <value>] [--api-version
    <value>] [-s <value>] [-e before insert|before update|before delete|after insert|after update|after delete|after
    undelete...]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -e, --event=<option>...    [default: before insert] Events that fire the trigger.
                             <options: before insert|before update|before delete|after insert|after update|after
                             delete|after undelete>
  -n, --name=<value>         (required) Name of the generated Apex trigger
  -s, --sobject=<value>      [default: SOBJECT] Salesforce object to generate a trigger on.
  -t, --template=<option>    [default: ApexTrigger] Template to use for file creation.
                             <options: ApexTrigger>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate an Apex trigger.

  Generates the Apex trigger *.trigger file and associated metadata file. These files must be contained in a parent
  directory called "triggers" in your package directory. Either run this command from an existing directory of this
  name, or use the --output-dir flag to generate one or point to an existing one.

  If you don't specify the --sobject flag, the .trigger file contains the generic placeholder SOBJECT; replace it with
  the Salesforce object you want to generate a trigger for. If you don't specify --event, "before insert" is used.

ALIASES
  $ sf force apex trigger create
  $ sf apex generate trigger

EXAMPLES
  Generate two files associated with the MyTrigger Apex trigger (MyTrigger.trigger and MyTrigger.trigger-meta.xml) in
  the current directory:

    $ sf template generate apex trigger --name MyTrigger

  Similar to the previous example, but generate the files in the "force-app/main/default/triggers" directory:

    $ sf template generate apex trigger --name MyTrigger --output-dir force-app/main/default/triggers

  Generate files for a trigger that fires on the Account object before and after an insert:

    $ sf template generate apex trigger --name MyTrigger --sobject Account --event "before insert,after insert"

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Apex trigger

    The name can be up to 40 characters and must start with a letter.

  -t, --template=ApexTrigger  Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template.
```

_See code: [src/commands/template/generate/apex/trigger.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/apex/trigger.ts)_

## `sf template generate digital-experience site`

Generate an Experience Cloud site.

```
USAGE
  $ sf template generate digital-experience site -n <value> -t Build Your Own (LWR) [--json] [--flags-dir <value>] [-o <value>] [-p <value>]
    [-e <value>] [-d <value>]

FLAGS
  -d, --output-dir=<value>       Directory to generate the site files in.
  -e, --admin-email=<value>      Email address for the site administrator. Defaults to the username of the currently
                                 authenticated user.
  -n, --name=<value>             (required) Name of the Experience Cloud site to generate.
  -o, --target-org=<value>       Username or alias of the target org.
  -p, --url-path-prefix=<value>  URL path prefix for the site; must contain only alphanumeric characters.
  -t, --template-name=<option>   (required) Template to use when generating the site.
                                 <options: Build Your Own (LWR)>

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate an Experience Cloud site.

  Creates the metadata of an Experience Cloud site with the specified template, name, and URL path prefix. The output
  includes all the necessary metadata files, including DigitalExperienceConfig, DigitalExperienceBundle, Network, and
  CustomSite.
  Unlike `sf community create`, which builds the site directly in the org, this command generates only the local
  metadata.

EXAMPLES
  Generate an Experience Cloud site using the Build Your Own (LWR) template. The site is called "mysite" and has the
  URL path prefix "mysite":

    $ sf template generate digital-experience site --template-name "Build Your Own (LWR)" --name mysite \
      --url-path-prefix mysite

  Generate an Experience Cloud site like the last example, but generate the files into the specified output directory:

    $ sf template generate digital-experience site --template-name "Build Your Own (LWR)" --name mysite \
      --url-path-prefix mysite --output-dir force-app/main/default

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory to generate the site files in.

    The location can be an absolute path or relative to the current working directory. If not specified, the command
    reads your sfdx-project.json file and uses the default package directory. When running outside a Salesforce DX
    project, defaults to the current directory.
```

_See code: [src/commands/template/generate/digital-experience/site.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/digital-experience/site.ts)_

## `sf template generate flexipage`

Generate a FlexiPage, also known as a Lightning page.

```
USAGE
  $ sf template generate flexipage -n <value> -t RecordPage|AppPage|HomePage [--json] [--flags-dir <value>] [-d <value>]
    [--api-version <value>] [--label <value>] [--description <value>] [-s <value>] [--primary-field <value>]
    [--secondary-fields <value>...] [--detail-fields <value>...]

FLAGS
  -d, --output-dir=<value>           [default: .] Directory for saving the created files.
  -n, --name=<value>                 (required) Name of the FlexiPage.
  -s, --sobject=<value>              API name of the Salesforce object; required when creating a RecordPage.
  -t, --template=<option>            (required) Template type for the FlexiPage.
                                     <options: RecordPage|AppPage|HomePage>
      --api-version=<value>          Override the api version used for api requests made by this command
      --description=<value>          Description for the FlexiPage, which provides context about its purpose.
      --detail-fields=<value>...     Fields to display in the Details tab. Specify multiple fields separated by commas.
                                     Fields are split into two columns. Used only with RecordPage.
      --label=<value>                Label of this FlexiPage; if not specified, uses the FlexiPage name as the label.
      --primary-field=<value>        Primary field for the dynamic highlights header; typically 'Name'. Used only with
                                     RecordPage.
      --secondary-fields=<value>...  Secondary fields shown in the dynamic highlights header. Specify multiple fields
                                     separated by commas. Maximum of 11 fields. Used only with RecordPage.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a FlexiPage, also known as a Lightning page.

  FlexiPages are the metadata types associated with a Lightning page. A Lightning page represents a customizable screen
  made up of regions containing Lightning components.

  You can use this command to generate these types of FlexiPages; specify the type with the --template flag:

  - AppPage: A Lightning page used as the home page for a custom app or a standalone application page.
  - HomePage: A Lightning page used to override the Home page in Lightning Experience.
  - RecordPage: A Lightning page used to override an object record page in Lightning Experience. Requires that you
  specify the object name with the --sobject flag.

EXAMPLES
  Generate a RecordPage FlexiPage for the Account object in the current directory:

    $ sf template generate flexipage --name Account_Record_Page --template RecordPage --sobject Account

  Generate an AppPage FlexiPage in the "force-app/main/default/flexipages" directory:

    $ sf template generate flexipage --name Sales_Dashboard --template AppPage --output-dir \
      force-app/main/default/flexipages

  Generate a HomePage FlexiPage with a custom label:

    $ sf template generate flexipage --name Custom_Home --template HomePage --label "Sales Home Page"

  Generate a RecordPage with dynamic highlights and detail fields:

    $ sf template generate flexipage --name Property_Page --template RecordPage --sobject Rental_Property__c \
      --primary-field Name --secondary-fields Property_Address__c,City__c --detail-fields \
      Name,Property_Address__c,City__c,Monthly_Rent__c,Bedrooms__c

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the FlexiPage.

    The name can contain only alphanumeric characters, must start with a letter, and can't end with an underscore or
    contain two consecutive underscores.

  -s, --sobject=<value>  API name of the Salesforce object; required when creating a RecordPage.

    For RecordPage FlexiPages, you must specify the associated object API name, such as 'Account', 'Opportunity', or
    'Custom_Object__c'. This sets the `sobjectType` field in the FlexiPage metadata.
```

_See code: [src/commands/template/generate/flexipage/index.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/flexipage/index.ts)_

## `sf template generate lightning app`

Generate a Lightning App.

```
USAGE
  $ sf template generate lightning app -n <value> [--json] [--flags-dir <value>] [-t DefaultLightningApp] [-d <value>] [--api-version
    <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the generated Lightning App.
  -t, --template=<option>    [default: DefaultLightningApp] Template to use for file creation.
                             <options: DefaultLightningApp>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a Lightning App.

  Generates a Lightning App bundle in the specified directory or the current working directory. The bundle consists of
  multiple files in a folder with the designated name.

ALIASES
  $ sf force lightning app create
  $ sf lightning generate app

EXAMPLES
  Generate the metadata files for a Lightning app bundle called "myapp" in the current directory:

    $ sf template generate lightning app --name myapp

  Similar to the previous example, but generate the files in the "force-app/main/default/aura" directory:

    $ sf template generate lightning app --name myapp --output-dir force-app/main/default/aura

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Lightning App.

    The name can be up to 40 characters and must start with a letter.

  -t, --template=DefaultLightningApp  Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template. For Lightning Web Components, if
    this flag isn't specified, the CLI command automatically selects the template based on the "defaultLwcLanguage"
    field in the DX project's "sfdx-project.json" file.
```

_See code: [src/commands/template/generate/lightning/app.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/lightning/app.ts)_

## `sf template generate lightning component`

Generate a bundle for an Aura component or a Lightning web component.

```
USAGE
  $ sf template generate lightning component -n <value> [--json] [--flags-dir <value>] [-t
    default|analyticsDashboard|analyticsDashboardWithStep|typescript] [-d <value>] [--api-version <value>] [--type
    aura|lwc]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the generated Lightning Component.
  -t, --template=<option>    [default: default] Template to use for file creation.
                             <options: default|analyticsDashboard|analyticsDashboardWithStep|typescript>
      --api-version=<value>  Override the api version used for api requests made by this command
      --type=<option>        [default: aura] Type of the component bundle.
                             <options: aura|lwc>

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a bundle for an Aura component or a Lightning web component.

  Generates the bundle in the specified directory or the current working directory. The bundle consists of multiple
  files in a directory with the designated name. Lightning web components are contained in the directory with name
  "lwc", Aura components in "aura".

  To generate a Lightning web component, pass "--type lwc" to the command. If you don’t specify --type, Salesforce CLI
  generates an Aura component by default.

ALIASES
  $ sf force lightning component create
  $ sf lightning generate component

EXAMPLES
  Generate the metadata files for an Aura component bundle in the current directory:

    $ sf template generate lightning component --name mycomponent

  Generate a Lightning web component bundle in the current directory:

    $ sf template generate lightning component --name mycomponent --type lwc

  Generate an Aura component bundle in the "force-app/main/default/aura" directory:

    $ sf template generate lightning component --name mycomponent --output-dir force-app/main/default/aura

  Generate a Lightning web component bundle in the "force-app/main/default/lwc" directory:

    $ sf template generate lightning component --name mycomponent --type lwc --output-dir force-app/main/default/lwc

  Generate a TypeScript Lightning Web Component:

    $ sf template generate lightning component --name mycomponent --type lwc --template typescript

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Lightning Component.

    The name can be up to 40 characters and must start with a letter.

  -t, --template=default|analyticsDashboard|analyticsDashboardWithStep|typescript  Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template. For Lightning Web Components, if
    this flag isn't specified, the CLI command automatically selects the template based on the "defaultLwcLanguage"
    field in the DX project's "sfdx-project.json" file.
```

_See code: [src/commands/template/generate/lightning/component.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/lightning/component.ts)_

## `sf template generate lightning event`

Generate a Lightning Event.

```
USAGE
  $ sf template generate lightning event -n <value> [--json] [--flags-dir <value>] [-t DefaultLightningEvt] [-d <value>] [--api-version
    <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the generated Lightning Event.
  -t, --template=<option>    [default: DefaultLightningEvt] Template to use for file creation.
                             <options: DefaultLightningEvt>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a Lightning Event.

  Generates a Lightning Event bundle in the specified directory or the current working directory. The bundle consists of
  multiple files in a folder with the designated name.

ALIASES
  $ sf force lightning event create
  $ sf lightning generate event

EXAMPLES
  Generate the metadata files for a Lightning event bundle called "myevent" in the current directory:

    $ sf template generate lightning event --name myevent

  Similar to previous example, but generate the files in the "force-app/main/default/aura" directory:

    $ sf template generate lightning event --name myevent --output-dir force-app/main/default/aura

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Lightning Event.

    The name can be up to 40 characters and must start with a letter.

  -t, --template=DefaultLightningEvt  Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template. For Lightning Web Components, if
    this flag isn't specified, the CLI command automatically selects the template based on the "defaultLwcLanguage"
    field in the DX project's "sfdx-project.json" file.
```

_See code: [src/commands/template/generate/lightning/event.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/lightning/event.ts)_

## `sf template generate lightning interface`

Generate a Lightning Interface.

```
USAGE
  $ sf template generate lightning interface -n <value> [--json] [--flags-dir <value>] [-t DefaultLightningIntf] [-d <value>]
    [--api-version <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the generated Lightning Interface.
  -t, --template=<option>    [default: DefaultLightningIntf] Template to use for file creation.
                             <options: DefaultLightningIntf>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a Lightning Interface.

  Generates a Lightning Interface bundle in the specified directory or the current working directory. The bundle
  consists of multiple files in a folder with the designated name.

ALIASES
  $ sf force lightning interface create
  $ sf lightning generate interface

EXAMPLES
  Generate the metadata files for a Lightning interface bundle called "myinterface" in the current directory:

    $ sf template generate lightning interface --name myinterface

  Similar to the previous example but generate the files in the "force-app/main/default/aura" directory:

    $ sf template generate lightning interface --name myinterface --output-dir force-app/main/default/aura

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Lightning Interface.

    The name can be up to 40 characters and must start with a letter.

  -t, --template=DefaultLightningIntf  Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template. For Lightning Web Components, if
    this flag isn't specified, the CLI command automatically selects the template based on the "defaultLwcLanguage"
    field in the DX project's "sfdx-project.json" file.
```

_See code: [src/commands/template/generate/lightning/interface.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/lightning/interface.ts)_

## `sf template generate lightning test`

Generate a Lightning test.

```
USAGE
  $ sf template generate lightning test -n <value> [--json] [--flags-dir <value>] [-t DefaultLightningTest] [-d <value>]
    [--api-version <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the generated Lightning Test.
  -t, --template=<option>    [default: DefaultLightningTest] Template to use for file creation.
                             <options: DefaultLightningTest>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a Lightning test.

  Generates the test in the specified directory or the current working directory. The .resource file and associated
  metadata file are generated.

ALIASES
  $ sf force lightning test create
  $ sf lightning generate test

EXAMPLES
  Generate the metadata files for the Lightning test called MyLightningTest in the current directory:

    $ sf template generate lightning test --name MyLightningTest

  Similar to the previous example but generate the files in the "force-app/main/default/lightningTests" directory:

    $ sf template generate lightning test --name MyLightningTest --output-dir force-app/main/default/lightningTests

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Lightning Test.

    Name of the new Lightning test; can be up to 40 characters and must start with a letter.

  -t, --template=DefaultLightningTest  Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template. For Lightning Web Components, if
    this flag isn't specified, the CLI command automatically selects the template based on the "defaultLwcLanguage"
    field in the DX project's "sfdx-project.json" file.
```

_See code: [src/commands/template/generate/lightning/test.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/lightning/test.ts)_

## `sf template generate project`

Generate a Salesforce DX project.

```
USAGE
  $ sf template generate project -n <value> [--json] [--flags-dir <value>] [-t
    standard|empty|analytics|reactinternalapp|reactexternalapp|agent] [-d <value>] [-s <value>] [-p <value>] [-x]
    [--lwc-language javascript|typescript] [--api-version <value>]

FLAGS
  -d, --output-dir=<value>           [default: .] Directory for saving the created 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>            Namespace associated with this project and any connected scratch orgs.
  -t, --template=<option>            [default: standard] Template to use for project creation.
                                     <options: standard|empty|analytics|reactinternalapp|reactexternalapp|agent>
  -x, --manifest                     Generate a manifest (package.xml) for change-set based development.
      --api-version=<value>          Will set this version as sourceApiVersion in the sfdx-project.json file
      --lwc-language=<option>        Language of the Lightning Web Components. If not specified, "javascript" is used.
                                     <options: javascript|typescript>

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --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 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
  $ sf force project create
  $ sf project generate

EXAMPLES
  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

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated project.

    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.

  -p, --default-package-dir=<value>  Default package directory name.

    Metadata items such as classes and Lightning bundles are placed inside this folder.

  -t, --template=standard|empty|analytics|reactinternalapp|reactexternalapp|agent  Template to use for project creation.

    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.

    The reactinternalapp and reactexternalapp templates provide React-based project scaffolding for internal and
    external UI bundle use cases.

    The agent template provides project scaffolding for building Agentforce agents and includes a sample agent called
    Local Info Agent.

  -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.

  --api-version=<value>  Will set this version as sourceApiVersion in the sfdx-project.json file

    Override the api version used for api requests made by this command

  --lwc-language=javascript|typescript  Language of the Lightning Web Components. If not specified, "javascript" is used.

    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.
```

_See code: [src/commands/template/generate/project/index.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/project/index.ts)_

## `sf template generate static-resource`

Generate a static resource.

```
USAGE
  $ sf template generate static-resource -n <value> [--json] [--flags-dir <value>] [--type <value>] [-d <value>]
  [--api-version <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -n, --name=<value>         (required) Name of the generated static resource.
      --api-version=<value>  Override the api version used for api requests made by this command
      --type=<value>         [default: application/zip] Content type (mime type) of the generated static resource.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a static resource.

  Generates the metadata resource file in the specified directory or the current working directory. Static resource
  files must be contained in a parent directory called "staticresources" in your package directory. Either run this
  command from an existing directory of this name, or use the --output-dir flag to create one or point to an existing
  one.

ALIASES
  $ sf force staticresource create
  $ sf static-resource generate

EXAMPLES
  Generate the metadata file for a static resource called MyResource in the current directory:

    $ sf template generate static-resource --name MyResource

  Similar to previous example, but specifies a MIME type of application/json:

    $ sf template generate static-resource --name MyResource --type application/json

  Generate the resource file in the "force-app/main/default/staticresources" directory:

    $ sf template generate static-resource --name MyResource --output-dir force-app/main/default/staticresources

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated static resource.

    This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin
    with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.

  --type=<value>  Content type (mime type) of the generated static resource.

    Must be a valid MIME type such as application/json, application/javascript, application/zip, text/plain, text/css,
    etc.
```

_See code: [src/commands/template/generate/static-resource/index.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/static-resource/index.ts)_

## `sf template generate ui-bundle`

Generate a UI bundle, which contains the code and metadata to build a UI experience that uses non-native Salesforce frameworks, such as React.

```
USAGE
  $ sf template generate ui-bundle -n <value> [--json] [--flags-dir <value>] [-t default|reactbasic] [-l <value>] [-d <value>]
    [--api-version <value>]

FLAGS
  -d, --output-dir=<value>   Directory into which the files are created.
  -l, --label=<value>        Master label for the UI bundle.
  -n, --name=<value>         (required) API name of the generated UI bundle.
  -t, --template=<option>    [default: default] Template to use when creating the files for a specific UI framework.
                             <options: default|reactbasic>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a UI bundle, which contains the code and metadata to build a UI experience that uses non-native Salesforce
  frameworks, such as React.

  Salesforce provides native UI frameworks, such as Lighting Web Components (LWC), to build applications that run on the
  Salesforce Platform. But you can also use non-native JavaScript- or TypeScript-based UI frameworks, such as React, to
  build a UI experience for the Salesforce Platform and that you can launch from the App Launcher.

  These non-native UI experiences are defined by the "UIBundle" metadata type in your DX project. Use this command to
  generate the required DX project structure and files. For example, when you run this command and specify the name
  MyUiBundle, then the files are generated into a "uiBundles/MyUiBundle" directory. Use the --output-dir flag to specify
  a different directory.

  Use the --template flag for generating the files to get started with a speciic UI framework, such as React. Check out
  the README.md file in the generated "uiBundles/<bundlename>" directory for more information about the template.

EXAMPLES
  Generate a UI bundle called MyUiBundle in the current directory:

    $ sf template generate ui-bundle --name MyUiBundle

  Generate a React-based UI bundle:

    $ sf template generate ui-bundle --name MyReactApp --template reactbasic

  Generate the React-based UI bundle in the "force-app/main/default/uiBundles" directory:

    $ sf template generate ui-bundle --name MyUiBundle --template reactbasic --output-dir \
      force-app/main/default/uiBundles

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory into which the files are created.

    The location can be an absolute path or relative to the current working directory.

    If not specified, the command reads your sfdx-project.json and defaults to "uiBundles" directory within your default
    package directory. When running outside a Salesforce DX project, defaults to the current directory.

    **Important:** This command automatically ensures the output directory ends with "uiBundles". If your specified path
    doesn't end with "uiBundles", it's automatically appended. The UI bundle is created at "<output-dir>/<name>".

    **Examples:**

    - "--output-dir force-app/main/default" → Creates a UI bundle at "force-app/main/default/uiBundles/MyUiBundle/"
    - "--output-dir force-app/main/default/uiBundles" → Creates a UI bundle at
    "force-app/main/default/uiBundles/MyUiBundle/" (no change)

  -l, --label=<value>  Master label for the UI bundle.

    If not specified, the label is derived from the name.

  -n, --name=<value>  API name of the generated UI bundle.

    This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin
    with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.

  -t, --template=default|reactbasic  Template to use when creating the files for a specific UI framework.

    Supplied parameter values or default values are filled into a copy of the template.
```

_See code: [src/commands/template/generate/ui-bundle/index.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/ui-bundle/index.ts)_

## `sf template generate visualforce component`

Generate a Visualforce Component.

```
USAGE
  $ sf template generate visualforce component -n <value> -l <value> [--json] [--flags-dir <value>] [-t DefaultVFComponent] [-d <value>]
    [--api-version <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -l, --label=<value>        (required) Visualforce Component label.
  -n, --name=<value>         (required) Name of the generated Visualforce Component.
  -t, --template=<option>    [default: DefaultVFComponent] Template to use for file creation.
                             <options: DefaultVFComponent>
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a Visualforce Component.

  The command generates the .Component file and associated metadata file in the specified directory or the current
  working directory by default.

ALIASES
  $ sf force visualforce component create
  $ sf visualforce generate component

EXAMPLES
  Generate the metadata files for a Visualforce component in the current directory:

    $ sf template generate visualforce component --name mycomponent --label mylabel

  Similar to previous example, but generate the files in the directory "force-app/main/default/components":

    $ sf template generate visualforce component --name mycomponent --label mylabel --output-dir components

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Visualforce Component.

    The name can be up to 40 characters and must start with a letter.

  -t, --template=DefaultVFComponent  Template to use for file creation.

    Supplied parameter values or default values are filled into a copy of the template.
```

_See code: [src/commands/template/generate/visualforce/component.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/visualforce/component.ts)_

## `sf template generate visualforce page`

Generate a Visualforce Page.

```
USAGE
  $ sf template generate visualforce page -n <value> -l <value> [--json] [--flags-dir <value>] [-d <value>]
  [--api-version <value>]

FLAGS
  -d, --output-dir=<value>   [default: .] Directory for saving the created files.
  -l, --label=<value>        (required) Visualforce Page label.
  -n, --name=<value>         (required) Name of the generated Visualforce Page.
      --api-version=<value>  Override the api version used for api requests made by this command

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Generate a Visualforce Page.

  The command generates the .Page file and associated metadata file in the specified directory or the current working
  directory by default.

ALIASES
  $ sf force visualforce page create
  $ sf visualforce generate page

EXAMPLES
  Generate the metadata files for a Visualforce page in the current directory:

    $ sf template generate visualforce page --name mypage --label mylabel

  Similar to previous example, but generate the files in the directory "force-app/main/default/pages":

    $ sf template generate visualforce page --name mypage --label mylabel --output-dir pages

FLAG DESCRIPTIONS
  -d, --output-dir=<value>  Directory for saving the created files.

    The location can be an absolute path or relative to the current working directory. The default is the current
    directory.

  -n, --name=<value>  Name of the generated Visualforce Page.

    The name can be up to 40 characters and must start with a letter.
```

_See code: [src/commands/template/generate/visualforce/page.ts](https://github.com/salesforcecli/plugin-templates/blob/56.15.5/src/commands/template/generate/visualforce/page.ts)_

<!-- commandsstop -->