Sometimes when you are working with SalesForceDX / CLI,
the changes you make in the org aren't included in force:source:pull
This can happen often with:
- page layouts
- reports
- etc.
Assumes:
- /
- mdapi
- package.xml
- other nonsense
- dx
- force-app
- ...
- mdapi
1. Export your Salesforce DX files to a MetadataAPI folder
ex:
# delete the entire folder
rm -rdf ../mdapi
# use sfdx to convert the DX folder to
sfdx force:source:convert -r force-app -d ../mdapi
2. Use the CLI to retrieve a new folder using the generated package
ex:
# use the package of the newly converted package to retrieve
# mdapi will always get the latest - so bypassing `force:source:pull`
sfdx force:mdapi:retrieve -s -k ../mdapi/package.xml -r ../mdapiRefresh
3. Unzip the CLI results
ex:
# I use my old cli plugin to make it cross platform
# https://github.com/paulroth3d/sfdx-dbs-plugin#uncompress-a-folder
# but any unzip command is fine
sfdx dbs:zip:uncompress -s ../mdapiRefresh/unpackaged.zip -t ../mdapiRefresh/ -r
4. Import the freshly retrieved metadata back to the DX folder
ex:
# import the newly retrieved metadata back to the dx folder
sfdx force:mdapi:convert -r ../mdapiRefresh
5. Review and remove duplicate files
Typically I do this with two commands:
- one to merge the changes / review duplicates
- (usually with a command like DiffMerge - a free cross platform Diff/Merge Utility
- See the
reviewImportDuplicates.sh
file below
- one to remove all the duplicates once I'm done
- See the
removeDuplicates.sh
file below
- See the