Salesforce DX - Developer Experience

Goal: Provide source-driven development

With a focus on source-driven development, Salesforce DX makes it easier for developers to build together and deliver continuously using the tools that make them most productive.

It starts with our core principles:

  • Everything is driven from source code (scm - version control - git)
    • Source code and metadata exist outside of the org and provide more agility to develop Salesforce apps in a team environment.
    • Instead of the org, your version control system is the source of truth
  • Environments are easily created and disposable (scratch orgs)

    • Flexible and configurable scratch orgs that you build for development and automated environments. This new type of org makes it easier to build your apps and packages.
  • Development is organized around team collaboration

  • Metadata and code are modular
  • Development is based on open standards and extensibility
  • Processes and tools facilitate continuous delivery (CI/CD)
    • A powerful command-line interface (CLI) removes the complexity of working with your Salesforce org for development, continuous integration, and delivery.
  • Flexible packaging supports agile distribution model
$ sfdx --version
sfdx-cli/6.0.26-3d23012 (darwin-x64) node-v8.6.0
$ sfdx -h
Usage: sfdx COMMAND

Help topics, type sfdx help TOPIC for more details:

 force    tools for the Salesforce developer
 plugins  manage plugins
 update   update CLI
$ sfdx force -h
Usage: sfdx force: [-v] [--json] [--loglevel <string>] [flags]

Flags:
 -v, --version        display the Salesforce API version
 --json               format output as json
 --loglevel LOGLEVEL  logging level for this command invocation
                      (error*,trace,debug,info,warn,fatal)

Usage: sfdx force:COMMAND

Help topics, type sfdx help TOPIC for more details:

 force:alias        manage username aliases
 force:apex         work with Apex code
 force:auth         authorize an org for use with the Salesforce CLI
 force:config       configure the Salesforce CLI
 force:data         manipulate records in your org
 force:doc          display help for force commands
 force:lightning    create and test Lightning component bundles
 force:limits       view your org’s limits
 force:mdapi        retrieve and deploy metadata using Metadata API
 force:org          manage your Salesforce DX orgs
 force:package      install and uninstall first- and second-generation packages
 force:package1     develop first-generation managed and unmanaged packages
 force:package2     develop second-generation packages
 force:project      set up a Salesforce DX project
 force:schema       view standard and custom objects
 force:source       sync your project with your orgs
 force:user         perform user-related admin tasks
 force:visualforce  create and edit Visualforce files

Orgs - help

$ sfdx force:org -h
Usage: sfdx force:org:COMMAND [command-specific-options]

manage your Salesforce DX orgs

sfdx force:org commands: (get help with sfdx help force:org:COMMAND)
 force:org:create        create a scratch org
 force:org:delete        mark a scratch org for deletion
 force:org:display       get org description
 force:org:list          list all orgs you’ve created or authenticated to
 force:org:open          open an org in your browser
 force:org:shape:create  create a snapshot of org edition, features, and licenses
 force:org:shape:delete  delete all org shapes for a target org
 force:org:shape:list    list all org shapes you’ve created

List Orgs - help

 $ sfdx force:org:list -h
Usage: sfdx force:org:list [--all] [--clean] [-p] [--json] [--loglevel <string>]

list all orgs you’ve created or authenticated to

Flags:
 -p, --noprompt       do not prompt for confirmation
 --all                include expired, deleted, and unknown-status scratch orgs
 --clean              remove all local org authorizations for non-active orgs
 --json               format output as json
 --loglevel LOGLEVEL  logging level for this command invocation
                      (error*,trace,debug,info,warn,fatal)

Examples:
   $ sfdx force:org:list
   $ sfdx force:org:list --verbose --json
   $ sfdx force:org:list --verbose --json > tmp/MyOrgList.json

List Orgs

 $ sfdx force:org:list
=== Orgs
  ALIAS   USERNAME                              ORG ID              CONNECTED STATUS
  ──────  ────────────────────────────────────  ──────────────────  ─────────────────
          mohan.chinnappan.n.dx1@gmail.com      00Df4000000nn2KEAQ  authDecryptFailed
          mohan.chinnappan.n23@gmail.com        00Df40000003eOAEAY  Connected
          mohan.chinnappan.n30@gmail.com        00Df4000000nUtnEAE  authDecryptFailed
          mohan.chinnappan.n32@gmail.com        00Df4000001TuquEAC  authDecryptFailed
          mohan.chinnappan.n_devhub@gmail.com   00D1I000001UmBpUAK  authDecryptFailed
  DebHub  mohan.chinnappan.n2.devhub@gmail.com  00D1I000003nO9oUAE  Connected


No active scratch orgs found. Specify --all to see all scratch orgs

List orgs - JSON output




$ sfdx force:org:list --json | jq
{
  "status": 0,
  "result": {
    "nonScratchOrgs": [
      {
        "orgId": "00Df4000000nn2KEAQ",
        "accessToken": "d7f525ee28c319f861d1dbf3731e745b2534b243fbd19b35967e4f28ab85e5ae84fb29ddb24721d7ff047bc2f80c3c55cbdaedf778f5d528c0e1f785222a204c210d86b2277c3387d62764d5e159575d32c4f106bfb3b95a777b751a99a44f12b9cbea2f0750f0ab21c65d0a4f4350feec87949ff899:50e4a4b306cbc2a19154672ed6d4ecd5",
        "instanceUrl": "https://na59.salesforce.com",
        "loginUrl": "https://login.salesforce.com",
        "username": "mohan.chinnappan.n.dx1@gmail.com",
        "isDevHub": true,
        "connectedStatus": "authDecryptFailed",
        "lastUsed": "2017-12-28T16:50:54.000Z"
      },
      {
        "orgId": "00Df40000003eOAEAY",
        "accessToken": "0b908eaf1f8f60fe264469be1c82f656fdf18877e315fb849e9821e067485a737b0f12803d61515bcff19a76500e378d7c0f567ad53f0381eec4ab0ed918de22f6bba87f7f8fc481e3b4ad9d3f737ac66082893b11bcb0a9b790f838ee73ddaa678474825b08f89bdba948121c906dd0d5d8d34161cf:a7dfd4816975194de4f7b72dcb968ecc",
        "instanceUrl": "https://mohansun-lx1-dev-ed.my.salesforce.com",
        "loginUrl": "https://login.salesforce.com",
        "username": "mohan.chinnappan.n23@gmail.com",
        "connectedStatus": "Connected",
        "lastUsed": "2017-12-28T16:50:54.000Z"
      },
      {
        "orgId": "00Df4000000nUtnEAE",
        "accessToken": "02b44fc44756e7dfd18b19273a1529fb189aadce7d1a37bf2e7ab9d11da933bde554c32d5413ad185d893f159ecf499a0ba0593806d42c43b5d17ab3fd0223b8727b8e0301cdb59d166120478408ac0cc917248f0ca1efc4b893a7ff3d6bfa104324ff170f6b80710ed19efd031b2049acf3aabed48c:48309d2e17562f3b4f77a39398fff5cc",
        "instanceUrl": "https://mohansun-lx2-dev-ed.my.salesforce.com",
        "loginUrl": "https://login.salesforce.com",
        "username": "mohan.chinnappan.n30@gmail.com",
        "connectedStatus": "authDecryptFailed",
        "lastUsed": "2017-12-28T16:50:55.000Z"
      },
      {
        "orgId": "00Df4000001TuquEAC",
        "accessToken": "ddef552669e581ae8e9b2e40fc9afb5cfa2ea027726bcbe1fb7359e20a92e0d141428924fa1f784fda78f90ae284b291a1ea02aecc4547496acc2a255d9f45b1db6eaf1f7a483d1a3dd28d650a05bb863d3ecddd05d3aa20319320372eca277224a0f89606138c50cd6cc7815bb823ad51dc9b230ee0:9716f6aa36a49b644c3b15a189716ba1",
        "instanceUrl": "https://na59.salesforce.com",
        "loginUrl": "https://login.salesforce.com",
        "username": "mohan.chinnappan.n32@gmail.com",
        "isDevHub": true,
        "connectedStatus": "authDecryptFailed",
        "lastUsed": "2017-12-28T16:50:55.000Z"
      },
      {
        "orgId": "00D1I000001UmBpUAK",
        "accessToken": "22c54fad3bdca0c54209de95cf738634b6547e250addeffc7909edc6484af3936806dd67ac735b8aa398c1cf30095ca16d670b859596e4a4d87e19eeaa6b2bce52e8c6b3d255775ebffcfb50a62a9a401d330b395a3b2a1538d15e95c8c76e8cfc36f238a4c7e0b402fcb3f3f4f91b8f4f6791b0024c:dd89d22de3b99ffbf1e7f7a99fe2ad3d",
        "instanceUrl": "https://na73.salesforce.com",
        "loginUrl": "https://login.salesforce.com",
        "username": "mohan.chinnappan.n_devhub@gmail.com",
        "isDevHub": true,
        "connectedStatus": "authDecryptFailed",
        "lastUsed": "2017-12-28T16:50:54.000Z"
      },
      {
        "orgId": "00D1I000003nO9oUAE",
        "accessToken": "be1dabb89d3d02cf7ba6b05cd73769b2589aa1f5f29c9f048f4c4e3f989f1c09ce57bdaf074d109adcc6e4c683aa98716cd3175d92d8c6f164c1a38f9f04eba7c4cba0efea2bd28d7f7c7f062d1773d96a641a8bb61c5416fdbedc57c0cd93c62b009e6fae95e32b8546c8fff951c7ae02a197976831:1a8ef453c1f58c7a56762c56a3c7c8e6",
        "instanceUrl": "https://na73.salesforce.com",
        "loginUrl": "https://login.salesforce.com",
        "username": "mohan.chinnappan.n2.devhub@gmail.com",
        "isDevHub": true,
        "connectedStatus": "Connected",
        "lastUsed": "2017-12-28T16:50:54.000Z",
        "alias": "DebHub"
      }
    ],
    "scratchOrgs": []
  }
}

