Salesforce DX is a great way to let multiple peoples work together and also make deployment much easier. Salesforce DX make release cycle more efficient and easy. Version Control System become a source of truth rather than your salesforce.com org that is called source driven development. Each developer works in his personal scratch org and pushes code to the repository when necessary.
I struggled a little bit while adopting salesforce DX and hence writing all steps to get started with Salesforce DX.
Now you have pushed your local source and metadata to a scratch org. You can login into scratch org by <sfdx force:org:open> command and use it as your dev environment and keep your repo in sync.
I struggled a little bit while adopting salesforce DX and hence writing all steps to get started with Salesforce DX.
- Installing Salesforce DX Tools
- Install the Saleforce Command Line Interface (CLI):- Follows steps given on following salesforce help page to install CLI according to your machine. https://developer.salesforce.com/docs/atlas.en-us.214.0.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm#sfdx_setup_install_cl
- Install Git:- Install git according to your machine from the following a link. https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
- Install VS code Editor:- Install VS code editor from https://code.visualstudio.com/
- Install Salesforce VS code plug-in:- Search for “Salesforce Extensions for VS Code” in vs code marketplace or install from https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode-apex
- Salesforce DX Setup
- Step-1 Enable Dev Hub. Dev Hub allows you to create and manage scratch org. Scratch orgs are disposable Salesforce orgs to support development and testing. Every developer can have their own scratch org and quickly created from command line along with deploying all metadata from source code repository. You can learn more about enabling Dev Hub from the following link. https://developer.salesforce.com/docs/atlas.en-us.214.0.sfdx_setup.meta/sfdx_setup/sfdx_setup_enable_devhub.htm. Developer Account can’t be enabled as dev Hub for now and for learning the purpose you can create Sign Up for a Developer Hub Trial Org. That will have Dev Hub enabled for you. https://developer.salesforce.com/promotions/orgs/dx-signup
- Login Into Deb Hub and authorize:- Use the <sfdx force:auth:web:login -d -a DevHub> command from CLI to authorize your salesforce Deb Hub using a web flow. Here -a for ALIAS and -d for default dev hub username
- Step-2 Setting up Salesforce DX project:- Depending upon where you are at your salesforce project stage. You will pick one of the following paths.
- Create brand new Salesforce Project:- force:project:create -n MyNewProject
- Checkout Project from GIT to start for existing salesforce :- Run following git command to checkout project from git.
- git clone <GIT Repo URL>
- Create Scratch org with command : sfdx force:org:create -s -f config/project-scratch-def.json -a <alias name>
- Push local source code to scratch org by sfdx force:source:push
Now you have pushed your local source and metadata to a scratch org. You can login into scratch org by <sfdx force:org:open> command and use it as your dev environment and keep your repo in sync.
References
- https://developer.salesforce.com/blogs/2018/02/getting-started-salesforce-dx-part-1-5.html
- App Development with Salesforce DX
- SFDX Command References
- Salesforce DX videos