Salesforce Asked by Brian Miller on January 4, 2022
Although we use git repos to track all our projects, I oftentimes want to do another check against a production file before I overwrite it with an sfdx force:source:deploy
command (because as much as a git repo is kept up-to-date, you never know what renegade changes have been made to Production…)
Is there a simple sfdx
workflow or command to bring in that file and compare against my local project version? Context: I use VS Code and git for day-to-day development.
After installing the sfdx:source:diff
tool from @Mohith Shrivastava's response, you can use the --json
flag to return the locations of the remote and local files that VS Code uses to diff. You can then pass those files to git diff
to see the diff in the command line.
Here is the whole command:
SFDX_DIFF_JSON=$(sfdx force:source:diff -p force-app/main/default/classes/MyController.cls -u MyProductionOrg --json)
git diff $(echo ${SFDX_DIFF_JSON} | jq '.result.remote' -r) $(echo ${SFDX_DIFF_JSON} | jq '.result.local' -r)
Answered by bbbco on January 4, 2022
Have you tried using the Salesforce official Diff Feature on the Extension Pack for Salesforce
https://developer.salesforce.com/tools/vscode/en/user-guide/source-diff/
From the terminal, run sfdx plugins:install @salesforce/sfdx-diff.
After the installation is complete, @salesforce/sfdx-diff appears in the list of installed plugins when running sfdx plugins.
Use the vscode menu to take the diff
This requires enabling the preview flag from your vscode settings
Answered by Mohith Shrivastava on January 4, 2022
VS Code has an option to detect conflicts on deployment for non-source-tracked orgs. Go to Settings > Salesforce Feature Previews > Salesforcedx-vscode-core: Detect Conflicts At Sync. Note that this is still a limited feature, so some caution is advised.
In the interim, if I want to check for differences, I usually do:
git checkout -b temp-branch
git add force-app
git commit -m "temp commit for compare"
sfdx force:source:retrieve -p force-app
git diff
This gives me a line-by-line analysis of everything. I can also use --name-only
just to get a feel for which files are affected.
Answered by sfdcfox on January 4, 2022
2 Asked on January 2, 2022
1 Asked on January 2, 2022 by akouayri-hamza
1 Asked on January 2, 2022 by treblecode
0 Asked on January 2, 2022 by love-gupta
1 Asked on January 2, 2022
1 Asked on January 2, 2022 by crm-admin
2 Asked on December 31, 2021
3 Asked on December 31, 2021 by bighairdev
javascript lightning apps lightning aura components summer 16
2 Asked on December 31, 2021 by pmehra
1 Asked on December 31, 2021
1 Asked on December 31, 2021 by sfdclearner
2 Asked on December 31, 2021 by neo2049
1 Asked on December 31, 2021
2 Asked on December 31, 2021
1 Asked on December 31, 2021
lightning lightning aura components lightning data service lightning experience
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP