In my last post, I demonstrated how to authorise a dev hub and create an alias for it. Also, how to see a list of the orgs to which you are connected via CLI. In this post I am gonna demonstrate how to create an SFDX project and create a scratch org from it and also how to synchronise them both. I will also demonstrate how to push all these changes to Git (Git configuration is beyond the scope of this post but you can always google it). Lets get started!
How to create an SFDX Project:Before we even explore how to create a project, we need to understand why do we need to create a project. I am sure you guys must have asked this to yourselves. The simple reason behind this is the package model approach. Isolating features into projects helps us release these changes as a package rather than overlapping with other changes and releasing as an org deployment. And also, because projects contain the configuration file which allows us to create scratch orgs. so lets see how to create a project. Using terminal you can fire the following command to create a project.
Here, -n stands for name of the project. A project can also be created using the SFDX extension for VS Code. It is rather easy. Checkout the video to see how.
sfdx force:project:create -n projectname
How to create a Scratch Org from your SFDX Project:As seen in the video above, when you create an SFDX project, it automatically creates config files with information about the scratch org. Tweak the values to create a scratch org of your liking. So, here is how you use the config file to create a scratch org. Using the terminal fire up the following command.
What this above command does is, it creates a scratch org using the project definition file as mentioned with -f argument and alias TestOrg1 as mentioned with -a argument. We can also create a default scratch org using the SFDX VS Code extensions. Let’s see the video for that.
sfdx force:org:create -f config/project-scratch-def.json -a TestOrg1
So this is how we create SFDX projects and create scratch orgs from them. Next I will show how to sync these changes with your repository. Until then adios, Happy New Year!