lightning Commands

Use the lightning commands to create and test Lightning component bundles.

lightning:app:create

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

Command Syntax

sfdx force:lightning:app:create
-n APPNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --appname APPNAME
Required

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

Type: string
-t | --template TEMPLATE
Optional

The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningApp
Default value: DefaultLightningApp
-d | --outputdir OUTPUTDIR
Optional

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

Type: string
-a | --apiversion APIVERSION
Optional

The API version of the created source.

Type: string
Permissible values are: 44.0, 43.0
Default value: 44.0
--json
Optional

Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:app:create

If not supplied, the apiversion, template, and outputdir use default values.

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

If you don’t specify an outputdir, we create a subfolder in your current working directory with the name of your bundle. For example, if the current working directory is force-app and your Lightning bundle is called myBundle, we create force-app/myBundle/ to store the files in the bundle.

Examples:

1$ sfdx force:lightning:app:create -n myapp
1$ sfdx force:lightning:app:create -n myapp -d lightning

lightning:component:create

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

Command Syntax

sfdx force:lightning:component:create
-n COMPONENTNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --componentname COMPONENTNAME
Required

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

Type: string
-t | --template TEMPLATE
Optional

The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningCmp
Default value: DefaultLightningCmp
-d | --outputdir OUTPUTDIR
Optional

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

Type: string
-a | --apiversion APIVERSION
Optional

The API version of the created source.

Type: string
Permissible values are: 44.0, 43.0
Default value: 44.0
--json
Optional

Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:component:create

If not supplied, the apiversion, template, and outputdir use default values.

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

If you don’t specify an outputdir, we create a subfolder in your current working directory with the name of your bundle. For example, if the current working directory is force-app and your Lightning bundle is called myBundle, we create force-app/myBundle/ to store the files in the bundle.

Examples:

1$ sfdx force:lightning:component:create -n mycomponent
1$ sfdx force:lightning:component:create -n mycomponent -d lightning

lightning:event:create

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

Command Syntax

sfdx force:lightning:event:create
-n EVENTNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --eventname EVENTNAME
Required

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

Type: string
-t | --template TEMPLATE
Optional

The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningEvt
Default value: DefaultLightningEvt
-d | --outputdir OUTPUTDIR
Optional

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

Type: string
-a | --apiversion APIVERSION
Optional

The API version of the created source.

Type: string
Permissible values are: 44.0, 43.0
Default value: 44.0
--json
Optional

Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:event:create

If not supplied, the apiversion, template, and outputdir use default values.

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

If you don’t specify an outputdir, we create a subfolder in your current working directory with the name of your bundle. For example, if the current working directory is force-app and your Lightning bundle is called myBundle, we create force-app/myBundle/ to store the files in the bundle.

Examples:

1$ sfdx force:lightning:event:create -n myevent
1$ sfdx force:lightning:event:create -n myevent -d lightning

lightning:interface:create

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

Command Syntax

sfdx force:lightning:interface:create
-n INTERFACENAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[-a APIVERSION]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --interfacename INTERFACENAME
Required

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

Type: string
-t | --template TEMPLATE
Optional

The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningIntf
Default value: DefaultLightningIntf
-d | --outputdir OUTPUTDIR
Optional

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

Type: string
-a | --apiversion APIVERSION
Optional

The API version of the created source.

Type: string
Permissible values are: 44.0, 43.0
Default value: 44.0
--json
Optional

Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:interface:create

If not supplied, the apiversion, template, and outputdir use default values.

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

If you don’t specify an outputdir, we create a subfolder in your current working directory with the name of your bundle. For example, if the current working directory is force-app and your Lightning bundle is called myBundle, we create force-app/myBundle/ to store the files in the bundle.

Examples:

1$ sfdx force:lightning:interface:create -n myinterface
1$ sfdx force:lightning:interface:create -n myinterface -d lightning

lightning:lint

Runs a static analysis, or “lint,” tool on your Lightning component code. The default rules include recommended best practices and LockerService requirements. For details, including how to customize the rules for your org, see the Lightning Components Developer Guide.

Command Syntax

sfdx force:lightning:lint
[-i IGNORE]
[--files FILES]
[-j]
[--config CONFIG]
[--verbose]
[--exit]

Parameters

-i | --ignore IGNORE
Optional