Authorize an org for use with the Salesforce CLI

$ sfdx force:auth -h
Usage: sfdx force:auth:COMMAND [command-specific-options]

authorize an org for use with the Salesforce CLI

sfdx force:auth commands: (get help with sfdx help force:auth:COMMAND)
 force:auth:jwt:grant      authorize an org using the JWT flow
 force:auth:sfdxurl:store  authorize an org using an SFDX auth URL
 force:auth:web:login      authorize an org using the web login flow

Authorize an org using the web login flow

$ sfdx force:auth:web:login -h
Usage: sfdx force:auth:web:login [-i <string>] [-r <url>] [-d] [-s] [-a <string>] [--json] [--loglevel <string>]

authorize an org using the web login flow

Flags:
 -i, --clientid CLIENTID         OAuth client ID (sometimes called the consumer
                                 key)
 -r, --instanceurl INSTANCEURL   the login URL of the instance the org lives on
 -a, --setalias SETALIAS         set an alias for the authenticated org
 -d, --setdefaultdevhubusername  set the authenticated org as the default dev
                                 hub org for scratch org creation
 -s, --setdefaultusername        set the authenticated org as the default
                                 username that all commands run against
 --json                          format output as json
 --loglevel LOGLEVEL             logging level for this command invocation
                                 (error*,trace,debug,info,warn,fatal)

To log in to a sandbox, set --instanceurl to https://test.salesforce.com.

Examples:
   $ sfdx force:auth:web:login -a TestOrg1
   $ sfdx force:auth:web:login -i <OAuth client id>
   $ sfdx force:auth:web:login -r https://test.salesforce.com

Web login

sfdx force:auth:web:login --setdefaultdevhubusername
Successfully authorized mohan.chinnappan.n2.devhub@gmail.com with org ID 00D1I000003nO9oUAE
You may now close the browser

devhub login

create a scratch org - help


sfdx force:org:create -h
Usage: sfdx force:org:create name=value... [-f <filepath>] [-n] [-c] [-i <string>] [-s] [-a <string>] [-w <minutes>] [-d <number>] [-v <string>] [--json] [--loglevel <string>]

create a scratch org

Flags:
 -i, --clientid CLIENTID                          connected app consumer key
 -f, --definitionfile DEFINITIONFILE              path to a scratch org
                                                  definition file
 -d, --durationdays DURATIONDAYS                  duration of the scratch org
                                                  (in days) (default:7, min:1,
                                                  max:30)
 -c, --noancestors                                do not include
                                                  second-generation package
                                                  ancestors in the scratch org
 -n, --nonamespace                                creates the scratch org with
                                                  no namespace
 -a, --setalias SETALIAS                          set an alias for for the
                                                  created scratch org
 -s, --setdefaultusername                         set the created org as the
                                                  default username
 -v, --targetdevhubusername TARGETDEVHUBUSERNAME  username or alias for the dev
                                                  hub org; overrides default dev
                                                  hub org
 -w, --wait WAIT                                  the streaming client socket
                                                  timeout (in minutes)
                                                  (default:6, min:2)
 --json                                           format output as json
 --loglevel LOGLEVEL                              logging level for this command
                                                  invocation
                                                  (error*,trace,debug,info,warn,fatal)

