Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
sfdx-git-delta
Advanced tools
Generate the sfdx content in source format and destructive change from two git commits
Generate the sfdx content in source format and destructive change from two git commits
SFDX-Git-Delta (a.k.a. sgd) helps Technical Architects accomplish 2 things with their CI deployments:
If you are not a Salesforce Architect, probably not, sorry.
If you are a Technical Architect, then it’s a very useful tool for you, when the 3 conditions below are met:
Your Salesforce project uses a git repo as the source of truth.
➕
You use the new Source (DX) format in the repo.
➕
You have a CI/CD pipeline (Jenkins, Bitbucket Pipelines, GitLab CI...) that handles the deployment of the sources to the salesforce org(s).
DISCLAIMER:
⚠️ SFDX-Git-Delta is not an officially supported tool ⚠️
👷 Use it at your own risk, wear a helmet, and do not let non-technical people play with it 🔥
npm install sfdx-git-delta@latest -g
If you run your CI jobs inside a Docker image (which is very common), you can add sgd to your image, such as in this example: https://hub.docker.com/r/mehdisfdc/sfdx-cli-gitlab/dockerfile
To see the full list and description of the sgd options, run sgd --help
-V, --version output the version number
-t, --to [sha] commit sha to where the diff is done [HEAD] (default: "HEAD")
-f, --from [sha] commit sha from where the diff is done [git rev-list —max-parents=0 HEAD]
-o, --output [dir] source package specific output [./output] (default: "./output")
-a, --api-version [version] salesforce API version [48] (default: "48")
-r, --repo [dir] git repository location [./repo] (default: "./repo")
-d, --generate-delta generate delta files in [./output] folder
-h, --help output usage information
Works in Unix like system. Windows is not tested.
Git command line is required on the system where the command line is running.
sgd --to HEAD --from HEAD^ --repo . --output .
echo "--- package.xml generated with added and modified metadata ---"
cat package/package.xml
echo
echo "---- Deploying added and modified metadata ----"
sfdx force:source:deploy -x package/package.xml
echo "--- destructiveChanges.xml generated with deleted metadata ---"
cat destructiveChanges/destructiveChanges.xml
echo
echo "--- Deleting removed metadata ---"
sfdx force:mdapi:deploy -d destructiveChanges --ignorewarnings
Let’s take a look at the following scenario:
The CI pipelines deploys the sources to Production anytime there is a new commit in the master branch.
In our example, the latest commit to master is composed of:
In this situation, we would expect the CI pipeline to:
So let’s do it!
From the project repo folder, the CI pipeline will run the following command
sgd --to HEAD --from HEAD^ --repo . --output .
which means:
Analyse the difference between HEAD (latest commit) and HEAD^ (previous commit), from the current folder, and output the result in the same folder.
The sgd
command will produces 2 usefull artefacts:
1) A package.xml
file, inside a package
folder. This package.xml file contains only the metadata that has been added and changed, and that needs to be deployed in the target org.
Content of the package.xml
file in our scenario:
2) A destructivePackage.xml
file, inside a destructivePackage
folder. This destructivePackage.xml file contains only the metadata that has been removed or renamed, and that needs to be deleted from the target org.
Content of the destructivePackage.xml
file in our scenario:
In addition, we could also have generated a copy of the force-app folder with only the added and changed metadata, by using the --generate-delta
option.
The CI pipeline can use the package/package.xml
file to deploy only this subset of metadata:
echo "--- package.xml generated with added and modified metadata ---"
cat package/package.xml
echo
echo "---- Deploying added and modified metadata ----"
sfdx force:source:deploy -x package/package.xml
The CI pipeline can use the destructiveChanges
folder to deploy the corresponding destructive change:
echo "--- destructiveChanges.xml generated with deleted metadata ---"
cat destructiveChanges/destructiveChanges.xml
echo
echo "--- Deleting removed metadata ---"
sfdx force:mdapi:deploy -d destructiveChanges --ignorewarnings
And voilà! 🥳
var sgd = require('sfdx-git-delta');
sgd({
'to':'', // commit sha to where the diff is done. Default : HEAD
'from':'', // commit sha from where the diff is done. Default : git rev-list --max-parents=0 HEAD
'output':'', // source package specific output. Default : ./output
'apiVersion':'', // salesforce API version. Default : 46
'repo':'' // git repository location. Default : ./repo
}, console.log);
SemVer is used for versioning.
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
Generate the sfdx content in source format and destructive change from two git commits
The npm package sfdx-git-delta receives a total of 81,009 weekly downloads. As such, sfdx-git-delta popularity was classified as popular.
We found that sfdx-git-delta demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.