A “glob” pattern used to filter folders (and their contents) out of the analysis. For example: --ignore **/foo/**.

--files FILES
Optional

A “glob” pattern used to add specific files to the analysis. For example, to only analyse your controller files, use --files **/*Controller.js. When specified, this value overrides the --ignore flag. The default is all .js files.

-j | --json
Optional

Format output as JSON, usually for integration with other tools. The default is standard text output format.

--config CONFIG
Optional

Path to a custom ESLint configuration file. Only code style rules are used, while the rest are ignored. For example: --config path/to/.eslintrc.

--verbose
Optional

Report both warnings and errors. The default is to report only errors.

--exit
Optional

Exit with error code 1 if there are lint issues. The default exits without an error code.

Help for lightning:lint

Examples:

1$ sfdx force:lightning:lint ./path/to/be/linted/

$ heroku lightning:lint ./path/to/be/linted/

lightning:test:create

Creates a Lightning test in the specified directory or the current working directory. The .resource file and associated metadata file are created.

Command Syntax

sfdx force:lightning:test:create
-n TESTNAME
[-t TEMPLATE]
[-d OUTPUTDIR]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --testname TESTNAME
Required

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

Type: string
-t | --template TEMPLATE
Optional

The template to use to create the file. Supplied parameter values or default values are filled into a copy of the template.

Type: string
Permissible values are: DefaultLightningTest
Default value: DefaultLightningTest
-d | --outputdir OUTPUTDIR
Optional

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

Type: string
--json
Optional

Formats output as JSON.

Type: string
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:test:create

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

Examples:

1$ sfdx force:lightning:test:create -n MyLightningTest
1$ sfdx force:lightning:test:create -n MyLightningTest -d lightningTests

lightning:test:install

Installs a Lightning Testing Service (LTS) unmanaged package into your org.

Command Syntax

sfdx force:lightning:test:install
[-w WAIT]
[-r RELEASEVERSION]
[-t PACKAGETYPE]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-w | --wait WAIT
Optional

Maximum number of minutes to wait for installation status.

Type: minutes
Default value: 2
-r | --releaseversion RELEASEVERSION
Optional

The release version of LTS unmanaged package you want to install.

Type: string
Default value: latest
-t | --packagetype PACKAGETYPE
Optional

Type of LTS unmanaged package to install. 'jasmine' and 'mocha' contains the essentials for development, 'full' contains both, and adds sample components and tests in the package. 'full' is best for 'kicking the tires' of LTS.

Type: string
Permissible values are: jasmine, mocha, full
Default value: full
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:test:install

Examples:

1$ sfdx force:lightning:test:install
1$ sfdx force:lightning:test:install -w 0 -r v1.0
1$ sfdx force:lightning:test:install -t jasmine

lightning:test:run

Runs Lightning component tests. The Lightning Testing Service (LTS) unmanaged package must be installed in your org. For details, see the LTS documentation.

Command Syntax

sfdx force:lightning:test:run
[-a APPNAME]
[-d OUTPUTDIR]
[-r RESULTFORMAT]
[-f CONFIGFILE]
[-o]
[-t TIMEOUT]
[-u TARGETUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-a | --appname APPNAME
Optional

Name of your Lightning test application. The name is case insensitive, and ".app" is optional, so "Test" and "test.app" are equivalent.

Default value: Test.app

Type: string
-d | --outputdir OUTPUTDIR
Optional

Directory path to store test run artifacts: log files, test results, and so on.

Type: directory
-r | --resultformat RESULTFORMAT
Optional

Format to use when displaying test results. If you also specify the --json flag, --json overrides this parameter.

Type: string
Permissible values are: human, tap, junit, json
Default value: human
-f | --configfile CONFIGFILE
Optional

Path to a test configuration file to configure WebDriver and other settings. For details, see the LTS documentation.

Type: filepath
-o | --leavebrowseropen
Optional

Leaves browser open after the test finishes so that you can view the test suite results.

Type: flag
-t | --timeout TIMEOUT
Optional

Time, in milliseconds, to wait for the results element to be present in the DOM, before failing and moving on to the next test.

Type: number
Default value: 60000
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for lightning:test:run

Examples:

1$ sfdx force:lightning:test:run
1$ sfdx force:lightning:test:run -a tests -r human
1$ sfdx force:lightning:test:run -f config/myConfigFile.json -d testResultFolder