Newer Version Available

This content describes an older version of this product. View Latest

Use a Sample Repo to Get Started

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

    SSH:

    1git clone git@github.com:trailheadapps/dreamhouse-lwc.git
  2. Change to the dreamhouse-lwc project directory.
    1cd dreamhouse-lwc
  3. 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 DevHub
    Enter your Dev Hub org credentials in the browser that opens. After you log in successfully, you can close the browser.
  4. 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-org
    The command uses the default Dev Hub you set with the sf org login web command in a previous step.
  5. View the orgs that you've either created or logged into.
    1sf org list

    The first table displays the Dev Hub you logged into and the second table displays the scratch org you created. The right-most column in both tables indicates the default scratch org and Dev Hub org with (U) and (D), respectively. The ALIAS column displays the aliases you assigned each org. Here’s some sample output.

    1Non-scratch orgs
    2========================================================================================
    3|     ALIAS  USERNAME                                   ORG ID         CONNECTED STATUS 
    4| ─── ────── ────────────────────────────────────────── ────────────── ──────────────── 
    5| (D) DevHub jules@sf.com                               00DB0000000c7j Connected        
    6
    7Scratch orgs
    8==============================================================================
    9|     ALIAS          USERNAME                  ORG ID         EXPIRATION DATE 
    10| ─── ────────────── ───────────────────────── ────────────── ─────────────── 
    11| (U) my-scratch-org test-ibnpzayw@example.com 00D9A000000EFo 2023-05-12
  6. Deploy the Dreamforce app, whose source is in the force-app directory, to the scratch org.
    1sf project deploy start --source-dir force-app
  7. Assign the dreamhouse permission set to the default scratch org user (test-ibnpzayw@example.com).
    1sf org assign permset --name dreamhouse
  8. 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
  9. Run Apex tests.
    1sf apex run test --result-format human --wait 1
    Apex 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.
  10. Open the scratch org and view the deployed metadata under Most Recently Used.
    1sf org open
  11. In App Launcher, find and open the Dreamhouse application.
Congrats! You just deployed an application to a new scratch org.