May 25, 2020
This is one of the best Project by Trailhead . There is a exhaustive lot you do but every minute you spend on this is worth a dime.
You create a Git Repository , a master branch, two feature branches and then merge them to master and finally deploy this master to a Trailhead playground. While you do this, you also create couple of scratch orgs to modify files. You will really see how everything connects. Go for it mate….experience the SFDX.
While deploying to one of the org, you will face an issue with admin profile. Just delete the admin profile from source code & move on…
- Git as a version control system and GitHub as a hosted repository
- Authorize a DevHub -> sfdx force:auth:web:login –setdefaultdevhubusername –setalias DevHub
- Use this Dev Hub as the default for all Salesforce DX projects on this computer so that you don’t have to specify again. sfdx force:config:set defaultdevhubusername=DevHub –global
- Use the Salesforce CLI to create a skeleton project structure named sfdx-chan -> sfdx force:project:create –projectname crmsmith
- Scratch org definition files allow you to easily create scratch orgs with different features or preferences for testing. ->sfdx-chan/config/project-scratch-def.json
- When syncing metadata between your local file system and a scratch org, or the other way around, you might have source files or metadata that you want to exclude. Sometimes, you make a change directly in a scratch org but you don’t want to pull that change into your local DX project. Sometimes, you have files in your local DX project that you don’t want to deploy – or can’t deploy – to your scratch org.In these situations, create a file named .forceignore to specify the files or directories you want to exclude.
- Retrieve Existing Metadata mkdir assets & In yourcrmsmith/assets folder, create a file named package.xml and save the below manifest contents into the file. This is the key, package.xml is the foundation of what files you want as part of your source code. I need to find an easy way to build package.xml
- In your CRMSMITH working directory, retrieve the DreamHouse app’s metadata sfdx force:source:retrieve –manifest assets/package.xml –targetusername DevHub –wait 10
- Export Sample Data -> sfdx force:data:tree:export –targetusername DevHub –outputdir assets/data –query “SELECT Id, Name, Email__c, Phone__c, Mobile_Phone__c, Title__c, Picture__c, ( SELECT Id, Address__c, Assessed_Value__c, Baths__c, Beds__c, Broker__c, City__c, Date_Agreement__c, Date_Closed__c, Date_Contracted__c, Date_Listed__c, Date_Pre_Market__c, Description__c, Location__Longitude__s, Location__Latitude__s, Picture__c, Price__c, Name, State__c, Status__c, Tags__c, Thumbnail__c, Title__c, Zip__c FROM Properties__r ) FROM Broker__c”
Creating a GitHub Repository
- Create a GitHub repository at https://github.com/new.
- Set your name to associate as the author of future Git commits. This should be your first and/or last name. git config –global user.name “Your Name”
- Set your email address to associate as the author of future Git commits. This should be the email address you use with GitHub. git config –global user.email “email@example.com”
- In your sfdx-chan working directory, initialize a local Git repository git init
- Add all files in the project to be tracked by Git git add .
- Commit the added files as a snapshot to the project’s version history. git commit –message “Initial commit of DreamHouse metadata”
- Link your local Git repository with your remote GitHub repository. Make sure to replace
YOUR_GITHUB_USERNAME with your actual GitHub username. git remote add origin https://github.com/YOUR_GITHUB_USERNAME/sfdx-project.git
- Push local commits (your file revisions) to the master branch on GitHub.git push origin master
- Branches allow developers to work on their own features without affecting the main codeline and to be isolated from changes going on elsewhere.
- In your sfdx-chan working directory, switch to a new Git branch named feature-chan-map > git checkout -b feature-chan-map
- Make some changes in both source code & org and do a git pull
- Add all modified files in the project to be tracked by Git (any files listed in
.gitignore file will be ignored) – git add .
- Commit the added files as a snapshot to the project’s version history –git commit –message “Added map component to property page”
- Push the local feature branch to GitHub git push -u origin feature-chan-map
- Clone the master branch : git clone https://github.com/YOUR_GITHUB_USERNAME/sfdx-project.git sfdx-maria
- Switch to a new feature-maria-gallery git checkout -b feature-maria-gallery
- Modify files and then got add . + git commit –message “Added gallery component to property page” + git push -u origin feature-maria-gallery
Merge Feature Branches and Deploy Metadata
- git checkout master
- git pull origin master
- sfdx force:source:deploy –targetusername DevHub –sourcepath force-app