Salesforce DX Absolute Beginner ( Part 3 Of 7 )

In this third part of the salesforce DX series, I am going to show how to set up salesforce dx project from the beginning. I am assuming that you are implementing the new application or project from the beginning. So there is no salesforce metadata is configured. Follow this basic workflow when you are starting the application from the beginning

1. Login into Dev Hub from CLI 

First, you need to login to the Dev Hub from the CLI to start the new project.
 Run the force:auth:web:login CLI command. If you are authorizing a Dev Hub org, use the —setdefaultdevhubusername parameter if you want the Dev Hub org to be the default for commands that accept the —targetdevhubusername parameter.

After Successful login into the Dev Hub, you can see the success message into the CLI as shown below.

 2. Create an SFDX Project

A Salesforce DX project has a specific structure and a configuration file that identifies the directory as a Salesforce DX project.Use the force:project:create command to create a skeleton project structure for your Salesforce DX project. The force:project:create command generates these samples configuration files to get you started.

 The force:project:create command generates these samples as shown below.
 3. Create a Scratch Org for Development

You can create scratch orgs for different functions, such as for feature development, for development of packages that contain a namespace, or for user acceptance testing and much other use cases. Use force:org: create to create a scratch orgs .

4.Open scratch Org
 You can open scratch org by running force:org:open command from the CLI. After login into the scratch org, you can make any configuration changes. Later you can pull them into local folders.

Or

5. Push and Pull the code

Go and create some couple of objects in the salesforce scratch org after that we will pull into the local salesforce dx by using the pull commands. You can pull configuration and code from scratch org by using force:source:pull command.

Create an Apex Class from the CLI with below command

Make some changes to the code as shown below.
Now push the changes to Scratch org from the local development with force:source:push command
After successfully push, you can able to see the changes in the scratch org
Here are the overall highlights of this post before starting part 4.
  •  Login to the Dev Hub
  • Create a Scratch Org
  • Create Salesforce DX Project
  • Pull changes into Salesforce DX project from the scratch org
  • Make changes locally and push into scratch org.