hardis:org:configure:files
Description
Command Behavior
Configures a project for exporting file attachments from a Salesforce org.
This command streamlines the setup of configurations for mass downloading files (such as Notes, Attachments, or Salesforce Files) associated with Salesforce records. It's particularly useful for data backups, migrations, or integrating Salesforce files with external systems.
Key functionalities:
- Template-Based Configuration: Allows you to choose from predefined templates for common file export scenarios or start with a blank configuration. Templates can pre-populate the export settings.
- Interactive Setup: Guides you through defining the export project folder name and other export parameters.
export.jsonGeneration: Creates anexport.jsonfile within the designated project folder. This file contains the configuration for the file export operation, including:- SOQL Query: A SOQL query to select the parent records from which files will be exported.
- File Types: Specifies which types of files (e.g.,
ContentVersion,Attachment) to include. - File Size Filtering: Minimum file size in KB to filter files during export (files smaller than this will be skipped).
- Output Folder/File Naming: Defines how the exported files and their containing folders will be named based on record fields.
- Overwrite Options: Controls whether existing files or parent records should be overwritten during the export.
See this article for a practical example:
Technical explanations
The command's technical implementation involves:
- Template Selection: It uses
selectTemplateto present predefined file export templates or a blank option to the user. - Interactive Prompts: The
promptFilesExportConfigurationutility is used to gather detailed export settings from the user, such as the SOQL query, file types, and naming conventions. - File System Operations: Employs
fs-extrato create the project directory (files/your-project-name/) and write theexport.jsonconfiguration file. - PascalCase Conversion: Uses
pascalcaseto format the files export path consistently. - JSON Serialization: Serializes the collected export configuration into a JSON string and writes it to
export.json. - WebSocket Communication: Uses
WebSocketClient.requestOpenFileto open the generatedexport.jsonfile in VS Code, facilitating immediate configuration.
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. | |||
| skipauth | boolean | Skip authentication check when a default username is required | |||
| websocket | option | Websocket host:port for VsCode SFDX Hardis UI integration |
Examples
$ sf hardis:org:configure:files
