The Project Structure and Source Format of Salesforce DX

The Project Structure and Source Format of Salesforce DX
Like Tweet Pin it Share Share Email

Ever Salesforce Dx projects have a specific structure and source format. The source of truth of Salesforce Dx uses a unique set of files and specific file extensions other than what you may have already accustomed to on using the Metadata API.

Source transformation

It is commonly seen that the metadata formatted sources are very large, which makes it difficult to find out what you are looking for. If you are part of a team of other many developers who access and update the same metadata simultaneously, then you have to deal with multiple merging to a file.

Salesforce Dx solves this issue by providing a unique shape to the source, which breaks down all these large source files into small, digestible, and easy to manage sources through a version control system. This is called source format.

In a Salesforce Dx project, you can see custom objects as well as custom object translations in many intuitive subdirectories. The model of source format will make it much easier to find out what you exactly want to get in order to update or change.

The static resources

The static resources have to reside in the director – /main/default/staticresources. Commands like force:source:push or force:source:pull support auto-expansion or compressing the archive MIME types in a project. It supports .zip or.jar MIME types. In this manner, source files are integrated easily into the Salesforce DX project.

As per an example set by Flosum.com, when you upload any static resource archive using Setup UI of Scratch Org, then command force:source:pull will expand it to the directory structure inside the project. In order to mimic this process from the existing file system, just add the directory structure and get it compressed into the static resources directory root and then make an associated resource-meta.xml file.

READ  Top 3 New Technologies for Study

File extensions

When you try to covert the existing metadata formats to the source format, then an XML file can be created for each bit. The files which contain XML markup have an .xml extension. The XML editor can be used to look at the source files. In order to sync the local projects and Scratch Org, a particular director structure with custom objects can be used in Salesforce DX projects, which has custom object translations, documents, and Lightning components, etc.

Conventionally, the static resources get stored as binary objects in the file systems with ‘.resource’ extensions. However, source format tends to handle the static resources differently by supporting the content IME types. Say, for example, the .gif files may get stored at the .gif directory instead of .resource. By storing the files against their MIME extensions, you may be able to manage better and the files using an associated editor.

Custom objects

When the need is for conversion of metadata format to the source format, the custom objects get placed in <package directory>/main/default/objects. Each of these has a unique subdirectory which specifies the type of the custom object. Some parts of custom objects are also getting extracted to go into corresponding subdirectories like:

  • business Processes
  • compact Layouts
  • fields
  • fieldSets
  • listViews
  • record Types
  • sharing Reasons
  • validationRules
  • web Links etc.

Finally, the documents must be inside the directories of the parent folder, and the parent folder for documents must be in the documents directory.