sfcc-cartridge-diff v1.1.0

SFCC Cartridge Diff Tool
Command Line Tool for Salesforce Commerce Cloud Cartridge Compare. SFCC Cartridge Diff Tool. Working with SFCC Cartridge overrides just got easier: Compare client cartridge against other cartridges, Generate diffs between override files & Filter using local git changes.

Introduction
Working with SFCC Cartridge overrides just got easier:
- Compare client cartridge against other cartridges
- Generate diffs between override files
- Filter using local git changes
Install
Requirements
Install via NPM
npm install -g sfcc-cartridge-diffInstall via Clone
git clone https://github.com/redvanworkshop/sfcc-cartridge-diff.git
cd sfcc-cartridge-diff
npm install -gUsage
You can use this tool in any of your SFCC projects. Change to the directory that contains your
dw.jsonfile to run the terminal command.
cd /path/to/sfcc/project
sfcc-diff --cartridge app_client_name --optionsOPTIONS:
| Name | Param | Alias | Definition |
|---|---|---|---|
| Cartridge | --cartridge | -c | Source Cartridge |
| Diff | --diff | -d | Show Full Diff |
| Exclude | --exclude | -e | List of Cartridges to Exclude |
| Filter | --filter | -f | Filter Results for Match |
| Include | --include | -i | List of Cartridges to Include |
| Junk Only | --junk-only | -j | Junk Files Only |
| Modified Only | --modified-only | -m | Modified Files Only |
Examples
Comparing Client Cartridge to All Cartridges:
This is the Default Behavior and will compare the provided cartridge to ALL cartridges in the current directory ( event nested ones ).
sfcc-diff --cartridge app_client_name
sfcc-diff -c app_client_nameComparing Client Cartridge to Specific Cartridges:
If you only care about a couple of cartridges, you can speed things up by specifying which ones to compare against.
sfcc-diff --cartridge app_client_name --include storefront-reference-architecture,rvw_autobahn_core
sfcc-diff -c app_client_name -i storefront-reference-architecture,rvw_autobahn_coreComparing Client Cartridge to All Cartridges Except Specific Ones:
For when you want to compare your client cartridge to ALL cartridges, but want to leave a couple out.
sfcc-diff --cartridge app_client_name --exclude link_paypal,int_payeezy
sfcc-diff -c app_client_name -e link_paypal,int_payeezyComparing Client Cartridge to All Cartridges using Only Modified Files:
Limit compare to just the modified files from your client
--cartridgein your current git commit.
sfcc-diff --cartridge app_client_name --modified-only
sfcc-diff -c app_client_name -mComparing Client Cartridge to All Cartridges and just show Junk Files:
Sometimes a file gets copied over to override another cartridge, but ends up not being modified. These junk files are normally hard to catch via
gitsince the file is technically new.
sfcc-diff --cartridge app_client_name --junk-only
sfcc-diff -c app_client_name -jComparing Client Cartridge to All Cartridges and Filtering for ISML Files:
If you want to limit the results to just what matches a filter, you can use the
--filterflag. This will match on the entire relative URL, not just the file name.
sfcc-diff --cartridge app_client_name --filter .isml
sfcc-diff -c app_client_name -f .ismlComparing Client Cartridge to Specific Cartridge and Generate Diff:
Want to actually see the changes between cartridge files? Just pass in a the Diff option and it will render it in your terminal window.
sfcc-diff --cartridge app_client_name --include storefront-reference-architecture --diff
sfcc-diff -c app_client_name -i storefront-reference-architecture -dComparing Client Cartridge to Specific Cartridge and Generate Diff in External App:
Want to use an existing Diff Tool to generate the diff instead of displaying it in your terminal window? Just pass in the name of a tool you already have configured with git.
sfcc-diff --cartridge app_client_name --include storefront-reference-architecture --diff=ksdiff
sfcc-diff -c app_client_name -i storefront-reference-architecture -d ksdiffNOTE: In order to use an external app, you will need to have one configured in your ~/.gitconfig file.
Here are a couple of apps you can use for external diffs, and how to configure them.
ksdiff - Kaleidoscope
[difftool "ksdiff"]
prompt = false
trustExitCode = true
cmd = ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\"bcomp - Beyond Compare
[difftool "bcomp"]
prompt = false
trustExitCode = true
cmd = bcompare -solo \"$LOCAL\" \"$REMOTE\"meld - Meld
[difftool "meld"]
prompt = false
trustExitCode = true
cmd = meld --newtab --label=\"$MERGED\" \"$LOCAL\" \"$REMOTE\" &> /dev/null &kdiff3 - KDiff3
[difftool "kdiff3"]
prompt = false
trustExitCode = true
cmd = open -W -a kdiff3 -n --args \"$LOCAL\" \"$REMOTE\" &> /dev/null &