Tata AIG General Insurance Company - Insurer Innovation Award 2024
Cleveland Developers: CLI in the C-L-E slide deck
1. CLI in the C-L-E
Using the Salesforce Command Line Interface
2. Installing the CLI
Mac/Windows/Ubuntu:
1. https://developer.salesforce.com/tools/
sfdxcli
2. Choose your OS (Mac, Windows,
Linux)
Option 2: Install w/npm
1. Make sure node version is
LTS
2. Run npm install
@salesforce/cli
--global
https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm
3. Updating CLI
If you used the installer:
● CLI should be auto updated
● If not just run:
sf update
If you installed with npm:
● You must manually update
● Run:
npm install
--global
@salesforce/cli
https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_update_cli.htm#sfd
x_setup_update_cli
4. CLI & VS Code
You can run CLI using the
Salesforce CLI Integration
extension. Ctrl/CMD + Shift
+ P will guide you to most
commands. You can also
type commands manually in
the Terminal.
1. Make sure the Salesforce
Extension Pack is installed
and up to date (this
includes the Salesforce
CLI Integration)
2. Ctrl/CMD + Shift + P OR
Run from Terminal
6. HELP!!!
sf --help or sf -h
Example:
sf --help project
retrieve start
Results give you Usage, Options &
Description
https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_unified.htm
7. Create a Project
sf project generate -n PROJECTNAME
Creates a project folder in your current location
8. Connect An Org
sf org login web OR
sf org login web -r URL
Lets you connect via a Salesforce Login Screen in a
browser. 2nd version let’s you specify the instance (e.g.
https://mydomain--sandboxname.sandbox.my.salesforce.com)
sf org list
Lists the orgs you’ve authorized with their usernames and
connectivity status.
10. Explore the Schema
sf sobject list -s OBJECTTYPE
OBJECTTYPE includes Standard, Custom or All.
sf sobject describe -s OBJECTNAME
OBJECTNAME is the object and the
result is the object’s metadata.
11. Pull/Retrieve Source (Code/Metadata)
for a non-Scratch org
sf project retrieve start -m METADATATYPE
METADATATYPE includes ApexClass, ApexPage (VF),
ApexTrigger, AuraDefinitionBundle (Lightning Component),
LightningComponentBundle (LWC).
More METADATATYPES:
https://developer.salesforce.com/docs/atlas.en-us.api_meta.
meta/api_meta/meta_objects_intro.htm#!
12. Create New Code
sf apex generate class -n CLASSNAME
sf apex generate trigger -n TRIGGERNAME
sf visualforce generate page -n PAGENAME -l LABEL
sf lightning component generate -n COMPONENTNAME --type
aura|lwc
Note: You need to navigate to the folder
where your code needs to be first!
13. Deploy New or Updated Code
for a non-Scratch org
sf project deploy start -o USERNAME
Other Parameters (use only 1 of the following):
-d SOURCEPATH single file or folder
-m METADATA comma separated list of type:name,
wildcards supported
-x MANIFEST complete path of
package.xml file listing
components to deploy
14. Testing Code
sf apex run test -n CLASSNAME
This will run your Apex Test Class (repeat tag for multiple
classes)
Other Parameters:
-c displays code coverage results
-l LEVEL without CLASSNAME, specify level
-d PATH output results to a directory
15. Testing Code
sf apex run test -n CLASSNAME
This will run your Apex Test Class (repeat tag for multiple
classes)
Other Parameters:
-c displays code coverage results
-l LEVEL without CLASSNAME, specify level
-d PATH output results to a directory
16. Testing Code
sf force lightning lwc test run -n
TESTNAME
This will run your Lightning Jest Tests
17. Data
CLI commands let you
create, get and query data!
sf data create record
sf data get record
sf data query
20. Trailhead on the CLI
Modules
● App Development with Salesforce DX
● Command-Line Interface
● Lightning Web Components Basics
● Package Development Model
● Unlocked Packages for Customers
21. Trailhead on the CLI
Projects
● Quick Start: Salesforce DX
● Quick Start: Unlocked Packages
● Quick Start: Visual Studio Code for Salesforce Development
● Set Up Your Lightning Web Components Developer Tools
● Quick Start: Lightning Web Components
● Find and Fix Bugs with Apex Replay Debugger
● Build a Bear-Tracking App with Lightning Web Components