Newer Version Available
Run Through the Dreamhouse Example
- Open a terminal or command prompt window, and clone the dreamhouse-lwc GitHub sample repo using HTTPS
or SSH.
1git clone https://github.com/trailheadapps/dreamhouse-lwc.git 2 --or-- 3 git clone git@github.com:trailheadapps/dreamhouse-lwc.git - Change to the dreamhouse-lwc project directory.
1cd dreamhouse-lwc - Log in to your Dev Hub org to authorize it to create scratch orgs. Set it as your default Dev
Hub and assign it an alias.
1sf login org --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 it as your default, and
assign it an alias.
1sf env 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 login command in a previous step.
- View the environments (in this case, orgs) that you've either created or logged into.
1sf env listThe first table displays the Dev Hub you logged into and the second table displays the scratch org you created. The right-most Config column in both tables indicates the default scratch org and Dev Hub org with the target-org and target-dev-hub configuration variables, respectively. The left-most Aliases column displays the aliases you assigned each org. Here’s some sample output.
1Salesforce Orgs 2===================================================================================================== 3| Aliases Username Org ID Instance Url Auth Method Config 4| ------- ---------------------- ------ -------------------------------- ----------- ------------- 5| user@unicorn-qv0giu.com 00D5e123 https://unicorn.my.salesforce.com web 6| DevHub user@moose-qycot1.com 00D3h456 https://moose.my.salesforce.com web target-dev-hub 7 8Scratch Orgs 9======================================================================================================== 10| Aliases Username Org ID Instance Url Auth Method Config 11 ------------- -------------------- --------- --------------------------------- ---------- ---------- 12| my-scratch-org test-0xo@example.com 00D1D0789 https://ability.my.salesforce.com web target-org - Deploy the Dreamforce app, whose source is in the force-app directory, to the scratch org.
1sf deploy metadata --source-dir force-app - Assign the dreamhouse permission set to the default user.
1sfdx force:user:permset:assign -n dreamhouse - Import sample data into the scratch org.
1sfdx force:data:tree:import -p data/sample-data-plan.json - Run Apex tests.
1sfdx force:apex:test:run --resultformat human - Open the scratch org and view the pushed metadata under Most Recently Used.
1sf env open --target-env my-scratch-org - Optionally, in the App Launcher, find and open Dreamhouse, just to make sure it deployed correctly.
- In the Salesforce UI, make a small cosmetic change to an item. For example, update a comment in the GeocodingServiceTest Apex class. This step is to later show how you retrieve metadata from an org.
- Back in the terminal or command window, retrieve the small change you made in the org to your
project.
1sf retrieve metadata --source-dir force-appConfirm that the small change you made in your org has been retrieved to your project by viewing the file force-app/main/default/classes/GeocodingServiceTest.cls.