sfdx-hardis 6.17.2-alpha202512261745.0 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,12 +57,13 @@
57
57
  "world:hello"
58
58
  ]
59
59
  },
60
- "hardis:cache:clear": {
60
+ "hardis:auth:login": {
61
61
  "aliases": [],
62
62
  "args": {},
63
- "description": "\n## Command Behavior\n\n**Clears the local cache generated by the sfdx-hardis plugin.**\n\nThis command is designed to remove temporary files, stored configurations, and other cached data that sfdx-hardis uses to optimize its operations. Clearing the cache can be beneficial for:\n\n- **Troubleshooting:** Resolving unexpected behavior or inconsistencies.\n- **Disk Space Management:** Freeing up storage on your local machine.\n- **Ensuring Fresh Data:** Guaranteeing that the plugin operates with the most current data and configurations.\n\n## Technical explanations\n\nThe command's technical implementation is straightforward:\n\n- **Direct Function Call:** It directly invokes the `clearCache()` function, which is imported from \buri../../../common/cache/index.js\buri.\n- **Cache Management Logic:** The \buriclearCache()` function encapsulates the logic for identifying and removing the specific files and directories that constitute the sfdx-hardis cache.\n",
63
+ "description": "\n## Command Behavior\n\n**Authenticates to a Salesforce org, primarily designed for CI/CD workflows.**\n\nThis command facilitates secure and automated logins to Salesforce organizations within continuous integration and continuous delivery pipelines. It leverages pre-configured authentication details, ensuring that CI/CD processes can interact with Salesforce without manual intervention.\n\nKey aspects:\n\n- **Configuration-Driven:** It relies on authentication variables and files set up by dedicated configuration commands:\n - For CI/CD repositories: [Configure Org CI Authentication](https://sfdx-hardis.cloudity.com/hardis/project/configure/auth/)\n - For Monitoring repositories: [Configure Org Monitoring](https://sfdx-hardis.cloudity.com/hardis/org/configure/monitoring/)\n- **Technical Org Support:** Supports authentication to a 'technical org' (e.g., for calling Agentforce from another org) by utilizing the `SFDX_AUTH_URL_TECHNICAL_ORG` environment variable. If this variable is set, the command authenticates to this org with the alias `TECHNICAL_ORG`.\n\nTo obtain the `SFDX_AUTH_URL_TECHNICAL_ORG` value, you can run `sf org display --verbose --json` and copy the `sfdxAuthUrl` field from the output.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical flow involves:\n\n- **Flag Parsing:** It parses command-line flags such as `instanceurl`, `devhub`, `scratchorg`, and `debug` to determine the authentication context.\n- **Authentication Hook:** It triggers an internal authentication hook (`this.config.runHook('auth', ...`)) which is responsible for executing the actual authentication logic based on the provided flags (e.g., whether it's a Dev Hub or a scratch org).\n- **Environment Variable Check:** It checks for the presence of `SFDX_AUTH_URL_TECHNICAL_ORG` or `TECHNICAL_ORG_ALIAS` environment variables.\n- **`authOrg` Utility:** If a technical org is configured, it calls the `authOrg` utility function to perform the authentication for that specific org, ensuring it's connected and available for subsequent operations.\n- **Salesforce CLI Integration:** It integrates with the Salesforce CLI's authentication mechanisms to establish and manage org connections.\n</details>\n",
64
64
  "examples": [
65
- "$ sf hardis:cache:clear"
65
+ "$ sf hardis:auth:login",
66
+ "CI=true CI_COMMIT_REF_NAME=monitoring_myclient sf hardis:auth:login"
66
67
  ],
67
68
  "flags": {
68
69
  "json": {
@@ -80,6 +81,28 @@
80
81
  "multiple": false,
81
82
  "type": "option"
82
83
  },
84
+ "instanceurl": {
85
+ "char": "r",
86
+ "description": "URL of org instance",
87
+ "name": "instanceurl",
88
+ "hasDynamicHelp": false,
89
+ "multiple": false,
90
+ "type": "option"
91
+ },
92
+ "devhub": {
93
+ "char": "h",
94
+ "description": "Also connect associated DevHub",
95
+ "name": "devhub",
96
+ "allowNo": false,
97
+ "type": "boolean"
98
+ },
99
+ "scratchorg": {
100
+ "char": "s",
101
+ "description": "Scratch org",
102
+ "name": "scratchorg",
103
+ "allowNo": false,
104
+ "type": "boolean"
105
+ },
83
106
  "debug": {
84
107
  "char": "d",
85
108
  "description": "Activate debug mode (more logs)",
@@ -103,42 +126,38 @@
103
126
  },
104
127
  "hasDynamicHelp": false,
105
128
  "hiddenAliases": [],
106
- "id": "hardis:cache:clear",
129
+ "id": "hardis:auth:login",
107
130
  "pluginAlias": "sfdx-hardis",
108
131
  "pluginName": "sfdx-hardis",
109
132
  "pluginType": "core",
110
133
  "strict": true,
111
134
  "enableJsonFlag": true,
112
- "title": "Clear sfdx-hardis cache",
113
- "uiConfig": {
114
- "hide": true
115
- },
135
+ "title": "Login",
116
136
  "requiresProject": false,
117
137
  "isESM": true,
118
138
  "relativePath": [
119
139
  "lib",
120
140
  "commands",
121
141
  "hardis",
122
- "cache",
123
- "clear.js"
142
+ "auth",
143
+ "login.js"
124
144
  ],
125
145
  "aliasPermutations": [],
126
146
  "permutations": [
127
- "hardis:cache:clear",
128
- "cache:hardis:clear",
129
- "cache:clear:hardis",
130
- "hardis:clear:cache",
131
- "clear:hardis:cache",
132
- "clear:cache:hardis"
147
+ "hardis:auth:login",
148
+ "auth:hardis:login",
149
+ "auth:login:hardis",
150
+ "hardis:login:auth",
151
+ "login:hardis:auth",
152
+ "login:auth:hardis"
133
153
  ]
134
154
  },
135
- "hardis:auth:login": {
155
+ "hardis:cache:clear": {
136
156
  "aliases": [],
137
157
  "args": {},
138
- "description": "\n## Command Behavior\n\n**Authenticates to a Salesforce org, primarily designed for CI/CD workflows.**\n\nThis command facilitates secure and automated logins to Salesforce organizations within continuous integration and continuous delivery pipelines. It leverages pre-configured authentication details, ensuring that CI/CD processes can interact with Salesforce without manual intervention.\n\nKey aspects:\n\n- **Configuration-Driven:** It relies on authentication variables and files set up by dedicated configuration commands:\n - For CI/CD repositories: [Configure Org CI Authentication](https://sfdx-hardis.cloudity.com/hardis/project/configure/auth/)\n - For Monitoring repositories: [Configure Org Monitoring](https://sfdx-hardis.cloudity.com/hardis/org/configure/monitoring/)\n- **Technical Org Support:** Supports authentication to a 'technical org' (e.g., for calling Agentforce from another org) by utilizing the `SFDX_AUTH_URL_TECHNICAL_ORG` environment variable. If this variable is set, the command authenticates to this org with the alias `TECHNICAL_ORG`.\n\nTo obtain the `SFDX_AUTH_URL_TECHNICAL_ORG` value, you can run `sf org display --verbose --json` and copy the `sfdxAuthUrl` field from the output.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical flow involves:\n\n- **Flag Parsing:** It parses command-line flags such as `instanceurl`, `devhub`, `scratchorg`, and `debug` to determine the authentication context.\n- **Authentication Hook:** It triggers an internal authentication hook (`this.config.runHook('auth', ...`)) which is responsible for executing the actual authentication logic based on the provided flags (e.g., whether it's a Dev Hub or a scratch org).\n- **Environment Variable Check:** It checks for the presence of `SFDX_AUTH_URL_TECHNICAL_ORG` or `TECHNICAL_ORG_ALIAS` environment variables.\n- **`authOrg` Utility:** If a technical org is configured, it calls the `authOrg` utility function to perform the authentication for that specific org, ensuring it's connected and available for subsequent operations.\n- **Salesforce CLI Integration:** It integrates with the Salesforce CLI's authentication mechanisms to establish and manage org connections.\n</details>\n",
158
+ "description": "\n## Command Behavior\n\n**Clears the local cache generated by the sfdx-hardis plugin.**\n\nThis command is designed to remove temporary files, stored configurations, and other cached data that sfdx-hardis uses to optimize its operations. Clearing the cache can be beneficial for:\n\n- **Troubleshooting:** Resolving unexpected behavior or inconsistencies.\n- **Disk Space Management:** Freeing up storage on your local machine.\n- **Ensuring Fresh Data:** Guaranteeing that the plugin operates with the most current data and configurations.\n\n## Technical explanations\n\nThe command's technical implementation is straightforward:\n\n- **Direct Function Call:** It directly invokes the `clearCache()` function, which is imported from \buri../../../common/cache/index.js\buri.\n- **Cache Management Logic:** The \buriclearCache()` function encapsulates the logic for identifying and removing the specific files and directories that constitute the sfdx-hardis cache.\n",
139
159
  "examples": [
140
- "$ sf hardis:auth:login",
141
- "CI=true CI_COMMIT_REF_NAME=monitoring_myclient sf hardis:auth:login"
160
+ "$ sf hardis:cache:clear"
142
161
  ],
143
162
  "flags": {
144
163
  "json": {
@@ -156,28 +175,6 @@
156
175
  "multiple": false,
157
176
  "type": "option"
158
177
  },
159
- "instanceurl": {
160
- "char": "r",
161
- "description": "URL of org instance",
162
- "name": "instanceurl",
163
- "hasDynamicHelp": false,
164
- "multiple": false,
165
- "type": "option"
166
- },
167
- "devhub": {
168
- "char": "h",
169
- "description": "Also connect associated DevHub",
170
- "name": "devhub",
171
- "allowNo": false,
172
- "type": "boolean"
173
- },
174
- "scratchorg": {
175
- "char": "s",
176
- "description": "Scratch org",
177
- "name": "scratchorg",
178
- "allowNo": false,
179
- "type": "boolean"
180
- },
181
178
  "debug": {
182
179
  "char": "d",
183
180
  "description": "Activate debug mode (more logs)",
@@ -201,30 +198,33 @@
201
198
  },
202
199
  "hasDynamicHelp": false,
203
200
  "hiddenAliases": [],
204
- "id": "hardis:auth:login",
201
+ "id": "hardis:cache:clear",
205
202
  "pluginAlias": "sfdx-hardis",
206
203
  "pluginName": "sfdx-hardis",
207
204
  "pluginType": "core",
208
205
  "strict": true,
209
206
  "enableJsonFlag": true,
210
- "title": "Login",
207
+ "title": "Clear sfdx-hardis cache",
208
+ "uiConfig": {
209
+ "hide": true
210
+ },
211
211
  "requiresProject": false,
212
212
  "isESM": true,
213
213
  "relativePath": [
214
214
  "lib",
215
215
  "commands",
216
216
  "hardis",
217
- "auth",
218
- "login.js"
217
+ "cache",
218
+ "clear.js"
219
219
  ],
220
220
  "aliasPermutations": [],
221
221
  "permutations": [
222
- "hardis:auth:login",
223
- "auth:hardis:login",
224
- "auth:login:hardis",
225
- "hardis:login:auth",
226
- "login:hardis:auth",
227
- "login:auth:hardis"
222
+ "hardis:cache:clear",
223
+ "cache:hardis:clear",
224
+ "cache:clear:hardis",
225
+ "hardis:clear:cache",
226
+ "clear:hardis:cache",
227
+ "clear:cache:hardis"
228
228
  ]
229
229
  },
230
230
  "hardis:config:get": {
@@ -3140,12 +3140,12 @@
3140
3140
  "lint:project:hardis"
3141
3141
  ]
3142
3142
  },
3143
- "hardis:source:deploy": {
3143
+ "hardis:scratch:create": {
3144
3144
  "aliases": [],
3145
3145
  "args": {},
3146
- "description": "sfdx-hardis wrapper for sfdx force:source:deploy that displays tips to solve deployment errors.\n\nAdditional to the base command wrapper: If using **--checkonly**, add options **--checkcoverage** and **--coverageformatters json-summary** to check that org coverage is > 75% (or value defined in .sfdx-hardis.yml property **apexTestsMinCoverageOrgWide**)\n\n### Deployment results\n\nYou can also have deployment results as pull request comments, on:\n\n- GitHub (see [GitHub Pull Requests comments config](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-setup-integration-github/))\n- Gitlab (see [Gitlab integration configuration](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-setup-integration-gitlab/))\n- Azure DevOps (see [Azure integration configuration](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-setup-integration-azure/))\n\n\n[![Assisted solving of Salesforce deployments errors](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deployment-errors.jpg)](https://nicolas.vuillamy.fr/assisted-solving-of-salesforce-deployments-errors-47f3666a9ed0)\n\n### Deployment pre or post commands\n\nYou can define command lines to run before or after a deployment, with parameters:\n\n- **id**: Unique Id for the command\n- **label**: Human readable label for the command\n- **skipIfError**: If defined to \"true\", the post-command won't be run if there is a deployment failure\n- **context**: Defines the context where the command will be run. Can be **all** (default), **check-deployment-only** or **process-deployment-only**\n- **runOnlyOnceByOrg**: If set to true, the command will be run only one time per org. A record of SfdxHardisTrace__c is stored to make that possible (it needs to be existing in target org)\n\nIf the commands are not the same depending on the target org, you can define them into **config/branches/.sfdx-hardis-BRANCHNAME.yml** instead of root **config/.sfdx-hardis.yml**\n\nExample:\n\n```yaml\ncommandsPreDeploy:\n - id: knowledgeUnassign\n label: Remove KnowledgeUser right to the user who has it\n command: sf data update record --sobject User --where \"UserPermissionsKnowledgeUser='true'\" --values \"UserPermissionsKnowledgeUser='false'\" --json\n - id: knowledgeAssign\n label: Assign Knowledge user to the deployment user\n command: sf data update record --sobject User --where \"Username='deploy.github@myclient.com'\" --values \"UserPermissionsKnowledgeUser='true'\" --json\n\ncommandsPostDeploy:\n - id: knowledgeUnassign\n label: Remove KnowledgeUser right to the user who has it\n command: sf data update record --sobject User --where \"UserPermissionsKnowledgeUser='true'\" --values \"UserPermissionsKnowledgeUser='false'\" --json\n - id: knowledgeAssign\n label: Assign Knowledge user to desired username\n command: sf data update record --sobject User --where \"Username='admin-yser@myclient.com'\" --values \"UserPermissionsKnowledgeUser='true'\" --json\n - id: someActionToRunJustOneTime\n label: And to run only if deployment is success\n command: sf sfdmu:run ...\n skipIfError: true\n context: process-deployment-only\n runOnlyOnceByOrg: true\n```\n\nNotes:\n\n- You can disable coloring of errors in red by defining env variable SFDX_HARDIS_DEPLOY_ERR_COLORS=false\n\n[See documentation of Salesforce command](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_deploy)\n",
3146
+ "description": "\n## Command Behavior\n\n**Creates and fully initializes a Salesforce scratch org with complete development environment setup.**\n\nThis command is a comprehensive scratch org provisioning tool that automates the entire process of creating, configuring, and initializing a Salesforce scratch org for development work. It handles everything from basic org creation to advanced configuration including package installation, metadata deployment, and data initialization.\n\nKey functionalities:\n\n- **Intelligent Org Management:** Automatically generates unique scratch org aliases based on username, git branch, and timestamp, with options to reuse existing orgs or force creation of new ones.\n- **Scratch Org Pool Integration:** Supports fetching pre-configured scratch orgs from pools for faster development cycles and CI/CD optimization.\n- **Custom Scratch Definition:** Dynamically builds project-scratch-def.json files with user-specific configurations including email, username patterns, and org shape settings (set variable **SCRATCH_ORG_SHAPE** to use org shapes).\n- **Package Installation:** Automatically installs all configured packages defined in `installedPackages` configuration property.\n- **Metadata Deployment:** Pushes source code and deploys metadata using optimized deployment strategies for scratch org environments.\n- **Permission Set Assignment:** Assigns specified permission sets defined in `initPermissionSets` configuration to the scratch org user.\n- **Apex Script Execution:** Runs custom Apex initialization scripts defined in `scratchOrgInitApexScripts` for org-specific setup.\n- **Data Loading:** Loads initial data using SFDMU data packages from `dataPackages` configuration for realistic development environments.\n- **User Configuration:** Automatically configures the scratch org admin user with proper names, email, country settings, and marketing user permissions.\n- **Password Generation:** Creates and stores secure passwords for easy scratch org access during development.\n- **CI/CD Integration:** Provides specialized handling for continuous integration environments including automated cleanup and pool management.\n- **Error Handling:** Comprehensive error recovery including scratch org cleanup on failure and detailed troubleshooting messages.\n\nThe command configuration can be customized using:\n\n- `config/.sfdx-hardis.yml` file with properties like `installedPackages`, `initPermissionSets`, `scratchOrgInitApexScripts`, and `dataPackages`.\n- Environment variable **SCRATCH_ORG_SHAPE** with shape org id, if you want to use org shapes\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Configuration Management:** Loads hierarchical configuration from `.sfdx-hardis.yml`, branch-specific, and user-specific configuration files using `getConfig('user')`.\n- **Alias Generation Logic:** Creates intelligent scratch org aliases using username, git branch, timestamp patterns with CI and pool prefixes for different environments.\n- **Scratch Org Definition Building:** Dynamically constructs `project-scratch-def.json` with user email, custom usernames, org shapes, and feature flags like StateAndCountryPicklist and MarketingUser.\n- **Pool Integration:** Implements scratch org pool fetching using `fetchScratchOrg` for rapid org provisioning in development and CI environments.\n- **Salesforce CLI Integration:** Executes `sf org create scratch` commands with proper parameter handling including wait times, duration, and dev hub targeting.\n- **Package Installation Pipeline:** Uses `installPackages` utility to install managed and unmanaged packages with dependency resolution and error handling.\n- **Metadata Deployment:** Leverages `initOrgMetadatas` for optimized source pushing and metadata deployment specific to scratch org environments.\n- **Permission Set Assignment:** Implements `initPermissionSetAssignments` for automated permission set assignment to scratch org users.\n- **Apex Script Execution:** Runs custom Apex initialization scripts using `initApexScripts` for org-specific configuration and setup.\n- **Data Loading Integration:** Uses SFDMU integration through `initOrgData` for comprehensive data loading from configured data packages.\n- **User Management:** Performs SOQL queries and DML operations to configure scratch org users with proper names, emails, country codes, and permission flags.\n- **Authentication Management:** Handles SFDX auth URL generation and storage for CI/CD environments and scratch org pool management.\n- **Error Recovery:** Implements comprehensive error handling with scratch org cleanup, pool management, and detailed error messaging for troubleshooting.\n- **WebSocket Integration:** Provides real-time status updates and file reporting through WebSocket connections for VS Code extension integration.\n</details>\n",
3147
3147
  "examples": [
3148
- "$ sf hardis:source:deploy -x manifest/package.xml --wait 60 --ignorewarnings --testlevel RunLocalTests --postdestructivechanges ./manifest/destructiveChanges.xml --target-org nicolas.vuillamy@cloudity.com.sfdxhardis --checkonly --checkcoverage --verbose --coverageformatters json-summary"
3148
+ "$ sf hardis:scratch:create"
3149
3149
  ],
3150
3150
  "flags": {
3151
3151
  "json": {
@@ -3163,321 +3163,138 @@
3163
3163
  "multiple": false,
3164
3164
  "type": "option"
3165
3165
  },
3166
- "checkonly": {
3167
- "char": "c",
3168
- "description": "checkonly",
3169
- "name": "checkonly",
3166
+ "forcenew": {
3167
+ "char": "n",
3168
+ "description": "If an existing scratch org exists, do not reuse it but create a new one",
3169
+ "name": "forcenew",
3170
3170
  "allowNo": false,
3171
3171
  "type": "boolean"
3172
3172
  },
3173
- "soapdeploy": {
3174
- "description": "soapDeploy",
3175
- "name": "soapdeploy",
3173
+ "pool": {
3174
+ "description": "Creates the scratch org for a scratch org pool",
3175
+ "name": "pool",
3176
3176
  "allowNo": false,
3177
3177
  "type": "boolean"
3178
3178
  },
3179
- "wait": {
3180
- "char": "w",
3181
- "description": "wait",
3182
- "name": "wait",
3183
- "default": 60,
3184
- "hasDynamicHelp": false,
3185
- "multiple": false,
3186
- "type": "option"
3179
+ "debug": {
3180
+ "char": "d",
3181
+ "description": "Activate debug mode (more logs)",
3182
+ "name": "debug",
3183
+ "allowNo": false,
3184
+ "type": "boolean"
3187
3185
  },
3188
- "testlevel": {
3189
- "char": "l",
3190
- "description": "testlevel",
3191
- "name": "testlevel",
3192
- "default": "NoTestRun",
3186
+ "websocket": {
3187
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3188
+ "name": "websocket",
3193
3189
  "hasDynamicHelp": false,
3194
3190
  "multiple": false,
3195
- "options": [
3196
- "NoTestRun",
3197
- "RunSpecifiedTests",
3198
- "RunLocalTests",
3199
- "RunAllTestsInOrg"
3200
- ],
3201
- "type": "option"
3202
- },
3203
- "runtests": {
3204
- "char": "r",
3205
- "description": "runTests",
3206
- "name": "runtests",
3207
- "default": [],
3208
- "hasDynamicHelp": false,
3209
- "multiple": true,
3210
3191
  "type": "option"
3211
3192
  },
3212
- "ignoreerrors": {
3213
- "description": "ignoreErrors",
3214
- "name": "ignoreerrors",
3193
+ "skipauth": {
3194
+ "description": "Skip authentication check when a default username is required",
3195
+ "name": "skipauth",
3215
3196
  "allowNo": false,
3216
3197
  "type": "boolean"
3217
3198
  },
3218
- "ignorewarnings": {
3219
- "char": "g",
3220
- "description": "ignoreWarnings",
3221
- "name": "ignorewarnings",
3199
+ "target-dev-hub": {
3200
+ "aliases": [
3201
+ "targetdevhubusername"
3202
+ ],
3203
+ "char": "v",
3204
+ "deprecateAliases": true,
3205
+ "name": "target-dev-hub",
3206
+ "noCacheDefault": true,
3207
+ "required": true,
3208
+ "summary": "Username or alias of the Dev Hub org. Not required if the `target-dev-hub` configuration variable is already set.",
3209
+ "hasDynamicHelp": true,
3210
+ "multiple": false,
3211
+ "type": "option"
3212
+ }
3213
+ },
3214
+ "hasDynamicHelp": true,
3215
+ "hiddenAliases": [],
3216
+ "id": "hardis:scratch:create",
3217
+ "pluginAlias": "sfdx-hardis",
3218
+ "pluginName": "sfdx-hardis",
3219
+ "pluginType": "core",
3220
+ "strict": true,
3221
+ "enableJsonFlag": true,
3222
+ "title": "Create and initialize scratch org",
3223
+ "requiresProject": true,
3224
+ "requiresSfdxPlugins": [
3225
+ "sfdmu"
3226
+ ],
3227
+ "isESM": true,
3228
+ "relativePath": [
3229
+ "lib",
3230
+ "commands",
3231
+ "hardis",
3232
+ "scratch",
3233
+ "create.js"
3234
+ ],
3235
+ "aliasPermutations": [],
3236
+ "permutations": [
3237
+ "hardis:scratch:create",
3238
+ "scratch:hardis:create",
3239
+ "scratch:create:hardis",
3240
+ "hardis:create:scratch",
3241
+ "create:hardis:scratch",
3242
+ "create:scratch:hardis"
3243
+ ]
3244
+ },
3245
+ "hardis:scratch:delete": {
3246
+ "aliases": [],
3247
+ "args": {},
3248
+ "description": "## Command Behavior\n\n**Provides an assisted menu to delete Salesforce scratch orgs associated with a Dev Hub.**\n\nThis command simplifies the process of cleaning up your Salesforce development environments by allowing you to easily select and delete multiple scratch orgs. This is crucial for managing your scratch org limits and ensuring that you don't accumulate unnecessary or expired orgs.\n\nKey functionalities:\n\n- **Interactive Scratch Org Selection:** Displays a list of all active scratch orgs linked to your Dev Hub, including their usernames, instance URLs, and last used dates.\n- **Multi-Selection:** Allows you to select multiple scratch orgs for deletion.\n- **Confirmation Prompt:** Prompts for confirmation before proceeding with the deletion, ensuring that you don't accidentally delete important orgs.\n- **Dev Hub Integration:** Works with your configured Dev Hub to manage scratch orgs.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce CLI Integration:** It executes the `sf org list` command to retrieve a list of all scratch orgs associated with the current Dev Hub. It then filters this list to show only active orgs.\n- **Interactive Prompts:** Uses the `prompts` library to present a multi-select menu of scratch orgs to the user.\n- **Scratch Org Deletion:** For each selected scratch org, it executes the `sf org delete scratch --no-prompt` command to perform the deletion.\n- **Error Handling:** Includes basic error handling for Salesforce CLI commands.\n- **Data Sorting:** Sorts the list of scratch orgs by username, alias, and instance URL for better readability in the interactive menu.\n</details>\n",
3249
+ "examples": [
3250
+ "$ sf hardis:scratch:delete"
3251
+ ],
3252
+ "flags": {
3253
+ "json": {
3254
+ "description": "Format output as json.",
3255
+ "helpGroup": "GLOBAL",
3256
+ "name": "json",
3222
3257
  "allowNo": false,
3223
3258
  "type": "boolean"
3224
3259
  },
3225
- "validateddeployrequestid": {
3226
- "char": "q",
3227
- "description": "validateDeployRequestId",
3228
- "exclusive": [
3229
- "manifest",
3230
- "metadata",
3231
- "sourcepath",
3232
- "checkonly",
3233
- "testlevel",
3234
- "runtests",
3235
- "ignoreerrors",
3236
- "ignorewarnings"
3237
- ],
3238
- "name": "validateddeployrequestid",
3260
+ "flags-dir": {
3261
+ "helpGroup": "GLOBAL",
3262
+ "name": "flags-dir",
3263
+ "summary": "Import flag values from a directory.",
3239
3264
  "hasDynamicHelp": false,
3240
3265
  "multiple": false,
3241
3266
  "type": "option"
3242
3267
  },
3243
- "verbose": {
3244
- "description": "verbose",
3245
- "name": "verbose",
3246
- "allowNo": false,
3247
- "type": "boolean"
3248
- },
3249
- "metadata": {
3250
- "char": "m",
3251
- "description": "metadata",
3252
- "exclusive": [
3253
- "manifest",
3254
- "sourcepath"
3255
- ],
3256
- "name": "metadata",
3257
- "hasDynamicHelp": false,
3258
- "multiple": true,
3259
- "type": "option"
3260
- },
3261
- "sourcepath": {
3262
- "char": "p",
3263
- "description": "sourcePath",
3264
- "exclusive": [
3265
- "manifest",
3266
- "metadata"
3267
- ],
3268
- "name": "sourcepath",
3269
- "hasDynamicHelp": false,
3270
- "multiple": true,
3271
- "type": "option"
3272
- },
3273
- "manifest": {
3274
- "char": "x",
3275
- "description": "flagsLong.manifest",
3276
- "exclusive": [
3277
- "metadata",
3278
- "sourcepath"
3279
- ],
3280
- "name": "manifest",
3281
- "hasDynamicHelp": false,
3282
- "multiple": false,
3283
- "type": "option"
3284
- },
3285
- "predestructivechanges": {
3286
- "dependsOn": [
3287
- "manifest"
3288
- ],
3289
- "description": "predestructivechanges",
3290
- "name": "predestructivechanges",
3291
- "hasDynamicHelp": false,
3292
- "multiple": false,
3293
- "type": "option"
3294
- },
3295
- "postdestructivechanges": {
3296
- "dependsOn": [
3297
- "manifest"
3298
- ],
3299
- "description": "postdestructivechanges",
3300
- "name": "postdestructivechanges",
3301
- "hasDynamicHelp": false,
3302
- "multiple": false,
3303
- "type": "option"
3304
- },
3305
- "tracksource": {
3306
- "char": "t",
3307
- "description": "tracksource",
3308
- "exclusive": [
3309
- "checkonly",
3310
- "validateddeployrequestid"
3311
- ],
3312
- "name": "tracksource",
3313
- "allowNo": false,
3314
- "type": "boolean"
3315
- },
3316
- "forceoverwrite": {
3317
- "char": "f",
3318
- "dependsOn": [
3319
- "tracksource"
3320
- ],
3321
- "description": "forceoverwrite",
3322
- "name": "forceoverwrite",
3323
- "allowNo": false,
3324
- "type": "boolean"
3325
- },
3326
- "resultsdir": {
3327
- "description": "resultsdir",
3328
- "name": "resultsdir",
3329
- "hasDynamicHelp": false,
3330
- "multiple": false,
3331
- "type": "option"
3332
- },
3333
- "coverageformatters": {
3334
- "description": "coverageformatters",
3335
- "name": "coverageformatters",
3336
- "hasDynamicHelp": false,
3337
- "multiple": true,
3338
- "type": "option"
3339
- },
3340
- "junit": {
3341
- "description": "junit",
3342
- "name": "junit",
3343
- "allowNo": false,
3344
- "type": "boolean"
3345
- },
3346
- "checkcoverage": {
3347
- "description": "Check Apex org coverage",
3348
- "name": "checkcoverage",
3349
- "allowNo": false,
3350
- "type": "boolean"
3351
- },
3352
- "debug": {
3353
- "description": "debug",
3354
- "name": "debug",
3268
+ "debug": {
3269
+ "char": "d",
3270
+ "description": "Activate debug mode (more logs)",
3271
+ "name": "debug",
3355
3272
  "allowNo": false,
3356
3273
  "type": "boolean"
3357
3274
  },
3358
3275
  "websocket": {
3359
- "description": "websocket",
3276
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3360
3277
  "name": "websocket",
3361
3278
  "hasDynamicHelp": false,
3362
3279
  "multiple": false,
3363
3280
  "type": "option"
3364
3281
  },
3365
- "target-org": {
3366
- "aliases": [
3367
- "targetusername",
3368
- "u"
3369
- ],
3370
- "char": "o",
3371
- "deprecateAliases": true,
3372
- "name": "target-org",
3373
- "noCacheDefault": true,
3374
- "required": true,
3375
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
3376
- "hasDynamicHelp": true,
3377
- "multiple": false,
3378
- "type": "option"
3379
- }
3380
- },
3381
- "hasDynamicHelp": true,
3382
- "hiddenAliases": [],
3383
- "id": "hardis:source:deploy",
3384
- "pluginAlias": "sfdx-hardis",
3385
- "pluginName": "sfdx-hardis",
3386
- "pluginType": "core",
3387
- "strict": true,
3388
- "enableJsonFlag": true,
3389
- "requiresProject": true,
3390
- "isESM": true,
3391
- "relativePath": [
3392
- "lib",
3393
- "commands",
3394
- "hardis",
3395
- "source",
3396
- "deploy.js"
3397
- ],
3398
- "aliasPermutations": [],
3399
- "permutations": [
3400
- "hardis:source:deploy",
3401
- "source:hardis:deploy",
3402
- "source:deploy:hardis",
3403
- "hardis:deploy:source",
3404
- "deploy:hardis:source",
3405
- "deploy:source:hardis"
3406
- ]
3407
- },
3408
- "hardis:source:push": {
3409
- "aliases": [],
3410
- "args": {},
3411
- "description": "sfdx-hardis wrapper for sfdx force:source:push that displays tips to solve deployment errors.\n\n[![Assisted solving of Salesforce deployments errors](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deployment-errors.jpg)](https://nicolas.vuillamy.fr/assisted-solving-of-salesforce-deployments-errors-47f3666a9ed0)\n\n[See documentation of Salesforce command](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_push)\n",
3412
- "flags": {
3413
- "json": {
3414
- "description": "Format output as json.",
3415
- "helpGroup": "GLOBAL",
3416
- "name": "json",
3417
- "allowNo": false,
3418
- "type": "boolean"
3419
- },
3420
- "flags-dir": {
3421
- "helpGroup": "GLOBAL",
3422
- "name": "flags-dir",
3423
- "summary": "Import flag values from a directory.",
3424
- "hasDynamicHelp": false,
3425
- "multiple": false,
3426
- "type": "option"
3427
- },
3428
- "forceoverwrite": {
3429
- "char": "f",
3430
- "description": "forceoverwrite",
3431
- "name": "forceoverwrite",
3432
- "allowNo": false,
3433
- "type": "boolean"
3434
- },
3435
- "wait": {
3436
- "char": "w",
3437
- "description": "wait",
3438
- "name": "wait",
3439
- "default": 60,
3440
- "hasDynamicHelp": false,
3441
- "multiple": false,
3442
- "type": "option"
3443
- },
3444
- "ignorewarnings": {
3445
- "char": "g",
3446
- "description": "ignorewarnings",
3447
- "name": "ignorewarnings",
3448
- "allowNo": false,
3449
- "type": "boolean"
3450
- },
3451
- "quiet": {
3452
- "description": "quiet",
3453
- "name": "quiet",
3454
- "allowNo": false,
3455
- "type": "boolean"
3456
- },
3457
- "debug": {
3458
- "description": "debug",
3459
- "name": "debug",
3282
+ "skipauth": {
3283
+ "description": "Skip authentication check when a default username is required",
3284
+ "name": "skipauth",
3460
3285
  "allowNo": false,
3461
3286
  "type": "boolean"
3462
3287
  },
3463
- "websocket": {
3464
- "description": "websocket",
3465
- "name": "websocket",
3466
- "hasDynamicHelp": false,
3467
- "multiple": false,
3468
- "type": "option"
3469
- },
3470
- "target-org": {
3288
+ "target-dev-hub": {
3471
3289
  "aliases": [
3472
- "targetusername",
3473
- "u"
3290
+ "targetdevhubusername"
3474
3291
  ],
3475
- "char": "o",
3292
+ "char": "v",
3476
3293
  "deprecateAliases": true,
3477
- "name": "target-org",
3294
+ "name": "target-dev-hub",
3478
3295
  "noCacheDefault": true,
3479
3296
  "required": true,
3480
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
3297
+ "summary": "Username or alias of the Dev Hub org. Not required if the `target-dev-hub` configuration variable is already set.",
3481
3298
  "hasDynamicHelp": true,
3482
3299
  "multiple": false,
3483
3300
  "type": "option"
@@ -3485,36 +3302,38 @@
3485
3302
  },
3486
3303
  "hasDynamicHelp": true,
3487
3304
  "hiddenAliases": [],
3488
- "id": "hardis:source:push",
3305
+ "id": "hardis:scratch:delete",
3489
3306
  "pluginAlias": "sfdx-hardis",
3490
3307
  "pluginName": "sfdx-hardis",
3491
3308
  "pluginType": "core",
3492
3309
  "strict": true,
3493
3310
  "enableJsonFlag": true,
3494
- "requiresProject": true,
3311
+ "title": "Delete scratch orgs(s)",
3495
3312
  "isESM": true,
3496
3313
  "relativePath": [
3497
3314
  "lib",
3498
3315
  "commands",
3499
3316
  "hardis",
3500
- "source",
3501
- "push.js"
3317
+ "scratch",
3318
+ "delete.js"
3502
3319
  ],
3503
3320
  "aliasPermutations": [],
3504
3321
  "permutations": [
3505
- "hardis:source:push",
3506
- "source:hardis:push",
3507
- "source:push:hardis",
3508
- "hardis:push:source",
3509
- "push:hardis:source",
3510
- "push:source:hardis"
3322
+ "hardis:scratch:delete",
3323
+ "scratch:hardis:delete",
3324
+ "scratch:delete:hardis",
3325
+ "hardis:delete:scratch",
3326
+ "delete:hardis:scratch",
3327
+ "delete:scratch:hardis"
3511
3328
  ]
3512
3329
  },
3513
- "hardis:source:retrieve": {
3330
+ "hardis:scratch:pull": {
3514
3331
  "aliases": [],
3515
3332
  "args": {},
3516
- "description": "\n## Command Behavior\n\n**A wrapper command for Salesforce CLI's `sf project retrieve start` (formerly `sfdx force:source:retrieve`), with enhanced interactive features.**\n\nThis command facilitates the retrieval of metadata from a Salesforce org into your local project. It provides an assisted experience, especially when no specific retrieval constraints are provided.\n\nKey features:\n\n- **Assisted Metadata Selection:** If no `sourcepath`, `manifest`, `metadata`, or `packagenames` flags are specified, an interactive menu will prompt you to select the metadata types you wish to retrieve.\n- **Assisted Org Selection:** If no target org is specified, an interactive menu will guide you to choose an org for the retrieval operation.\n- **Backward Compatibility:** While this command wraps the newer `sf project retrieve start`, it maintains compatibility with the older `sfdx force:source:retrieve` flags.\n\n**Important Note:** The underlying Salesforce CLI command `sfdx force:source:retrieve` is being deprecated by Salesforce in November 2024. It is recommended to migrate to `sf project retrieve start` for future compatibility. See [Salesforce CLI Migration Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_mig_deploy_retrieve.htm) for more information.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThis command acts as an intelligent wrapper around the Salesforce CLI's source retrieval functionality:\n\n- **Command Wrapping:** It uses the `wrapSfdxCoreCommand` utility to execute the `sfdx force:source:retrieve` (or its equivalent `sf project retrieve start`) command, passing through all relevant flags and arguments.\n- **Interactive Prompts:** It leverages `MetadataUtils.promptMetadataTypes()` and `promptOrgUsernameDefault()` to provide interactive menus for metadata and org selection when the user does not provide them as flags.\n- **Argument Transformation:** It dynamically constructs the command-line arguments for the underlying Salesforce CLI command based on user selections and provided flags.\n- **Error Handling:** It includes basic error handling, such as prompting the user to re-select an org if an issue occurs during org selection.\n- **Deprecation Warning:** It explicitly logs warnings about the deprecation of `sfdx force:source:retrieve` to inform users about upcoming changes.\n</details>\n",
3517
- "examples": [],
3333
+ "description": "\n## Command Behavior\n\n**Pulls metadata changes from your scratch org or source-tracked sandbox into your local project files.**\n\nThis command is essential for synchronizing your local development environment with the changes you've made directly in your Salesforce org. After pulling, you can then stage and commit the relevant files to your version control system.\n\nKey features and considerations:\n\n- **Underlying Command:** Internally, this command executes `sf project retrieve start` to fetch the metadata.\n- **Error Handling:** If the pull operation encounters errors, it offers to automatically add the problematic items to your `.forceignore` file and then attempts to pull again, helping you resolve conflicts and ignore unwanted metadata.\n- **Missing Updates:** If you don't see certain updated items in the pull results, you might need to manually retrieve them using the Salesforce Extension's **Org Browser** or the **Salesforce CLI** directly. Refer to the [Retrieve Metadatas documentation](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-publish-task/#retrieve-metadatas) for more details.\n- **Automatic Retrieval:** You can configure the `autoRetrieveWhenPull` property in your `.sfdx-hardis.yml` file to always retrieve specific metadata types (e.g., `CustomApplication`) that might not always be detected as updates by `project:retrieve:start`.\n\nExample `.sfdx-hardis.yml` configuration for `autoRetrieveWhenPull`:\n```yaml\nautoRetrieveWhenPull:\n - CustomApplication:MyCustomApplication\n - CustomApplication:MyOtherCustomApplication\n - CustomApplication:MyThirdCustomApp\n```\n\nFor a visual explanation of the process, watch this video:\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/Ik6whtflmfY\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation focuses on robust metadata synchronization:\n\n- **Salesforce CLI Wrapper:** It acts as a wrapper around the standard Salesforce CLI `sf project retrieve start` command, providing enhanced error handling and configuration options.\n- **Force Source Pull Utility:** The core logic resides in the `forceSourcePull` utility function, which orchestrates the retrieval process, including handling `.forceignore` updates.\n- **Configuration Integration:** It reads the `autoRetrieveWhenPull` setting from the project's `.sfdx-hardis.yml` to determine additional metadata to retrieve automatically.\n- **User Feedback:** Provides clear messages to the user regarding the pull status and guidance for troubleshooting.\n</details>\n",
3334
+ "examples": [
3335
+ "$ sf hardis:scratch:pull"
3336
+ ],
3518
3337
  "flags": {
3519
3338
  "json": {
3520
3339
  "description": "Format output as json.",
@@ -3528,101 +3347,18 @@
3528
3347
  "name": "flags-dir",
3529
3348
  "summary": "Import flag values from a directory.",
3530
3349
  "hasDynamicHelp": false,
3531
- "multiple": false,
3532
- "type": "option"
3533
- },
3534
- "apiversion": {
3535
- "char": "a",
3536
- "description": "Override the api version used for api requests made by this command",
3537
- "name": "apiversion",
3538
- "hasDynamicHelp": false,
3539
- "multiple": false,
3540
- "type": "option"
3541
- },
3542
- "sourcepath": {
3543
- "char": "p",
3544
- "description": "sourcePath",
3545
- "exclusive": [
3546
- "manifest",
3547
- "metadata"
3548
- ],
3549
- "name": "sourcepath",
3550
- "hasDynamicHelp": false,
3551
- "multiple": true,
3552
- "type": "option"
3553
- },
3554
- "wait": {
3555
- "char": "w",
3556
- "description": "wait",
3557
- "name": "wait",
3558
- "hasDynamicHelp": false,
3559
- "multiple": false,
3560
- "type": "option"
3561
- },
3562
- "manifest": {
3563
- "char": "x",
3564
- "description": "manifest",
3565
- "exclusive": [
3566
- "metadata",
3567
- "sourcepath"
3568
- ],
3569
- "name": "manifest",
3570
- "hasDynamicHelp": false,
3571
- "multiple": false,
3572
- "type": "option"
3573
- },
3574
- "metadata": {
3575
- "char": "m",
3576
- "description": "metadata",
3577
- "exclusive": [
3578
- "manifest",
3579
- "sourcepath"
3580
- ],
3581
- "name": "metadata",
3582
- "hasDynamicHelp": false,
3583
- "multiple": true,
3584
- "type": "option"
3585
- },
3586
- "packagenames": {
3587
- "char": "n",
3588
- "description": "packagenames",
3589
- "name": "packagenames",
3590
- "hasDynamicHelp": false,
3591
- "multiple": true,
3592
- "type": "option"
3593
- },
3594
- "tracksource": {
3595
- "char": "t",
3596
- "description": "tracksource",
3597
- "name": "tracksource",
3598
- "allowNo": false,
3599
- "type": "boolean"
3600
- },
3601
- "forceoverwrite": {
3602
- "char": "f",
3603
- "dependsOn": [
3604
- "tracksource"
3605
- ],
3606
- "description": "forceoverwrite",
3607
- "name": "forceoverwrite",
3608
- "allowNo": false,
3609
- "type": "boolean"
3610
- },
3611
- "verbose": {
3612
- "description": "verbose",
3613
- "name": "verbose",
3614
- "allowNo": false,
3615
- "type": "boolean"
3350
+ "multiple": false,
3351
+ "type": "option"
3616
3352
  },
3617
3353
  "debug": {
3618
3354
  "char": "d",
3619
- "description": "debugMode",
3355
+ "description": "Activate debug mode (more logs)",
3620
3356
  "name": "debug",
3621
3357
  "allowNo": false,
3622
3358
  "type": "boolean"
3623
3359
  },
3624
3360
  "websocket": {
3625
- "description": "websocket",
3361
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3626
3362
  "name": "websocket",
3627
3363
  "hasDynamicHelp": false,
3628
3364
  "multiple": false,
@@ -3652,37 +3388,38 @@
3652
3388
  },
3653
3389
  "hasDynamicHelp": true,
3654
3390
  "hiddenAliases": [],
3655
- "id": "hardis:source:retrieve",
3391
+ "id": "hardis:scratch:pull",
3656
3392
  "pluginAlias": "sfdx-hardis",
3657
3393
  "pluginName": "sfdx-hardis",
3658
3394
  "pluginType": "core",
3659
3395
  "strict": true,
3660
3396
  "enableJsonFlag": true,
3397
+ "title": "Scratch PULL",
3661
3398
  "requiresProject": true,
3662
3399
  "isESM": true,
3663
3400
  "relativePath": [
3664
3401
  "lib",
3665
3402
  "commands",
3666
3403
  "hardis",
3667
- "source",
3668
- "retrieve.js"
3404
+ "scratch",
3405
+ "pull.js"
3669
3406
  ],
3670
3407
  "aliasPermutations": [],
3671
3408
  "permutations": [
3672
- "hardis:source:retrieve",
3673
- "source:hardis:retrieve",
3674
- "source:retrieve:hardis",
3675
- "hardis:retrieve:source",
3676
- "retrieve:hardis:source",
3677
- "retrieve:source:hardis"
3409
+ "hardis:scratch:pull",
3410
+ "scratch:hardis:pull",
3411
+ "scratch:pull:hardis",
3412
+ "hardis:pull:scratch",
3413
+ "pull:hardis:scratch",
3414
+ "pull:scratch:hardis"
3678
3415
  ]
3679
3416
  },
3680
- "hardis:work:new": {
3417
+ "hardis:scratch:push": {
3681
3418
  "aliases": [],
3682
3419
  "args": {},
3683
- "description": "\n## Command Behavior\n\n**Assisted menu to start working on a Salesforce User Story, streamlining the setup of your development environment.**\n\nThis command guides you through the process of preparing your local environment and a Salesforce org for a new development or configuration based User Story. It automates several steps, ensuring consistency and adherence to project standards.\n\nKey features include:\n\n- **Git Branch Management:** Ensures your local Git repository is up-to-date with the target branch and creates a new Git branch with a formatted name based on your User Story details. Branch naming conventions can be customized via the `branchPrefixChoices` property in `.sfdx-hardis.yml`.\n\n- **Org Provisioning & Initialization:** Facilitates the creation and initialization of either a scratch org or a source-tracked sandbox. The configuration for org initialization (e.g., package installation, source push, permission set assignments, Apex script execution, data loading) can be defined in `config/.sfdx-hardis.yml\n- **Project-Specific Configuration:** Supports defining multiple target branches (`availableTargetBranches`) and projects (`availableProjects`) in `.sfdx-hardis.yml`, allowing for tailored User Stories workflows.\n\n- **User Story Name Validation:** Enforces User Story name formatting using `newTaskNameRegex` and provides examples via `newTaskNameRegexExample\n- **Shared Development Sandboxes:** Accounts for scenarios with shared development sandboxes, adjusting prompts to prevent accidental overwrites.\n\nAdvanced instructions are available in the [Create New User Story documentation](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-create-new-task/).\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's logic orchestrates various underlying processes:\n\n- **Git Operations:** Utilizes `checkGitClean`, `ensureGitBranch`, `gitCheckOutRemote`, and `git().pull()` to manage Git repository state and branches.\n- **Interactive Prompts:** Leverages the `prompts` library to gather user input for User Story type, source types, and User Story names.\n- **Configuration Management:** Reads and applies project-specific configurations from `.sfdx-hardis.yml` using `getConfig` and `setConfig- **Org Initialization Utilities:** Calls a suite of utility functions for org setup, including `initApexScripts`, `initOrgData`, `initOrgMetadatas`, `initPermissionSetAssignments`, `installPackages`, and `makeSureOrgIsConnected- **Salesforce CLI Interaction:** Executes Salesforce CLI commands (e.g., `sf config set target-org`, `sf org open`, `sf project delete tracking`) via `execCommand` and `execSfdxJson- **Dynamic Org Selection:** Presents choices for scratch orgs or sandboxes based on project configuration and existing orgs, dynamically calling `ScratchCreate.run` or `SandboxCreate.run` as needed.\n- **WebSocket Communication:** Sends refresh status messages via `WebSocketClient.sendRefreshStatusMessage()` to update connected VS Code clients.\n</details>\n",
3420
+ "description": "## Command Behavior\n\n**Pushes local Salesforce DX source files to a scratch org or source-tracked sandbox.**\n\nThis command is a fundamental operation in Salesforce DX development, allowing developers to synchronize their local codebase with their development org. It ensures that changes made locally are reflected in the scratch org, enabling testing and validation.\n\nKey functionalities:\n\n- **Source Synchronization:** Deploys all local changes (metadata and code) to the target scratch org.\n- **Underlying Command:** Internally, this command executes `sf project deploy start` to perform the push operation.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce CLI Wrapper:** It acts as a wrapper around the standard Salesforce CLI `sf project deploy start` command.\n- **`forceSourcePush` Utility:** The core logic resides in the `forceSourcePush` utility function, which orchestrates the deployment process.\n- **Connection Handling:** It uses the connection to the target org to perform the push operation.\n</details>\n",
3684
3421
  "examples": [
3685
- "$ sf hardis:work:new"
3422
+ "$ sf hardis:scratch:push"
3686
3423
  ],
3687
3424
  "flags": {
3688
3425
  "json": {
@@ -3720,20 +3457,6 @@
3720
3457
  "allowNo": false,
3721
3458
  "type": "boolean"
3722
3459
  },
3723
- "target-dev-hub": {
3724
- "aliases": [
3725
- "targetdevhubusername"
3726
- ],
3727
- "char": "v",
3728
- "deprecateAliases": true,
3729
- "name": "target-dev-hub",
3730
- "noCacheDefault": true,
3731
- "required": false,
3732
- "summary": "Username or alias of the Dev Hub org.",
3733
- "hasDynamicHelp": true,
3734
- "multiple": false,
3735
- "type": "option"
3736
- },
3737
3460
  "target-org": {
3738
3461
  "aliases": [
3739
3462
  "targetusername",
@@ -3743,7 +3466,8 @@
3743
3466
  "deprecateAliases": true,
3744
3467
  "name": "target-org",
3745
3468
  "noCacheDefault": true,
3746
- "summary": "Username or alias of the target org.",
3469
+ "required": true,
3470
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
3747
3471
  "hasDynamicHelp": true,
3748
3472
  "multiple": false,
3749
3473
  "type": "option"
@@ -3751,38 +3475,38 @@
3751
3475
  },
3752
3476
  "hasDynamicHelp": true,
3753
3477
  "hiddenAliases": [],
3754
- "id": "hardis:work:new",
3478
+ "id": "hardis:scratch:push",
3755
3479
  "pluginAlias": "sfdx-hardis",
3756
3480
  "pluginName": "sfdx-hardis",
3757
3481
  "pluginType": "core",
3758
3482
  "strict": true,
3759
3483
  "enableJsonFlag": true,
3760
- "title": "New User Story",
3484
+ "title": "Scratch PUSH",
3761
3485
  "requiresProject": true,
3762
3486
  "isESM": true,
3763
3487
  "relativePath": [
3764
3488
  "lib",
3765
3489
  "commands",
3766
3490
  "hardis",
3767
- "work",
3768
- "new.js"
3491
+ "scratch",
3492
+ "push.js"
3769
3493
  ],
3770
3494
  "aliasPermutations": [],
3771
3495
  "permutations": [
3772
- "hardis:work:new",
3773
- "work:hardis:new",
3774
- "work:new:hardis",
3775
- "hardis:new:work",
3776
- "new:hardis:work",
3777
- "new:work:hardis"
3496
+ "hardis:scratch:push",
3497
+ "scratch:hardis:push",
3498
+ "scratch:push:hardis",
3499
+ "hardis:push:scratch",
3500
+ "push:hardis:scratch",
3501
+ "push:scratch:hardis"
3778
3502
  ]
3779
3503
  },
3780
- "hardis:work:refresh": {
3504
+ "hardis:source:deploy": {
3781
3505
  "aliases": [],
3782
3506
  "args": {},
3783
- "description": "\n## Command Behavior\n\n**Refreshes your local Git branch and Salesforce org with the latest content from another Git branch.**\n\nThis command is designed to help developers keep their local development environment synchronized with changes made by other team members. It automates the process of pulling updates from a designated branch, merging them into your current working branch, and then pushing those changes to your scratch org or source-tracked sandbox.\n\nKey functionalities:\n\n- **Pre-Merge Check:** Prompts the user to confirm that they have saved their current work before proceeding with the merge, preventing accidental data loss.\n- **Branch Selection:** Allows you to select a target Git branch (e.g., `integration`, `preprod`) from which to pull updates.\n- **Git Operations:** Performs a series of Git operations:\n - Pulls the latest version of the selected merge branch.\n - Stashes your uncommitted local changes before merging.\n - Merges the selected branch into your current local branch.\n - Handles merge conflicts interactively, prompting the user to resolve them.\n - Restores your stashed changes after the merge.\n- **Org Synchronization:** Pushes the updated local branch content to your scratch org or source-tracked sandbox, ensuring your org reflects the latest merged code.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Configuration Loading:** It retrieves project configurations using `getConfig` to determine the default development branch.\n- **Git Integration:** Extensively uses `simple-git` (`git()`) for various Git operations:\n - `git().branch()`: Lists local and remote branches.\n - `git().stash()`: Saves and restores uncommitted changes.\n - `git().fetch()`: Fetches updates from remote repositories.\n - `git().checkout()`: Switches between branches.\n - `git().pull()`: Pulls changes from a remote branch.\n - `git().merge()`: Merges one branch into another, handling conflicts.\n- **Interactive Prompts:** Uses the `prompts` library to guide the user through confirmations (e.g., saving work) and branch selection.\n- **Salesforce CLI Integration:** It uses `forceSourcePull` to pull changes from the scratch org and `forceSourcePush` to push changes to the scratch org.\n- **Error Handling:** Includes robust error handling for Git operations (e.g., merge conflicts) and provides guidance to the user for resolution.\n- **Environment Variable Check:** Checks for an `EXPERIMENTAL` environment variable to gate access to this command, indicating it might not be fully stable.\n</details>\n",
3507
+ "description": "sfdx-hardis wrapper for sfdx force:source:deploy that displays tips to solve deployment errors.\n\nAdditional to the base command wrapper: If using **--checkonly**, add options **--checkcoverage** and **--coverageformatters json-summary** to check that org coverage is > 75% (or value defined in .sfdx-hardis.yml property **apexTestsMinCoverageOrgWide**)\n\n### Deployment results\n\nYou can also have deployment results as pull request comments, on:\n\n- GitHub (see [GitHub Pull Requests comments config](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-setup-integration-github/))\n- Gitlab (see [Gitlab integration configuration](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-setup-integration-gitlab/))\n- Azure DevOps (see [Azure integration configuration](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-setup-integration-azure/))\n\n\n[![Assisted solving of Salesforce deployments errors](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deployment-errors.jpg)](https://nicolas.vuillamy.fr/assisted-solving-of-salesforce-deployments-errors-47f3666a9ed0)\n\n### Deployment pre or post commands\n\nYou can define command lines to run before or after a deployment, with parameters:\n\n- **id**: Unique Id for the command\n- **label**: Human readable label for the command\n- **skipIfError**: If defined to \"true\", the post-command won't be run if there is a deployment failure\n- **context**: Defines the context where the command will be run. Can be **all** (default), **check-deployment-only** or **process-deployment-only**\n- **runOnlyOnceByOrg**: If set to true, the command will be run only one time per org. A record of SfdxHardisTrace__c is stored to make that possible (it needs to be existing in target org)\n\nIf the commands are not the same depending on the target org, you can define them into **config/branches/.sfdx-hardis-BRANCHNAME.yml** instead of root **config/.sfdx-hardis.yml**\n\nExample:\n\n```yaml\ncommandsPreDeploy:\n - id: knowledgeUnassign\n label: Remove KnowledgeUser right to the user who has it\n command: sf data update record --sobject User --where \"UserPermissionsKnowledgeUser='true'\" --values \"UserPermissionsKnowledgeUser='false'\" --json\n - id: knowledgeAssign\n label: Assign Knowledge user to the deployment user\n command: sf data update record --sobject User --where \"Username='deploy.github@myclient.com'\" --values \"UserPermissionsKnowledgeUser='true'\" --json\n\ncommandsPostDeploy:\n - id: knowledgeUnassign\n label: Remove KnowledgeUser right to the user who has it\n command: sf data update record --sobject User --where \"UserPermissionsKnowledgeUser='true'\" --values \"UserPermissionsKnowledgeUser='false'\" --json\n - id: knowledgeAssign\n label: Assign Knowledge user to desired username\n command: sf data update record --sobject User --where \"Username='admin-yser@myclient.com'\" --values \"UserPermissionsKnowledgeUser='true'\" --json\n - id: someActionToRunJustOneTime\n label: And to run only if deployment is success\n command: sf sfdmu:run ...\n skipIfError: true\n context: process-deployment-only\n runOnlyOnceByOrg: true\n```\n\nNotes:\n\n- You can disable coloring of errors in red by defining env variable SFDX_HARDIS_DEPLOY_ERR_COLORS=false\n\n[See documentation of Salesforce command](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_deploy)\n",
3784
3508
  "examples": [
3785
- "$ sf hardis:work:refresh"
3509
+ "$ sf hardis:source:deploy -x manifest/package.xml --wait 60 --ignorewarnings --testlevel RunLocalTests --postdestructivechanges ./manifest/destructiveChanges.xml --target-org nicolas.vuillamy@cloudity.com.sfdxhardis --checkonly --checkcoverage --verbose --coverageformatters json-summary"
3786
3510
  ],
3787
3511
  "flags": {
3788
3512
  "json": {
@@ -3800,33 +3524,205 @@
3800
3524
  "multiple": false,
3801
3525
  "type": "option"
3802
3526
  },
3803
- "nopull": {
3804
- "char": "n",
3805
- "description": "No scratch pull before save (careful if you use that!)",
3806
- "name": "nopull",
3527
+ "checkonly": {
3528
+ "char": "c",
3529
+ "description": "checkonly",
3530
+ "name": "checkonly",
3531
+ "allowNo": false,
3532
+ "type": "boolean"
3533
+ },
3534
+ "soapdeploy": {
3535
+ "description": "soapDeploy",
3536
+ "name": "soapdeploy",
3537
+ "allowNo": false,
3538
+ "type": "boolean"
3539
+ },
3540
+ "wait": {
3541
+ "char": "w",
3542
+ "description": "wait",
3543
+ "name": "wait",
3544
+ "default": 60,
3545
+ "hasDynamicHelp": false,
3546
+ "multiple": false,
3547
+ "type": "option"
3548
+ },
3549
+ "testlevel": {
3550
+ "char": "l",
3551
+ "description": "testlevel",
3552
+ "name": "testlevel",
3553
+ "default": "NoTestRun",
3554
+ "hasDynamicHelp": false,
3555
+ "multiple": false,
3556
+ "options": [
3557
+ "NoTestRun",
3558
+ "RunSpecifiedTests",
3559
+ "RunLocalTests",
3560
+ "RunAllTestsInOrg"
3561
+ ],
3562
+ "type": "option"
3563
+ },
3564
+ "runtests": {
3565
+ "char": "r",
3566
+ "description": "runTests",
3567
+ "name": "runtests",
3568
+ "default": [],
3569
+ "hasDynamicHelp": false,
3570
+ "multiple": true,
3571
+ "type": "option"
3572
+ },
3573
+ "ignoreerrors": {
3574
+ "description": "ignoreErrors",
3575
+ "name": "ignoreerrors",
3576
+ "allowNo": false,
3577
+ "type": "boolean"
3578
+ },
3579
+ "ignorewarnings": {
3580
+ "char": "g",
3581
+ "description": "ignoreWarnings",
3582
+ "name": "ignorewarnings",
3583
+ "allowNo": false,
3584
+ "type": "boolean"
3585
+ },
3586
+ "validateddeployrequestid": {
3587
+ "char": "q",
3588
+ "description": "validateDeployRequestId",
3589
+ "exclusive": [
3590
+ "manifest",
3591
+ "metadata",
3592
+ "sourcepath",
3593
+ "checkonly",
3594
+ "testlevel",
3595
+ "runtests",
3596
+ "ignoreerrors",
3597
+ "ignorewarnings"
3598
+ ],
3599
+ "name": "validateddeployrequestid",
3600
+ "hasDynamicHelp": false,
3601
+ "multiple": false,
3602
+ "type": "option"
3603
+ },
3604
+ "verbose": {
3605
+ "description": "verbose",
3606
+ "name": "verbose",
3607
+ "allowNo": false,
3608
+ "type": "boolean"
3609
+ },
3610
+ "metadata": {
3611
+ "char": "m",
3612
+ "description": "metadata",
3613
+ "exclusive": [
3614
+ "manifest",
3615
+ "sourcepath"
3616
+ ],
3617
+ "name": "metadata",
3618
+ "hasDynamicHelp": false,
3619
+ "multiple": true,
3620
+ "type": "option"
3621
+ },
3622
+ "sourcepath": {
3623
+ "char": "p",
3624
+ "description": "sourcePath",
3625
+ "exclusive": [
3626
+ "manifest",
3627
+ "metadata"
3628
+ ],
3629
+ "name": "sourcepath",
3630
+ "hasDynamicHelp": false,
3631
+ "multiple": true,
3632
+ "type": "option"
3633
+ },
3634
+ "manifest": {
3635
+ "char": "x",
3636
+ "description": "flagsLong.manifest",
3637
+ "exclusive": [
3638
+ "metadata",
3639
+ "sourcepath"
3640
+ ],
3641
+ "name": "manifest",
3642
+ "hasDynamicHelp": false,
3643
+ "multiple": false,
3644
+ "type": "option"
3645
+ },
3646
+ "predestructivechanges": {
3647
+ "dependsOn": [
3648
+ "manifest"
3649
+ ],
3650
+ "description": "predestructivechanges",
3651
+ "name": "predestructivechanges",
3652
+ "hasDynamicHelp": false,
3653
+ "multiple": false,
3654
+ "type": "option"
3655
+ },
3656
+ "postdestructivechanges": {
3657
+ "dependsOn": [
3658
+ "manifest"
3659
+ ],
3660
+ "description": "postdestructivechanges",
3661
+ "name": "postdestructivechanges",
3662
+ "hasDynamicHelp": false,
3663
+ "multiple": false,
3664
+ "type": "option"
3665
+ },
3666
+ "tracksource": {
3667
+ "char": "t",
3668
+ "description": "tracksource",
3669
+ "exclusive": [
3670
+ "checkonly",
3671
+ "validateddeployrequestid"
3672
+ ],
3673
+ "name": "tracksource",
3674
+ "allowNo": false,
3675
+ "type": "boolean"
3676
+ },
3677
+ "forceoverwrite": {
3678
+ "char": "f",
3679
+ "dependsOn": [
3680
+ "tracksource"
3681
+ ],
3682
+ "description": "forceoverwrite",
3683
+ "name": "forceoverwrite",
3684
+ "allowNo": false,
3685
+ "type": "boolean"
3686
+ },
3687
+ "resultsdir": {
3688
+ "description": "resultsdir",
3689
+ "name": "resultsdir",
3690
+ "hasDynamicHelp": false,
3691
+ "multiple": false,
3692
+ "type": "option"
3693
+ },
3694
+ "coverageformatters": {
3695
+ "description": "coverageformatters",
3696
+ "name": "coverageformatters",
3697
+ "hasDynamicHelp": false,
3698
+ "multiple": true,
3699
+ "type": "option"
3700
+ },
3701
+ "junit": {
3702
+ "description": "junit",
3703
+ "name": "junit",
3704
+ "allowNo": false,
3705
+ "type": "boolean"
3706
+ },
3707
+ "checkcoverage": {
3708
+ "description": "Check Apex org coverage",
3709
+ "name": "checkcoverage",
3807
3710
  "allowNo": false,
3808
3711
  "type": "boolean"
3809
3712
  },
3810
3713
  "debug": {
3811
- "char": "d",
3812
- "description": "Activate debug mode (more logs)",
3714
+ "description": "debug",
3813
3715
  "name": "debug",
3814
3716
  "allowNo": false,
3815
3717
  "type": "boolean"
3816
3718
  },
3817
3719
  "websocket": {
3818
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3720
+ "description": "websocket",
3819
3721
  "name": "websocket",
3820
3722
  "hasDynamicHelp": false,
3821
3723
  "multiple": false,
3822
3724
  "type": "option"
3823
3725
  },
3824
- "skipauth": {
3825
- "description": "Skip authentication check when a default username is required",
3826
- "name": "skipauth",
3827
- "allowNo": false,
3828
- "type": "boolean"
3829
- },
3830
3726
  "target-org": {
3831
3727
  "aliases": [
3832
3728
  "targetusername",
@@ -3845,39 +3741,35 @@
3845
3741
  },
3846
3742
  "hasDynamicHelp": true,
3847
3743
  "hiddenAliases": [],
3848
- "id": "hardis:work:refresh",
3744
+ "id": "hardis:source:deploy",
3849
3745
  "pluginAlias": "sfdx-hardis",
3850
3746
  "pluginName": "sfdx-hardis",
3851
3747
  "pluginType": "core",
3852
3748
  "strict": true,
3853
3749
  "enableJsonFlag": true,
3854
- "title": "Refresh User Story branch",
3855
3750
  "requiresProject": true,
3856
3751
  "isESM": true,
3857
3752
  "relativePath": [
3858
3753
  "lib",
3859
3754
  "commands",
3860
3755
  "hardis",
3861
- "work",
3862
- "refresh.js"
3756
+ "source",
3757
+ "deploy.js"
3863
3758
  ],
3864
3759
  "aliasPermutations": [],
3865
3760
  "permutations": [
3866
- "hardis:work:refresh",
3867
- "work:hardis:refresh",
3868
- "work:refresh:hardis",
3869
- "hardis:refresh:work",
3870
- "refresh:hardis:work",
3871
- "refresh:work:hardis"
3761
+ "hardis:source:deploy",
3762
+ "source:hardis:deploy",
3763
+ "source:deploy:hardis",
3764
+ "hardis:deploy:source",
3765
+ "deploy:hardis:source",
3766
+ "deploy:source:hardis"
3872
3767
  ]
3873
3768
  },
3874
- "hardis:work:resetselection": {
3769
+ "hardis:source:push": {
3875
3770
  "aliases": [],
3876
3771
  "args": {},
3877
- "description": "\n## Command Behavior\n\n**Resets the local Git repository to allow for a new selection of files to be included in a merge request.**\n\nThis command is designed to be used when you need to re-evaluate which changes should be part of your next merge request. It performs a soft Git reset, effectively unstaging all committed changes since the last merge with the target branch, and then cleans up any generated files.\n\nKey functionalities:\n\n- **Target Branch Selection:** Prompts you to select the target branch of your current or future merge request.\n- **Soft Git Reset:** Performs a `git reset --soft` operation to uncommit changes, moving the HEAD pointer back but keeping the changes in your working directory.\n- **Generated File Cleanup:** Resets and checks out `manifest/package.xml` and `manifest/destructiveChanges.xml` to their state before the reset, ensuring a clean slate for new selections.\n- **Force Push Authorization:** Sets a flag in your user configuration (`canForcePush: true`) to allow a force push in the subsequent `hardis:work:save` command, as the history will have been rewritten.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Git Integration:** Uses `simple-git` (`git()`) to interact with the Git repository:\n - `git().branch()`: Retrieves information about local and remote branches.\n - `git().log()`: Fetches the commit history to determine which commits to reset.\n - `git().reset()`: Performs the soft reset operation.\n - `git().checkout()`: Resets specific files (`package.xml`, `destructiveChanges.xml`) to their previous state.\n - `git().status()`: Displays the current status of the Git repository after the reset.\n- **Interactive Prompts:** Uses the `prompts` library to confirm the reset operation with the user and to select the target branch.\n- **Configuration Management:** Updates the user's configuration (`.sfdx-hardis.yml`) using `setConfig` to set the `canForcePush` flag.\n- **Error Handling:** Includes a check to prevent resetting protected branches.\n</details>\n",
3878
- "examples": [
3879
- "$ sf hardis:work:resetsave"
3880
- ],
3772
+ "description": "sfdx-hardis wrapper for sfdx force:source:push that displays tips to solve deployment errors.\n\n[![Assisted solving of Salesforce deployments errors](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deployment-errors.jpg)](https://nicolas.vuillamy.fr/assisted-solving-of-salesforce-deployments-errors-47f3666a9ed0)\n\n[See documentation of Salesforce command](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_push)\n",
3881
3773
  "flags": {
3882
3774
  "json": {
3883
3775
  "description": "Format output as json.",
@@ -3894,26 +3786,48 @@
3894
3786
  "multiple": false,
3895
3787
  "type": "option"
3896
3788
  },
3789
+ "forceoverwrite": {
3790
+ "char": "f",
3791
+ "description": "forceoverwrite",
3792
+ "name": "forceoverwrite",
3793
+ "allowNo": false,
3794
+ "type": "boolean"
3795
+ },
3796
+ "wait": {
3797
+ "char": "w",
3798
+ "description": "wait",
3799
+ "name": "wait",
3800
+ "default": 60,
3801
+ "hasDynamicHelp": false,
3802
+ "multiple": false,
3803
+ "type": "option"
3804
+ },
3805
+ "ignorewarnings": {
3806
+ "char": "g",
3807
+ "description": "ignorewarnings",
3808
+ "name": "ignorewarnings",
3809
+ "allowNo": false,
3810
+ "type": "boolean"
3811
+ },
3812
+ "quiet": {
3813
+ "description": "quiet",
3814
+ "name": "quiet",
3815
+ "allowNo": false,
3816
+ "type": "boolean"
3817
+ },
3897
3818
  "debug": {
3898
- "char": "d",
3899
- "description": "Activate debug mode (more logs)",
3819
+ "description": "debug",
3900
3820
  "name": "debug",
3901
3821
  "allowNo": false,
3902
3822
  "type": "boolean"
3903
3823
  },
3904
3824
  "websocket": {
3905
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3825
+ "description": "websocket",
3906
3826
  "name": "websocket",
3907
3827
  "hasDynamicHelp": false,
3908
3828
  "multiple": false,
3909
3829
  "type": "option"
3910
3830
  },
3911
- "skipauth": {
3912
- "description": "Skip authentication check when a default username is required",
3913
- "name": "skipauth",
3914
- "allowNo": false,
3915
- "type": "boolean"
3916
- },
3917
3831
  "target-org": {
3918
3832
  "aliases": [
3919
3833
  "targetusername",
@@ -3932,40 +3846,36 @@
3932
3846
  },
3933
3847
  "hasDynamicHelp": true,
3934
3848
  "hiddenAliases": [],
3935
- "id": "hardis:work:resetselection",
3849
+ "id": "hardis:source:push",
3936
3850
  "pluginAlias": "sfdx-hardis",
3937
3851
  "pluginName": "sfdx-hardis",
3938
3852
  "pluginType": "core",
3939
3853
  "strict": true,
3940
3854
  "enableJsonFlag": true,
3941
- "title": "Select again",
3942
3855
  "requiresProject": true,
3943
3856
  "isESM": true,
3944
3857
  "relativePath": [
3945
3858
  "lib",
3946
3859
  "commands",
3947
3860
  "hardis",
3948
- "work",
3949
- "resetselection.js"
3861
+ "source",
3862
+ "push.js"
3950
3863
  ],
3951
3864
  "aliasPermutations": [],
3952
3865
  "permutations": [
3953
- "hardis:work:resetselection",
3954
- "work:hardis:resetselection",
3955
- "work:resetselection:hardis",
3956
- "hardis:resetselection:work",
3957
- "resetselection:hardis:work",
3958
- "resetselection:work:hardis"
3866
+ "hardis:source:push",
3867
+ "source:hardis:push",
3868
+ "source:push:hardis",
3869
+ "hardis:push:source",
3870
+ "push:hardis:source",
3871
+ "push:source:hardis"
3959
3872
  ]
3960
3873
  },
3961
- "hardis:work:save": {
3874
+ "hardis:source:retrieve": {
3962
3875
  "aliases": [],
3963
3876
  "args": {},
3964
- "description": "\n## Command Behavior\n\n**Guides the user through the process of saving their work, preparing it for a Merge Request (also named Pull Request), and pushing changes to the remote Git repository.**\n\nThis command automates several critical steps involved in finalizing a development User Story and integrating it into the main codebase. It ensures that your local changes are properly synchronized, cleaned, and committed before being pushed.\n\nKey functionalities include:\n\n- **Git Status Management:** Ensures a clean Git working directory by handling ongoing merges and unstaging files.\n- **Org Synchronization (Optional):** Prompts the user to pull the latest metadata updates from their scratch org or source-tracked sandbox, ensuring local files reflect the org's state.\n- **Package.xml Updates:** Automatically generates `package.xml` and `destructiveChanges.xml` files based on the Git delta between your current branch and the target branch, reflecting added, modified, and deleted metadata.\n- **Automated Source Cleaning:** Applies predefined cleaning operations to your local Salesforce sources, such as removing unwanted references, minimizing profiles, or cleaning XML files based on configurations in your `.sfdx-hardis.yml`.\n - `autoCleanTypes`: A list of automated source cleanings, configurable via [hardis:project:clean:references](${CONSTANTS.DOC_URL_ROOT}/hardis/project/clean/references/).\n - `autoRemoveUserPermissions`: A list of user permissions to automatically remove from profile metadata.\n- **Deployment Plan Generation:** Builds an automated deployment plan based on the updated `package.xml` and configured deployment splits.\n- **Commit and Push:** Guides the user to commit the changes and push them to the remote Git repository, optionally handling force pushes if a branch reset occurred.\n- **Merge Request Guidance:** Provides information and links to facilitate the creation of a merge request after the changes are pushed.\n\nExample `.sfdx-hardis.yml` configuration:\n\n```yaml\nautoCleanTypes:\n - checkPermissions\n - destructivechanges\n - datadotcom\n - minimizeProfiles\n - listViewsMine\nautoRemoveUserPermissions:\n - EnableCommunityAppLauncher\n - FieldServiceAccess\n - OmnichannelInventorySync\n - SendExternalEmailAvailable\n - UseOmnichannelInventoryAPIs\n - ViewDataLeakageEvents\n - ViewMLModels\n - ViewPlatformEvents\n - WorkCalibrationUser\n```\n\nAdvanced instructions are available in the [Publish a User Story documentation](${CONSTANTS.DOC_URL_ROOT}/salesforce-ci-cd-publish-task/).\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves a series of orchestrated steps:\n\n- **Git Integration:** Extensively uses the `git` utility for status checks, adding files, committing, and pushing. It also leverages `sfdx-git-delta` for generating metadata differences between Git revisions.\n- **Interactive Prompts:** Employs the `prompts` library to interact with the user for decisions like pulling sources or pushing commits.\n- **Configuration Management:** Reads and updates project and user configurations using `getConfig` and `setConfig` to store preferences and deployment plans.\n- **Metadata Synchronization:** Calls `forceSourcePull` to retrieve metadata from the org and `callSfdxGitDelta` to generate `package.xml` and `destructiveChanges.xml` based on Git changes.\n- **XML Manipulation:** Utilizes `appendPackageXmlFilesContent`, `removePackageXmlFilesContent`, `parseXmlFile`, and `writeXmlFile` for modifying `package.xml` and `destructiveChanges.xml` files.\n- **Automated Cleaning:** Integrates with `CleanReferences.run` and `CleanXml.run` commands to perform automated cleaning operations on the Salesforce source files.\n- **Deployment Plan Building:** Dynamically constructs a deployment plan by analyzing the `package.xml` content and applying configured deployment splits.\n- **WebSocket Communication:** Uses `WebSocketClient.sendRefreshStatusMessage` to notify connected VS Code clients about status updates.\n- **External Tool Integration:** Requires the `sfdx-git-delta` plugin to be installed for its core functionality.\n</details>\n",
3965
- "examples": [
3966
- "$ sf hardis:work:task:save",
3967
- "$ sf hardis:work:task:save --nopull --nogit --noclean"
3968
- ],
3877
+ "description": "\n## Command Behavior\n\n**A wrapper command for Salesforce CLI's `sf project retrieve start` (formerly `sfdx force:source:retrieve`), with enhanced interactive features.**\n\nThis command facilitates the retrieval of metadata from a Salesforce org into your local project. It provides an assisted experience, especially when no specific retrieval constraints are provided.\n\nKey features:\n\n- **Assisted Metadata Selection:** If no `sourcepath`, `manifest`, `metadata`, or `packagenames` flags are specified, an interactive menu will prompt you to select the metadata types you wish to retrieve.\n- **Assisted Org Selection:** If no target org is specified, an interactive menu will guide you to choose an org for the retrieval operation.\n- **Backward Compatibility:** While this command wraps the newer `sf project retrieve start`, it maintains compatibility with the older `sfdx force:source:retrieve` flags.\n\n**Important Note:** The underlying Salesforce CLI command `sfdx force:source:retrieve` is being deprecated by Salesforce in November 2024. It is recommended to migrate to `sf project retrieve start` for future compatibility. See [Salesforce CLI Migration Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_mig_deploy_retrieve.htm) for more information.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThis command acts as an intelligent wrapper around the Salesforce CLI's source retrieval functionality:\n\n- **Command Wrapping:** It uses the `wrapSfdxCoreCommand` utility to execute the `sfdx force:source:retrieve` (or its equivalent `sf project retrieve start`) command, passing through all relevant flags and arguments.\n- **Interactive Prompts:** It leverages `MetadataUtils.promptMetadataTypes()` and `promptOrgUsernameDefault()` to provide interactive menus for metadata and org selection when the user does not provide them as flags.\n- **Argument Transformation:** It dynamically constructs the command-line arguments for the underlying Salesforce CLI command based on user selections and provided flags.\n- **Error Handling:** It includes basic error handling, such as prompting the user to re-select an org if an issue occurs during org selection.\n- **Deprecation Warning:** It explicitly logs warnings about the deprecation of `sfdx force:source:retrieve` to inform users about upcoming changes.\n</details>\n",
3878
+ "examples": [],
3969
3879
  "flags": {
3970
3880
  "json": {
3971
3881
  "description": "Format output as json.",
@@ -3982,49 +3892,98 @@
3982
3892
  "multiple": false,
3983
3893
  "type": "option"
3984
3894
  },
3985
- "nopull": {
3895
+ "apiversion": {
3896
+ "char": "a",
3897
+ "description": "Override the api version used for api requests made by this command",
3898
+ "name": "apiversion",
3899
+ "hasDynamicHelp": false,
3900
+ "multiple": false,
3901
+ "type": "option"
3902
+ },
3903
+ "sourcepath": {
3904
+ "char": "p",
3905
+ "description": "sourcePath",
3906
+ "exclusive": [
3907
+ "manifest",
3908
+ "metadata"
3909
+ ],
3910
+ "name": "sourcepath",
3911
+ "hasDynamicHelp": false,
3912
+ "multiple": true,
3913
+ "type": "option"
3914
+ },
3915
+ "wait": {
3916
+ "char": "w",
3917
+ "description": "wait",
3918
+ "name": "wait",
3919
+ "hasDynamicHelp": false,
3920
+ "multiple": false,
3921
+ "type": "option"
3922
+ },
3923
+ "manifest": {
3924
+ "char": "x",
3925
+ "description": "manifest",
3926
+ "exclusive": [
3927
+ "metadata",
3928
+ "sourcepath"
3929
+ ],
3930
+ "name": "manifest",
3931
+ "hasDynamicHelp": false,
3932
+ "multiple": false,
3933
+ "type": "option"
3934
+ },
3935
+ "metadata": {
3936
+ "char": "m",
3937
+ "description": "metadata",
3938
+ "exclusive": [
3939
+ "manifest",
3940
+ "sourcepath"
3941
+ ],
3942
+ "name": "metadata",
3943
+ "hasDynamicHelp": false,
3944
+ "multiple": true,
3945
+ "type": "option"
3946
+ },
3947
+ "packagenames": {
3986
3948
  "char": "n",
3987
- "description": "No scratch pull before save",
3988
- "name": "nopull",
3989
- "allowNo": false,
3990
- "type": "boolean"
3949
+ "description": "packagenames",
3950
+ "name": "packagenames",
3951
+ "hasDynamicHelp": false,
3952
+ "multiple": true,
3953
+ "type": "option"
3991
3954
  },
3992
- "nogit": {
3993
- "char": "g",
3994
- "description": "No automated git operations",
3995
- "name": "nogit",
3955
+ "tracksource": {
3956
+ "char": "t",
3957
+ "description": "tracksource",
3958
+ "name": "tracksource",
3996
3959
  "allowNo": false,
3997
3960
  "type": "boolean"
3998
3961
  },
3999
- "noclean": {
4000
- "char": "c",
4001
- "description": "No cleaning of local sources",
4002
- "name": "noclean",
3962
+ "forceoverwrite": {
3963
+ "char": "f",
3964
+ "dependsOn": [
3965
+ "tracksource"
3966
+ ],
3967
+ "description": "forceoverwrite",
3968
+ "name": "forceoverwrite",
4003
3969
  "allowNo": false,
4004
3970
  "type": "boolean"
4005
3971
  },
4006
- "auto": {
4007
- "description": "No user prompts (when called from CI for example)",
4008
- "name": "auto",
3972
+ "verbose": {
3973
+ "description": "verbose",
3974
+ "name": "verbose",
4009
3975
  "allowNo": false,
4010
3976
  "type": "boolean"
4011
3977
  },
4012
- "targetbranch": {
4013
- "description": "Name of the Merge Request target branch. Will be guessed or prompted if not provided.",
4014
- "name": "targetbranch",
4015
- "hasDynamicHelp": false,
4016
- "multiple": false,
4017
- "type": "option"
4018
- },
4019
3978
  "debug": {
4020
3979
  "char": "d",
4021
- "description": "Activate debug mode (more logs)",
3980
+ "description": "debugMode",
4022
3981
  "name": "debug",
4023
3982
  "allowNo": false,
4024
3983
  "type": "boolean"
4025
3984
  },
4026
3985
  "websocket": {
4027
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3986
+ "description": "websocket",
4028
3987
  "name": "websocket",
4029
3988
  "hasDynamicHelp": false,
4030
3989
  "multiple": false,
@@ -4054,41 +4013,37 @@
4054
4013
  },
4055
4014
  "hasDynamicHelp": true,
4056
4015
  "hiddenAliases": [],
4057
- "id": "hardis:work:save",
4016
+ "id": "hardis:source:retrieve",
4058
4017
  "pluginAlias": "sfdx-hardis",
4059
4018
  "pluginName": "sfdx-hardis",
4060
4019
  "pluginType": "core",
4061
4020
  "strict": true,
4062
4021
  "enableJsonFlag": true,
4063
- "title": "Save User Story",
4064
4022
  "requiresProject": true,
4065
- "requiresSfdxPlugins": [
4066
- "sfdx-git-delta"
4067
- ],
4068
4023
  "isESM": true,
4069
4024
  "relativePath": [
4070
4025
  "lib",
4071
4026
  "commands",
4072
4027
  "hardis",
4073
- "work",
4074
- "save.js"
4028
+ "source",
4029
+ "retrieve.js"
4075
4030
  ],
4076
4031
  "aliasPermutations": [],
4077
4032
  "permutations": [
4078
- "hardis:work:save",
4079
- "work:hardis:save",
4080
- "work:save:hardis",
4081
- "hardis:save:work",
4082
- "save:hardis:work",
4083
- "save:work:hardis"
4033
+ "hardis:source:retrieve",
4034
+ "source:hardis:retrieve",
4035
+ "source:retrieve:hardis",
4036
+ "hardis:retrieve:source",
4037
+ "retrieve:hardis:source",
4038
+ "retrieve:source:hardis"
4084
4039
  ]
4085
4040
  },
4086
- "hardis:work:ws": {
4041
+ "hardis:work:new": {
4087
4042
  "aliases": [],
4088
4043
  "args": {},
4089
- "description": "\n## Command Behavior\n\n**Performs technical operations related to WebSocket communication, primarily for internal use by the sfdx-hardis VS Code extension.**\n\nThis command is not intended for direct end-user interaction. It facilitates communication between the sfdx-hardis CLI and the VS Code Extension, enabling features like real-time status updates and plugin refreshes.\n\nKey functionalities:\n\n- **Refresh Status (`--event refreshStatus`):** Sends a message to the VS Code Extension to refresh its displayed status, ensuring that the UI reflects the latest state of Salesforce orgs or project activities.\n- **Refresh Plugins (`--event refreshPlugins`):** Sends a message to the VS Code Extension to refresh its loaded plugins, useful after installing or updating sfdx-hardis or other related extensions.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **WebSocketClient:** It utilizes the `WebSocketClient` utility to establish and manage WebSocket connections.\n- **Event-Driven Communication:** It listens for specific events (e.g., `refreshStatus`, `refreshPlugins`) and triggers corresponding actions on the connected WebSocket client.\n- **Internal Use:** This command is primarily called programmatically by the VS Code Extension to maintain synchronization and provide a seamless user experience.\n</details>\n",
4044
+ "description": "\n## Command Behavior\n\n**Assisted menu to start working on a Salesforce User Story, streamlining the setup of your development environment.**\n\nThis command guides you through the process of preparing your local environment and a Salesforce org for a new development or configuration based User Story. It automates several steps, ensuring consistency and adherence to project standards.\n\nKey features include:\n\n- **Git Branch Management:** Ensures your local Git repository is up-to-date with the target branch and creates a new Git branch with a formatted name based on your User Story details. Branch naming conventions can be customized via the `branchPrefixChoices` property in `.sfdx-hardis.yml`.\n\n- **Org Provisioning & Initialization:** Facilitates the creation and initialization of either a scratch org or a source-tracked sandbox. The configuration for org initialization (e.g., package installation, source push, permission set assignments, Apex script execution, data loading) can be defined in `config/.sfdx-hardis.yml\n- **Project-Specific Configuration:** Supports defining multiple target branches (`availableTargetBranches`) and projects (`availableProjects`) in `.sfdx-hardis.yml`, allowing for tailored User Stories workflows.\n\n- **User Story Name Validation:** Enforces User Story name formatting using `newTaskNameRegex` and provides examples via `newTaskNameRegexExample\n- **Shared Development Sandboxes:** Accounts for scenarios with shared development sandboxes, adjusting prompts to prevent accidental overwrites.\n\nAdvanced instructions are available in the [Create New User Story documentation](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-create-new-task/).\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's logic orchestrates various underlying processes:\n\n- **Git Operations:** Utilizes `checkGitClean`, `ensureGitBranch`, `gitCheckOutRemote`, and `git().pull()` to manage Git repository state and branches.\n- **Interactive Prompts:** Leverages the `prompts` library to gather user input for User Story type, source types, and User Story names.\n- **Configuration Management:** Reads and applies project-specific configurations from `.sfdx-hardis.yml` using `getConfig` and `setConfig- **Org Initialization Utilities:** Calls a suite of utility functions for org setup, including `initApexScripts`, `initOrgData`, `initOrgMetadatas`, `initPermissionSetAssignments`, `installPackages`, and `makeSureOrgIsConnected- **Salesforce CLI Interaction:** Executes Salesforce CLI commands (e.g., `sf config set target-org`, `sf org open`, `sf project delete tracking`) via `execCommand` and `execSfdxJson- **Dynamic Org Selection:** Presents choices for scratch orgs or sandboxes based on project configuration and existing orgs, dynamically calling `ScratchCreate.run` or `SandboxCreate.run` as needed.\n- **WebSocket Communication:** Sends refresh status messages via `WebSocketClient.sendRefreshStatusMessage()` to update connected VS Code clients.\n</details>\n",
4090
4045
  "examples": [
4091
- "$ sf hardis:work:ws --event refreshStatus"
4046
+ "$ sf hardis:work:new"
4092
4047
  ],
4093
4048
  "flags": {
4094
4049
  "json": {
@@ -4106,14 +4061,6 @@
4106
4061
  "multiple": false,
4107
4062
  "type": "option"
4108
4063
  },
4109
- "event": {
4110
- "char": "e",
4111
- "description": "WebSocket event",
4112
- "name": "event",
4113
- "hasDynamicHelp": false,
4114
- "multiple": false,
4115
- "type": "option"
4116
- },
4117
4064
  "debug": {
4118
4065
  "char": "d",
4119
4066
  "description": "Activate debug mode (more logs)",
@@ -4128,50 +4075,75 @@
4128
4075
  "multiple": false,
4129
4076
  "type": "option"
4130
4077
  },
4131
- "skipauth": {
4132
- "description": "Skip authentication check when a default username is required",
4133
- "name": "skipauth",
4134
- "allowNo": false,
4135
- "type": "boolean"
4078
+ "skipauth": {
4079
+ "description": "Skip authentication check when a default username is required",
4080
+ "name": "skipauth",
4081
+ "allowNo": false,
4082
+ "type": "boolean"
4083
+ },
4084
+ "target-dev-hub": {
4085
+ "aliases": [
4086
+ "targetdevhubusername"
4087
+ ],
4088
+ "char": "v",
4089
+ "deprecateAliases": true,
4090
+ "name": "target-dev-hub",
4091
+ "noCacheDefault": true,
4092
+ "required": false,
4093
+ "summary": "Username or alias of the Dev Hub org.",
4094
+ "hasDynamicHelp": true,
4095
+ "multiple": false,
4096
+ "type": "option"
4097
+ },
4098
+ "target-org": {
4099
+ "aliases": [
4100
+ "targetusername",
4101
+ "u"
4102
+ ],
4103
+ "char": "o",
4104
+ "deprecateAliases": true,
4105
+ "name": "target-org",
4106
+ "noCacheDefault": true,
4107
+ "summary": "Username or alias of the target org.",
4108
+ "hasDynamicHelp": true,
4109
+ "multiple": false,
4110
+ "type": "option"
4136
4111
  }
4137
4112
  },
4138
- "hasDynamicHelp": false,
4113
+ "hasDynamicHelp": true,
4139
4114
  "hiddenAliases": [],
4140
- "id": "hardis:work:ws",
4115
+ "id": "hardis:work:new",
4141
4116
  "pluginAlias": "sfdx-hardis",
4142
4117
  "pluginName": "sfdx-hardis",
4143
4118
  "pluginType": "core",
4144
4119
  "strict": true,
4145
4120
  "enableJsonFlag": true,
4146
- "title": "WebSocket operations",
4147
- "uiConfig": {
4148
- "hide": true
4149
- },
4150
- "requiresProject": false,
4121
+ "title": "New User Story",
4122
+ "requiresProject": true,
4151
4123
  "isESM": true,
4152
4124
  "relativePath": [
4153
4125
  "lib",
4154
4126
  "commands",
4155
4127
  "hardis",
4156
4128
  "work",
4157
- "ws.js"
4129
+ "new.js"
4158
4130
  ],
4159
4131
  "aliasPermutations": [],
4160
4132
  "permutations": [
4161
- "hardis:work:ws",
4162
- "work:hardis:ws",
4163
- "work:ws:hardis",
4164
- "hardis:ws:work",
4165
- "ws:hardis:work",
4166
- "ws:work:hardis"
4133
+ "hardis:work:new",
4134
+ "work:hardis:new",
4135
+ "work:new:hardis",
4136
+ "hardis:new:work",
4137
+ "new:hardis:work",
4138
+ "new:work:hardis"
4167
4139
  ]
4168
4140
  },
4169
- "hardis:scratch:create": {
4141
+ "hardis:work:refresh": {
4170
4142
  "aliases": [],
4171
4143
  "args": {},
4172
- "description": "\n## Command Behavior\n\n**Creates and fully initializes a Salesforce scratch org with complete development environment setup.**\n\nThis command is a comprehensive scratch org provisioning tool that automates the entire process of creating, configuring, and initializing a Salesforce scratch org for development work. It handles everything from basic org creation to advanced configuration including package installation, metadata deployment, and data initialization.\n\nKey functionalities:\n\n- **Intelligent Org Management:** Automatically generates unique scratch org aliases based on username, git branch, and timestamp, with options to reuse existing orgs or force creation of new ones.\n- **Scratch Org Pool Integration:** Supports fetching pre-configured scratch orgs from pools for faster development cycles and CI/CD optimization.\n- **Custom Scratch Definition:** Dynamically builds project-scratch-def.json files with user-specific configurations including email, username patterns, and org shape settings (set variable **SCRATCH_ORG_SHAPE** to use org shapes).\n- **Package Installation:** Automatically installs all configured packages defined in `installedPackages` configuration property.\n- **Metadata Deployment:** Pushes source code and deploys metadata using optimized deployment strategies for scratch org environments.\n- **Permission Set Assignment:** Assigns specified permission sets defined in `initPermissionSets` configuration to the scratch org user.\n- **Apex Script Execution:** Runs custom Apex initialization scripts defined in `scratchOrgInitApexScripts` for org-specific setup.\n- **Data Loading:** Loads initial data using SFDMU data packages from `dataPackages` configuration for realistic development environments.\n- **User Configuration:** Automatically configures the scratch org admin user with proper names, email, country settings, and marketing user permissions.\n- **Password Generation:** Creates and stores secure passwords for easy scratch org access during development.\n- **CI/CD Integration:** Provides specialized handling for continuous integration environments including automated cleanup and pool management.\n- **Error Handling:** Comprehensive error recovery including scratch org cleanup on failure and detailed troubleshooting messages.\n\nThe command configuration can be customized using:\n\n- `config/.sfdx-hardis.yml` file with properties like `installedPackages`, `initPermissionSets`, `scratchOrgInitApexScripts`, and `dataPackages`.\n- Environment variable **SCRATCH_ORG_SHAPE** with shape org id, if you want to use org shapes\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Configuration Management:** Loads hierarchical configuration from `.sfdx-hardis.yml`, branch-specific, and user-specific configuration files using `getConfig('user')`.\n- **Alias Generation Logic:** Creates intelligent scratch org aliases using username, git branch, timestamp patterns with CI and pool prefixes for different environments.\n- **Scratch Org Definition Building:** Dynamically constructs `project-scratch-def.json` with user email, custom usernames, org shapes, and feature flags like StateAndCountryPicklist and MarketingUser.\n- **Pool Integration:** Implements scratch org pool fetching using `fetchScratchOrg` for rapid org provisioning in development and CI environments.\n- **Salesforce CLI Integration:** Executes `sf org create scratch` commands with proper parameter handling including wait times, duration, and dev hub targeting.\n- **Package Installation Pipeline:** Uses `installPackages` utility to install managed and unmanaged packages with dependency resolution and error handling.\n- **Metadata Deployment:** Leverages `initOrgMetadatas` for optimized source pushing and metadata deployment specific to scratch org environments.\n- **Permission Set Assignment:** Implements `initPermissionSetAssignments` for automated permission set assignment to scratch org users.\n- **Apex Script Execution:** Runs custom Apex initialization scripts using `initApexScripts` for org-specific configuration and setup.\n- **Data Loading Integration:** Uses SFDMU integration through `initOrgData` for comprehensive data loading from configured data packages.\n- **User Management:** Performs SOQL queries and DML operations to configure scratch org users with proper names, emails, country codes, and permission flags.\n- **Authentication Management:** Handles SFDX auth URL generation and storage for CI/CD environments and scratch org pool management.\n- **Error Recovery:** Implements comprehensive error handling with scratch org cleanup, pool management, and detailed error messaging for troubleshooting.\n- **WebSocket Integration:** Provides real-time status updates and file reporting through WebSocket connections for VS Code extension integration.\n</details>\n",
4144
+ "description": "\n## Command Behavior\n\n**Refreshes your local Git branch and Salesforce org with the latest content from another Git branch.**\n\nThis command is designed to help developers keep their local development environment synchronized with changes made by other team members. It automates the process of pulling updates from a designated branch, merging them into your current working branch, and then pushing those changes to your scratch org or source-tracked sandbox.\n\nKey functionalities:\n\n- **Pre-Merge Check:** Prompts the user to confirm that they have saved their current work before proceeding with the merge, preventing accidental data loss.\n- **Branch Selection:** Allows you to select a target Git branch (e.g., `integration`, `preprod`) from which to pull updates.\n- **Git Operations:** Performs a series of Git operations:\n - Pulls the latest version of the selected merge branch.\n - Stashes your uncommitted local changes before merging.\n - Merges the selected branch into your current local branch.\n - Handles merge conflicts interactively, prompting the user to resolve them.\n - Restores your stashed changes after the merge.\n- **Org Synchronization:** Pushes the updated local branch content to your scratch org or source-tracked sandbox, ensuring your org reflects the latest merged code.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Configuration Loading:** It retrieves project configurations using `getConfig` to determine the default development branch.\n- **Git Integration:** Extensively uses `simple-git` (`git()`) for various Git operations:\n - `git().branch()`: Lists local and remote branches.\n - `git().stash()`: Saves and restores uncommitted changes.\n - `git().fetch()`: Fetches updates from remote repositories.\n - `git().checkout()`: Switches between branches.\n - `git().pull()`: Pulls changes from a remote branch.\n - `git().merge()`: Merges one branch into another, handling conflicts.\n- **Interactive Prompts:** Uses the `prompts` library to guide the user through confirmations (e.g., saving work) and branch selection.\n- **Salesforce CLI Integration:** It uses `forceSourcePull` to pull changes from the scratch org and `forceSourcePush` to push changes to the scratch org.\n- **Error Handling:** Includes robust error handling for Git operations (e.g., merge conflicts) and provides guidance to the user for resolution.\n- **Environment Variable Check:** Checks for an `EXPERIMENTAL` environment variable to gate access to this command, indicating it might not be fully stable.\n</details>\n",
4173
4145
  "examples": [
4174
- "$ sf hardis:scratch:create"
4146
+ "$ sf hardis:work:refresh"
4175
4147
  ],
4176
4148
  "flags": {
4177
4149
  "json": {
@@ -4189,16 +4161,10 @@
4189
4161
  "multiple": false,
4190
4162
  "type": "option"
4191
4163
  },
4192
- "forcenew": {
4164
+ "nopull": {
4193
4165
  "char": "n",
4194
- "description": "If an existing scratch org exists, do not reuse it but create a new one",
4195
- "name": "forcenew",
4196
- "allowNo": false,
4197
- "type": "boolean"
4198
- },
4199
- "pool": {
4200
- "description": "Creates the scratch org for a scratch org pool",
4201
- "name": "pool",
4166
+ "description": "No scratch pull before save (careful if you use that!)",
4167
+ "name": "nopull",
4202
4168
  "allowNo": false,
4203
4169
  "type": "boolean"
4204
4170
  },
@@ -4222,16 +4188,17 @@
4222
4188
  "allowNo": false,
4223
4189
  "type": "boolean"
4224
4190
  },
4225
- "target-dev-hub": {
4191
+ "target-org": {
4226
4192
  "aliases": [
4227
- "targetdevhubusername"
4193
+ "targetusername",
4194
+ "u"
4228
4195
  ],
4229
- "char": "v",
4196
+ "char": "o",
4230
4197
  "deprecateAliases": true,
4231
- "name": "target-dev-hub",
4198
+ "name": "target-org",
4232
4199
  "noCacheDefault": true,
4233
4200
  "required": true,
4234
- "summary": "Username or alias of the Dev Hub org. Not required if the `target-dev-hub` configuration variable is already set.",
4201
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
4235
4202
  "hasDynamicHelp": true,
4236
4203
  "multiple": false,
4237
4204
  "type": "option"
@@ -4239,41 +4206,38 @@
4239
4206
  },
4240
4207
  "hasDynamicHelp": true,
4241
4208
  "hiddenAliases": [],
4242
- "id": "hardis:scratch:create",
4209
+ "id": "hardis:work:refresh",
4243
4210
  "pluginAlias": "sfdx-hardis",
4244
4211
  "pluginName": "sfdx-hardis",
4245
4212
  "pluginType": "core",
4246
4213
  "strict": true,
4247
4214
  "enableJsonFlag": true,
4248
- "title": "Create and initialize scratch org",
4215
+ "title": "Refresh User Story branch",
4249
4216
  "requiresProject": true,
4250
- "requiresSfdxPlugins": [
4251
- "sfdmu"
4252
- ],
4253
4217
  "isESM": true,
4254
4218
  "relativePath": [
4255
4219
  "lib",
4256
4220
  "commands",
4257
4221
  "hardis",
4258
- "scratch",
4259
- "create.js"
4222
+ "work",
4223
+ "refresh.js"
4260
4224
  ],
4261
4225
  "aliasPermutations": [],
4262
4226
  "permutations": [
4263
- "hardis:scratch:create",
4264
- "scratch:hardis:create",
4265
- "scratch:create:hardis",
4266
- "hardis:create:scratch",
4267
- "create:hardis:scratch",
4268
- "create:scratch:hardis"
4227
+ "hardis:work:refresh",
4228
+ "work:hardis:refresh",
4229
+ "work:refresh:hardis",
4230
+ "hardis:refresh:work",
4231
+ "refresh:hardis:work",
4232
+ "refresh:work:hardis"
4269
4233
  ]
4270
4234
  },
4271
- "hardis:scratch:delete": {
4235
+ "hardis:work:resetselection": {
4272
4236
  "aliases": [],
4273
4237
  "args": {},
4274
- "description": "## Command Behavior\n\n**Provides an assisted menu to delete Salesforce scratch orgs associated with a Dev Hub.**\n\nThis command simplifies the process of cleaning up your Salesforce development environments by allowing you to easily select and delete multiple scratch orgs. This is crucial for managing your scratch org limits and ensuring that you don't accumulate unnecessary or expired orgs.\n\nKey functionalities:\n\n- **Interactive Scratch Org Selection:** Displays a list of all active scratch orgs linked to your Dev Hub, including their usernames, instance URLs, and last used dates.\n- **Multi-Selection:** Allows you to select multiple scratch orgs for deletion.\n- **Confirmation Prompt:** Prompts for confirmation before proceeding with the deletion, ensuring that you don't accidentally delete important orgs.\n- **Dev Hub Integration:** Works with your configured Dev Hub to manage scratch orgs.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce CLI Integration:** It executes the `sf org list` command to retrieve a list of all scratch orgs associated with the current Dev Hub. It then filters this list to show only active orgs.\n- **Interactive Prompts:** Uses the `prompts` library to present a multi-select menu of scratch orgs to the user.\n- **Scratch Org Deletion:** For each selected scratch org, it executes the `sf org delete scratch --no-prompt` command to perform the deletion.\n- **Error Handling:** Includes basic error handling for Salesforce CLI commands.\n- **Data Sorting:** Sorts the list of scratch orgs by username, alias, and instance URL for better readability in the interactive menu.\n</details>\n",
4238
+ "description": "\n## Command Behavior\n\n**Resets the local Git repository to allow for a new selection of files to be included in a merge request.**\n\nThis command is designed to be used when you need to re-evaluate which changes should be part of your next merge request. It performs a soft Git reset, effectively unstaging all committed changes since the last merge with the target branch, and then cleans up any generated files.\n\nKey functionalities:\n\n- **Target Branch Selection:** Prompts you to select the target branch of your current or future merge request.\n- **Soft Git Reset:** Performs a `git reset --soft` operation to uncommit changes, moving the HEAD pointer back but keeping the changes in your working directory.\n- **Generated File Cleanup:** Resets and checks out `manifest/package.xml` and `manifest/destructiveChanges.xml` to their state before the reset, ensuring a clean slate for new selections.\n- **Force Push Authorization:** Sets a flag in your user configuration (`canForcePush: true`) to allow a force push in the subsequent `hardis:work:save` command, as the history will have been rewritten.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Git Integration:** Uses `simple-git` (`git()`) to interact with the Git repository:\n - `git().branch()`: Retrieves information about local and remote branches.\n - `git().log()`: Fetches the commit history to determine which commits to reset.\n - `git().reset()`: Performs the soft reset operation.\n - `git().checkout()`: Resets specific files (`package.xml`, `destructiveChanges.xml`) to their previous state.\n - `git().status()`: Displays the current status of the Git repository after the reset.\n- **Interactive Prompts:** Uses the `prompts` library to confirm the reset operation with the user and to select the target branch.\n- **Configuration Management:** Updates the user's configuration (`.sfdx-hardis.yml`) using `setConfig` to set the `canForcePush` flag.\n- **Error Handling:** Includes a check to prevent resetting protected branches.\n</details>\n",
4275
4239
  "examples": [
4276
- "$ sf hardis:scratch:delete"
4240
+ "$ sf hardis:work:resetsave"
4277
4241
  ],
4278
4242
  "flags": {
4279
4243
  "json": {
@@ -4311,16 +4275,17 @@
4311
4275
  "allowNo": false,
4312
4276
  "type": "boolean"
4313
4277
  },
4314
- "target-dev-hub": {
4278
+ "target-org": {
4315
4279
  "aliases": [
4316
- "targetdevhubusername"
4280
+ "targetusername",
4281
+ "u"
4317
4282
  ],
4318
- "char": "v",
4283
+ "char": "o",
4319
4284
  "deprecateAliases": true,
4320
- "name": "target-dev-hub",
4285
+ "name": "target-org",
4321
4286
  "noCacheDefault": true,
4322
4287
  "required": true,
4323
- "summary": "Username or alias of the Dev Hub org. Not required if the `target-dev-hub` configuration variable is already set.",
4288
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
4324
4289
  "hasDynamicHelp": true,
4325
4290
  "multiple": false,
4326
4291
  "type": "option"
@@ -4328,37 +4293,39 @@
4328
4293
  },
4329
4294
  "hasDynamicHelp": true,
4330
4295
  "hiddenAliases": [],
4331
- "id": "hardis:scratch:delete",
4296
+ "id": "hardis:work:resetselection",
4332
4297
  "pluginAlias": "sfdx-hardis",
4333
4298
  "pluginName": "sfdx-hardis",
4334
4299
  "pluginType": "core",
4335
4300
  "strict": true,
4336
4301
  "enableJsonFlag": true,
4337
- "title": "Delete scratch orgs(s)",
4302
+ "title": "Select again",
4303
+ "requiresProject": true,
4338
4304
  "isESM": true,
4339
4305
  "relativePath": [
4340
4306
  "lib",
4341
4307
  "commands",
4342
4308
  "hardis",
4343
- "scratch",
4344
- "delete.js"
4309
+ "work",
4310
+ "resetselection.js"
4345
4311
  ],
4346
4312
  "aliasPermutations": [],
4347
4313
  "permutations": [
4348
- "hardis:scratch:delete",
4349
- "scratch:hardis:delete",
4350
- "scratch:delete:hardis",
4351
- "hardis:delete:scratch",
4352
- "delete:hardis:scratch",
4353
- "delete:scratch:hardis"
4314
+ "hardis:work:resetselection",
4315
+ "work:hardis:resetselection",
4316
+ "work:resetselection:hardis",
4317
+ "hardis:resetselection:work",
4318
+ "resetselection:hardis:work",
4319
+ "resetselection:work:hardis"
4354
4320
  ]
4355
4321
  },
4356
- "hardis:scratch:pull": {
4322
+ "hardis:work:save": {
4357
4323
  "aliases": [],
4358
4324
  "args": {},
4359
- "description": "\n## Command Behavior\n\n**Pulls metadata changes from your scratch org or source-tracked sandbox into your local project files.**\n\nThis command is essential for synchronizing your local development environment with the changes you've made directly in your Salesforce org. After pulling, you can then stage and commit the relevant files to your version control system.\n\nKey features and considerations:\n\n- **Underlying Command:** Internally, this command executes `sf project retrieve start` to fetch the metadata.\n- **Error Handling:** If the pull operation encounters errors, it offers to automatically add the problematic items to your `.forceignore` file and then attempts to pull again, helping you resolve conflicts and ignore unwanted metadata.\n- **Missing Updates:** If you don't see certain updated items in the pull results, you might need to manually retrieve them using the Salesforce Extension's **Org Browser** or the **Salesforce CLI** directly. Refer to the [Retrieve Metadatas documentation](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-publish-task/#retrieve-metadatas) for more details.\n- **Automatic Retrieval:** You can configure the `autoRetrieveWhenPull` property in your `.sfdx-hardis.yml` file to always retrieve specific metadata types (e.g., `CustomApplication`) that might not always be detected as updates by `project:retrieve:start`.\n\nExample `.sfdx-hardis.yml` configuration for `autoRetrieveWhenPull`:\n```yaml\nautoRetrieveWhenPull:\n - CustomApplication:MyCustomApplication\n - CustomApplication:MyOtherCustomApplication\n - CustomApplication:MyThirdCustomApp\n```\n\nFor a visual explanation of the process, watch this video:\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/Ik6whtflmfY\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation focuses on robust metadata synchronization:\n\n- **Salesforce CLI Wrapper:** It acts as a wrapper around the standard Salesforce CLI `sf project retrieve start` command, providing enhanced error handling and configuration options.\n- **Force Source Pull Utility:** The core logic resides in the `forceSourcePull` utility function, which orchestrates the retrieval process, including handling `.forceignore` updates.\n- **Configuration Integration:** It reads the `autoRetrieveWhenPull` setting from the project's `.sfdx-hardis.yml` to determine additional metadata to retrieve automatically.\n- **User Feedback:** Provides clear messages to the user regarding the pull status and guidance for troubleshooting.\n</details>\n",
4325
+ "description": "\n## Command Behavior\n\n**Guides the user through the process of saving their work, preparing it for a Merge Request (also named Pull Request), and pushing changes to the remote Git repository.**\n\nThis command automates several critical steps involved in finalizing a development User Story and integrating it into the main codebase. It ensures that your local changes are properly synchronized, cleaned, and committed before being pushed.\n\nKey functionalities include:\n\n- **Git Status Management:** Ensures a clean Git working directory by handling ongoing merges and unstaging files.\n- **Org Synchronization (Optional):** Prompts the user to pull the latest metadata updates from their scratch org or source-tracked sandbox, ensuring local files reflect the org's state.\n- **Package.xml Updates:** Automatically generates `package.xml` and `destructiveChanges.xml` files based on the Git delta between your current branch and the target branch, reflecting added, modified, and deleted metadata.\n- **Automated Source Cleaning:** Applies predefined cleaning operations to your local Salesforce sources, such as removing unwanted references, minimizing profiles, or cleaning XML files based on configurations in your `.sfdx-hardis.yml`.\n - `autoCleanTypes`: A list of automated source cleanings, configurable via [hardis:project:clean:references](${CONSTANTS.DOC_URL_ROOT}/hardis/project/clean/references/).\n - `autoRemoveUserPermissions`: A list of user permissions to automatically remove from profile metadata.\n- **Deployment Plan Generation:** Builds an automated deployment plan based on the updated `package.xml` and configured deployment splits.\n- **Commit and Push:** Guides the user to commit the changes and push them to the remote Git repository, optionally handling force pushes if a branch reset occurred.\n- **Merge Request Guidance:** Provides information and links to facilitate the creation of a merge request after the changes are pushed.\n\nExample `.sfdx-hardis.yml` configuration:\n\n```yaml\nautoCleanTypes:\n - checkPermissions\n - destructivechanges\n - datadotcom\n - minimizeProfiles\n - listViewsMine\nautoRemoveUserPermissions:\n - EnableCommunityAppLauncher\n - FieldServiceAccess\n - OmnichannelInventorySync\n - SendExternalEmailAvailable\n - UseOmnichannelInventoryAPIs\n - ViewDataLeakageEvents\n - ViewMLModels\n - ViewPlatformEvents\n - WorkCalibrationUser\n```\n\nAdvanced instructions are available in the [Publish a User Story documentation](${CONSTANTS.DOC_URL_ROOT}/salesforce-ci-cd-publish-task/).\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves a series of orchestrated steps:\n\n- **Git Integration:** Extensively uses the `git` utility for status checks, adding files, committing, and pushing. It also leverages `sfdx-git-delta` for generating metadata differences between Git revisions.\n- **Interactive Prompts:** Employs the `prompts` library to interact with the user for decisions like pulling sources or pushing commits.\n- **Configuration Management:** Reads and updates project and user configurations using `getConfig` and `setConfig` to store preferences and deployment plans.\n- **Metadata Synchronization:** Calls `forceSourcePull` to retrieve metadata from the org and `callSfdxGitDelta` to generate `package.xml` and `destructiveChanges.xml` based on Git changes.\n- **XML Manipulation:** Utilizes `appendPackageXmlFilesContent`, `removePackageXmlFilesContent`, `parseXmlFile`, and `writeXmlFile` for modifying `package.xml` and `destructiveChanges.xml` files.\n- **Automated Cleaning:** Integrates with `CleanReferences.run` and `CleanXml.run` commands to perform automated cleaning operations on the Salesforce source files.\n- **Deployment Plan Building:** Dynamically constructs a deployment plan by analyzing the `package.xml` content and applying configured deployment splits.\n- **WebSocket Communication:** Uses `WebSocketClient.sendRefreshStatusMessage` to notify connected VS Code clients about status updates.\n- **External Tool Integration:** Requires the `sfdx-git-delta` plugin to be installed for its core functionality.\n</details>\n",
4360
4326
  "examples": [
4361
- "$ sf hardis:scratch:pull"
4327
+ "$ sf hardis:work:task:save",
4328
+ "$ sf hardis:work:task:save --nopull --nogit --noclean"
4362
4329
  ],
4363
4330
  "flags": {
4364
4331
  "json": {
@@ -4376,6 +4343,40 @@
4376
4343
  "multiple": false,
4377
4344
  "type": "option"
4378
4345
  },
4346
+ "nopull": {
4347
+ "char": "n",
4348
+ "description": "No scratch pull before save",
4349
+ "name": "nopull",
4350
+ "allowNo": false,
4351
+ "type": "boolean"
4352
+ },
4353
+ "nogit": {
4354
+ "char": "g",
4355
+ "description": "No automated git operations",
4356
+ "name": "nogit",
4357
+ "allowNo": false,
4358
+ "type": "boolean"
4359
+ },
4360
+ "noclean": {
4361
+ "char": "c",
4362
+ "description": "No cleaning of local sources",
4363
+ "name": "noclean",
4364
+ "allowNo": false,
4365
+ "type": "boolean"
4366
+ },
4367
+ "auto": {
4368
+ "description": "No user prompts (when called from CI for example)",
4369
+ "name": "auto",
4370
+ "allowNo": false,
4371
+ "type": "boolean"
4372
+ },
4373
+ "targetbranch": {
4374
+ "description": "Name of the Merge Request target branch. Will be guessed or prompted if not provided.",
4375
+ "name": "targetbranch",
4376
+ "hasDynamicHelp": false,
4377
+ "multiple": false,
4378
+ "type": "option"
4379
+ },
4379
4380
  "debug": {
4380
4381
  "char": "d",
4381
4382
  "description": "Activate debug mode (more logs)",
@@ -4414,38 +4415,41 @@
4414
4415
  },
4415
4416
  "hasDynamicHelp": true,
4416
4417
  "hiddenAliases": [],
4417
- "id": "hardis:scratch:pull",
4418
+ "id": "hardis:work:save",
4418
4419
  "pluginAlias": "sfdx-hardis",
4419
4420
  "pluginName": "sfdx-hardis",
4420
4421
  "pluginType": "core",
4421
4422
  "strict": true,
4422
4423
  "enableJsonFlag": true,
4423
- "title": "Scratch PULL",
4424
+ "title": "Save User Story",
4424
4425
  "requiresProject": true,
4426
+ "requiresSfdxPlugins": [
4427
+ "sfdx-git-delta"
4428
+ ],
4425
4429
  "isESM": true,
4426
4430
  "relativePath": [
4427
4431
  "lib",
4428
4432
  "commands",
4429
4433
  "hardis",
4430
- "scratch",
4431
- "pull.js"
4434
+ "work",
4435
+ "save.js"
4432
4436
  ],
4433
4437
  "aliasPermutations": [],
4434
4438
  "permutations": [
4435
- "hardis:scratch:pull",
4436
- "scratch:hardis:pull",
4437
- "scratch:pull:hardis",
4438
- "hardis:pull:scratch",
4439
- "pull:hardis:scratch",
4440
- "pull:scratch:hardis"
4439
+ "hardis:work:save",
4440
+ "work:hardis:save",
4441
+ "work:save:hardis",
4442
+ "hardis:save:work",
4443
+ "save:hardis:work",
4444
+ "save:work:hardis"
4441
4445
  ]
4442
4446
  },
4443
- "hardis:scratch:push": {
4447
+ "hardis:work:ws": {
4444
4448
  "aliases": [],
4445
4449
  "args": {},
4446
- "description": "## Command Behavior\n\n**Pushes local Salesforce DX source files to a scratch org or source-tracked sandbox.**\n\nThis command is a fundamental operation in Salesforce DX development, allowing developers to synchronize their local codebase with their development org. It ensures that changes made locally are reflected in the scratch org, enabling testing and validation.\n\nKey functionalities:\n\n- **Source Synchronization:** Deploys all local changes (metadata and code) to the target scratch org.\n- **Underlying Command:** Internally, this command executes `sf project deploy start` to perform the push operation.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce CLI Wrapper:** It acts as a wrapper around the standard Salesforce CLI `sf project deploy start` command.\n- **`forceSourcePush` Utility:** The core logic resides in the `forceSourcePush` utility function, which orchestrates the deployment process.\n- **Connection Handling:** It uses the connection to the target org to perform the push operation.\n</details>\n",
4450
+ "description": "\n## Command Behavior\n\n**Performs technical operations related to WebSocket communication, primarily for internal use by the sfdx-hardis VS Code extension.**\n\nThis command is not intended for direct end-user interaction. It facilitates communication between the sfdx-hardis CLI and the VS Code Extension, enabling features like real-time status updates and plugin refreshes.\n\nKey functionalities:\n\n- **Refresh Status (`--event refreshStatus`):** Sends a message to the VS Code Extension to refresh its displayed status, ensuring that the UI reflects the latest state of Salesforce orgs or project activities.\n- **Refresh Plugins (`--event refreshPlugins`):** Sends a message to the VS Code Extension to refresh its loaded plugins, useful after installing or updating sfdx-hardis or other related extensions.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **WebSocketClient:** It utilizes the `WebSocketClient` utility to establish and manage WebSocket connections.\n- **Event-Driven Communication:** It listens for specific events (e.g., `refreshStatus`, `refreshPlugins`) and triggers corresponding actions on the connected WebSocket client.\n- **Internal Use:** This command is primarily called programmatically by the VS Code Extension to maintain synchronization and provide a seamless user experience.\n</details>\n",
4447
4451
  "examples": [
4448
- "$ sf hardis:scratch:push"
4452
+ "$ sf hardis:work:ws --event refreshStatus"
4449
4453
  ],
4450
4454
  "flags": {
4451
4455
  "json": {
@@ -4463,6 +4467,14 @@
4463
4467
  "multiple": false,
4464
4468
  "type": "option"
4465
4469
  },
4470
+ "event": {
4471
+ "char": "e",
4472
+ "description": "WebSocket event",
4473
+ "name": "event",
4474
+ "hasDynamicHelp": false,
4475
+ "multiple": false,
4476
+ "type": "option"
4477
+ },
4466
4478
  "debug": {
4467
4479
  "char": "d",
4468
4480
  "description": "Activate debug mode (more logs)",
@@ -4482,49 +4494,37 @@
4482
4494
  "name": "skipauth",
4483
4495
  "allowNo": false,
4484
4496
  "type": "boolean"
4485
- },
4486
- "target-org": {
4487
- "aliases": [
4488
- "targetusername",
4489
- "u"
4490
- ],
4491
- "char": "o",
4492
- "deprecateAliases": true,
4493
- "name": "target-org",
4494
- "noCacheDefault": true,
4495
- "required": true,
4496
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
4497
- "hasDynamicHelp": true,
4498
- "multiple": false,
4499
- "type": "option"
4500
4497
  }
4501
4498
  },
4502
- "hasDynamicHelp": true,
4499
+ "hasDynamicHelp": false,
4503
4500
  "hiddenAliases": [],
4504
- "id": "hardis:scratch:push",
4501
+ "id": "hardis:work:ws",
4505
4502
  "pluginAlias": "sfdx-hardis",
4506
4503
  "pluginName": "sfdx-hardis",
4507
4504
  "pluginType": "core",
4508
4505
  "strict": true,
4509
4506
  "enableJsonFlag": true,
4510
- "title": "Scratch PUSH",
4511
- "requiresProject": true,
4507
+ "title": "WebSocket operations",
4508
+ "uiConfig": {
4509
+ "hide": true
4510
+ },
4511
+ "requiresProject": false,
4512
4512
  "isESM": true,
4513
4513
  "relativePath": [
4514
4514
  "lib",
4515
4515
  "commands",
4516
4516
  "hardis",
4517
- "scratch",
4518
- "push.js"
4517
+ "work",
4518
+ "ws.js"
4519
4519
  ],
4520
4520
  "aliasPermutations": [],
4521
4521
  "permutations": [
4522
- "hardis:scratch:push",
4523
- "scratch:hardis:push",
4524
- "scratch:push:hardis",
4525
- "hardis:push:scratch",
4526
- "push:hardis:scratch",
4527
- "push:scratch:hardis"
4522
+ "hardis:work:ws",
4523
+ "work:hardis:ws",
4524
+ "work:ws:hardis",
4525
+ "hardis:ws:work",
4526
+ "ws:hardis:work",
4527
+ "ws:work:hardis"
4528
4528
  ]
4529
4529
  },
4530
4530
  "hardis:datacloud:extract:agentforce-conversations": {
@@ -5924,6 +5924,275 @@
5924
5924
  "import:data:org:hardis"
5925
5925
  ]
5926
5926
  },
5927
+ "hardis:org:files:export": {
5928
+ "aliases": [],
5929
+ "args": {},
5930
+ "description": "\n## Command Behavior\n\n**Exports file attachments (ContentVersion, Attachment) from a Salesforce org based on a predefined configuration.**\n\nThis command enables the mass download of files associated with Salesforce records, providing a robust solution for backing up files, migrating them to other systems, or integrating them with external document management solutions.\n\nKey functionalities:\n\n- **Configuration-Driven Export:** Relies on an `export.json` file within a designated file export project to define the export criteria, including the SOQL query for parent records, file types to export, output naming conventions, and file size filtering.\n- **File Size Filtering:** Supports minimum file size filtering via the `fileSizeMin` configuration parameter (in KB). Files smaller than the specified size will be skipped during export.\n- **File Validation:** After downloading each file, validates the integrity by:\n - **Checksum Validation:** For ContentVersion files, compares MD5 checksum with Salesforce's stored checksum\n - **Size Validation:** For both ContentVersion and Attachment files, verifies actual file size matches expected size\n - **Status Tracking:** Files are categorized with specific statuses: `success` (valid files), `failed` (download errors), `skipped` (filtered files), `invalid` (downloaded but failed validation)\n - All validation results are logged in the CSV export log for audit purposes\n- **Resume/Restart Capability:** \n - **Resume Mode:** When `--resume` flag is used (default in CI environments), checks existing downloaded files for validity. Valid files are skipped, invalid files are re-downloaded.\n - **Restart Mode:** When resume is disabled, clears the output folder and starts a fresh export.\n - **Interactive Mode:** When existing files are found and `--resume` is not explicitly specified (non-CI environments), prompts the user to choose between resume or restart.\n- **Interactive Project Selection:** If the file export project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Configurable Export Options:** Allows overriding default export settings such as `chunksize` (number of records processed in a batch), `polltimeout` (timeout for Bulk API calls), and `startchunknumber` (to resume a failed export).\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for a practical example:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesExporter Class:** The core logic is encapsulated within the `FilesExporter` class, which orchestrates the entire export process.\n- **SOQL Queries (Bulk API):** It uses Salesforce Bulk API queries to efficiently retrieve large volumes of parent record IDs and file metadata, including checksums and file sizes.\n- **File Download:** Downloads the actual file content from Salesforce.\n- **File Validation:** After each successful download, validates file integrity by comparing checksums (ContentVersion) and file sizes (both ContentVersion and Attachment) against Salesforce metadata.\n- **Resume Logic:** In resume mode, checks for existing files before downloading, validates their integrity, and only re-downloads invalid or missing files. This enables efficient recovery from interrupted exports.\n- **File System Operations:** Writes the downloaded files to the local file system, organizing them into folders based on the configured naming conventions.\n- **Configuration Loading:** Reads the `export.json` file to get the export configuration. It also allows for interactive overriding of these settings.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file export project, `promptFilesExportConfiguration` for customizing export options, and prompts for resume/restart choice when existing files are found.\n- **Error Handling:** Includes mechanisms to handle potential errors during the export process, such as network issues, API limits, and file validation failures. Each file is assigned a specific status (`success`, `failed`, `skipped`, `invalid`) for comprehensive tracking and troubleshooting.\n</details>\n",
5931
+ "examples": [
5932
+ "$ sf hardis:org:files:export"
5933
+ ],
5934
+ "flags": {
5935
+ "json": {
5936
+ "description": "Format output as json.",
5937
+ "helpGroup": "GLOBAL",
5938
+ "name": "json",
5939
+ "allowNo": false,
5940
+ "type": "boolean"
5941
+ },
5942
+ "flags-dir": {
5943
+ "helpGroup": "GLOBAL",
5944
+ "name": "flags-dir",
5945
+ "summary": "Import flag values from a directory.",
5946
+ "hasDynamicHelp": false,
5947
+ "multiple": false,
5948
+ "type": "option"
5949
+ },
5950
+ "path": {
5951
+ "char": "p",
5952
+ "description": "Path to the file export project",
5953
+ "name": "path",
5954
+ "hasDynamicHelp": false,
5955
+ "multiple": false,
5956
+ "type": "option"
5957
+ },
5958
+ "chunksize": {
5959
+ "char": "c",
5960
+ "description": "Number of records to add in a chunk before it is processed",
5961
+ "name": "chunksize",
5962
+ "default": 1000,
5963
+ "hasDynamicHelp": false,
5964
+ "multiple": false,
5965
+ "type": "option"
5966
+ },
5967
+ "polltimeout": {
5968
+ "char": "t",
5969
+ "description": "Timeout in MS for Bulk API calls",
5970
+ "name": "polltimeout",
5971
+ "default": 300000,
5972
+ "hasDynamicHelp": false,
5973
+ "multiple": false,
5974
+ "type": "option"
5975
+ },
5976
+ "startchunknumber": {
5977
+ "char": "s",
5978
+ "description": "Chunk number to start from",
5979
+ "name": "startchunknumber",
5980
+ "default": 0,
5981
+ "hasDynamicHelp": false,
5982
+ "multiple": false,
5983
+ "type": "option"
5984
+ },
5985
+ "resume": {
5986
+ "char": "r",
5987
+ "description": "Resume previous export by checking existing files (default in CI)",
5988
+ "name": "resume",
5989
+ "allowNo": false,
5990
+ "type": "boolean"
5991
+ },
5992
+ "debug": {
5993
+ "char": "d",
5994
+ "description": "Activate debug mode (more logs)",
5995
+ "name": "debug",
5996
+ "allowNo": false,
5997
+ "type": "boolean"
5998
+ },
5999
+ "websocket": {
6000
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
6001
+ "name": "websocket",
6002
+ "hasDynamicHelp": false,
6003
+ "multiple": false,
6004
+ "type": "option"
6005
+ },
6006
+ "skipauth": {
6007
+ "description": "Skip authentication check when a default username is required",
6008
+ "name": "skipauth",
6009
+ "allowNo": false,
6010
+ "type": "boolean"
6011
+ },
6012
+ "target-org": {
6013
+ "aliases": [
6014
+ "targetusername",
6015
+ "u"
6016
+ ],
6017
+ "char": "o",
6018
+ "deprecateAliases": true,
6019
+ "name": "target-org",
6020
+ "noCacheDefault": true,
6021
+ "required": true,
6022
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
6023
+ "hasDynamicHelp": true,
6024
+ "multiple": false,
6025
+ "type": "option"
6026
+ }
6027
+ },
6028
+ "hasDynamicHelp": true,
6029
+ "hiddenAliases": [],
6030
+ "id": "hardis:org:files:export",
6031
+ "pluginAlias": "sfdx-hardis",
6032
+ "pluginName": "sfdx-hardis",
6033
+ "pluginType": "core",
6034
+ "strict": true,
6035
+ "enableJsonFlag": true,
6036
+ "title": "Export files",
6037
+ "requiresProject": false,
6038
+ "isESM": true,
6039
+ "relativePath": [
6040
+ "lib",
6041
+ "commands",
6042
+ "hardis",
6043
+ "org",
6044
+ "files",
6045
+ "export.js"
6046
+ ],
6047
+ "aliasPermutations": [],
6048
+ "permutations": [
6049
+ "hardis:org:files:export",
6050
+ "org:hardis:files:export",
6051
+ "org:files:hardis:export",
6052
+ "org:files:export:hardis",
6053
+ "hardis:files:org:export",
6054
+ "files:hardis:org:export",
6055
+ "files:org:hardis:export",
6056
+ "files:org:export:hardis",
6057
+ "hardis:files:export:org",
6058
+ "files:hardis:export:org",
6059
+ "files:export:hardis:org",
6060
+ "files:export:org:hardis",
6061
+ "hardis:org:export:files",
6062
+ "org:hardis:export:files",
6063
+ "org:export:hardis:files",
6064
+ "org:export:files:hardis",
6065
+ "hardis:export:org:files",
6066
+ "export:hardis:org:files",
6067
+ "export:org:hardis:files",
6068
+ "export:org:files:hardis",
6069
+ "hardis:export:files:org",
6070
+ "export:hardis:files:org",
6071
+ "export:files:hardis:org",
6072
+ "export:files:org:hardis"
6073
+ ]
6074
+ },
6075
+ "hardis:org:files:import": {
6076
+ "aliases": [],
6077
+ "args": {},
6078
+ "description": "\nThis command facilitates the mass upload of files into Salesforce, allowing you to populate records with associated documents, images, or other file types. It's a crucial tool for data migration, content seeding, or synchronizing external file repositories with Salesforce.\n\nKey functionalities:\n\n- **Configuration-Driven Import:** Relies on an `export.json` file within a designated file export project (created using `sf hardis:org:configure:files`) to determine which files to import and how they should be associated with Salesforce records.\n- **Interactive Project Selection:** If the file import project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Overwrite Option:** The `--overwrite` flag allows you to replace existing files in Salesforce with local versions that have the same name. Be aware that this option doubles the number of API calls used.\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for how to export files, which is often a prerequisite for importing:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesImporter Class:** The core logic is encapsulated within the `FilesImporter` class, which orchestrates the entire import process.\n- **File System Scan:** Scans the local file system within the configured project directory to identify files for import.\n- **Salesforce API Interaction:** Uses Salesforce APIs (e.g., ContentVersion, Attachment) to upload files and associate them with records.\n- **Configuration Loading:** Reads the `export.json` file to get the import configuration, including SOQL queries to identify parent records for file association.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file import project and `prompts` for confirming the overwrite behavior.\n- **Error Handling:** Includes mechanisms to handle potential errors during the import process, such as API limits or file upload failures.\n</details>\n",
6079
+ "examples": [
6080
+ "$ sf hardis:org:files:import"
6081
+ ],
6082
+ "flags": {
6083
+ "json": {
6084
+ "description": "Format output as json.",
6085
+ "helpGroup": "GLOBAL",
6086
+ "name": "json",
6087
+ "allowNo": false,
6088
+ "type": "boolean"
6089
+ },
6090
+ "flags-dir": {
6091
+ "helpGroup": "GLOBAL",
6092
+ "name": "flags-dir",
6093
+ "summary": "Import flag values from a directory.",
6094
+ "hasDynamicHelp": false,
6095
+ "multiple": false,
6096
+ "type": "option"
6097
+ },
6098
+ "path": {
6099
+ "char": "p",
6100
+ "description": "Path to the file export project",
6101
+ "name": "path",
6102
+ "hasDynamicHelp": false,
6103
+ "multiple": false,
6104
+ "type": "option"
6105
+ },
6106
+ "overwrite": {
6107
+ "char": "f",
6108
+ "description": "Override existing files (doubles the number of API calls)",
6109
+ "name": "overwrite",
6110
+ "allowNo": false,
6111
+ "type": "boolean"
6112
+ },
6113
+ "debug": {
6114
+ "char": "d",
6115
+ "description": "Activate debug mode (more logs)",
6116
+ "name": "debug",
6117
+ "allowNo": false,
6118
+ "type": "boolean"
6119
+ },
6120
+ "websocket": {
6121
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
6122
+ "name": "websocket",
6123
+ "hasDynamicHelp": false,
6124
+ "multiple": false,
6125
+ "type": "option"
6126
+ },
6127
+ "skipauth": {
6128
+ "description": "Skip authentication check when a default username is required",
6129
+ "name": "skipauth",
6130
+ "allowNo": false,
6131
+ "type": "boolean"
6132
+ },
6133
+ "target-org": {
6134
+ "aliases": [
6135
+ "targetusername",
6136
+ "u"
6137
+ ],
6138
+ "char": "o",
6139
+ "deprecateAliases": true,
6140
+ "name": "target-org",
6141
+ "noCacheDefault": true,
6142
+ "required": true,
6143
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
6144
+ "hasDynamicHelp": true,
6145
+ "multiple": false,
6146
+ "type": "option"
6147
+ }
6148
+ },
6149
+ "hasDynamicHelp": true,
6150
+ "hiddenAliases": [],
6151
+ "id": "hardis:org:files:import",
6152
+ "pluginAlias": "sfdx-hardis",
6153
+ "pluginName": "sfdx-hardis",
6154
+ "pluginType": "core",
6155
+ "strict": true,
6156
+ "enableJsonFlag": true,
6157
+ "title": "Import files",
6158
+ "requiresProject": false,
6159
+ "isESM": true,
6160
+ "relativePath": [
6161
+ "lib",
6162
+ "commands",
6163
+ "hardis",
6164
+ "org",
6165
+ "files",
6166
+ "import.js"
6167
+ ],
6168
+ "aliasPermutations": [],
6169
+ "permutations": [
6170
+ "hardis:org:files:import",
6171
+ "org:hardis:files:import",
6172
+ "org:files:hardis:import",
6173
+ "org:files:import:hardis",
6174
+ "hardis:files:org:import",
6175
+ "files:hardis:org:import",
6176
+ "files:org:hardis:import",
6177
+ "files:org:import:hardis",
6178
+ "hardis:files:import:org",
6179
+ "files:hardis:import:org",
6180
+ "files:import:hardis:org",
6181
+ "files:import:org:hardis",
6182
+ "hardis:org:import:files",
6183
+ "org:hardis:import:files",
6184
+ "org:import:hardis:files",
6185
+ "org:import:files:hardis",
6186
+ "hardis:import:org:files",
6187
+ "import:hardis:org:files",
6188
+ "import:org:hardis:files",
6189
+ "import:org:files:hardis",
6190
+ "hardis:import:files:org",
6191
+ "import:hardis:files:org",
6192
+ "import:files:hardis:org",
6193
+ "import:files:org:hardis"
6194
+ ]
6195
+ },
5927
6196
  "hardis:org:diagnose:audittrail": {
5928
6197
  "aliases": [],
5929
6198
  "args": {},
@@ -6671,246 +6940,9 @@
6671
6940
  "hardis:org:diagnose:unsecure-connected-apps": {
6672
6941
  "aliases": [],
6673
6942
  "args": {},
6674
- "description": "\n## Command Behavior\n\n**Detects unsecured Connected Apps in a Salesforce org and generates detailed reports for security analysis.**\n\nThis command is a critical security diagnostic tool that helps administrators identify Connected Apps that may pose security risks due to improper configuration. It provides comprehensive analysis of OAuth tokens and Connected App security settings to ensure proper access control.\n\nKey functionalities:\n\n- **OAuth Token Analysis:** Queries all OAuth tokens in the org using SOQL to retrieve comprehensive token information including app names, users, authorization status, and usage statistics.\n- **Security Status Assessment:** Evaluates each Connected App's security configuration by checking the `IsUsingAdminAuthorization` flag to determine if admin pre-approval is required.\n- **Unsecured App Detection:** Identifies Connected Apps that allow users to authorize themselves without admin approval, which can pose security risks.\n- **Detailed Reporting:** Generates two comprehensive CSV reports:\n - **OAuth Tokens Report:** Lists all OAuth tokens with security status, user information, and usage data\n - **Connected Apps Summary:** Aggregates unsecured Connected Apps with counts of associated OAuth tokens\n- **Visual Indicators:** Uses status icons (❌ for unsecured, ✅ for secured) to provide immediate visual feedback on security status.\n- **Security Recommendations:** Provides actionable guidance on how to secure Connected Apps through proper configuration.\n- **Notifications:** Sends alerts to configured channels (Grafana, Slack, MS Teams) with security findings and attached reports.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-org-security/) and can output Grafana, Slack and MsTeams Notifications.\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/jHv8yrSK8Dg\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query Execution:** Executes a comprehensive SOQL query on the `OauthToken` object, joining with `AppMenuItem` and `User` objects to gather complete security context.\n- **Security Analysis Logic:** Analyzes the `AppMenuItem.IsUsingAdminAuthorization` field to determine if a Connected App requires admin pre-approval for user authorization.\n- **Data Transformation:** Processes raw SOQL results to add security status indicators and reorganize data for optimal reporting and analysis.\n- **Aggregation Processing:** Groups OAuth tokens by Connected App name to provide summary statistics and identify the most problematic applications.\n- **Report Generation:** Uses `generateCsvFile` to create structured CSV reports with proper formatting and metadata for easy analysis and sharing.\n- **Notification Integration:** Integrates with the `NotifProvider` to send security alerts with detailed metrics, including the number of unsecured Connected Apps and associated OAuth tokens.\n- **File Management:** Generates multiple output formats (CSV, XLSX) and manages file paths using `generateReportPath` for consistent report organization.\n- **Connection Management:** Uses `setConnectionVariables` to ensure proper authentication context for notification providers that require org connection details.\n</details>\n",
6675
- "examples": [
6676
- "$ sf hardis:org:diagnose:unsecure-connected-apps"
6677
- ],
6678
- "flags": {
6679
- "json": {
6680
- "description": "Format output as json.",
6681
- "helpGroup": "GLOBAL",
6682
- "name": "json",
6683
- "allowNo": false,
6684
- "type": "boolean"
6685
- },
6686
- "flags-dir": {
6687
- "helpGroup": "GLOBAL",
6688
- "name": "flags-dir",
6689
- "summary": "Import flag values from a directory.",
6690
- "hasDynamicHelp": false,
6691
- "multiple": false,
6692
- "type": "option"
6693
- },
6694
- "outputfile": {
6695
- "char": "f",
6696
- "description": "Force the path and name of output report file. Must end with .csv",
6697
- "name": "outputfile",
6698
- "hasDynamicHelp": false,
6699
- "multiple": false,
6700
- "type": "option"
6701
- },
6702
- "debug": {
6703
- "char": "d",
6704
- "description": "Activate debug mode (more logs)",
6705
- "name": "debug",
6706
- "allowNo": false,
6707
- "type": "boolean"
6708
- },
6709
- "websocket": {
6710
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
6711
- "name": "websocket",
6712
- "hasDynamicHelp": false,
6713
- "multiple": false,
6714
- "type": "option"
6715
- },
6716
- "skipauth": {
6717
- "description": "Skip authentication check when a default username is required",
6718
- "name": "skipauth",
6719
- "allowNo": false,
6720
- "type": "boolean"
6721
- },
6722
- "target-org": {
6723
- "aliases": [
6724
- "targetusername",
6725
- "u"
6726
- ],
6727
- "char": "o",
6728
- "deprecateAliases": true,
6729
- "name": "target-org",
6730
- "noCacheDefault": true,
6731
- "required": true,
6732
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
6733
- "hasDynamicHelp": true,
6734
- "multiple": false,
6735
- "type": "option"
6736
- }
6737
- },
6738
- "hasDynamicHelp": true,
6739
- "hiddenAliases": [],
6740
- "id": "hardis:org:diagnose:unsecure-connected-apps",
6741
- "pluginAlias": "sfdx-hardis",
6742
- "pluginName": "sfdx-hardis",
6743
- "pluginType": "core",
6744
- "strict": true,
6745
- "enableJsonFlag": true,
6746
- "title": "Detect Unsecured Connected Apps",
6747
- "requiresProject": false,
6748
- "isESM": true,
6749
- "relativePath": [
6750
- "lib",
6751
- "commands",
6752
- "hardis",
6753
- "org",
6754
- "diagnose",
6755
- "unsecure-connected-apps.js"
6756
- ],
6757
- "aliasPermutations": [],
6758
- "permutations": [
6759
- "hardis:org:diagnose:unsecure-connected-apps",
6760
- "org:hardis:diagnose:unsecure-connected-apps",
6761
- "org:diagnose:hardis:unsecure-connected-apps",
6762
- "org:diagnose:unsecure-connected-apps:hardis",
6763
- "hardis:diagnose:org:unsecure-connected-apps",
6764
- "diagnose:hardis:org:unsecure-connected-apps",
6765
- "diagnose:org:hardis:unsecure-connected-apps",
6766
- "diagnose:org:unsecure-connected-apps:hardis",
6767
- "hardis:diagnose:unsecure-connected-apps:org",
6768
- "diagnose:hardis:unsecure-connected-apps:org",
6769
- "diagnose:unsecure-connected-apps:hardis:org",
6770
- "diagnose:unsecure-connected-apps:org:hardis",
6771
- "hardis:org:unsecure-connected-apps:diagnose",
6772
- "org:hardis:unsecure-connected-apps:diagnose",
6773
- "org:unsecure-connected-apps:hardis:diagnose",
6774
- "org:unsecure-connected-apps:diagnose:hardis",
6775
- "hardis:unsecure-connected-apps:org:diagnose",
6776
- "unsecure-connected-apps:hardis:org:diagnose",
6777
- "unsecure-connected-apps:org:hardis:diagnose",
6778
- "unsecure-connected-apps:org:diagnose:hardis",
6779
- "hardis:unsecure-connected-apps:diagnose:org",
6780
- "unsecure-connected-apps:hardis:diagnose:org",
6781
- "unsecure-connected-apps:diagnose:hardis:org",
6782
- "unsecure-connected-apps:diagnose:org:hardis"
6783
- ]
6784
- },
6785
- "hardis:org:diagnose:unused-apex-classes": {
6786
- "aliases": [],
6787
- "args": {},
6788
- "description": "List all async Apex classes (Batch,Queueable,Schedulable) that has not been called for more than 365 days.\n \nThe result class list probably can be removed from the project, and that will improve your test classes performances 😊\n\nThe number of unused day is overridable using --days option. \n\nThe command uses queries on AsyncApexJob and CronTrigger technical tables to build the result.\n\nApex Classes CreatedBy and CreatedOn fields are calculated from MIN(date from git, date from org)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-apex-classes/) and can output Grafana, Slack and MsTeams Notifications.\n\n![](https://sfdx-hardis.cloudity.com/assets/images/screenshot-monitoring-unused-apex-grafana.jpg)\n",
6789
- "examples": [
6790
- "$ sf hardis:org:diagnose:unused-apex-classes",
6791
- "$ sf hardis:org:diagnose:unused-apex-classes --days 700"
6792
- ],
6793
- "flags": {
6794
- "json": {
6795
- "description": "Format output as json.",
6796
- "helpGroup": "GLOBAL",
6797
- "name": "json",
6798
- "allowNo": false,
6799
- "type": "boolean"
6800
- },
6801
- "flags-dir": {
6802
- "helpGroup": "GLOBAL",
6803
- "name": "flags-dir",
6804
- "summary": "Import flag values from a directory.",
6805
- "hasDynamicHelp": false,
6806
- "multiple": false,
6807
- "type": "option"
6808
- },
6809
- "outputfile": {
6810
- "char": "f",
6811
- "description": "Force the path and name of output report file. Must end with .csv",
6812
- "name": "outputfile",
6813
- "hasDynamicHelp": false,
6814
- "multiple": false,
6815
- "type": "option"
6816
- },
6817
- "days": {
6818
- "char": "t",
6819
- "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
6820
- "name": "days",
6821
- "hasDynamicHelp": false,
6822
- "multiple": false,
6823
- "type": "option"
6824
- },
6825
- "debug": {
6826
- "char": "d",
6827
- "description": "Activate debug mode (more logs)",
6828
- "name": "debug",
6829
- "allowNo": false,
6830
- "type": "boolean"
6831
- },
6832
- "websocket": {
6833
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
6834
- "name": "websocket",
6835
- "hasDynamicHelp": false,
6836
- "multiple": false,
6837
- "type": "option"
6838
- },
6839
- "skipauth": {
6840
- "description": "Skip authentication check when a default username is required",
6841
- "name": "skipauth",
6842
- "allowNo": false,
6843
- "type": "boolean"
6844
- },
6845
- "target-org": {
6846
- "aliases": [
6847
- "targetusername",
6848
- "u"
6849
- ],
6850
- "char": "o",
6851
- "deprecateAliases": true,
6852
- "name": "target-org",
6853
- "noCacheDefault": true,
6854
- "required": true,
6855
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
6856
- "hasDynamicHelp": true,
6857
- "multiple": false,
6858
- "type": "option"
6859
- }
6860
- },
6861
- "hasDynamicHelp": true,
6862
- "hiddenAliases": [],
6863
- "id": "hardis:org:diagnose:unused-apex-classes",
6864
- "pluginAlias": "sfdx-hardis",
6865
- "pluginName": "sfdx-hardis",
6866
- "pluginType": "core",
6867
- "strict": true,
6868
- "enableJsonFlag": true,
6869
- "title": "Detect unused Apex classes in an org",
6870
- "requiresProject": false,
6871
- "isESM": true,
6872
- "relativePath": [
6873
- "lib",
6874
- "commands",
6875
- "hardis",
6876
- "org",
6877
- "diagnose",
6878
- "unused-apex-classes.js"
6879
- ],
6880
- "aliasPermutations": [],
6881
- "permutations": [
6882
- "hardis:org:diagnose:unused-apex-classes",
6883
- "org:hardis:diagnose:unused-apex-classes",
6884
- "org:diagnose:hardis:unused-apex-classes",
6885
- "org:diagnose:unused-apex-classes:hardis",
6886
- "hardis:diagnose:org:unused-apex-classes",
6887
- "diagnose:hardis:org:unused-apex-classes",
6888
- "diagnose:org:hardis:unused-apex-classes",
6889
- "diagnose:org:unused-apex-classes:hardis",
6890
- "hardis:diagnose:unused-apex-classes:org",
6891
- "diagnose:hardis:unused-apex-classes:org",
6892
- "diagnose:unused-apex-classes:hardis:org",
6893
- "diagnose:unused-apex-classes:org:hardis",
6894
- "hardis:org:unused-apex-classes:diagnose",
6895
- "org:hardis:unused-apex-classes:diagnose",
6896
- "org:unused-apex-classes:hardis:diagnose",
6897
- "org:unused-apex-classes:diagnose:hardis",
6898
- "hardis:unused-apex-classes:org:diagnose",
6899
- "unused-apex-classes:hardis:org:diagnose",
6900
- "unused-apex-classes:org:hardis:diagnose",
6901
- "unused-apex-classes:org:diagnose:hardis",
6902
- "hardis:unused-apex-classes:diagnose:org",
6903
- "unused-apex-classes:hardis:diagnose:org",
6904
- "unused-apex-classes:diagnose:hardis:org",
6905
- "unused-apex-classes:diagnose:org:hardis"
6906
- ]
6907
- },
6908
- "hardis:org:diagnose:unused-connected-apps": {
6909
- "aliases": [],
6910
- "args": {},
6911
- "description": "\n## Command Behavior\n\n**Identifies and reports on potentially unused Connected Apps in a Salesforce org, suggesting candidates for deletion or deactivation.**\n\nThis command helps improve org security and reduce technical debt by pinpointing Connected Apps that are no longer actively used. Connected Apps can pose security risks if left unmonitored, and cleaning them up contributes to a healthier Salesforce environment.\n\nKey functionalities:\n\n- **Connected App Data Collection:** Gathers information about all Connected Apps in the org, including creation and last modified dates, and associated users.\n- **Usage Analysis:** Analyzes `LoginHistory` and `OAuthToken` records to determine the last usage date of each Connected App.\n- **Inactivity Detection:** Flags Connected Apps as potentially unused if they have no recent login history or OAuth token usage.\n- **Accessibility Check:** Examines Connected App metadata to identify if they are accessible (e.g., if they require admin approval and have no profiles or permission sets assigned).\n- **Ignored Apps:** Automatically ignores a predefined list of common Salesforce Connected Apps (e.g., `Salesforce CLI`, `Salesforce Mobile Dashboards`). You can extend this list by defining the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n- **CSV Report Generation:** Generates a CSV file containing details of all analyzed Connected Apps, including their usage status, last usage date, and reasons for being flagged as potentially unused.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of potentially unused Connected Apps.\n\n**Default Ignored Connected Apps:**\n\n- Ant Migration Tool\n- Chatter Desktop\n- Chatter Mobile for BlackBerry\n- Force.com IDE\n- OIQ_Integration\n- Salesforce CLI\n- Salesforce Files\n- Salesforce Mobile Dashboards\n- Salesforce Touch\n- Salesforce for Outlook\n- SalesforceA\n- SalesforceA for Android\n- SalesforceA for iOS\n- SalesforceDX Namespace Registry\n- SalesforceIQ\n\nYou can add more ignored apps by defining a comma-separated list of names in the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n\n_Example: \nALLOWED_INACTIVE_CONNECTED_APPS=My App 1,My App 2, My App 3_\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-connected-apps/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It performs SOQL queries against `ConnectedApplication`, `LoginHistory`, and `OAuthToken` objects to gather comprehensive data about Connected Apps and their usage.\n- **Temporary SFDX Project:** It creates a temporary SFDX project to retrieve Connected App metadata, allowing for local parsing and analysis of their XML files.\n- **Metadata Parsing:** It parses the `connectedApp-meta.xml` files to check for `isAdminApproved` and the presence of `profileName` or `permissionsetName` to determine accessibility.\n- **Data Correlation:** It correlates data from various Salesforce objects to build a complete picture of each Connected App's usage and status.\n- **Date Calculation:** Uses `moment` to calculate the time since the last OAuth token usage.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused Connected Apps.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **File System Operations:** Uses `fs-extra` for creating and removing temporary directories and files.\n- **Environment Variable Reading:** Reads the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable to customize the list of ignored Connected Apps.\n</details>\n",
6943
+ "description": "\n## Command Behavior\n\n**Detects unsecured Connected Apps in a Salesforce org and generates detailed reports for security analysis.**\n\nThis command is a critical security diagnostic tool that helps administrators identify Connected Apps that may pose security risks due to improper configuration. It provides comprehensive analysis of OAuth tokens and Connected App security settings to ensure proper access control.\n\nKey functionalities:\n\n- **OAuth Token Analysis:** Queries all OAuth tokens in the org using SOQL to retrieve comprehensive token information including app names, users, authorization status, and usage statistics.\n- **Security Status Assessment:** Evaluates each Connected App's security configuration by checking the `IsUsingAdminAuthorization` flag to determine if admin pre-approval is required.\n- **Unsecured App Detection:** Identifies Connected Apps that allow users to authorize themselves without admin approval, which can pose security risks.\n- **Detailed Reporting:** Generates two comprehensive CSV reports:\n - **OAuth Tokens Report:** Lists all OAuth tokens with security status, user information, and usage data\n - **Connected Apps Summary:** Aggregates unsecured Connected Apps with counts of associated OAuth tokens\n- **Visual Indicators:** Uses status icons (❌ for unsecured, ✅ for secured) to provide immediate visual feedback on security status.\n- **Security Recommendations:** Provides actionable guidance on how to secure Connected Apps through proper configuration.\n- **Notifications:** Sends alerts to configured channels (Grafana, Slack, MS Teams) with security findings and attached reports.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-org-security/) and can output Grafana, Slack and MsTeams Notifications.\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/jHv8yrSK8Dg\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query Execution:** Executes a comprehensive SOQL query on the `OauthToken` object, joining with `AppMenuItem` and `User` objects to gather complete security context.\n- **Security Analysis Logic:** Analyzes the `AppMenuItem.IsUsingAdminAuthorization` field to determine if a Connected App requires admin pre-approval for user authorization.\n- **Data Transformation:** Processes raw SOQL results to add security status indicators and reorganize data for optimal reporting and analysis.\n- **Aggregation Processing:** Groups OAuth tokens by Connected App name to provide summary statistics and identify the most problematic applications.\n- **Report Generation:** Uses `generateCsvFile` to create structured CSV reports with proper formatting and metadata for easy analysis and sharing.\n- **Notification Integration:** Integrates with the `NotifProvider` to send security alerts with detailed metrics, including the number of unsecured Connected Apps and associated OAuth tokens.\n- **File Management:** Generates multiple output formats (CSV, XLSX) and manages file paths using `generateReportPath` for consistent report organization.\n- **Connection Management:** Uses `setConnectionVariables` to ensure proper authentication context for notification providers that require org connection details.\n</details>\n",
6912
6944
  "examples": [
6913
- "$ sf hardis:org:diagnose:unused-connected-apps"
6945
+ "$ sf hardis:org:diagnose:unsecure-connected-apps"
6914
6946
  ],
6915
6947
  "flags": {
6916
6948
  "json": {
@@ -6974,30 +7006,13 @@
6974
7006
  },
6975
7007
  "hasDynamicHelp": true,
6976
7008
  "hiddenAliases": [],
6977
- "id": "hardis:org:diagnose:unused-connected-apps",
7009
+ "id": "hardis:org:diagnose:unsecure-connected-apps",
6978
7010
  "pluginAlias": "sfdx-hardis",
6979
7011
  "pluginName": "sfdx-hardis",
6980
7012
  "pluginType": "core",
6981
7013
  "strict": true,
6982
7014
  "enableJsonFlag": true,
6983
- "title": "Unused Connected Apps in an org",
6984
- "allowedInactiveConnectedApps": [
6985
- "Ant Migration Tool",
6986
- "Chatter Desktop",
6987
- "Chatter Mobile for BlackBerry",
6988
- "Force.com IDE",
6989
- "OIQ_Integration",
6990
- "Salesforce CLI",
6991
- "Salesforce Files",
6992
- "Salesforce Mobile Dashboards",
6993
- "Salesforce Touch",
6994
- "Salesforce for Outlook",
6995
- "SalesforceA",
6996
- "SalesforceA for Android",
6997
- "SalesforceA for iOS",
6998
- "SalesforceDX Namespace Registry",
6999
- "SalesforceIQ"
7000
- ],
7015
+ "title": "Detect Unsecured Connected Apps",
7001
7016
  "requiresProject": false,
7002
7017
  "isESM": true,
7003
7018
  "relativePath": [
@@ -7006,43 +7021,43 @@
7006
7021
  "hardis",
7007
7022
  "org",
7008
7023
  "diagnose",
7009
- "unused-connected-apps.js"
7024
+ "unsecure-connected-apps.js"
7010
7025
  ],
7011
7026
  "aliasPermutations": [],
7012
7027
  "permutations": [
7013
- "hardis:org:diagnose:unused-connected-apps",
7014
- "org:hardis:diagnose:unused-connected-apps",
7015
- "org:diagnose:hardis:unused-connected-apps",
7016
- "org:diagnose:unused-connected-apps:hardis",
7017
- "hardis:diagnose:org:unused-connected-apps",
7018
- "diagnose:hardis:org:unused-connected-apps",
7019
- "diagnose:org:hardis:unused-connected-apps",
7020
- "diagnose:org:unused-connected-apps:hardis",
7021
- "hardis:diagnose:unused-connected-apps:org",
7022
- "diagnose:hardis:unused-connected-apps:org",
7023
- "diagnose:unused-connected-apps:hardis:org",
7024
- "diagnose:unused-connected-apps:org:hardis",
7025
- "hardis:org:unused-connected-apps:diagnose",
7026
- "org:hardis:unused-connected-apps:diagnose",
7027
- "org:unused-connected-apps:hardis:diagnose",
7028
- "org:unused-connected-apps:diagnose:hardis",
7029
- "hardis:unused-connected-apps:org:diagnose",
7030
- "unused-connected-apps:hardis:org:diagnose",
7031
- "unused-connected-apps:org:hardis:diagnose",
7032
- "unused-connected-apps:org:diagnose:hardis",
7033
- "hardis:unused-connected-apps:diagnose:org",
7034
- "unused-connected-apps:hardis:diagnose:org",
7035
- "unused-connected-apps:diagnose:hardis:org",
7036
- "unused-connected-apps:diagnose:org:hardis"
7028
+ "hardis:org:diagnose:unsecure-connected-apps",
7029
+ "org:hardis:diagnose:unsecure-connected-apps",
7030
+ "org:diagnose:hardis:unsecure-connected-apps",
7031
+ "org:diagnose:unsecure-connected-apps:hardis",
7032
+ "hardis:diagnose:org:unsecure-connected-apps",
7033
+ "diagnose:hardis:org:unsecure-connected-apps",
7034
+ "diagnose:org:hardis:unsecure-connected-apps",
7035
+ "diagnose:org:unsecure-connected-apps:hardis",
7036
+ "hardis:diagnose:unsecure-connected-apps:org",
7037
+ "diagnose:hardis:unsecure-connected-apps:org",
7038
+ "diagnose:unsecure-connected-apps:hardis:org",
7039
+ "diagnose:unsecure-connected-apps:org:hardis",
7040
+ "hardis:org:unsecure-connected-apps:diagnose",
7041
+ "org:hardis:unsecure-connected-apps:diagnose",
7042
+ "org:unsecure-connected-apps:hardis:diagnose",
7043
+ "org:unsecure-connected-apps:diagnose:hardis",
7044
+ "hardis:unsecure-connected-apps:org:diagnose",
7045
+ "unsecure-connected-apps:hardis:org:diagnose",
7046
+ "unsecure-connected-apps:org:hardis:diagnose",
7047
+ "unsecure-connected-apps:org:diagnose:hardis",
7048
+ "hardis:unsecure-connected-apps:diagnose:org",
7049
+ "unsecure-connected-apps:hardis:diagnose:org",
7050
+ "unsecure-connected-apps:diagnose:hardis:org",
7051
+ "unsecure-connected-apps:diagnose:org:hardis"
7037
7052
  ]
7038
7053
  },
7039
- "hardis:org:diagnose:unusedlicenses": {
7054
+ "hardis:org:diagnose:unused-apex-classes": {
7040
7055
  "aliases": [],
7041
7056
  "args": {},
7042
- "description": "\n## Command Behavior\n\n**Detects and suggests the deletion of unused Permission Set License Assignments in a Salesforce org.**\n\nWhen a Permission Set (PS) linked to a Permission Set License (PSL) is assigned to a user, a Permission Set License Assignment (PSLA) is automatically created. However, when that PS is unassigned from the user, the PSLA is *not* automatically deleted. This can lead to organizations being charged for unused PSLAs, representing a hidden cost and technical debt.\n\nThis command identifies such useless PSLAs and provides options to delete them, helping to optimize license usage and reduce unnecessary expenses.\n\nKey functionalities:\n\n- **PSLA Detection:** Queries the Salesforce org to find all active PSLAs.\n- **Usage Verification:** Correlates PSLAs with actual Permission Set Assignments and Permission Set Group Assignments to determine if the underlying Permission Sets are still assigned to the user.\n- **Special Case Handling:** Accounts for specific scenarios where profiles might implicitly assign PSLAs (e.g., `Salesforce API Only` profile assigning `SalesforceAPIIntegrationPsl`) and allows for always excluding certain PSLAs from the unused check.\n- **Reporting:** Generates a CSV report of all identified unused PSLAs, including the user and the associated Permission Set License.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of unused PSLAs.\n- **Interactive Deletion:** In non-CI environments, it offers an interactive prompt to bulk delete the identified unused PSLAs.\n\nMany thanks to [Vincent Finet](https://www.linkedin.com/in/vincentfinet/) for the inspiration during his great speaker session at [French Touch Dreamin '23](https://frenchtouchdreamin.com/), and his kind agreement for reusing such inspiration in this command 😊\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-licenses/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves extensive querying of Salesforce objects and data correlation:\n\n- **SOQL Queries (Bulk API):** It uses `bulkQuery` and `bulkQueryChunksIn` to efficiently retrieve large volumes of data from `PermissionSetLicenseAssign`, `PermissionSetLicense`, `PermissionSet`, `PermissionSetGroupComponent`, and `PermissionSetAssignment` objects.\n- **Data Correlation:** It meticulously correlates data across these objects to determine if a `PermissionSetLicenseAssign` record has a corresponding active assignment to a Permission Set or Permission Set Group for the same user.\n- **Filtering Logic:** It applies complex filtering logic to exclude PSLAs that are genuinely in use or are part of predefined exceptions (e.g., `alwaysExcludeForActiveUsersPermissionSetLicenses`).\n- **Bulk Deletion:** If the user opts to delete unused PSLAs, it uses `bulkUpdate` with the `delete` operation to efficiently remove multiple records.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused PSLAs.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Interaction:** Uses `prompts` for interactive confirmation before performing deletion operations.\n</details>\n",
7057
+ "description": "List all async Apex classes (Batch,Queueable,Schedulable) that has not been called for more than 365 days.\n \nThe result class list probably can be removed from the project, and that will improve your test classes performances 😊\n\nThe number of unused day is overridable using --days option. \n\nThe command uses queries on AsyncApexJob and CronTrigger technical tables to build the result.\n\nApex Classes CreatedBy and CreatedOn fields are calculated from MIN(date from git, date from org)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-apex-classes/) and can output Grafana, Slack and MsTeams Notifications.\n\n![](https://sfdx-hardis.cloudity.com/assets/images/screenshot-monitoring-unused-apex-grafana.jpg)\n",
7043
7058
  "examples": [
7044
- "$ sf hardis:org:diagnose:unusedlicenses",
7045
- "$ sf hardis:org:diagnose:unusedlicenses --fix"
7059
+ "$ sf hardis:org:diagnose:unused-apex-classes",
7060
+ "$ sf hardis:org:diagnose:unused-apex-classes --days 700"
7046
7061
  ],
7047
7062
  "flags": {
7048
7063
  "json": {
@@ -7068,6 +7083,14 @@
7068
7083
  "multiple": false,
7069
7084
  "type": "option"
7070
7085
  },
7086
+ "days": {
7087
+ "char": "t",
7088
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7089
+ "name": "days",
7090
+ "hasDynamicHelp": false,
7091
+ "multiple": false,
7092
+ "type": "option"
7093
+ },
7071
7094
  "debug": {
7072
7095
  "char": "d",
7073
7096
  "description": "Activate debug mode (more logs)",
@@ -7106,32 +7129,14 @@
7106
7129
  },
7107
7130
  "hasDynamicHelp": true,
7108
7131
  "hiddenAliases": [],
7109
- "id": "hardis:org:diagnose:unusedlicenses",
7132
+ "id": "hardis:org:diagnose:unused-apex-classes",
7110
7133
  "pluginAlias": "sfdx-hardis",
7111
7134
  "pluginName": "sfdx-hardis",
7112
7135
  "pluginType": "core",
7113
7136
  "strict": true,
7114
7137
  "enableJsonFlag": true,
7115
- "title": "Detect unused Permission Set Licenses (beta)",
7138
+ "title": "Detect unused Apex classes in an org",
7116
7139
  "requiresProject": false,
7117
- "additionalPermissionSetsToAlwaysGet": [
7118
- "Sales_User"
7119
- ],
7120
- "permSetsPermSetLicenses": [
7121
- {
7122
- "permSet": "Sales_User",
7123
- "permSetLicense": "SalesUserPsl"
7124
- }
7125
- ],
7126
- "profilesPermissionSetLicenses": [
7127
- {
7128
- "profile": "Salesforce API Only",
7129
- "permSetLicense": "SalesforceAPIIntegrationPsl"
7130
- }
7131
- ],
7132
- "alwaysExcludeForActiveUsersPermissionSetLicenses": [
7133
- "IdentityConnect"
7134
- ],
7135
7140
  "isESM": true,
7136
7141
  "relativePath": [
7137
7142
  "lib",
@@ -7139,46 +7144,42 @@
7139
7144
  "hardis",
7140
7145
  "org",
7141
7146
  "diagnose",
7142
- "unusedlicenses.js"
7147
+ "unused-apex-classes.js"
7143
7148
  ],
7144
7149
  "aliasPermutations": [],
7145
7150
  "permutations": [
7146
- "hardis:org:diagnose:unusedlicenses",
7147
- "org:hardis:diagnose:unusedlicenses",
7148
- "org:diagnose:hardis:unusedlicenses",
7149
- "org:diagnose:unusedlicenses:hardis",
7150
- "hardis:diagnose:org:unusedlicenses",
7151
- "diagnose:hardis:org:unusedlicenses",
7152
- "diagnose:org:hardis:unusedlicenses",
7153
- "diagnose:org:unusedlicenses:hardis",
7154
- "hardis:diagnose:unusedlicenses:org",
7155
- "diagnose:hardis:unusedlicenses:org",
7156
- "diagnose:unusedlicenses:hardis:org",
7157
- "diagnose:unusedlicenses:org:hardis",
7158
- "hardis:org:unusedlicenses:diagnose",
7159
- "org:hardis:unusedlicenses:diagnose",
7160
- "org:unusedlicenses:hardis:diagnose",
7161
- "org:unusedlicenses:diagnose:hardis",
7162
- "hardis:unusedlicenses:org:diagnose",
7163
- "unusedlicenses:hardis:org:diagnose",
7164
- "unusedlicenses:org:hardis:diagnose",
7165
- "unusedlicenses:org:diagnose:hardis",
7166
- "hardis:unusedlicenses:diagnose:org",
7167
- "unusedlicenses:hardis:diagnose:org",
7168
- "unusedlicenses:diagnose:hardis:org",
7169
- "unusedlicenses:diagnose:org:hardis"
7151
+ "hardis:org:diagnose:unused-apex-classes",
7152
+ "org:hardis:diagnose:unused-apex-classes",
7153
+ "org:diagnose:hardis:unused-apex-classes",
7154
+ "org:diagnose:unused-apex-classes:hardis",
7155
+ "hardis:diagnose:org:unused-apex-classes",
7156
+ "diagnose:hardis:org:unused-apex-classes",
7157
+ "diagnose:org:hardis:unused-apex-classes",
7158
+ "diagnose:org:unused-apex-classes:hardis",
7159
+ "hardis:diagnose:unused-apex-classes:org",
7160
+ "diagnose:hardis:unused-apex-classes:org",
7161
+ "diagnose:unused-apex-classes:hardis:org",
7162
+ "diagnose:unused-apex-classes:org:hardis",
7163
+ "hardis:org:unused-apex-classes:diagnose",
7164
+ "org:hardis:unused-apex-classes:diagnose",
7165
+ "org:unused-apex-classes:hardis:diagnose",
7166
+ "org:unused-apex-classes:diagnose:hardis",
7167
+ "hardis:unused-apex-classes:org:diagnose",
7168
+ "unused-apex-classes:hardis:org:diagnose",
7169
+ "unused-apex-classes:org:hardis:diagnose",
7170
+ "unused-apex-classes:org:diagnose:hardis",
7171
+ "hardis:unused-apex-classes:diagnose:org",
7172
+ "unused-apex-classes:hardis:diagnose:org",
7173
+ "unused-apex-classes:diagnose:hardis:org",
7174
+ "unused-apex-classes:diagnose:org:hardis"
7170
7175
  ]
7171
7176
  },
7172
- "hardis:org:diagnose:unusedusers": {
7177
+ "hardis:org:diagnose:unused-connected-apps": {
7173
7178
  "aliases": [],
7174
7179
  "args": {},
7175
- "description": "\n## Command Behavior\n\n**Detects and reports on inactive or unused Salesforce user accounts, helping to optimize license usage and enhance security.**\n\nEfficient user management is vital in Salesforce to ensure resources are optimized and costs are controlled. However, inactive or unused user accounts can often go unnoticed, leading to wasted licenses and potential security risks. This tool addresses this challenge by enabling administrators to identify users who haven't logged in within a specified period.\n\nBy analyzing user login activity and last login timestamps, this feature highlights inactive user accounts, allowing administrators to take appropriate action. Whether it's deactivating dormant accounts, freeing up licenses, or ensuring compliance with security policies, this functionality empowers administrators to maintain a lean and secure Salesforce environment.\n\nKey functionalities:\n\n- **Inactivity Detection:** Identifies users who have not logged in for a specified number of days (`--days` flag, default 180 days in CI, 365 days otherwise).\n- **License Type Filtering:** Allows filtering users by license type using `--licensetypes` (e.g., `all-crm`, `all-paying`) or specific license identifiers using `--licenseidentifiers`.\n - `all-crm`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT` licenses.\n - `all-paying`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT`, `PID_Customer_Community`, `PID_Customer_Community_Login`, `PID_Partner_Community`, `PID_Partner_Community_Login` licenses.\n - Note: You can see the full list of available license identifiers in [Salesforce Documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/sfdx_cli_reference/sforce_api_objects_userlicense.htm).\n- **Active User Retrieval:** The `--returnactiveusers` flag inverts the command, allowing you to retrieve active users who *have* logged in during the specified period.\n- **CSV Report Generation:** Generates a CSV file containing details of all identified users (inactive or active), including their last login date, profile, and license information.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of inactive or active users.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-inactive-users/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query (Bulk API):** It uses `bulkQuery` to efficiently retrieve user records from the Salesforce `User` object. The SOQL query dynamically constructs its WHERE clause based on the `--days`, `--licensetypes`, `--licenseidentifiers`, and `--returnactiveusers` flags.\n- **Interactive Prompts:** Uses `prompts` to interactively ask the user for the number of inactive days and license types if not provided via flags.\n- **License Mapping:** Internally maps common license type aliases (e.g., `all-crm`) to their corresponding Salesforce `LicenseDefinitionKey` values.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of users.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Feedback:** Provides a summary of the findings in the console, indicating the number of inactive or active users found.\n</details>",
7180
+ "description": "\n## Command Behavior\n\n**Identifies and reports on potentially unused Connected Apps in a Salesforce org, suggesting candidates for deletion or deactivation.**\n\nThis command helps improve org security and reduce technical debt by pinpointing Connected Apps that are no longer actively used. Connected Apps can pose security risks if left unmonitored, and cleaning them up contributes to a healthier Salesforce environment.\n\nKey functionalities:\n\n- **Connected App Data Collection:** Gathers information about all Connected Apps in the org, including creation and last modified dates, and associated users.\n- **Usage Analysis:** Analyzes `LoginHistory` and `OAuthToken` records to determine the last usage date of each Connected App.\n- **Inactivity Detection:** Flags Connected Apps as potentially unused if they have no recent login history or OAuth token usage.\n- **Accessibility Check:** Examines Connected App metadata to identify if they are accessible (e.g., if they require admin approval and have no profiles or permission sets assigned).\n- **Ignored Apps:** Automatically ignores a predefined list of common Salesforce Connected Apps (e.g., `Salesforce CLI`, `Salesforce Mobile Dashboards`). You can extend this list by defining the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n- **CSV Report Generation:** Generates a CSV file containing details of all analyzed Connected Apps, including their usage status, last usage date, and reasons for being flagged as potentially unused.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of potentially unused Connected Apps.\n\n**Default Ignored Connected Apps:**\n\n- Ant Migration Tool\n- Chatter Desktop\n- Chatter Mobile for BlackBerry\n- Force.com IDE\n- OIQ_Integration\n- Salesforce CLI\n- Salesforce Files\n- Salesforce Mobile Dashboards\n- Salesforce Touch\n- Salesforce for Outlook\n- SalesforceA\n- SalesforceA for Android\n- SalesforceA for iOS\n- SalesforceDX Namespace Registry\n- SalesforceIQ\n\nYou can add more ignored apps by defining a comma-separated list of names in the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n\n_Example: \nALLOWED_INACTIVE_CONNECTED_APPS=My App 1,My App 2, My App 3_\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-connected-apps/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It performs SOQL queries against `ConnectedApplication`, `LoginHistory`, and `OAuthToken` objects to gather comprehensive data about Connected Apps and their usage.\n- **Temporary SFDX Project:** It creates a temporary SFDX project to retrieve Connected App metadata, allowing for local parsing and analysis of their XML files.\n- **Metadata Parsing:** It parses the `connectedApp-meta.xml` files to check for `isAdminApproved` and the presence of `profileName` or `permissionsetName` to determine accessibility.\n- **Data Correlation:** It correlates data from various Salesforce objects to build a complete picture of each Connected App's usage and status.\n- **Date Calculation:** Uses `moment` to calculate the time since the last OAuth token usage.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused Connected Apps.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **File System Operations:** Uses `fs-extra` for creating and removing temporary directories and files.\n- **Environment Variable Reading:** Reads the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable to customize the list of ignored Connected Apps.\n</details>\n",
7176
7181
  "examples": [
7177
- "$ sf hardis:org:diagnose:unusedusers",
7178
- "$ sf hardis:org:diagnose:unusedusers --days 365",
7179
- "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm",
7180
- "$ sf hardis:org:diagnose:unusedusers --days 60 --licenseidentifiers SFDC,AUL,AUL1",
7181
- "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm --returnactiveusers"
7182
+ "$ sf hardis:org:diagnose:unused-connected-apps"
7182
7183
  ],
7183
7184
  "flags": {
7184
7185
  "json": {
@@ -7204,41 +7205,6 @@
7204
7205
  "multiple": false,
7205
7206
  "type": "option"
7206
7207
  },
7207
- "days": {
7208
- "char": "t",
7209
- "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7210
- "name": "days",
7211
- "hasDynamicHelp": false,
7212
- "multiple": false,
7213
- "type": "option"
7214
- },
7215
- "licensetypes": {
7216
- "char": "l",
7217
- "description": "Type of licenses to check. If set, do not use licenseidentifiers option. In CI, default is all-crm",
7218
- "name": "licensetypes",
7219
- "hasDynamicHelp": false,
7220
- "multiple": false,
7221
- "options": [
7222
- "all",
7223
- "all-crm",
7224
- "all-paying"
7225
- ],
7226
- "type": "option"
7227
- },
7228
- "licenseidentifiers": {
7229
- "char": "i",
7230
- "description": "Comma-separated list of license identifiers, in case licensetypes is not used.. Identifiers available at https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_userlicense.htm",
7231
- "name": "licenseidentifiers",
7232
- "hasDynamicHelp": false,
7233
- "multiple": false,
7234
- "type": "option"
7235
- },
7236
- "returnactiveusers": {
7237
- "description": "Inverts the command by returning the active users",
7238
- "name": "returnactiveusers",
7239
- "allowNo": false,
7240
- "type": "boolean"
7241
- },
7242
7208
  "debug": {
7243
7209
  "char": "d",
7244
7210
  "description": "Activate debug mode (more logs)",
@@ -7277,13 +7243,30 @@
7277
7243
  },
7278
7244
  "hasDynamicHelp": true,
7279
7245
  "hiddenAliases": [],
7280
- "id": "hardis:org:diagnose:unusedusers",
7246
+ "id": "hardis:org:diagnose:unused-connected-apps",
7281
7247
  "pluginAlias": "sfdx-hardis",
7282
7248
  "pluginName": "sfdx-hardis",
7283
7249
  "pluginType": "core",
7284
7250
  "strict": true,
7285
7251
  "enableJsonFlag": true,
7286
- "title": "Detect unused Users in Salesforce",
7252
+ "title": "Unused Connected Apps in an org",
7253
+ "allowedInactiveConnectedApps": [
7254
+ "Ant Migration Tool",
7255
+ "Chatter Desktop",
7256
+ "Chatter Mobile for BlackBerry",
7257
+ "Force.com IDE",
7258
+ "OIQ_Integration",
7259
+ "Salesforce CLI",
7260
+ "Salesforce Files",
7261
+ "Salesforce Mobile Dashboards",
7262
+ "Salesforce Touch",
7263
+ "Salesforce for Outlook",
7264
+ "SalesforceA",
7265
+ "SalesforceA for Android",
7266
+ "SalesforceA for iOS",
7267
+ "SalesforceDX Namespace Registry",
7268
+ "SalesforceIQ"
7269
+ ],
7287
7270
  "requiresProject": false,
7288
7271
  "isESM": true,
7289
7272
  "relativePath": [
@@ -7292,42 +7275,43 @@
7292
7275
  "hardis",
7293
7276
  "org",
7294
7277
  "diagnose",
7295
- "unusedusers.js"
7278
+ "unused-connected-apps.js"
7296
7279
  ],
7297
7280
  "aliasPermutations": [],
7298
7281
  "permutations": [
7299
- "hardis:org:diagnose:unusedusers",
7300
- "org:hardis:diagnose:unusedusers",
7301
- "org:diagnose:hardis:unusedusers",
7302
- "org:diagnose:unusedusers:hardis",
7303
- "hardis:diagnose:org:unusedusers",
7304
- "diagnose:hardis:org:unusedusers",
7305
- "diagnose:org:hardis:unusedusers",
7306
- "diagnose:org:unusedusers:hardis",
7307
- "hardis:diagnose:unusedusers:org",
7308
- "diagnose:hardis:unusedusers:org",
7309
- "diagnose:unusedusers:hardis:org",
7310
- "diagnose:unusedusers:org:hardis",
7311
- "hardis:org:unusedusers:diagnose",
7312
- "org:hardis:unusedusers:diagnose",
7313
- "org:unusedusers:hardis:diagnose",
7314
- "org:unusedusers:diagnose:hardis",
7315
- "hardis:unusedusers:org:diagnose",
7316
- "unusedusers:hardis:org:diagnose",
7317
- "unusedusers:org:hardis:diagnose",
7318
- "unusedusers:org:diagnose:hardis",
7319
- "hardis:unusedusers:diagnose:org",
7320
- "unusedusers:hardis:diagnose:org",
7321
- "unusedusers:diagnose:hardis:org",
7322
- "unusedusers:diagnose:org:hardis"
7282
+ "hardis:org:diagnose:unused-connected-apps",
7283
+ "org:hardis:diagnose:unused-connected-apps",
7284
+ "org:diagnose:hardis:unused-connected-apps",
7285
+ "org:diagnose:unused-connected-apps:hardis",
7286
+ "hardis:diagnose:org:unused-connected-apps",
7287
+ "diagnose:hardis:org:unused-connected-apps",
7288
+ "diagnose:org:hardis:unused-connected-apps",
7289
+ "diagnose:org:unused-connected-apps:hardis",
7290
+ "hardis:diagnose:unused-connected-apps:org",
7291
+ "diagnose:hardis:unused-connected-apps:org",
7292
+ "diagnose:unused-connected-apps:hardis:org",
7293
+ "diagnose:unused-connected-apps:org:hardis",
7294
+ "hardis:org:unused-connected-apps:diagnose",
7295
+ "org:hardis:unused-connected-apps:diagnose",
7296
+ "org:unused-connected-apps:hardis:diagnose",
7297
+ "org:unused-connected-apps:diagnose:hardis",
7298
+ "hardis:unused-connected-apps:org:diagnose",
7299
+ "unused-connected-apps:hardis:org:diagnose",
7300
+ "unused-connected-apps:org:hardis:diagnose",
7301
+ "unused-connected-apps:org:diagnose:hardis",
7302
+ "hardis:unused-connected-apps:diagnose:org",
7303
+ "unused-connected-apps:hardis:diagnose:org",
7304
+ "unused-connected-apps:diagnose:hardis:org",
7305
+ "unused-connected-apps:diagnose:org:hardis"
7323
7306
  ]
7324
7307
  },
7325
- "hardis:org:files:export": {
7308
+ "hardis:org:diagnose:unusedlicenses": {
7326
7309
  "aliases": [],
7327
7310
  "args": {},
7328
- "description": "\n## Command Behavior\n\n**Exports file attachments (ContentVersion, Attachment) from a Salesforce org based on a predefined configuration.**\n\nThis command enables the mass download of files associated with Salesforce records, providing a robust solution for backing up files, migrating them to other systems, or integrating them with external document management solutions.\n\nKey functionalities:\n\n- **Configuration-Driven Export:** Relies on an `export.json` file within a designated file export project to define the export criteria, including the SOQL query for parent records, file types to export, output naming conventions, and file size filtering.\n- **File Size Filtering:** Supports minimum file size filtering via the `fileSizeMin` configuration parameter (in KB). Files smaller than the specified size will be skipped during export.\n- **File Validation:** After downloading each file, validates the integrity by:\n - **Checksum Validation:** For ContentVersion files, compares MD5 checksum with Salesforce's stored checksum\n - **Size Validation:** For both ContentVersion and Attachment files, verifies actual file size matches expected size\n - **Status Tracking:** Files are categorized with specific statuses: `success` (valid files), `failed` (download errors), `skipped` (filtered files), `invalid` (downloaded but failed validation)\n - All validation results are logged in the CSV export log for audit purposes\n- **Resume/Restart Capability:** \n - **Resume Mode:** When `--resume` flag is used (default in CI environments), checks existing downloaded files for validity. Valid files are skipped, invalid files are re-downloaded.\n - **Restart Mode:** When resume is disabled, clears the output folder and starts a fresh export.\n - **Interactive Mode:** When existing files are found and `--resume` is not explicitly specified (non-CI environments), prompts the user to choose between resume or restart.\n- **Interactive Project Selection:** If the file export project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Configurable Export Options:** Allows overriding default export settings such as `chunksize` (number of records processed in a batch), `polltimeout` (timeout for Bulk API calls), and `startchunknumber` (to resume a failed export).\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for a practical example:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesExporter Class:** The core logic is encapsulated within the `FilesExporter` class, which orchestrates the entire export process.\n- **SOQL Queries (Bulk API):** It uses Salesforce Bulk API queries to efficiently retrieve large volumes of parent record IDs and file metadata, including checksums and file sizes.\n- **File Download:** Downloads the actual file content from Salesforce.\n- **File Validation:** After each successful download, validates file integrity by comparing checksums (ContentVersion) and file sizes (both ContentVersion and Attachment) against Salesforce metadata.\n- **Resume Logic:** In resume mode, checks for existing files before downloading, validates their integrity, and only re-downloads invalid or missing files. This enables efficient recovery from interrupted exports.\n- **File System Operations:** Writes the downloaded files to the local file system, organizing them into folders based on the configured naming conventions.\n- **Configuration Loading:** Reads the `export.json` file to get the export configuration. It also allows for interactive overriding of these settings.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file export project, `promptFilesExportConfiguration` for customizing export options, and prompts for resume/restart choice when existing files are found.\n- **Error Handling:** Includes mechanisms to handle potential errors during the export process, such as network issues, API limits, and file validation failures. Each file is assigned a specific status (`success`, `failed`, `skipped`, `invalid`) for comprehensive tracking and troubleshooting.\n</details>\n",
7311
+ "description": "\n## Command Behavior\n\n**Detects and suggests the deletion of unused Permission Set License Assignments in a Salesforce org.**\n\nWhen a Permission Set (PS) linked to a Permission Set License (PSL) is assigned to a user, a Permission Set License Assignment (PSLA) is automatically created. However, when that PS is unassigned from the user, the PSLA is *not* automatically deleted. This can lead to organizations being charged for unused PSLAs, representing a hidden cost and technical debt.\n\nThis command identifies such useless PSLAs and provides options to delete them, helping to optimize license usage and reduce unnecessary expenses.\n\nKey functionalities:\n\n- **PSLA Detection:** Queries the Salesforce org to find all active PSLAs.\n- **Usage Verification:** Correlates PSLAs with actual Permission Set Assignments and Permission Set Group Assignments to determine if the underlying Permission Sets are still assigned to the user.\n- **Special Case Handling:** Accounts for specific scenarios where profiles might implicitly assign PSLAs (e.g., `Salesforce API Only` profile assigning `SalesforceAPIIntegrationPsl`) and allows for always excluding certain PSLAs from the unused check.\n- **Reporting:** Generates a CSV report of all identified unused PSLAs, including the user and the associated Permission Set License.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of unused PSLAs.\n- **Interactive Deletion:** In non-CI environments, it offers an interactive prompt to bulk delete the identified unused PSLAs.\n\nMany thanks to [Vincent Finet](https://www.linkedin.com/in/vincentfinet/) for the inspiration during his great speaker session at [French Touch Dreamin '23](https://frenchtouchdreamin.com/), and his kind agreement for reusing such inspiration in this command 😊\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-licenses/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves extensive querying of Salesforce objects and data correlation:\n\n- **SOQL Queries (Bulk API):** It uses `bulkQuery` and `bulkQueryChunksIn` to efficiently retrieve large volumes of data from `PermissionSetLicenseAssign`, `PermissionSetLicense`, `PermissionSet`, `PermissionSetGroupComponent`, and `PermissionSetAssignment` objects.\n- **Data Correlation:** It meticulously correlates data across these objects to determine if a `PermissionSetLicenseAssign` record has a corresponding active assignment to a Permission Set or Permission Set Group for the same user.\n- **Filtering Logic:** It applies complex filtering logic to exclude PSLAs that are genuinely in use or are part of predefined exceptions (e.g., `alwaysExcludeForActiveUsersPermissionSetLicenses`).\n- **Bulk Deletion:** If the user opts to delete unused PSLAs, it uses `bulkUpdate` with the `delete` operation to efficiently remove multiple records.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused PSLAs.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Interaction:** Uses `prompts` for interactive confirmation before performing deletion operations.\n</details>\n",
7329
7312
  "examples": [
7330
- "$ sf hardis:org:files:export"
7313
+ "$ sf hardis:org:diagnose:unusedlicenses",
7314
+ "$ sf hardis:org:diagnose:unusedlicenses --fix"
7331
7315
  ],
7332
7316
  "flags": {
7333
7317
  "json": {
@@ -7345,48 +7329,14 @@
7345
7329
  "multiple": false,
7346
7330
  "type": "option"
7347
7331
  },
7348
- "path": {
7349
- "char": "p",
7350
- "description": "Path to the file export project",
7351
- "name": "path",
7352
- "hasDynamicHelp": false,
7353
- "multiple": false,
7354
- "type": "option"
7355
- },
7356
- "chunksize": {
7357
- "char": "c",
7358
- "description": "Number of records to add in a chunk before it is processed",
7359
- "name": "chunksize",
7360
- "default": 1000,
7361
- "hasDynamicHelp": false,
7362
- "multiple": false,
7363
- "type": "option"
7364
- },
7365
- "polltimeout": {
7366
- "char": "t",
7367
- "description": "Timeout in MS for Bulk API calls",
7368
- "name": "polltimeout",
7369
- "default": 300000,
7370
- "hasDynamicHelp": false,
7371
- "multiple": false,
7372
- "type": "option"
7373
- },
7374
- "startchunknumber": {
7375
- "char": "s",
7376
- "description": "Chunk number to start from",
7377
- "name": "startchunknumber",
7378
- "default": 0,
7332
+ "outputfile": {
7333
+ "char": "f",
7334
+ "description": "Force the path and name of output report file. Must end with .csv",
7335
+ "name": "outputfile",
7379
7336
  "hasDynamicHelp": false,
7380
7337
  "multiple": false,
7381
7338
  "type": "option"
7382
7339
  },
7383
- "resume": {
7384
- "char": "r",
7385
- "description": "Resume previous export by checking existing files (default in CI)",
7386
- "name": "resume",
7387
- "allowNo": false,
7388
- "type": "boolean"
7389
- },
7390
7340
  "debug": {
7391
7341
  "char": "d",
7392
7342
  "description": "Activate debug mode (more logs)",
@@ -7425,57 +7375,79 @@
7425
7375
  },
7426
7376
  "hasDynamicHelp": true,
7427
7377
  "hiddenAliases": [],
7428
- "id": "hardis:org:files:export",
7378
+ "id": "hardis:org:diagnose:unusedlicenses",
7429
7379
  "pluginAlias": "sfdx-hardis",
7430
7380
  "pluginName": "sfdx-hardis",
7431
7381
  "pluginType": "core",
7432
7382
  "strict": true,
7433
7383
  "enableJsonFlag": true,
7434
- "title": "Export files",
7384
+ "title": "Detect unused Permission Set Licenses (beta)",
7435
7385
  "requiresProject": false,
7386
+ "additionalPermissionSetsToAlwaysGet": [
7387
+ "Sales_User"
7388
+ ],
7389
+ "permSetsPermSetLicenses": [
7390
+ {
7391
+ "permSet": "Sales_User",
7392
+ "permSetLicense": "SalesUserPsl"
7393
+ }
7394
+ ],
7395
+ "profilesPermissionSetLicenses": [
7396
+ {
7397
+ "profile": "Salesforce API Only",
7398
+ "permSetLicense": "SalesforceAPIIntegrationPsl"
7399
+ }
7400
+ ],
7401
+ "alwaysExcludeForActiveUsersPermissionSetLicenses": [
7402
+ "IdentityConnect"
7403
+ ],
7436
7404
  "isESM": true,
7437
7405
  "relativePath": [
7438
7406
  "lib",
7439
7407
  "commands",
7440
7408
  "hardis",
7441
7409
  "org",
7442
- "files",
7443
- "export.js"
7410
+ "diagnose",
7411
+ "unusedlicenses.js"
7444
7412
  ],
7445
7413
  "aliasPermutations": [],
7446
7414
  "permutations": [
7447
- "hardis:org:files:export",
7448
- "org:hardis:files:export",
7449
- "org:files:hardis:export",
7450
- "org:files:export:hardis",
7451
- "hardis:files:org:export",
7452
- "files:hardis:org:export",
7453
- "files:org:hardis:export",
7454
- "files:org:export:hardis",
7455
- "hardis:files:export:org",
7456
- "files:hardis:export:org",
7457
- "files:export:hardis:org",
7458
- "files:export:org:hardis",
7459
- "hardis:org:export:files",
7460
- "org:hardis:export:files",
7461
- "org:export:hardis:files",
7462
- "org:export:files:hardis",
7463
- "hardis:export:org:files",
7464
- "export:hardis:org:files",
7465
- "export:org:hardis:files",
7466
- "export:org:files:hardis",
7467
- "hardis:export:files:org",
7468
- "export:hardis:files:org",
7469
- "export:files:hardis:org",
7470
- "export:files:org:hardis"
7415
+ "hardis:org:diagnose:unusedlicenses",
7416
+ "org:hardis:diagnose:unusedlicenses",
7417
+ "org:diagnose:hardis:unusedlicenses",
7418
+ "org:diagnose:unusedlicenses:hardis",
7419
+ "hardis:diagnose:org:unusedlicenses",
7420
+ "diagnose:hardis:org:unusedlicenses",
7421
+ "diagnose:org:hardis:unusedlicenses",
7422
+ "diagnose:org:unusedlicenses:hardis",
7423
+ "hardis:diagnose:unusedlicenses:org",
7424
+ "diagnose:hardis:unusedlicenses:org",
7425
+ "diagnose:unusedlicenses:hardis:org",
7426
+ "diagnose:unusedlicenses:org:hardis",
7427
+ "hardis:org:unusedlicenses:diagnose",
7428
+ "org:hardis:unusedlicenses:diagnose",
7429
+ "org:unusedlicenses:hardis:diagnose",
7430
+ "org:unusedlicenses:diagnose:hardis",
7431
+ "hardis:unusedlicenses:org:diagnose",
7432
+ "unusedlicenses:hardis:org:diagnose",
7433
+ "unusedlicenses:org:hardis:diagnose",
7434
+ "unusedlicenses:org:diagnose:hardis",
7435
+ "hardis:unusedlicenses:diagnose:org",
7436
+ "unusedlicenses:hardis:diagnose:org",
7437
+ "unusedlicenses:diagnose:hardis:org",
7438
+ "unusedlicenses:diagnose:org:hardis"
7471
7439
  ]
7472
7440
  },
7473
- "hardis:org:files:import": {
7441
+ "hardis:org:diagnose:unusedusers": {
7474
7442
  "aliases": [],
7475
7443
  "args": {},
7476
- "description": "\nThis command facilitates the mass upload of files into Salesforce, allowing you to populate records with associated documents, images, or other file types. It's a crucial tool for data migration, content seeding, or synchronizing external file repositories with Salesforce.\n\nKey functionalities:\n\n- **Configuration-Driven Import:** Relies on an `export.json` file within a designated file export project (created using `sf hardis:org:configure:files`) to determine which files to import and how they should be associated with Salesforce records.\n- **Interactive Project Selection:** If the file import project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Overwrite Option:** The `--overwrite` flag allows you to replace existing files in Salesforce with local versions that have the same name. Be aware that this option doubles the number of API calls used.\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for how to export files, which is often a prerequisite for importing:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesImporter Class:** The core logic is encapsulated within the `FilesImporter` class, which orchestrates the entire import process.\n- **File System Scan:** Scans the local file system within the configured project directory to identify files for import.\n- **Salesforce API Interaction:** Uses Salesforce APIs (e.g., ContentVersion, Attachment) to upload files and associate them with records.\n- **Configuration Loading:** Reads the `export.json` file to get the import configuration, including SOQL queries to identify parent records for file association.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file import project and `prompts` for confirming the overwrite behavior.\n- **Error Handling:** Includes mechanisms to handle potential errors during the import process, such as API limits or file upload failures.\n</details>\n",
7444
+ "description": "\n## Command Behavior\n\n**Detects and reports on inactive or unused Salesforce user accounts, helping to optimize license usage and enhance security.**\n\nEfficient user management is vital in Salesforce to ensure resources are optimized and costs are controlled. However, inactive or unused user accounts can often go unnoticed, leading to wasted licenses and potential security risks. This tool addresses this challenge by enabling administrators to identify users who haven't logged in within a specified period.\n\nBy analyzing user login activity and last login timestamps, this feature highlights inactive user accounts, allowing administrators to take appropriate action. Whether it's deactivating dormant accounts, freeing up licenses, or ensuring compliance with security policies, this functionality empowers administrators to maintain a lean and secure Salesforce environment.\n\nKey functionalities:\n\n- **Inactivity Detection:** Identifies users who have not logged in for a specified number of days (`--days` flag, default 180 days in CI, 365 days otherwise).\n- **License Type Filtering:** Allows filtering users by license type using `--licensetypes` (e.g., `all-crm`, `all-paying`) or specific license identifiers using `--licenseidentifiers`.\n - `all-crm`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT` licenses.\n - `all-paying`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT`, `PID_Customer_Community`, `PID_Customer_Community_Login`, `PID_Partner_Community`, `PID_Partner_Community_Login` licenses.\n - Note: You can see the full list of available license identifiers in [Salesforce Documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/sfdx_cli_reference/sforce_api_objects_userlicense.htm).\n- **Active User Retrieval:** The `--returnactiveusers` flag inverts the command, allowing you to retrieve active users who *have* logged in during the specified period.\n- **CSV Report Generation:** Generates a CSV file containing details of all identified users (inactive or active), including their last login date, profile, and license information.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of inactive or active users.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-inactive-users/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query (Bulk API):** It uses `bulkQuery` to efficiently retrieve user records from the Salesforce `User` object. The SOQL query dynamically constructs its WHERE clause based on the `--days`, `--licensetypes`, `--licenseidentifiers`, and `--returnactiveusers` flags.\n- **Interactive Prompts:** Uses `prompts` to interactively ask the user for the number of inactive days and license types if not provided via flags.\n- **License Mapping:** Internally maps common license type aliases (e.g., `all-crm`) to their corresponding Salesforce `LicenseDefinitionKey` values.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of users.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Feedback:** Provides a summary of the findings in the console, indicating the number of inactive or active users found.\n</details>",
7477
7445
  "examples": [
7478
- "$ sf hardis:org:files:import"
7446
+ "$ sf hardis:org:diagnose:unusedusers",
7447
+ "$ sf hardis:org:diagnose:unusedusers --days 365",
7448
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm",
7449
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licenseidentifiers SFDC,AUL,AUL1",
7450
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm --returnactiveusers"
7479
7451
  ],
7480
7452
  "flags": {
7481
7453
  "json": {
@@ -7493,18 +7465,46 @@
7493
7465
  "multiple": false,
7494
7466
  "type": "option"
7495
7467
  },
7496
- "path": {
7497
- "char": "p",
7498
- "description": "Path to the file export project",
7499
- "name": "path",
7468
+ "outputfile": {
7469
+ "char": "f",
7470
+ "description": "Force the path and name of output report file. Must end with .csv",
7471
+ "name": "outputfile",
7500
7472
  "hasDynamicHelp": false,
7501
7473
  "multiple": false,
7502
7474
  "type": "option"
7503
7475
  },
7504
- "overwrite": {
7505
- "char": "f",
7506
- "description": "Override existing files (doubles the number of API calls)",
7507
- "name": "overwrite",
7476
+ "days": {
7477
+ "char": "t",
7478
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7479
+ "name": "days",
7480
+ "hasDynamicHelp": false,
7481
+ "multiple": false,
7482
+ "type": "option"
7483
+ },
7484
+ "licensetypes": {
7485
+ "char": "l",
7486
+ "description": "Type of licenses to check. If set, do not use licenseidentifiers option. In CI, default is all-crm",
7487
+ "name": "licensetypes",
7488
+ "hasDynamicHelp": false,
7489
+ "multiple": false,
7490
+ "options": [
7491
+ "all",
7492
+ "all-crm",
7493
+ "all-paying"
7494
+ ],
7495
+ "type": "option"
7496
+ },
7497
+ "licenseidentifiers": {
7498
+ "char": "i",
7499
+ "description": "Comma-separated list of license identifiers, in case licensetypes is not used.. Identifiers available at https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_userlicense.htm",
7500
+ "name": "licenseidentifiers",
7501
+ "hasDynamicHelp": false,
7502
+ "multiple": false,
7503
+ "type": "option"
7504
+ },
7505
+ "returnactiveusers": {
7506
+ "description": "Inverts the command by returning the active users",
7507
+ "name": "returnactiveusers",
7508
7508
  "allowNo": false,
7509
7509
  "type": "boolean"
7510
7510
  },
@@ -7546,13 +7546,13 @@
7546
7546
  },
7547
7547
  "hasDynamicHelp": true,
7548
7548
  "hiddenAliases": [],
7549
- "id": "hardis:org:files:import",
7549
+ "id": "hardis:org:diagnose:unusedusers",
7550
7550
  "pluginAlias": "sfdx-hardis",
7551
7551
  "pluginName": "sfdx-hardis",
7552
7552
  "pluginType": "core",
7553
7553
  "strict": true,
7554
7554
  "enableJsonFlag": true,
7555
- "title": "Import files",
7555
+ "title": "Detect unused Users in Salesforce",
7556
7556
  "requiresProject": false,
7557
7557
  "isESM": true,
7558
7558
  "relativePath": [
@@ -7560,35 +7560,35 @@
7560
7560
  "commands",
7561
7561
  "hardis",
7562
7562
  "org",
7563
- "files",
7564
- "import.js"
7563
+ "diagnose",
7564
+ "unusedusers.js"
7565
7565
  ],
7566
7566
  "aliasPermutations": [],
7567
7567
  "permutations": [
7568
- "hardis:org:files:import",
7569
- "org:hardis:files:import",
7570
- "org:files:hardis:import",
7571
- "org:files:import:hardis",
7572
- "hardis:files:org:import",
7573
- "files:hardis:org:import",
7574
- "files:org:hardis:import",
7575
- "files:org:import:hardis",
7576
- "hardis:files:import:org",
7577
- "files:hardis:import:org",
7578
- "files:import:hardis:org",
7579
- "files:import:org:hardis",
7580
- "hardis:org:import:files",
7581
- "org:hardis:import:files",
7582
- "org:import:hardis:files",
7583
- "org:import:files:hardis",
7584
- "hardis:import:org:files",
7585
- "import:hardis:org:files",
7586
- "import:org:hardis:files",
7587
- "import:org:files:hardis",
7588
- "hardis:import:files:org",
7589
- "import:hardis:files:org",
7590
- "import:files:hardis:org",
7591
- "import:files:org:hardis"
7568
+ "hardis:org:diagnose:unusedusers",
7569
+ "org:hardis:diagnose:unusedusers",
7570
+ "org:diagnose:hardis:unusedusers",
7571
+ "org:diagnose:unusedusers:hardis",
7572
+ "hardis:diagnose:org:unusedusers",
7573
+ "diagnose:hardis:org:unusedusers",
7574
+ "diagnose:org:hardis:unusedusers",
7575
+ "diagnose:org:unusedusers:hardis",
7576
+ "hardis:diagnose:unusedusers:org",
7577
+ "diagnose:hardis:unusedusers:org",
7578
+ "diagnose:unusedusers:hardis:org",
7579
+ "diagnose:unusedusers:org:hardis",
7580
+ "hardis:org:unusedusers:diagnose",
7581
+ "org:hardis:unusedusers:diagnose",
7582
+ "org:unusedusers:hardis:diagnose",
7583
+ "org:unusedusers:diagnose:hardis",
7584
+ "hardis:unusedusers:org:diagnose",
7585
+ "unusedusers:hardis:org:diagnose",
7586
+ "unusedusers:org:hardis:diagnose",
7587
+ "unusedusers:org:diagnose:hardis",
7588
+ "hardis:unusedusers:diagnose:org",
7589
+ "unusedusers:hardis:diagnose:org",
7590
+ "unusedusers:diagnose:hardis:org",
7591
+ "unusedusers:diagnose:org:hardis"
7592
7592
  ]
7593
7593
  },
7594
7594
  "hardis:org:fix:listviewmine": {
@@ -10298,262 +10298,30 @@
10298
10298
  ],
10299
10299
  "aliasPermutations": [],
10300
10300
  "permutations": [
10301
- "hardis:project:audit:remotesites",
10302
- "project:hardis:audit:remotesites",
10303
- "project:audit:hardis:remotesites",
10304
- "project:audit:remotesites:hardis",
10305
- "hardis:audit:project:remotesites",
10306
- "audit:hardis:project:remotesites",
10307
- "audit:project:hardis:remotesites",
10308
- "audit:project:remotesites:hardis",
10309
- "hardis:audit:remotesites:project",
10310
- "audit:hardis:remotesites:project",
10311
- "audit:remotesites:hardis:project",
10312
- "audit:remotesites:project:hardis",
10313
- "hardis:project:remotesites:audit",
10314
- "project:hardis:remotesites:audit",
10315
- "project:remotesites:hardis:audit",
10316
- "project:remotesites:audit:hardis",
10317
- "hardis:remotesites:project:audit",
10318
- "remotesites:hardis:project:audit",
10319
- "remotesites:project:hardis:audit",
10320
- "remotesites:project:audit:hardis",
10321
- "hardis:remotesites:audit:project",
10322
- "remotesites:hardis:audit:project",
10323
- "remotesites:audit:hardis:project",
10324
- "remotesites:audit:project:hardis"
10325
- ]
10326
- },
10327
- "hardis:project:configure:auth": {
10328
- "aliases": [],
10329
- "args": {},
10330
- "description": "\n## Command Behavior\n\n**Configures authentication between a Git branch and a target Salesforce org for CI/CD deployments.**\n\nThis command facilitates the setup of automated CI/CD pipelines, enabling seamless deployments from specific Git branches to designated Salesforce orgs. It supports both standard Salesforce orgs and Dev Hub configurations, catering to various enterprise deployment workflows.\n\nKey functionalities include:\n\n- **Org Selection/Login:** Guides the user to select an existing Salesforce org or log in to a new one.\n- **Git Branch Association:** Allows associating a specific Git branch with the chosen Salesforce org.\n- **Merge Target Definition:** Enables defining target Git branches into which the configured branch can merge, ensuring controlled deployment flows.\n- **Salesforce Username Configuration:** Prompts for the Salesforce username to be used by the CI server for deployments.\n- **SSL Certificate Generation:** Automatically generates an SSL certificate for secure authentication.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's implementation involves several key technical aspects:\n\n- **SF CLI Integration:** Utilizes \n@salesforce/sf-plugins-core\n for command structure and flag parsing.\n- **Interactive Prompts:** Employs the \nprompts\n library for interactive user input, guiding the configuration process.\n- **Git Integration:** Interacts with Git to retrieve branch information using \n`git().branch([\"--list\", \"-r\"])`\n.\n- **Configuration Management:** Leverages internal utilities (`checkConfig`, `getConfig`, `setConfig`, `setInConfigFile`) to read from and write to project-specific configuration files (e.g., `.sfdx-hardis.<branchName>.yml`).\n- **Salesforce CLI Execution:** Executes Salesforce CLI commands programmatically via `execSfdxJson` for org interactions.\n- **SSL Certificate Generation:** Calls `generateSSLCertificate` to create necessary SSL certificates for JWT-based authentication.\n- **WebSocket Communication:** Uses `WebSocketClient` for potential communication with external tools or processes, such as restarting the command in VS Code.\n- **Dependency Check:** Ensures the presence of `openssl` on the system, which is required for SSL certificate generation.\n",
10331
- "examples": [
10332
- "$ sf hardis:project:configure:auth"
10333
- ],
10334
- "flags": {
10335
- "json": {
10336
- "description": "Format output as json.",
10337
- "helpGroup": "GLOBAL",
10338
- "name": "json",
10339
- "allowNo": false,
10340
- "type": "boolean"
10341
- },
10342
- "flags-dir": {
10343
- "helpGroup": "GLOBAL",
10344
- "name": "flags-dir",
10345
- "summary": "Import flag values from a directory.",
10346
- "hasDynamicHelp": false,
10347
- "multiple": false,
10348
- "type": "option"
10349
- },
10350
- "devhub": {
10351
- "char": "b",
10352
- "description": "Configure project DevHub",
10353
- "name": "devhub",
10354
- "allowNo": false,
10355
- "type": "boolean"
10356
- },
10357
- "debug": {
10358
- "char": "d",
10359
- "description": "Activate debug mode (more logs)",
10360
- "name": "debug",
10361
- "allowNo": false,
10362
- "type": "boolean"
10363
- },
10364
- "websocket": {
10365
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
10366
- "name": "websocket",
10367
- "hasDynamicHelp": false,
10368
- "multiple": false,
10369
- "type": "option"
10370
- },
10371
- "skipauth": {
10372
- "description": "Skip authentication check when a default username is required",
10373
- "name": "skipauth",
10374
- "allowNo": false,
10375
- "type": "boolean"
10376
- },
10377
- "target-org": {
10378
- "aliases": [
10379
- "targetusername",
10380
- "u"
10381
- ],
10382
- "char": "o",
10383
- "deprecateAliases": true,
10384
- "name": "target-org",
10385
- "noCacheDefault": true,
10386
- "summary": "Username or alias of the target org.",
10387
- "hasDynamicHelp": true,
10388
- "multiple": false,
10389
- "type": "option"
10390
- },
10391
- "target-dev-hub": {
10392
- "aliases": [
10393
- "targetdevhubusername"
10394
- ],
10395
- "char": "v",
10396
- "deprecateAliases": true,
10397
- "name": "target-dev-hub",
10398
- "noCacheDefault": true,
10399
- "required": false,
10400
- "summary": "Username or alias of the Dev Hub org.",
10401
- "hasDynamicHelp": true,
10402
- "multiple": false,
10403
- "type": "option"
10404
- }
10405
- },
10406
- "hasDynamicHelp": true,
10407
- "hiddenAliases": [],
10408
- "id": "hardis:project:configure:auth",
10409
- "pluginAlias": "sfdx-hardis",
10410
- "pluginName": "sfdx-hardis",
10411
- "pluginType": "core",
10412
- "strict": true,
10413
- "enableJsonFlag": true,
10414
- "title": "Configure authentication",
10415
- "requiresProject": false,
10416
- "requiresDependencies": [
10417
- "openssl"
10418
- ],
10419
- "isESM": true,
10420
- "relativePath": [
10421
- "lib",
10422
- "commands",
10423
- "hardis",
10424
- "project",
10425
- "configure",
10426
- "auth.js"
10427
- ],
10428
- "aliasPermutations": [],
10429
- "permutations": [
10430
- "hardis:project:configure:auth",
10431
- "project:hardis:configure:auth",
10432
- "project:configure:hardis:auth",
10433
- "project:configure:auth:hardis",
10434
- "hardis:configure:project:auth",
10435
- "configure:hardis:project:auth",
10436
- "configure:project:hardis:auth",
10437
- "configure:project:auth:hardis",
10438
- "hardis:configure:auth:project",
10439
- "configure:hardis:auth:project",
10440
- "configure:auth:hardis:project",
10441
- "configure:auth:project:hardis",
10442
- "hardis:project:auth:configure",
10443
- "project:hardis:auth:configure",
10444
- "project:auth:hardis:configure",
10445
- "project:auth:configure:hardis",
10446
- "hardis:auth:project:configure",
10447
- "auth:hardis:project:configure",
10448
- "auth:project:hardis:configure",
10449
- "auth:project:configure:hardis",
10450
- "hardis:auth:configure:project",
10451
- "auth:hardis:configure:project",
10452
- "auth:configure:hardis:project",
10453
- "auth:configure:project:hardis"
10454
- ]
10455
- },
10456
- "hardis:project:convert:profilestopermsets": {
10457
- "aliases": [],
10458
- "args": {},
10459
- "description": "\n## Command Behavior\n\n**Converts existing Salesforce Profiles into Permission Sets, facilitating a more granular and recommended security model.**\n\nThis command helps in migrating permissions from Profiles to Permission Sets, which is a best practice for managing user access in Salesforce. It creates a new Permission Set for each specified Profile, adopting a naming convention of `PS_PROFILENAME`.\n\nKey functionalities:\n\n- **Profile to Permission Set Conversion:** Automatically extracts permissions from a Profile and creates a corresponding Permission Set.\n- **Naming Convention:** New Permission Sets are named with a `PS_` prefix followed by the Profile name (e.g., `PS_Standard_User`).\n- **Exclusion Filter:** Allows you to exclude specific Profiles from the conversion process using the `--except` flag.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **External Plugin Integration:** It relies on the `shane-sfdx-plugins` (specifically the `sf shane:profile:convert` command) to perform the actual conversion.\n- **File System Scan:** It reads the contents of the `force-app/main/default/profiles` directory to identify all available Profile metadata files.\n- **Command Execution:** For each identified Profile (that is not excluded), it constructs and executes the `sf shane:profile:convert` command with the appropriate Profile name and desired Permission Set name.\n- **Error Handling:** Includes basic error handling for the external command execution.\n</details>\n",
10460
- "examples": [
10461
- "$ sf hardis:project:convert:profilestopermsets"
10462
- ],
10463
- "flags": {
10464
- "json": {
10465
- "description": "Format output as json.",
10466
- "helpGroup": "GLOBAL",
10467
- "name": "json",
10468
- "allowNo": false,
10469
- "type": "boolean"
10470
- },
10471
- "flags-dir": {
10472
- "helpGroup": "GLOBAL",
10473
- "name": "flags-dir",
10474
- "summary": "Import flag values from a directory.",
10475
- "hasDynamicHelp": false,
10476
- "multiple": false,
10477
- "type": "option"
10478
- },
10479
- "except": {
10480
- "char": "e",
10481
- "description": "List of filters",
10482
- "name": "except",
10483
- "default": [],
10484
- "hasDynamicHelp": false,
10485
- "multiple": true,
10486
- "type": "option"
10487
- },
10488
- "debug": {
10489
- "char": "d",
10490
- "description": "Activate debug mode (more logs)",
10491
- "name": "debug",
10492
- "allowNo": false,
10493
- "type": "boolean"
10494
- },
10495
- "websocket": {
10496
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
10497
- "name": "websocket",
10498
- "hasDynamicHelp": false,
10499
- "multiple": false,
10500
- "type": "option"
10501
- },
10502
- "skipauth": {
10503
- "description": "Skip authentication check when a default username is required",
10504
- "name": "skipauth",
10505
- "allowNo": false,
10506
- "type": "boolean"
10507
- }
10508
- },
10509
- "hasDynamicHelp": false,
10510
- "hiddenAliases": [],
10511
- "id": "hardis:project:convert:profilestopermsets",
10512
- "pluginAlias": "sfdx-hardis",
10513
- "pluginName": "sfdx-hardis",
10514
- "pluginType": "core",
10515
- "strict": true,
10516
- "enableJsonFlag": true,
10517
- "title": "Convert Profiles into Permission Sets",
10518
- "requiresProject": true,
10519
- "requiresSfdxPlugins": [
10520
- "shane-sfdx-plugins"
10521
- ],
10522
- "isESM": true,
10523
- "relativePath": [
10524
- "lib",
10525
- "commands",
10526
- "hardis",
10527
- "project",
10528
- "convert",
10529
- "profilestopermsets.js"
10530
- ],
10531
- "aliasPermutations": [],
10532
- "permutations": [
10533
- "hardis:project:convert:profilestopermsets",
10534
- "project:hardis:convert:profilestopermsets",
10535
- "project:convert:hardis:profilestopermsets",
10536
- "project:convert:profilestopermsets:hardis",
10537
- "hardis:convert:project:profilestopermsets",
10538
- "convert:hardis:project:profilestopermsets",
10539
- "convert:project:hardis:profilestopermsets",
10540
- "convert:project:profilestopermsets:hardis",
10541
- "hardis:convert:profilestopermsets:project",
10542
- "convert:hardis:profilestopermsets:project",
10543
- "convert:profilestopermsets:hardis:project",
10544
- "convert:profilestopermsets:project:hardis",
10545
- "hardis:project:profilestopermsets:convert",
10546
- "project:hardis:profilestopermsets:convert",
10547
- "project:profilestopermsets:hardis:convert",
10548
- "project:profilestopermsets:convert:hardis",
10549
- "hardis:profilestopermsets:project:convert",
10550
- "profilestopermsets:hardis:project:convert",
10551
- "profilestopermsets:project:hardis:convert",
10552
- "profilestopermsets:project:convert:hardis",
10553
- "hardis:profilestopermsets:convert:project",
10554
- "profilestopermsets:hardis:convert:project",
10555
- "profilestopermsets:convert:hardis:project",
10556
- "profilestopermsets:convert:project:hardis"
10301
+ "hardis:project:audit:remotesites",
10302
+ "project:hardis:audit:remotesites",
10303
+ "project:audit:hardis:remotesites",
10304
+ "project:audit:remotesites:hardis",
10305
+ "hardis:audit:project:remotesites",
10306
+ "audit:hardis:project:remotesites",
10307
+ "audit:project:hardis:remotesites",
10308
+ "audit:project:remotesites:hardis",
10309
+ "hardis:audit:remotesites:project",
10310
+ "audit:hardis:remotesites:project",
10311
+ "audit:remotesites:hardis:project",
10312
+ "audit:remotesites:project:hardis",
10313
+ "hardis:project:remotesites:audit",
10314
+ "project:hardis:remotesites:audit",
10315
+ "project:remotesites:hardis:audit",
10316
+ "project:remotesites:audit:hardis",
10317
+ "hardis:remotesites:project:audit",
10318
+ "remotesites:hardis:project:audit",
10319
+ "remotesites:project:hardis:audit",
10320
+ "remotesites:project:audit:hardis",
10321
+ "hardis:remotesites:audit:project",
10322
+ "remotesites:hardis:audit:project",
10323
+ "remotesites:audit:hardis:project",
10324
+ "remotesites:audit:project:hardis"
10557
10325
  ]
10558
10326
  },
10559
10327
  "hardis:project:clean:emptyitems": {
@@ -12142,6 +11910,238 @@
12142
11910
  "xml:clean:project:hardis"
12143
11911
  ]
12144
11912
  },
11913
+ "hardis:project:convert:profilestopermsets": {
11914
+ "aliases": [],
11915
+ "args": {},
11916
+ "description": "\n## Command Behavior\n\n**Converts existing Salesforce Profiles into Permission Sets, facilitating a more granular and recommended security model.**\n\nThis command helps in migrating permissions from Profiles to Permission Sets, which is a best practice for managing user access in Salesforce. It creates a new Permission Set for each specified Profile, adopting a naming convention of `PS_PROFILENAME`.\n\nKey functionalities:\n\n- **Profile to Permission Set Conversion:** Automatically extracts permissions from a Profile and creates a corresponding Permission Set.\n- **Naming Convention:** New Permission Sets are named with a `PS_` prefix followed by the Profile name (e.g., `PS_Standard_User`).\n- **Exclusion Filter:** Allows you to exclude specific Profiles from the conversion process using the `--except` flag.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **External Plugin Integration:** It relies on the `shane-sfdx-plugins` (specifically the `sf shane:profile:convert` command) to perform the actual conversion.\n- **File System Scan:** It reads the contents of the `force-app/main/default/profiles` directory to identify all available Profile metadata files.\n- **Command Execution:** For each identified Profile (that is not excluded), it constructs and executes the `sf shane:profile:convert` command with the appropriate Profile name and desired Permission Set name.\n- **Error Handling:** Includes basic error handling for the external command execution.\n</details>\n",
11917
+ "examples": [
11918
+ "$ sf hardis:project:convert:profilestopermsets"
11919
+ ],
11920
+ "flags": {
11921
+ "json": {
11922
+ "description": "Format output as json.",
11923
+ "helpGroup": "GLOBAL",
11924
+ "name": "json",
11925
+ "allowNo": false,
11926
+ "type": "boolean"
11927
+ },
11928
+ "flags-dir": {
11929
+ "helpGroup": "GLOBAL",
11930
+ "name": "flags-dir",
11931
+ "summary": "Import flag values from a directory.",
11932
+ "hasDynamicHelp": false,
11933
+ "multiple": false,
11934
+ "type": "option"
11935
+ },
11936
+ "except": {
11937
+ "char": "e",
11938
+ "description": "List of filters",
11939
+ "name": "except",
11940
+ "default": [],
11941
+ "hasDynamicHelp": false,
11942
+ "multiple": true,
11943
+ "type": "option"
11944
+ },
11945
+ "debug": {
11946
+ "char": "d",
11947
+ "description": "Activate debug mode (more logs)",
11948
+ "name": "debug",
11949
+ "allowNo": false,
11950
+ "type": "boolean"
11951
+ },
11952
+ "websocket": {
11953
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
11954
+ "name": "websocket",
11955
+ "hasDynamicHelp": false,
11956
+ "multiple": false,
11957
+ "type": "option"
11958
+ },
11959
+ "skipauth": {
11960
+ "description": "Skip authentication check when a default username is required",
11961
+ "name": "skipauth",
11962
+ "allowNo": false,
11963
+ "type": "boolean"
11964
+ }
11965
+ },
11966
+ "hasDynamicHelp": false,
11967
+ "hiddenAliases": [],
11968
+ "id": "hardis:project:convert:profilestopermsets",
11969
+ "pluginAlias": "sfdx-hardis",
11970
+ "pluginName": "sfdx-hardis",
11971
+ "pluginType": "core",
11972
+ "strict": true,
11973
+ "enableJsonFlag": true,
11974
+ "title": "Convert Profiles into Permission Sets",
11975
+ "requiresProject": true,
11976
+ "requiresSfdxPlugins": [
11977
+ "shane-sfdx-plugins"
11978
+ ],
11979
+ "isESM": true,
11980
+ "relativePath": [
11981
+ "lib",
11982
+ "commands",
11983
+ "hardis",
11984
+ "project",
11985
+ "convert",
11986
+ "profilestopermsets.js"
11987
+ ],
11988
+ "aliasPermutations": [],
11989
+ "permutations": [
11990
+ "hardis:project:convert:profilestopermsets",
11991
+ "project:hardis:convert:profilestopermsets",
11992
+ "project:convert:hardis:profilestopermsets",
11993
+ "project:convert:profilestopermsets:hardis",
11994
+ "hardis:convert:project:profilestopermsets",
11995
+ "convert:hardis:project:profilestopermsets",
11996
+ "convert:project:hardis:profilestopermsets",
11997
+ "convert:project:profilestopermsets:hardis",
11998
+ "hardis:convert:profilestopermsets:project",
11999
+ "convert:hardis:profilestopermsets:project",
12000
+ "convert:profilestopermsets:hardis:project",
12001
+ "convert:profilestopermsets:project:hardis",
12002
+ "hardis:project:profilestopermsets:convert",
12003
+ "project:hardis:profilestopermsets:convert",
12004
+ "project:profilestopermsets:hardis:convert",
12005
+ "project:profilestopermsets:convert:hardis",
12006
+ "hardis:profilestopermsets:project:convert",
12007
+ "profilestopermsets:hardis:project:convert",
12008
+ "profilestopermsets:project:hardis:convert",
12009
+ "profilestopermsets:project:convert:hardis",
12010
+ "hardis:profilestopermsets:convert:project",
12011
+ "profilestopermsets:hardis:convert:project",
12012
+ "profilestopermsets:convert:hardis:project",
12013
+ "profilestopermsets:convert:project:hardis"
12014
+ ]
12015
+ },
12016
+ "hardis:project:configure:auth": {
12017
+ "aliases": [],
12018
+ "args": {},
12019
+ "description": "\n## Command Behavior\n\n**Configures authentication between a Git branch and a target Salesforce org for CI/CD deployments.**\n\nThis command facilitates the setup of automated CI/CD pipelines, enabling seamless deployments from specific Git branches to designated Salesforce orgs. It supports both standard Salesforce orgs and Dev Hub configurations, catering to various enterprise deployment workflows.\n\nKey functionalities include:\n\n- **Org Selection/Login:** Guides the user to select an existing Salesforce org or log in to a new one.\n- **Git Branch Association:** Allows associating a specific Git branch with the chosen Salesforce org.\n- **Merge Target Definition:** Enables defining target Git branches into which the configured branch can merge, ensuring controlled deployment flows.\n- **Salesforce Username Configuration:** Prompts for the Salesforce username to be used by the CI server for deployments.\n- **SSL Certificate Generation:** Automatically generates an SSL certificate for secure authentication.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's implementation involves several key technical aspects:\n\n- **SF CLI Integration:** Utilizes \n@salesforce/sf-plugins-core\n for command structure and flag parsing.\n- **Interactive Prompts:** Employs the \nprompts\n library for interactive user input, guiding the configuration process.\n- **Git Integration:** Interacts with Git to retrieve branch information using \n`git().branch([\"--list\", \"-r\"])`\n.\n- **Configuration Management:** Leverages internal utilities (`checkConfig`, `getConfig`, `setConfig`, `setInConfigFile`) to read from and write to project-specific configuration files (e.g., `.sfdx-hardis.<branchName>.yml`).\n- **Salesforce CLI Execution:** Executes Salesforce CLI commands programmatically via `execSfdxJson` for org interactions.\n- **SSL Certificate Generation:** Calls `generateSSLCertificate` to create necessary SSL certificates for JWT-based authentication.\n- **WebSocket Communication:** Uses `WebSocketClient` for potential communication with external tools or processes, such as restarting the command in VS Code.\n- **Dependency Check:** Ensures the presence of `openssl` on the system, which is required for SSL certificate generation.\n",
12020
+ "examples": [
12021
+ "$ sf hardis:project:configure:auth"
12022
+ ],
12023
+ "flags": {
12024
+ "json": {
12025
+ "description": "Format output as json.",
12026
+ "helpGroup": "GLOBAL",
12027
+ "name": "json",
12028
+ "allowNo": false,
12029
+ "type": "boolean"
12030
+ },
12031
+ "flags-dir": {
12032
+ "helpGroup": "GLOBAL",
12033
+ "name": "flags-dir",
12034
+ "summary": "Import flag values from a directory.",
12035
+ "hasDynamicHelp": false,
12036
+ "multiple": false,
12037
+ "type": "option"
12038
+ },
12039
+ "devhub": {
12040
+ "char": "b",
12041
+ "description": "Configure project DevHub",
12042
+ "name": "devhub",
12043
+ "allowNo": false,
12044
+ "type": "boolean"
12045
+ },
12046
+ "debug": {
12047
+ "char": "d",
12048
+ "description": "Activate debug mode (more logs)",
12049
+ "name": "debug",
12050
+ "allowNo": false,
12051
+ "type": "boolean"
12052
+ },
12053
+ "websocket": {
12054
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
12055
+ "name": "websocket",
12056
+ "hasDynamicHelp": false,
12057
+ "multiple": false,
12058
+ "type": "option"
12059
+ },
12060
+ "skipauth": {
12061
+ "description": "Skip authentication check when a default username is required",
12062
+ "name": "skipauth",
12063
+ "allowNo": false,
12064
+ "type": "boolean"
12065
+ },
12066
+ "target-org": {
12067
+ "aliases": [
12068
+ "targetusername",
12069
+ "u"
12070
+ ],
12071
+ "char": "o",
12072
+ "deprecateAliases": true,
12073
+ "name": "target-org",
12074
+ "noCacheDefault": true,
12075
+ "summary": "Username or alias of the target org.",
12076
+ "hasDynamicHelp": true,
12077
+ "multiple": false,
12078
+ "type": "option"
12079
+ },
12080
+ "target-dev-hub": {
12081
+ "aliases": [
12082
+ "targetdevhubusername"
12083
+ ],
12084
+ "char": "v",
12085
+ "deprecateAliases": true,
12086
+ "name": "target-dev-hub",
12087
+ "noCacheDefault": true,
12088
+ "required": false,
12089
+ "summary": "Username or alias of the Dev Hub org.",
12090
+ "hasDynamicHelp": true,
12091
+ "multiple": false,
12092
+ "type": "option"
12093
+ }
12094
+ },
12095
+ "hasDynamicHelp": true,
12096
+ "hiddenAliases": [],
12097
+ "id": "hardis:project:configure:auth",
12098
+ "pluginAlias": "sfdx-hardis",
12099
+ "pluginName": "sfdx-hardis",
12100
+ "pluginType": "core",
12101
+ "strict": true,
12102
+ "enableJsonFlag": true,
12103
+ "title": "Configure authentication",
12104
+ "requiresProject": false,
12105
+ "requiresDependencies": [
12106
+ "openssl"
12107
+ ],
12108
+ "isESM": true,
12109
+ "relativePath": [
12110
+ "lib",
12111
+ "commands",
12112
+ "hardis",
12113
+ "project",
12114
+ "configure",
12115
+ "auth.js"
12116
+ ],
12117
+ "aliasPermutations": [],
12118
+ "permutations": [
12119
+ "hardis:project:configure:auth",
12120
+ "project:hardis:configure:auth",
12121
+ "project:configure:hardis:auth",
12122
+ "project:configure:auth:hardis",
12123
+ "hardis:configure:project:auth",
12124
+ "configure:hardis:project:auth",
12125
+ "configure:project:hardis:auth",
12126
+ "configure:project:auth:hardis",
12127
+ "hardis:configure:auth:project",
12128
+ "configure:hardis:auth:project",
12129
+ "configure:auth:hardis:project",
12130
+ "configure:auth:project:hardis",
12131
+ "hardis:project:auth:configure",
12132
+ "project:hardis:auth:configure",
12133
+ "project:auth:hardis:configure",
12134
+ "project:auth:configure:hardis",
12135
+ "hardis:auth:project:configure",
12136
+ "auth:hardis:project:configure",
12137
+ "auth:project:hardis:configure",
12138
+ "auth:project:configure:hardis",
12139
+ "hardis:auth:configure:project",
12140
+ "auth:hardis:configure:project",
12141
+ "auth:configure:hardis:project",
12142
+ "auth:configure:project:hardis"
12143
+ ]
12144
+ },
12145
12145
  "hardis:project:deploy:notify": {
12146
12146
  "aliases": [],
12147
12147
  "args": {},
@@ -16104,5 +16104,5 @@
16104
16104
  ]
16105
16105
  }
16106
16106
  },
16107
- "version": "6.17.2-alpha202512261745.0"
16107
+ "version": "6.18.0"
16108
16108
  }