Newer Version Available
Use a Sample Repo to Get Started with Salesforce DX
The quickest way to get going with Salesforce DX tooling is to clone the dreamhouse-lwc GitHub repo. Use its configuration files and
Salesforce application to try some commonly used Salesforce CLI commands. In addition to
source code for the application, the repo includes sample data and Apex tests.
This task assumes you have a Dev Hub org. See Select and Enable a Dev Hub Org for more
information.
- If you haven't already, install Salesforce CLI on your computer.
-
Open a terminal or command prompt window, and clone the dreamhouse-lwc GitHub
sample repo using HTTPS or SSH.
HTTPS:
1git clone https://github.com/trailheadapps/dreamhouse-lwc.gitSSH:
1git clone git@github.com:trailheadapps/dreamhouse-lwc.git -
Change to the dreamhouse-lwc project
directory.
1cd dreamhouse-lwc -
Authorize your Dev Hub org by logging into it, set it as your default, and
assign it an alias.
1sf org login web --set-default-dev-hub --alias DevHubEnter your Dev Hub org credentials in the browser that opens. After you log in successfully, you can close the browser. -
Create a scratch org using the config/project-scratch-def.json file, set the org as your
default, and assign it an alias.
1sf org create scratch --definition-file config/project-scratch-def.json --set-default --alias my-scratch-orgThe command uses the default Dev Hub you set with the sf org login web command in a previous step. -
View the orgs that you've either created or logged into.
1sf org listThe table displays the Dev Hub you logged into and the scratch org you created. The right-most column indicates the default scratch org and Dev Hub org; in the real-life output you see cute emojis, but in the output below we use (S) and (D), respectively. The Alias column displays the aliases you assigned each org. Here’s some sample output.
1Type Alias Username Org ID Status Expires 2 ── ─────── ────────────── ────────────────────────────────────── ────────────────── ───────────────────── ────────── 3 (D) DevHub DevHub jules@sf.com 00Daj0AUXXXXXXXXXX Connected 4 Sandbox jules@sf.com.jssandtwo 00D02000EAMXXXXXXX Connected 5 (S) Scratch my-scratch-org test-loo73bj6givn@example.com 00D7xOjgTEASXXXXXX Active 2024-05-16 6 7Legend: (D)=DevHub, (S)=Default Org Use --all to see expired and deleted scratch orgs -
Deploy the Dreamforce app, whose source is in the force-app directory, to the scratch org.
1sf project deploy start --source-dir force-app -
Assign the dreamhouse permission set to
the default scratch org user (test-ibnpzayw@example.com).
1sf org assign permset --name dreamhouse -
Import sample data from three objects (Contact, Property, and Broker) into the
scratch org using the specified plan definition file.
1sf data import tree --plan data/sample-data-plan.json -
Run Apex tests.
1sf apex run test --result-format human --wait 1Apex tests run asynchronously by default. If the tests finish before the --wait value, the results are displayed. Otherwise, use the displayed command to get the results using a job ID. -
Open the scratch org and view the deployed metadata under Most Recently
Used.
1sf org open - In App Launcher, find and open the Dreamhouse application.
Congrats! You just deployed an application to a new scratch org.