Salesforce Developer Experience (DX) is a new way to manage and develop apps on the Lightning Platform across their entire life cycle. It brings together the best of the Lightning Platform to enable source-driven development, team collaboration with governance, and new levels of agility for custom app development on Salesforce.
its a powerful command-line interface (CLI) removes the complexity of working with your Salesforce org for development, continuous integration, and delivery.
The main part SFDX cover is related to Source control. SFDX is a command line tool but we can also use Visual studio plug-in to do the development
Setup SFDX
Initially we need to create Dev Hub org. You can signup for a trial org from here. https://developer.salesforce.com/promotions/orgs/dx-signup
macOS | https://sfdc.co/sfdx_cli_osx |
Windows 32-bit | https://sfdc.co/sfdx_cli_win |
Windows 64-bit | https://sfdc.co/sfdx_cli_win64 |
Debian/Ubuntu 64 | https://sfdc.co/sfdx_cli_linuxDownload the archive from one of the URLs in the manifest, extract the archive, then run the ./install script. |
Debian/Ubuntu x86 | https://sfdc.co/sfdx_cli_linux_x86 |
Based on PC type download and install CLI.
- So now we need to do login in our devhub org and authenticate the SFDX to use that.
We can create alias for org as we want . We can use sfdx force:org:list to see all active org.
2) Now create a local project where you will store all the metadata.
3) In the Next step create a new scratch org where going to do the development.
- The -s option indicates that we want this scratch org to be the default org for this project.
- The -f option is the path to the project scratch org configuration file.
To get list of all org using list command
Now we setup SFDX. and you can find many commands for various action can be done through CLI from developer guide
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm
How to Convert Package code Using SFDX
To Convert package first we need to authenticate our Dev Hub org. Then we need to create a new project to store our project metadata.
What is Dev Hub ?
It’s a org where Salesforce stores all related scratch org information. We need to enable Dev Hub in our production or developer org.
1)To create package run the below code in CLI.
2)In the next step authentic the package org to take a backup of code.
It will run Web Auth Flow and will open a window.
3)Now make a directory to store the metadata and fetch the data from source. it gives us a zip file. Which we need to unzip.
4)After convert this metadata into SFDX format.
sfdx force:mdapi:convert -r ./dummy
5)Now Create a new scratch org to move our metadata . For that we need to use project-scratch-def file.
6) Once org created , we are ready to push our code into new scratch org.
sfdx force:source:push
7) Once Code pushed succesfully we can see success message and now we can open the org and can continue with our development.
For more info refer salesforce guide:
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm