hardis:org:retrieve:sources:dx2
Description
Command Behavior
Retrieves Salesforce metadata from an org into SFDX source format, offering flexible input options for specifying metadata to retrieve.
This command provides an alternative and enhanced way to pull metadata from any Salesforce org into your local SFDX project. It's particularly useful when you need fine-grained control over which metadata components are retrieved, either by providing a custom package.xml or by using predefined templates.
Key functionalities:
package.xmlInput: You can specify the path to apackage.xmlfile using the--packagexmlflag, which defines the exact metadata components to retrieve.- Template-Based Retrieval: Use the
--templateflag to leverage predefinedpackage.xmltemplates provided by sfdx-hardis (e.g.,wavefor CRM Analytics metadata), simplifying common retrieval scenarios. - Interactive Input: If neither
--packagexmlnor--templateis provided, the command will interactively prompt you to select apackage.xmlfile or a template. - Target Org Selection: Allows you to specify the Salesforce org from which to retrieve the sources. If not provided, it will prompt for selection.
Technical explanations
The command's technical implementation involves:
- Org Selection: It uses
promptOrgto guide the user in selecting the target Salesforce org if not provided via flags. package.xmlResolution: It determines thepackage.xmlto use based on the provided flags (--packagexmlor--template). If a template is used, it resolves the path to the corresponding template file within the sfdx-hardis installation.- File System Operations: It checks if the specified
package.xmlfile exists. If the file is outside the current project directory, it copies it to a temporary location within the project to ensure proper handling by the Salesforce CLI. - Salesforce CLI Retrieval: It executes the
sf project retrieve startcommand, passing the resolvedpackage.xmlpath and the target username to retrieve the sources. - User Feedback: Provides clear messages to the user about the retrieval process and its success.
Parameters
| Name | Type | Description | Default | Required | Options |
|---|---|---|---|---|---|
| debug -d |
boolean | Activate debug mode (more logs) | |||
| flags-dir | option | undefined | |||
| json | boolean | Format output as json. | |||
| packagexml -x |
option | Path to package.xml file | |||
| skipauth | boolean | Skip authentication check when a default username is required | |||
| target-org -o |
option | undefined | |||
| template -t |
option | sfdx-hardis package.xml Template name. ex: wave | |||
| websocket | option | Websocket host:port for VsCode SFDX Hardis UI integration |
Examples
$ sf hardis:org:retrieve:sources:dx2