Convert Files in Metadata Format to Source Format
If you already have a repo in which you’ve retrieved metadata from an org using the
Metadata API directly, the files are in metadata format. You can convert these files into source
format and add them to your Salesforce DX project. You can then deploy and retrieve them to and
from your org using CLI commands and use source tracking to track changes.
The convert command ignores all files that start with a “dot,” such as .DS_Store. To exclude more files from the convert process, add a .forceignore file.
- Change to your Salesforce DX project directory.
-
Convert the files from metadata format to source format with the project convert mdapi command. Let’s say your metadata-format
files are in a directory called /Users/testing/mdapi_project.
sf project convert mdapi --root-dir /Users/testing/mdapi_project
The --root-dir flag is the name of the directory that contains the metadata format files.
The converted source is stored in the default package directory indicated in the sfdx-project.json file, typically named force-app. Use the --output-dir flag to put the converted files in a different package directory; the command creates the directory if it doesn’t exist.
- If the convert created a package directory in your project, add it to your sfdx-project.json file.