Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to migrate Eclipse/Metadata format project to SFDX Source format project.
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied, please supply the project directory, the source directory within the project directory and optionally 'yes' to preserve the original metadata."
exit 1
fi
if [ -z "$2" ]
then
echo "Need additional arguments, please supply the project directory, the source directory within the project director and optional 'yes' to preserve the original metadata."
exit 1
fi
proj_folder="`cd "${1}";pwd`"
src_folder="`cd "${2}";pwd`"
echo " ===> Changing to project folder "$proj_folder"..."
cd $proj_folder
echo " ===> Creating SFDX project..."
sfdx force:project:create -n migrate >/dev/null
cd migrate
echo " ===> Converting MDAPI format to source format..."
oldSpinnerValue=$FORCE_SHOW_SPINNER
export FORCE_SHOW_SPINNER=
mditems="`sfdx force:mdapi:convert -d force-app -r $src_folder --json | jq '.result | length'`"
export FORCE_SHOW_SPINNER=$oldSpinnerValue
echo " ===> Converted "$mditems" metadata items..."
cd ..
echo " ===> Moving the SFDX project contents to the orginal project folder..."
cp -R migrate/. .
rm -rf migrate
if [ -z "$3" ]
then
echo " ===> Removing the original source folder..."
rm -rf $src_folder
fi
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.