Skip to content

hardis:project:clean:hiddenitems

Description

Command Behavior

Removes hidden or temporary metadata items from your Salesforce DX project sources.

This command helps clean up your local Salesforce project by deleting files that are marked as hidden or are temporary artifacts. These files can sometimes be generated by Salesforce CLI or other tools and are not intended to be part of your version-controlled source.

Key functionalities:

  • Targeted File Scan: Scans for files with specific extensions (.app, .cmp, .evt, .tokens, .html, .css, .js, .xml) within the specified root folder (defaults to force-app).
  • Hidden Content Detection: Identifies files whose content starts with (hidden). This is a convention used by some Salesforce tools to mark temporary or internal files.
  • Component Folder Removal: If a hidden file is part of a Lightning Web Component (LWC) or Aura component folder, the entire component folder is removed to ensure a complete cleanup.
Technical explanations

The command's technical implementation involves:

  • File Discovery: Uses glob to find files matching the specified patterns within the folder.
  • Content Reading: Reads the content of each file.
  • Hidden Marker Check: Checks if the file content starts with the literal string (hidden).
  • Folder or File Removal: If a file is identified as hidden:
    • If it's within an lwc or aura component folder, the entire component folder is removed using fs.remove.
    • Otherwise, only the individual file is removed.
  • Logging: Provides clear messages about which items are being removed and a summary of the total number of hidden items cleaned.

Parameters

Name Type Description Default Required Options
debug
-d
boolean Activate debug mode (more logs)
flags-dir option undefined
folder
-f
option Root folder force-app
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:project:clean:hiddenitems