To set up a connected app for your new scratch org, specify the value that was returned when you created a connected app in your Dev Hub org as --clientid.

Examples:
   $ sfdx force:org:create -f config/enterprise-scratch-def.json -a TestOrg1
   $ sfdx force:org:create -a MyDevOrg -s -v me@myhub.org edition=Developer
   $ sfdx force:org:create -f config/enterprise-scratch-def.json -a OrgWithOverrides username=testuser1@mycompany.org

Sample scratch org definition file (myDevOrg_100-scratch-def.json)

{
    "orgName": "mchinnappan Company",
    "edition": "Developer",
    "orgPreferences" : {
        "enabled": ["S1DesktopEnabled"]
    }
}

Create scratch org MyDevOrg_100

$ sfdx force:org:create -f ./config/myDevOrg_100-scratch-def.json -a MyDevOrg_100
Successfully created scratch org: 00D5C0000000OTsUAM, username: test-wncfnsrx2mbf@mchinnappan_company.net

----

sfdx force:org:list
=== Orgs
     ALIAS   USERNAME                              ORG ID              CONNECTED STATUS
───  ──────  ────────────────────────────────────  ──────────────────  ─────────────────
             mohan.chinnappan.n.dx1@gmail.com      00Df4000000nn2KEAQ  authDecryptFailed
             mohan.chinnappan.n23@gmail.com        00Df40000003eOAEAY  Connected
             mohan.chinnappan.n30@gmail.com        00Df4000000nUtnEAE  authDecryptFailed
             mohan.chinnappan.n32@gmail.com        00Df4000001TuquEAC  authDecryptFailed
             mohan.chinnappan.n_devhub@gmail.com   00D1I000001UmBpUAK  authDecryptFailed
(D)  DebHub  mohan.chinnappan.n2.devhub@gmail.com  00D1I000003nO9oUAE  Connected


  ALIAS         SCRATCH ORG NAME     USERNAME                                   ORG ID              EXPIRATION DATE
  ────────────  ───────────────────  ─────────────────────────────────────────  ──────────────────  ───────────────
  MyDevOrg_100  mchinnappan Company  test-wncfnsrx2mbf@mchinnappan_company.net  00D5C0000000OTsUAM  2018-01-04

Changing DevHub alias


sfdx force:auth:web:login --setdefaultdevhubusername --setalias DevHub
Successfully authorized mohan.chinnappan.n2.devhub@gmail.com with org ID 00D1I000003nO9oUAE
You may now close the browser
~/sfdc/sfdx/book:
$ sfdx force:org:list
=== Orgs
    ALIAS   USERNAME                              ORG ID              CONNECTED STATUS
───  ──────  ────────────────────────────────────  ──────────────────  ─────────────────
            mohan.chinnappan.n.dx1@gmail.com      00Df4000000nn2KEAQ  authDecryptFailed
            mohan.chinnappan.n23@gmail.com        00Df40000003eOAEAY  Connected
            mohan.chinnappan.n30@gmail.com        00Df4000000nUtnEAE  authDecryptFailed
            mohan.chinnappan.n32@gmail.com        00Df4000001TuquEAC  authDecryptFailed
            mohan.chinnappan.n_devhub@gmail.com   00D1I000001UmBpUAK  authDecryptFailed
(D)  DevHub  mohan.chinnappan.n2.devhub@gmail.com  00D1I000003nO9oUAE  Connected


 ALIAS         SCRATCH ORG NAME     USERNAME                                   ORG ID              EXPIRATION DATE
 ────────────  ───────────────────  ─────────────────────────────────────────  ──────────────────  ───────────────
 MyDevOrg_100  mchinnappan Company  test-wncfnsrx2mbf@mchinnappan_company.net  00D5C0000000OTsUAM  2018-01-04

scratch orgs list

References

  1. Introducing the Salesforce DX Open Beta

results matching ""

    No results matching ""