sfdx-hardis 6.17.2-alpha202512261745.0 → 6.17.2-alpha202512261823.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.
@@ -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,216 +3163,138 @@
3163
3163
  "multiple": false,
3164
3164
  "type": "option"
3165
3165
  },
3166
- "checkonly": {
3167
- "char": "c",
3168
- "description": "checkonly",
3169
- "name": "checkonly",
3170
- "allowNo": false,
3171
- "type": "boolean"
3172
- },
3173
- "soapdeploy": {
3174
- "description": "soapDeploy",
3175
- "name": "soapdeploy",
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",
3176
3170
  "allowNo": false,
3177
3171
  "type": "boolean"
3178
3172
  },
3179
- "wait": {
3180
- "char": "w",
3181
- "description": "wait",
3182
- "name": "wait",
3183
- "default": 60,
3184
- "hasDynamicHelp": false,
3185
- "multiple": false,
3186
- "type": "option"
3187
- },
3188
- "testlevel": {
3189
- "char": "l",
3190
- "description": "testlevel",
3191
- "name": "testlevel",
3192
- "default": "NoTestRun",
3193
- "hasDynamicHelp": false,
3194
- "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
- "type": "option"
3211
- },
3212
- "ignoreerrors": {
3213
- "description": "ignoreErrors",
3214
- "name": "ignoreerrors",
3173
+ "pool": {
3174
+ "description": "Creates the scratch org for a scratch org pool",
3175
+ "name": "pool",
3215
3176
  "allowNo": false,
3216
3177
  "type": "boolean"
3217
3178
  },
3218
- "ignorewarnings": {
3219
- "char": "g",
3220
- "description": "ignoreWarnings",
3221
- "name": "ignorewarnings",
3179
+ "debug": {
3180
+ "char": "d",
3181
+ "description": "Activate debug mode (more logs)",
3182
+ "name": "debug",
3222
3183
  "allowNo": false,
3223
3184
  "type": "boolean"
3224
3185
  },
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",
3186
+ "websocket": {
3187
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3188
+ "name": "websocket",
3239
3189
  "hasDynamicHelp": false,
3240
3190
  "multiple": false,
3241
3191
  "type": "option"
3242
3192
  },
3243
- "verbose": {
3244
- "description": "verbose",
3245
- "name": "verbose",
3193
+ "skipauth": {
3194
+ "description": "Skip authentication check when a default username is required",
3195
+ "name": "skipauth",
3246
3196
  "allowNo": false,
3247
3197
  "type": "boolean"
3248
3198
  },
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"
3199
+ "target-dev-hub": {
3200
+ "aliases": [
3201
+ "targetdevhubusername"
3298
3202
  ],
3299
- "description": "postdestructivechanges",
3300
- "name": "postdestructivechanges",
3301
- "hasDynamicHelp": false,
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,
3302
3210
  "multiple": false,
3303
3211
  "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",
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",
3323
3257
  "allowNo": false,
3324
3258
  "type": "boolean"
3325
3259
  },
3326
- "resultsdir": {
3327
- "description": "resultsdir",
3328
- "name": "resultsdir",
3260
+ "flags-dir": {
3261
+ "helpGroup": "GLOBAL",
3262
+ "name": "flags-dir",
3263
+ "summary": "Import flag values from a directory.",
3329
3264
  "hasDynamicHelp": false,
3330
3265
  "multiple": false,
3331
3266
  "type": "option"
3332
3267
  },
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
3268
  "debug": {
3353
- "description": "debug",
3269
+ "char": "d",
3270
+ "description": "Activate debug mode (more logs)",
3354
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": {
3282
+ "skipauth": {
3283
+ "description": "Skip authentication check when a default username is required",
3284
+ "name": "skipauth",
3285
+ "allowNo": false,
3286
+ "type": "boolean"
3287
+ },
3288
+ "target-dev-hub": {
3366
3289
  "aliases": [
3367
- "targetusername",
3368
- "u"
3290
+ "targetdevhubusername"
3369
3291
  ],
3370
- "char": "o",
3292
+ "char": "v",
3371
3293
  "deprecateAliases": true,
3372
- "name": "target-org",
3294
+ "name": "target-dev-hub",
3373
3295
  "noCacheDefault": true,
3374
3296
  "required": true,
3375
- "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.",
3376
3298
  "hasDynamicHelp": true,
3377
3299
  "multiple": false,
3378
3300
  "type": "option"
@@ -3380,35 +3302,38 @@
3380
3302
  },
3381
3303
  "hasDynamicHelp": true,
3382
3304
  "hiddenAliases": [],
3383
- "id": "hardis:source:deploy",
3305
+ "id": "hardis:scratch:delete",
3384
3306
  "pluginAlias": "sfdx-hardis",
3385
3307
  "pluginName": "sfdx-hardis",
3386
3308
  "pluginType": "core",
3387
3309
  "strict": true,
3388
3310
  "enableJsonFlag": true,
3389
- "requiresProject": true,
3311
+ "title": "Delete scratch orgs(s)",
3390
3312
  "isESM": true,
3391
3313
  "relativePath": [
3392
3314
  "lib",
3393
3315
  "commands",
3394
3316
  "hardis",
3395
- "source",
3396
- "deploy.js"
3317
+ "scratch",
3318
+ "delete.js"
3397
3319
  ],
3398
3320
  "aliasPermutations": [],
3399
3321
  "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"
3322
+ "hardis:scratch:delete",
3323
+ "scratch:hardis:delete",
3324
+ "scratch:delete:hardis",
3325
+ "hardis:delete:scratch",
3326
+ "delete:hardis:scratch",
3327
+ "delete:scratch:hardis"
3406
3328
  ]
3407
3329
  },
3408
- "hardis:source:push": {
3330
+ "hardis:scratch:pull": {
3409
3331
  "aliases": [],
3410
3332
  "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",
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
+ ],
3412
3337
  "flags": {
3413
3338
  "json": {
3414
3339
  "description": "Format output as json.",
@@ -3420,53 +3345,31 @@
3420
3345
  "flags-dir": {
3421
3346
  "helpGroup": "GLOBAL",
3422
3347
  "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"
3348
+ "summary": "Import flag values from a directory.",
3349
+ "hasDynamicHelp": false,
3350
+ "multiple": false,
3351
+ "type": "option"
3456
3352
  },
3457
3353
  "debug": {
3458
- "description": "debug",
3354
+ "char": "d",
3355
+ "description": "Activate debug mode (more logs)",
3459
3356
  "name": "debug",
3460
3357
  "allowNo": false,
3461
3358
  "type": "boolean"
3462
3359
  },
3463
3360
  "websocket": {
3464
- "description": "websocket",
3361
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3465
3362
  "name": "websocket",
3466
3363
  "hasDynamicHelp": false,
3467
3364
  "multiple": false,
3468
3365
  "type": "option"
3469
3366
  },
3367
+ "skipauth": {
3368
+ "description": "Skip authentication check when a default username is required",
3369
+ "name": "skipauth",
3370
+ "allowNo": false,
3371
+ "type": "boolean"
3372
+ },
3470
3373
  "target-org": {
3471
3374
  "aliases": [
3472
3375
  "targetusername",
@@ -3485,36 +3388,39 @@
3485
3388
  },
3486
3389
  "hasDynamicHelp": true,
3487
3390
  "hiddenAliases": [],
3488
- "id": "hardis:source:push",
3391
+ "id": "hardis:scratch:pull",
3489
3392
  "pluginAlias": "sfdx-hardis",
3490
3393
  "pluginName": "sfdx-hardis",
3491
3394
  "pluginType": "core",
3492
3395
  "strict": true,
3493
3396
  "enableJsonFlag": true,
3397
+ "title": "Scratch PULL",
3494
3398
  "requiresProject": true,
3495
3399
  "isESM": true,
3496
3400
  "relativePath": [
3497
3401
  "lib",
3498
3402
  "commands",
3499
3403
  "hardis",
3500
- "source",
3501
- "push.js"
3404
+ "scratch",
3405
+ "pull.js"
3502
3406
  ],
3503
3407
  "aliasPermutations": [],
3504
3408
  "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"
3409
+ "hardis:scratch:pull",
3410
+ "scratch:hardis:pull",
3411
+ "scratch:pull:hardis",
3412
+ "hardis:pull:scratch",
3413
+ "pull:hardis:scratch",
3414
+ "pull:scratch:hardis"
3511
3415
  ]
3512
3416
  },
3513
- "hardis:source:retrieve": {
3417
+ "hardis:scratch:push": {
3514
3418
  "aliases": [],
3515
3419
  "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": [],
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",
3421
+ "examples": [
3422
+ "$ sf hardis:scratch:push"
3423
+ ],
3518
3424
  "flags": {
3519
3425
  "json": {
3520
3426
  "description": "Format output as json.",
@@ -3531,98 +3437,15 @@
3531
3437
  "multiple": false,
3532
3438
  "type": "option"
3533
3439
  },
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"
3616
- },
3617
3440
  "debug": {
3618
3441
  "char": "d",
3619
- "description": "debugMode",
3442
+ "description": "Activate debug mode (more logs)",
3620
3443
  "name": "debug",
3621
3444
  "allowNo": false,
3622
3445
  "type": "boolean"
3623
3446
  },
3624
3447
  "websocket": {
3625
- "description": "websocket",
3448
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3626
3449
  "name": "websocket",
3627
3450
  "hasDynamicHelp": false,
3628
3451
  "multiple": false,
@@ -3652,37 +3475,38 @@
3652
3475
  },
3653
3476
  "hasDynamicHelp": true,
3654
3477
  "hiddenAliases": [],
3655
- "id": "hardis:source:retrieve",
3478
+ "id": "hardis:scratch:push",
3656
3479
  "pluginAlias": "sfdx-hardis",
3657
3480
  "pluginName": "sfdx-hardis",
3658
3481
  "pluginType": "core",
3659
3482
  "strict": true,
3660
3483
  "enableJsonFlag": true,
3484
+ "title": "Scratch PUSH",
3661
3485
  "requiresProject": true,
3662
3486
  "isESM": true,
3663
3487
  "relativePath": [
3664
3488
  "lib",
3665
3489
  "commands",
3666
3490
  "hardis",
3667
- "source",
3668
- "retrieve.js"
3491
+ "scratch",
3492
+ "push.js"
3669
3493
  ],
3670
3494
  "aliasPermutations": [],
3671
3495
  "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"
3496
+ "hardis:scratch:push",
3497
+ "scratch:hardis:push",
3498
+ "scratch:push:hardis",
3499
+ "hardis:push:scratch",
3500
+ "push:hardis:scratch",
3501
+ "push:scratch:hardis"
3678
3502
  ]
3679
3503
  },
3680
- "hardis:work:new": {
3504
+ "hardis:source:deploy": {
3681
3505
  "aliases": [],
3682
3506
  "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",
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",
3684
3508
  "examples": [
3685
- "$ sf hardis:work:new"
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"
3686
3510
  ],
3687
3511
  "flags": {
3688
3512
  "json": {
@@ -3697,136 +3521,208 @@
3697
3521
  "name": "flags-dir",
3698
3522
  "summary": "Import flag values from a directory.",
3699
3523
  "hasDynamicHelp": false,
3700
- "multiple": false,
3524
+ "multiple": false,
3525
+ "type": "option"
3526
+ },
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,
3701
3632
  "type": "option"
3702
3633
  },
3703
- "debug": {
3704
- "char": "d",
3705
- "description": "Activate debug mode (more logs)",
3706
- "name": "debug",
3707
- "allowNo": false,
3708
- "type": "boolean"
3709
- },
3710
- "websocket": {
3711
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
3712
- "name": "websocket",
3634
+ "manifest": {
3635
+ "char": "x",
3636
+ "description": "flagsLong.manifest",
3637
+ "exclusive": [
3638
+ "metadata",
3639
+ "sourcepath"
3640
+ ],
3641
+ "name": "manifest",
3713
3642
  "hasDynamicHelp": false,
3714
3643
  "multiple": false,
3715
3644
  "type": "option"
3716
3645
  },
3717
- "skipauth": {
3718
- "description": "Skip authentication check when a default username is required",
3719
- "name": "skipauth",
3720
- "allowNo": false,
3721
- "type": "boolean"
3722
- },
3723
- "target-dev-hub": {
3724
- "aliases": [
3725
- "targetdevhubusername"
3646
+ "predestructivechanges": {
3647
+ "dependsOn": [
3648
+ "manifest"
3726
3649
  ],
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,
3650
+ "description": "predestructivechanges",
3651
+ "name": "predestructivechanges",
3652
+ "hasDynamicHelp": false,
3734
3653
  "multiple": false,
3735
3654
  "type": "option"
3736
3655
  },
3737
- "target-org": {
3738
- "aliases": [
3739
- "targetusername",
3740
- "u"
3656
+ "postdestructivechanges": {
3657
+ "dependsOn": [
3658
+ "manifest"
3741
3659
  ],
3742
- "char": "o",
3743
- "deprecateAliases": true,
3744
- "name": "target-org",
3745
- "noCacheDefault": true,
3746
- "summary": "Username or alias of the target org.",
3747
- "hasDynamicHelp": true,
3660
+ "description": "postdestructivechanges",
3661
+ "name": "postdestructivechanges",
3662
+ "hasDynamicHelp": false,
3748
3663
  "multiple": false,
3749
3664
  "type": "option"
3750
- }
3751
- },
3752
- "hasDynamicHelp": true,
3753
- "hiddenAliases": [],
3754
- "id": "hardis:work:new",
3755
- "pluginAlias": "sfdx-hardis",
3756
- "pluginName": "sfdx-hardis",
3757
- "pluginType": "core",
3758
- "strict": true,
3759
- "enableJsonFlag": true,
3760
- "title": "New User Story",
3761
- "requiresProject": true,
3762
- "isESM": true,
3763
- "relativePath": [
3764
- "lib",
3765
- "commands",
3766
- "hardis",
3767
- "work",
3768
- "new.js"
3769
- ],
3770
- "aliasPermutations": [],
3771
- "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"
3778
- ]
3779
- },
3780
- "hardis:work:refresh": {
3781
- "aliases": [],
3782
- "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",
3784
- "examples": [
3785
- "$ sf hardis:work:refresh"
3786
- ],
3787
- "flags": {
3788
- "json": {
3789
- "description": "Format output as json.",
3790
- "helpGroup": "GLOBAL",
3791
- "name": "json",
3665
+ },
3666
+ "tracksource": {
3667
+ "char": "t",
3668
+ "description": "tracksource",
3669
+ "exclusive": [
3670
+ "checkonly",
3671
+ "validateddeployrequestid"
3672
+ ],
3673
+ "name": "tracksource",
3792
3674
  "allowNo": false,
3793
3675
  "type": "boolean"
3794
3676
  },
3795
- "flags-dir": {
3796
- "helpGroup": "GLOBAL",
3797
- "name": "flags-dir",
3798
- "summary": "Import flag values from a directory.",
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",
3799
3690
  "hasDynamicHelp": false,
3800
3691
  "multiple": false,
3801
3692
  "type": "option"
3802
3693
  },
3803
- "nopull": {
3804
- "char": "n",
3805
- "description": "No scratch pull before save (careful if you use that!)",
3806
- "name": "nopull",
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": {
3962
- "aliases": [],
3963
- "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
- ],
3874
+ "hardis:source:retrieve": {
3875
+ "aliases": [],
3876
+ "args": {},
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)",
@@ -4133,45 +4080,70 @@
4133
4080
  "name": "skipauth",
4134
4081
  "allowNo": false,
4135
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,15 +5924,13 @@
5924
5924
  "import:data:org:hardis"
5925
5925
  ]
5926
5926
  },
5927
- "hardis:org:diagnose:audittrail": {
5927
+ "hardis:org:fix:listviewmine": {
5928
5928
  "aliases": [],
5929
5929
  "args": {},
5930
- "description": "Export Audit trail into a CSV file with selected criteria, and highlight suspect actions\n\nAlso detects updates of Custom Settings values (disable by defining `SKIP_AUDIT_TRAIL_CUSTOM_SETTINGS=true`)\n\nRegular setup actions performed in major orgs are filtered.\n\n- \"\"\n - createScratchOrg\n - changedsenderemail\n - deleteScratchOrg\n - loginasgrantedtopartnerbt\n- Certificate and Key Management\n - insertCertificate\n- Custom App Licenses\n - addeduserpackagelicense\n - granteduserpackagelicense\n - revokeduserpackagelicense\n- Customer Portal\n - createdcustomersuccessuser\n - CSPUserDisabled\n- Currency\n - updateddatedexchrate\n- Data Management\n - queueMembership\n- Email Administration\n - dkimRotationPreparationSuccessful\n - dkimRotationSuccessful\n- External Objects\n - xdsEncryptedFieldChange\n- Groups\n - groupMembership\n- Holidays\n - holiday_insert\n- Inbox mobile and legacy desktop apps\n - enableSIQUserNonEAC\n - siqUserAcceptedTOS\n- Manage Users\n - activateduser\n - createduser\n - changedcommunitynickname\n - changedemail\n - changedfederationid\n - changedpassword\n - changedinteractionuseroffon\n - changedinteractionuseronoff\n - changedmarketinguseroffon\n - changedmarketinguseronoff\n - changedofflineuseroffon\n - changedprofileforuserstdtostd\n - changedprofileforuser\n - changedprofileforusercusttostd\n - changedprofileforuserstdtocust\n - changedroleforusertonone\n - changedroleforuser\n - changedroleforuserfromnone\n - changedUserAdminVerifiedStatusVerified\n - changedUserEmailVerifiedStatusUnverified\n - changedUserEmailVerifiedStatusVerified\n - changedknowledgeuseroffon\n - changedsfcontentuseroffon\n - changedsupportuseroffon\n - changedusername\n - changedUserPhoneNumber\n - changedUserPhoneVerifiedStatusUnverified\n - changedUserPhoneVerifiedStatusVerified\n - deactivateduser\n - deleteAuthenticatorPairing\n - deleteTwoFactorInfo2\n - deleteTwoFactorTempCode\n - frozeuser\n - insertAuthenticatorPairing\n - insertTwoFactorInfo2\n - insertTwoFactorTempCode\n - lightningloginenroll\n - PermSetAssign\n - PermSetGroupAssign\n - PermSetGroupUnassign\n - PermSetLicenseAssign\n - PermSetUnassign\n - PermSetLicenseUnassign\n - registeredUserPhoneNumber\n - resetpassword\n - suNetworkAdminLogin\n - suNetworkAdminLogout\n - suOrgAdminLogin\n - suOrgAdminLogout\n - unfrozeuser\n - useremailchangesent\n- Mobile Administration\n - assigneduserstomobileconfig\n- Reporting Snapshots\n - createdReportJob\n - deletedReportJob\n- Sandboxes\n - DeleteSandbox\n\nBy default, deployment user defined in .sfdx-hardis.yml targetUsername property will be excluded.\n\nYou can define additional users to exclude in .sfdx-hardis.yml **monitoringExcludeUsernames** property.\n\nYou can also add more sections / actions considered as not suspect using property **monitoringAllowedSectionsActions**\n\nExample:\n\n```yaml\nmonitoringExcludeUsernames:\n - deploymentuser@cloudity.com\n - marketingcloud@cloudity.com\n - integration-user@cloudity.com\n\nmonitoringAllowedSectionsActions:\n \"Some section\": [] // Will ignore all actions from such section\n \"Some other section\": [\"actionType1\",\"actionType2\",\"actionType3\"] // Will ignore only those 3 actions from section \"Some other section\". Other actions in the same section will be considered as suspect.\n```\n\n## Excel output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-excel.jpg)\n\n## Local output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-local.jpg)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-suspect-audit-trail/) and can output Grafana, Slack and MsTeams Notifications.\n",
5930
+ "description": "Fix listviews whose scope Mine has been replaced by Everything\n\n[![Invalid scope:Mine, not allowed ? Deploy your ListViews anyway !](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-invalid-scope-mine.jpg)](https://nicolas.vuillamy.fr/invalid-scope-mine-not-allowed-deploy-your-listviews-anyway-443aceca8ac7)\n\nList of ListViews can be:\n\n- read from .sfdx-hardis.yml file in property **listViewsToSetToMine**\n- sent in argument listviews\n\nNote: property **listViewsToSetToMine** can be auto-generated by command hardis:work:save if .sfdx-hardis.yml contains the following configuration\n\n```yaml\nautoCleanTypes:\n - listViewsMine\n```\n\n- Example of sfdx-hardis.yml property `listViewsToSetToMine`:\n\n```yaml\nlistViewsToSetToMine:\n - \"force-app/main/default/objects/Operation__c/listViews/MyCurrentOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Operation__c/listViews/MyFinalizedOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/Default_Opportunity_Pipeline.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MyCurrentSubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MySubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Account/listViews/MyActivePartners.listView-meta.xml\"\n```\n\n- If manually written, this could also be:\n\n```yaml\nlistViewsToSetToMine:\n - \"Operation__c:MyCurrentOperations\"\n - \"Operation__c:MyFinalizedOperations\"\n - \"Opportunity:Default_Opportunity_Pipeline\"\n - \"Opportunity:MyCurrentSubscriptions\"\n - \"Opportunity:MySubscriptions\"\n - \"Account:MyActivePartners\"\n```\n\nTroubleshooting: if you need to run this command from an alpine-linux based docker image, use this workaround in your dockerfile:\n\n```dockerfile\n# Do not use puppeteer embedded chromium\nRUN apk add --update --no-cache chromium\nENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=\"true\"\nENV CHROMIUM_PATH=\"/usr/bin/chromium-browser\"\nENV PUPPETEER_EXECUTABLE_PATH=\"$\\{CHROMIUM_PATH}\" // remove \\ before {\n```\n",
5931
5931
  "examples": [
5932
- "$ sf hardis:org:diagnose:audittrail",
5933
- "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com",
5934
- "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com,bertrand@titi.com",
5935
- "$ sf hardis:org:diagnose:audittrail --lastndays 5"
5932
+ "$ sf hardis:org:fix:listviewmine",
5933
+ "$ sf hardis:org:fix:listviewmine --listviews Opportunity:MySubscriptions,Account:MyActivePartners"
5936
5934
  ],
5937
5935
  "flags": {
5938
5936
  "json": {
@@ -5950,26 +5948,10 @@
5950
5948
  "multiple": false,
5951
5949
  "type": "option"
5952
5950
  },
5953
- "excludeusers": {
5954
- "char": "e",
5955
- "description": "Comma-separated list of usernames to exclude",
5956
- "name": "excludeusers",
5957
- "hasDynamicHelp": false,
5958
- "multiple": false,
5959
- "type": "option"
5960
- },
5961
- "lastndays": {
5962
- "char": "t",
5963
- "description": "Number of days to extract from today (included)",
5964
- "name": "lastndays",
5965
- "hasDynamicHelp": false,
5966
- "multiple": false,
5967
- "type": "option"
5968
- },
5969
- "outputfile": {
5970
- "char": "f",
5971
- "description": "Force the path and name of output report file. Must end with .csv",
5972
- "name": "outputfile",
5951
+ "listviews": {
5952
+ "char": "l",
5953
+ "description": "Comma-separated list of listviews following format Object:ListViewName\nExample: Contact:MyContacts,Contact:MyActiveContacts,Opportunity:MYClosedOpportunities",
5954
+ "name": "listviews",
5973
5955
  "hasDynamicHelp": false,
5974
5956
  "multiple": false,
5975
5957
  "type": "option"
@@ -6012,57 +5994,57 @@
6012
5994
  },
6013
5995
  "hasDynamicHelp": true,
6014
5996
  "hiddenAliases": [],
6015
- "id": "hardis:org:diagnose:audittrail",
5997
+ "id": "hardis:org:fix:listviewmine",
6016
5998
  "pluginAlias": "sfdx-hardis",
6017
5999
  "pluginName": "sfdx-hardis",
6018
6000
  "pluginType": "core",
6019
6001
  "strict": true,
6020
6002
  "enableJsonFlag": true,
6021
- "title": "Diagnose content of Setup Audit Trail",
6022
- "requiresProject": false,
6003
+ "title": "Fix listviews with ",
6004
+ "requiresProject": true,
6023
6005
  "isESM": true,
6024
6006
  "relativePath": [
6025
6007
  "lib",
6026
6008
  "commands",
6027
6009
  "hardis",
6028
6010
  "org",
6029
- "diagnose",
6030
- "audittrail.js"
6011
+ "fix",
6012
+ "listviewmine.js"
6031
6013
  ],
6032
6014
  "aliasPermutations": [],
6033
6015
  "permutations": [
6034
- "hardis:org:diagnose:audittrail",
6035
- "org:hardis:diagnose:audittrail",
6036
- "org:diagnose:hardis:audittrail",
6037
- "org:diagnose:audittrail:hardis",
6038
- "hardis:diagnose:org:audittrail",
6039
- "diagnose:hardis:org:audittrail",
6040
- "diagnose:org:hardis:audittrail",
6041
- "diagnose:org:audittrail:hardis",
6042
- "hardis:diagnose:audittrail:org",
6043
- "diagnose:hardis:audittrail:org",
6044
- "diagnose:audittrail:hardis:org",
6045
- "diagnose:audittrail:org:hardis",
6046
- "hardis:org:audittrail:diagnose",
6047
- "org:hardis:audittrail:diagnose",
6048
- "org:audittrail:hardis:diagnose",
6049
- "org:audittrail:diagnose:hardis",
6050
- "hardis:audittrail:org:diagnose",
6051
- "audittrail:hardis:org:diagnose",
6052
- "audittrail:org:hardis:diagnose",
6053
- "audittrail:org:diagnose:hardis",
6054
- "hardis:audittrail:diagnose:org",
6055
- "audittrail:hardis:diagnose:org",
6056
- "audittrail:diagnose:hardis:org",
6057
- "audittrail:diagnose:org:hardis"
6016
+ "hardis:org:fix:listviewmine",
6017
+ "org:hardis:fix:listviewmine",
6018
+ "org:fix:hardis:listviewmine",
6019
+ "org:fix:listviewmine:hardis",
6020
+ "hardis:fix:org:listviewmine",
6021
+ "fix:hardis:org:listviewmine",
6022
+ "fix:org:hardis:listviewmine",
6023
+ "fix:org:listviewmine:hardis",
6024
+ "hardis:fix:listviewmine:org",
6025
+ "fix:hardis:listviewmine:org",
6026
+ "fix:listviewmine:hardis:org",
6027
+ "fix:listviewmine:org:hardis",
6028
+ "hardis:org:listviewmine:fix",
6029
+ "org:hardis:listviewmine:fix",
6030
+ "org:listviewmine:hardis:fix",
6031
+ "org:listviewmine:fix:hardis",
6032
+ "hardis:listviewmine:org:fix",
6033
+ "listviewmine:hardis:org:fix",
6034
+ "listviewmine:org:hardis:fix",
6035
+ "listviewmine:org:fix:hardis",
6036
+ "hardis:listviewmine:fix:org",
6037
+ "listviewmine:hardis:fix:org",
6038
+ "listviewmine:fix:hardis:org",
6039
+ "listviewmine:fix:org:hardis"
6058
6040
  ]
6059
6041
  },
6060
- "hardis:org:diagnose:instanceupgrade": {
6042
+ "hardis:org:files:export": {
6061
6043
  "aliases": [],
6062
6044
  "args": {},
6063
- "description": "\n## Command Behavior\n\n**Retrieves and displays the scheduled upgrade date for a Salesforce org's instance.**\n\nThis command provides crucial information about when your Salesforce instance will be upgraded to the next major release (Spring, Summer, or Winter). This is vital for release planning, testing, and ensuring compatibility with upcoming Salesforce features.\n\nKey functionalities:\n\n- **Instance Identification:** Determines the Salesforce instance name of your target org.\n- **Upgrade Date Retrieval:** Fetches the planned start time of the next major core service upgrade for that instance from the Salesforce Status API.\n- **Days Until Upgrade:** Calculates and displays the number of days remaining until the next major upgrade.\n- **Severity-Based Logging:** Adjusts the log severity (info, warning) based on the proximity of the upgrade date, providing a visual cue for urgency.\n- **Notifications:** Sends notifications to configured channels (e.g., Slack, MS Teams, Grafana) with the upgrade information, making it suitable for automated monitoring.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Query:** It first queries the `Organization` object in Salesforce to get the `InstanceName` of the target org.\n- **Salesforce Status API Integration:** It makes an HTTP GET request to the Salesforce Status API (`https://api.status.salesforce.com/v1/instances/{instanceName}/status`) to retrieve detailed information about the instance, including scheduled maintenances.\n- **Data Parsing:** It parses the JSON response from the Status API to extract the relevant major release upgrade information.\n- **Date Calculation:** Uses the `moment` library to calculate the difference in days between the current date and the planned upgrade date.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including the instance name, upgrade date, and days remaining, along with relevant metrics for monitoring dashboards.\n- **User Feedback:** Provides clear messages to the user about the upgrade status and proximity.\n</details>\n",
6045
+ "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",
6064
6046
  "examples": [
6065
- "$ sf hardis:org:diagnose:instanceupgrade"
6047
+ "$ sf hardis:org:files:export"
6066
6048
  ],
6067
6049
  "flags": {
6068
6050
  "json": {
@@ -6072,14 +6054,56 @@
6072
6054
  "allowNo": false,
6073
6055
  "type": "boolean"
6074
6056
  },
6075
- "flags-dir": {
6076
- "helpGroup": "GLOBAL",
6077
- "name": "flags-dir",
6078
- "summary": "Import flag values from a directory.",
6057
+ "flags-dir": {
6058
+ "helpGroup": "GLOBAL",
6059
+ "name": "flags-dir",
6060
+ "summary": "Import flag values from a directory.",
6061
+ "hasDynamicHelp": false,
6062
+ "multiple": false,
6063
+ "type": "option"
6064
+ },
6065
+ "path": {
6066
+ "char": "p",
6067
+ "description": "Path to the file export project",
6068
+ "name": "path",
6069
+ "hasDynamicHelp": false,
6070
+ "multiple": false,
6071
+ "type": "option"
6072
+ },
6073
+ "chunksize": {
6074
+ "char": "c",
6075
+ "description": "Number of records to add in a chunk before it is processed",
6076
+ "name": "chunksize",
6077
+ "default": 1000,
6078
+ "hasDynamicHelp": false,
6079
+ "multiple": false,
6080
+ "type": "option"
6081
+ },
6082
+ "polltimeout": {
6083
+ "char": "t",
6084
+ "description": "Timeout in MS for Bulk API calls",
6085
+ "name": "polltimeout",
6086
+ "default": 300000,
6087
+ "hasDynamicHelp": false,
6088
+ "multiple": false,
6089
+ "type": "option"
6090
+ },
6091
+ "startchunknumber": {
6092
+ "char": "s",
6093
+ "description": "Chunk number to start from",
6094
+ "name": "startchunknumber",
6095
+ "default": 0,
6079
6096
  "hasDynamicHelp": false,
6080
6097
  "multiple": false,
6081
6098
  "type": "option"
6082
6099
  },
6100
+ "resume": {
6101
+ "char": "r",
6102
+ "description": "Resume previous export by checking existing files (default in CI)",
6103
+ "name": "resume",
6104
+ "allowNo": false,
6105
+ "type": "boolean"
6106
+ },
6083
6107
  "debug": {
6084
6108
  "char": "d",
6085
6109
  "description": "Activate debug mode (more logs)",
@@ -6118,13 +6142,13 @@
6118
6142
  },
6119
6143
  "hasDynamicHelp": true,
6120
6144
  "hiddenAliases": [],
6121
- "id": "hardis:org:diagnose:instanceupgrade",
6145
+ "id": "hardis:org:files:export",
6122
6146
  "pluginAlias": "sfdx-hardis",
6123
6147
  "pluginName": "sfdx-hardis",
6124
6148
  "pluginType": "core",
6125
6149
  "strict": true,
6126
6150
  "enableJsonFlag": true,
6127
- "title": "Get Instance Upgrade date",
6151
+ "title": "Export files",
6128
6152
  "requiresProject": false,
6129
6153
  "isESM": true,
6130
6154
  "relativePath": [
@@ -6132,46 +6156,43 @@
6132
6156
  "commands",
6133
6157
  "hardis",
6134
6158
  "org",
6135
- "diagnose",
6136
- "instanceupgrade.js"
6159
+ "files",
6160
+ "export.js"
6137
6161
  ],
6138
6162
  "aliasPermutations": [],
6139
6163
  "permutations": [
6140
- "hardis:org:diagnose:instanceupgrade",
6141
- "org:hardis:diagnose:instanceupgrade",
6142
- "org:diagnose:hardis:instanceupgrade",
6143
- "org:diagnose:instanceupgrade:hardis",
6144
- "hardis:diagnose:org:instanceupgrade",
6145
- "diagnose:hardis:org:instanceupgrade",
6146
- "diagnose:org:hardis:instanceupgrade",
6147
- "diagnose:org:instanceupgrade:hardis",
6148
- "hardis:diagnose:instanceupgrade:org",
6149
- "diagnose:hardis:instanceupgrade:org",
6150
- "diagnose:instanceupgrade:hardis:org",
6151
- "diagnose:instanceupgrade:org:hardis",
6152
- "hardis:org:instanceupgrade:diagnose",
6153
- "org:hardis:instanceupgrade:diagnose",
6154
- "org:instanceupgrade:hardis:diagnose",
6155
- "org:instanceupgrade:diagnose:hardis",
6156
- "hardis:instanceupgrade:org:diagnose",
6157
- "instanceupgrade:hardis:org:diagnose",
6158
- "instanceupgrade:org:hardis:diagnose",
6159
- "instanceupgrade:org:diagnose:hardis",
6160
- "hardis:instanceupgrade:diagnose:org",
6161
- "instanceupgrade:hardis:diagnose:org",
6162
- "instanceupgrade:diagnose:hardis:org",
6163
- "instanceupgrade:diagnose:org:hardis"
6164
+ "hardis:org:files:export",
6165
+ "org:hardis:files:export",
6166
+ "org:files:hardis:export",
6167
+ "org:files:export:hardis",
6168
+ "hardis:files:org:export",
6169
+ "files:hardis:org:export",
6170
+ "files:org:hardis:export",
6171
+ "files:org:export:hardis",
6172
+ "hardis:files:export:org",
6173
+ "files:hardis:export:org",
6174
+ "files:export:hardis:org",
6175
+ "files:export:org:hardis",
6176
+ "hardis:org:export:files",
6177
+ "org:hardis:export:files",
6178
+ "org:export:hardis:files",
6179
+ "org:export:files:hardis",
6180
+ "hardis:export:org:files",
6181
+ "export:hardis:org:files",
6182
+ "export:org:hardis:files",
6183
+ "export:org:files:hardis",
6184
+ "hardis:export:files:org",
6185
+ "export:hardis:files:org",
6186
+ "export:files:hardis:org",
6187
+ "export:files:org:hardis"
6164
6188
  ]
6165
6189
  },
6166
- "hardis:org:diagnose:legacyapi": {
6190
+ "hardis:org:files:import": {
6167
6191
  "aliases": [],
6168
6192
  "args": {},
6169
- "description": "Checks if an org uses retired or someday retired API version\n\n\nSee article below\n\n[![Handle Salesforce API versions Deprecation like a pro](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deprecated-api.jpg)](https://nicolas.vuillamy.fr/handle-salesforce-api-versions-deprecation-like-a-pro-335065f52238)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-deprecated-api-calls/) and can output Grafana, Slack and MsTeams Notifications.\n",
6193
+ "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",
6170
6194
  "examples": [
6171
- "$ sf hardis:org:diagnose:legacyapi",
6172
- "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com",
6173
- "$ sf hardis:org:diagnose:legacyapi --outputfile 'c:/path/to/folder/legacyapi.csv'",
6174
- "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com --outputfile ./tmp/legacyapi.csv"
6195
+ "$ sf hardis:org:files:import"
6175
6196
  ],
6176
6197
  "flags": {
6177
6198
  "json": {
@@ -6189,31 +6210,20 @@
6189
6210
  "multiple": false,
6190
6211
  "type": "option"
6191
6212
  },
6192
- "eventtype": {
6193
- "char": "e",
6194
- "description": "Type of EventLogFile event to analyze",
6195
- "name": "eventtype",
6196
- "default": "ApiTotalUsage",
6197
- "hasDynamicHelp": false,
6198
- "multiple": false,
6199
- "type": "option"
6200
- },
6201
- "limit": {
6202
- "char": "l",
6203
- "description": "Number of latest EventLogFile events to analyze",
6204
- "name": "limit",
6205
- "default": 999,
6213
+ "path": {
6214
+ "char": "p",
6215
+ "description": "Path to the file export project",
6216
+ "name": "path",
6206
6217
  "hasDynamicHelp": false,
6207
6218
  "multiple": false,
6208
6219
  "type": "option"
6209
6220
  },
6210
- "outputfile": {
6221
+ "overwrite": {
6211
6222
  "char": "f",
6212
- "description": "Force the path and name of output report file. Must end with .csv",
6213
- "name": "outputfile",
6214
- "hasDynamicHelp": false,
6215
- "multiple": false,
6216
- "type": "option"
6223
+ "description": "Override existing files (doubles the number of API calls)",
6224
+ "name": "overwrite",
6225
+ "allowNo": false,
6226
+ "type": "boolean"
6217
6227
  },
6218
6228
  "debug": {
6219
6229
  "char": "d",
@@ -6253,13 +6263,13 @@
6253
6263
  },
6254
6264
  "hasDynamicHelp": true,
6255
6265
  "hiddenAliases": [],
6256
- "id": "hardis:org:diagnose:legacyapi",
6266
+ "id": "hardis:org:files:import",
6257
6267
  "pluginAlias": "sfdx-hardis",
6258
6268
  "pluginName": "sfdx-hardis",
6259
6269
  "pluginType": "core",
6260
6270
  "strict": true,
6261
6271
  "enableJsonFlag": true,
6262
- "title": "Check for legacy API use",
6272
+ "title": "Import files",
6263
6273
  "requiresProject": false,
6264
6274
  "isESM": true,
6265
6275
  "relativePath": [
@@ -6267,43 +6277,45 @@
6267
6277
  "commands",
6268
6278
  "hardis",
6269
6279
  "org",
6270
- "diagnose",
6271
- "legacyapi.js"
6280
+ "files",
6281
+ "import.js"
6272
6282
  ],
6273
6283
  "aliasPermutations": [],
6274
6284
  "permutations": [
6275
- "hardis:org:diagnose:legacyapi",
6276
- "org:hardis:diagnose:legacyapi",
6277
- "org:diagnose:hardis:legacyapi",
6278
- "org:diagnose:legacyapi:hardis",
6279
- "hardis:diagnose:org:legacyapi",
6280
- "diagnose:hardis:org:legacyapi",
6281
- "diagnose:org:hardis:legacyapi",
6282
- "diagnose:org:legacyapi:hardis",
6283
- "hardis:diagnose:legacyapi:org",
6284
- "diagnose:hardis:legacyapi:org",
6285
- "diagnose:legacyapi:hardis:org",
6286
- "diagnose:legacyapi:org:hardis",
6287
- "hardis:org:legacyapi:diagnose",
6288
- "org:hardis:legacyapi:diagnose",
6289
- "org:legacyapi:hardis:diagnose",
6290
- "org:legacyapi:diagnose:hardis",
6291
- "hardis:legacyapi:org:diagnose",
6292
- "legacyapi:hardis:org:diagnose",
6293
- "legacyapi:org:hardis:diagnose",
6294
- "legacyapi:org:diagnose:hardis",
6295
- "hardis:legacyapi:diagnose:org",
6296
- "legacyapi:hardis:diagnose:org",
6297
- "legacyapi:diagnose:hardis:org",
6298
- "legacyapi:diagnose:org:hardis"
6285
+ "hardis:org:files:import",
6286
+ "org:hardis:files:import",
6287
+ "org:files:hardis:import",
6288
+ "org:files:import:hardis",
6289
+ "hardis:files:org:import",
6290
+ "files:hardis:org:import",
6291
+ "files:org:hardis:import",
6292
+ "files:org:import:hardis",
6293
+ "hardis:files:import:org",
6294
+ "files:hardis:import:org",
6295
+ "files:import:hardis:org",
6296
+ "files:import:org:hardis",
6297
+ "hardis:org:import:files",
6298
+ "org:hardis:import:files",
6299
+ "org:import:hardis:files",
6300
+ "org:import:files:hardis",
6301
+ "hardis:import:org:files",
6302
+ "import:hardis:org:files",
6303
+ "import:org:hardis:files",
6304
+ "import:org:files:hardis",
6305
+ "hardis:import:files:org",
6306
+ "import:hardis:files:org",
6307
+ "import:files:hardis:org",
6308
+ "import:files:org:hardis"
6299
6309
  ]
6300
6310
  },
6301
- "hardis:org:diagnose:licenses": {
6311
+ "hardis:org:generate:packagexmlfull": {
6302
6312
  "aliases": [],
6303
6313
  "args": {},
6304
- "description": "\n**Lists and analyzes User Licenses and Permission Set Licenses subscribed and used in a Salesforce org.**\n\nThis command provides a comprehensive overview of your Salesforce license consumption. It's particularly useful for:\n\n- **License Management:** Understanding which licenses are active, how many are available, and how many are being used.\n- **Cost Optimization:** Identifying unused or underutilized licenses that could be reallocated or decommissioned.\n- **Compliance:** Ensuring that your organization is compliant with Salesforce licensing agreements.\n- **Monitoring:** Tracking license usage trends over time.\n\nKey functionalities:\n\n- **User License Details:** Retrieves information about standard and custom User Licenses, including `MasterLabel`, `Name`, `TotalLicenses`, and `UsedLicenses`.\n- **Permission Set License Details:** Retrieves information about Permission Set Licenses, including `MasterLabel`, `PermissionSetLicenseKey`, `TotalLicenses`, and `UsedLicenses`.\n- **Used Licenses Filter:** The `--usedonly` flag allows you to filter the report to show only licenses that have at least one `UsedLicenses` count greater than zero.\n- **CSV Report Generation:** Generates a CSV file containing all the retrieved license information, suitable for detailed analysis.\n- **Notifications:** Sends notifications to configured channels (e.g., Grafana, Slack, MS Teams) with a summary of license usage, including lists of active and used licenses.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It executes SOQL queries against the `UserLicense` and `PermissionSetLicense` objects in Salesforce to retrieve license data.\n- **Data Transformation:** It processes the query results, reformatting the data to be more readable and consistent for reporting purposes (e.g., removing `Id` and `attributes`, renaming `PermissionSetLicenseKey` to `Name`).\n- **Data Aggregation:** It aggregates license information, creating a `licensesByKey` object for quick lookups and a `usedLicenses` array for a concise list of actively used licenses.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of license data.\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 clear messages to the user about the license extraction process and the used licenses.\n</details>\n",
6314
+ "description": "\n## Command Behavior\n\n**Generates a comprehensive `package.xml` file for a Salesforce org, including all metadata components, even managed ones.**\n\nThis command is essential for various Salesforce development and administration tasks, especially when you need a complete snapshot of an org's metadata. It goes beyond typical source tracking by including managed package components, which is crucial for understanding the full metadata footprint of an org.\n\nKey functionalities:\n\n- **Full Org Metadata Retrieval:** Connects to a specified Salesforce org (or prompts for one if not provided) and retrieves a complete list of all metadata types and their members.\n- **Managed Package Inclusion:** Unlike standard source retrieval, this command explicitly includes metadata from managed packages, providing a truly comprehensive `package.xml`.\n- **Customizable Output:** Allows you to specify the output file path for the generated `package.xml`.\n- **Interactive Org Selection:** If no target org is specified, it interactively prompts the user to choose an org. (or use --no-prompt to skip this step)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce Metadata API Interaction:** It leverages the Salesforce Metadata API to list all available metadata types and then retrieve all components for each type.\n- **`buildOrgManifest` Utility:** The core logic for querying the org's metadata and constructing the `package.xml` is encapsulated within the `buildOrgManifest` utility function.\n- **XML Generation:** It dynamically builds the XML structure of the `package.xml` file, including the `types` and `members` elements for all retrieved metadata.\n- **File System Operations:** It writes the generated `package.xml` file to the specified output path.\n- **Interactive Prompts:** Uses `promptOrgUsernameDefault` to guide the user in selecting the target Salesforce org.\n</details>\n",
6305
6315
  "examples": [
6306
- "$ sf hardis:org:diagnose:licenses"
6316
+ "$ sf hardis:org:generate:packagexmlfull",
6317
+ "$ sf hardis:org:generate:packagexmlfull --outputfile /tmp/packagexmlfull.xml",
6318
+ "$ sf hardis:org:generate:packagexmlfull --target-org nico@example.com"
6307
6319
  ],
6308
6320
  "flags": {
6309
6321
  "json": {
@@ -6322,20 +6334,12 @@
6322
6334
  "type": "option"
6323
6335
  },
6324
6336
  "outputfile": {
6325
- "char": "f",
6326
- "description": "Force the path and name of output report file. Must end with .csv",
6337
+ "description": "Output package.xml file",
6327
6338
  "name": "outputfile",
6328
6339
  "hasDynamicHelp": false,
6329
6340
  "multiple": false,
6330
6341
  "type": "option"
6331
6342
  },
6332
- "usedonly": {
6333
- "char": "u",
6334
- "description": "Filter to have only used licenses",
6335
- "name": "usedonly",
6336
- "allowNo": false,
6337
- "type": "boolean"
6338
- },
6339
6343
  "debug": {
6340
6344
  "char": "d",
6341
6345
  "description": "Activate debug mode (more logs)",
@@ -6343,6 +6347,13 @@
6343
6347
  "allowNo": false,
6344
6348
  "type": "boolean"
6345
6349
  },
6350
+ "no-prompt": {
6351
+ "char": "n",
6352
+ "description": "Do not prompt for org username, use the default one",
6353
+ "name": "no-prompt",
6354
+ "allowNo": false,
6355
+ "type": "boolean"
6356
+ },
6346
6357
  "websocket": {
6347
6358
  "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
6348
6359
  "name": "websocket",
@@ -6374,13 +6385,13 @@
6374
6385
  },
6375
6386
  "hasDynamicHelp": true,
6376
6387
  "hiddenAliases": [],
6377
- "id": "hardis:org:diagnose:licenses",
6388
+ "id": "hardis:org:generate:packagexmlfull",
6378
6389
  "pluginAlias": "sfdx-hardis",
6379
6390
  "pluginName": "sfdx-hardis",
6380
6391
  "pluginType": "core",
6381
6392
  "strict": true,
6382
6393
  "enableJsonFlag": true,
6383
- "title": "List licenses subscribed and used in a Salesforce org",
6394
+ "title": "Generate Full Org package.xml",
6384
6395
  "requiresProject": false,
6385
6396
  "isESM": true,
6386
6397
  "relativePath": [
@@ -6388,43 +6399,46 @@
6388
6399
  "commands",
6389
6400
  "hardis",
6390
6401
  "org",
6391
- "diagnose",
6392
- "licenses.js"
6402
+ "generate",
6403
+ "packagexmlfull.js"
6393
6404
  ],
6394
6405
  "aliasPermutations": [],
6395
6406
  "permutations": [
6396
- "hardis:org:diagnose:licenses",
6397
- "org:hardis:diagnose:licenses",
6398
- "org:diagnose:hardis:licenses",
6399
- "org:diagnose:licenses:hardis",
6400
- "hardis:diagnose:org:licenses",
6401
- "diagnose:hardis:org:licenses",
6402
- "diagnose:org:hardis:licenses",
6403
- "diagnose:org:licenses:hardis",
6404
- "hardis:diagnose:licenses:org",
6405
- "diagnose:hardis:licenses:org",
6406
- "diagnose:licenses:hardis:org",
6407
- "diagnose:licenses:org:hardis",
6408
- "hardis:org:licenses:diagnose",
6409
- "org:hardis:licenses:diagnose",
6410
- "org:licenses:hardis:diagnose",
6411
- "org:licenses:diagnose:hardis",
6412
- "hardis:licenses:org:diagnose",
6413
- "licenses:hardis:org:diagnose",
6414
- "licenses:org:hardis:diagnose",
6415
- "licenses:org:diagnose:hardis",
6416
- "hardis:licenses:diagnose:org",
6417
- "licenses:hardis:diagnose:org",
6418
- "licenses:diagnose:hardis:org",
6419
- "licenses:diagnose:org:hardis"
6407
+ "hardis:org:generate:packagexmlfull",
6408
+ "org:hardis:generate:packagexmlfull",
6409
+ "org:generate:hardis:packagexmlfull",
6410
+ "org:generate:packagexmlfull:hardis",
6411
+ "hardis:generate:org:packagexmlfull",
6412
+ "generate:hardis:org:packagexmlfull",
6413
+ "generate:org:hardis:packagexmlfull",
6414
+ "generate:org:packagexmlfull:hardis",
6415
+ "hardis:generate:packagexmlfull:org",
6416
+ "generate:hardis:packagexmlfull:org",
6417
+ "generate:packagexmlfull:hardis:org",
6418
+ "generate:packagexmlfull:org:hardis",
6419
+ "hardis:org:packagexmlfull:generate",
6420
+ "org:hardis:packagexmlfull:generate",
6421
+ "org:packagexmlfull:hardis:generate",
6422
+ "org:packagexmlfull:generate:hardis",
6423
+ "hardis:packagexmlfull:org:generate",
6424
+ "packagexmlfull:hardis:org:generate",
6425
+ "packagexmlfull:org:hardis:generate",
6426
+ "packagexmlfull:org:generate:hardis",
6427
+ "hardis:packagexmlfull:generate:org",
6428
+ "packagexmlfull:hardis:generate:org",
6429
+ "packagexmlfull:generate:hardis:org",
6430
+ "packagexmlfull:generate:org:hardis"
6420
6431
  ]
6421
6432
  },
6422
- "hardis:org:diagnose:releaseupdates": {
6433
+ "hardis:org:diagnose:audittrail": {
6423
6434
  "aliases": [],
6424
6435
  "args": {},
6425
- "description": "Export Release Updates into a CSV file with selected criteria, and highlight Release Updates that should be checked.\n\nBefore publishing **Breaking Changes** ❌, Salesforce announce them in the setup menu [**Release Updates**](https://help.salesforce.com/s/articleView?id=sf.release_updates.htm&type=5)\n\n⚠️ Some of them are very important, because if you don't make the related upgrades in time (ex: before Winter 25) , your production org can crash !\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-release-updates/) and can output Grafana, Slack and MsTeams Notifications.\n",
6436
+ "description": "Export Audit trail into a CSV file with selected criteria, and highlight suspect actions\n\nAlso detects updates of Custom Settings values (disable by defining `SKIP_AUDIT_TRAIL_CUSTOM_SETTINGS=true`)\n\nRegular setup actions performed in major orgs are filtered.\n\n- \"\"\n - createScratchOrg\n - changedsenderemail\n - deleteScratchOrg\n - loginasgrantedtopartnerbt\n- Certificate and Key Management\n - insertCertificate\n- Custom App Licenses\n - addeduserpackagelicense\n - granteduserpackagelicense\n - revokeduserpackagelicense\n- Customer Portal\n - createdcustomersuccessuser\n - CSPUserDisabled\n- Currency\n - updateddatedexchrate\n- Data Management\n - queueMembership\n- Email Administration\n - dkimRotationPreparationSuccessful\n - dkimRotationSuccessful\n- External Objects\n - xdsEncryptedFieldChange\n- Groups\n - groupMembership\n- Holidays\n - holiday_insert\n- Inbox mobile and legacy desktop apps\n - enableSIQUserNonEAC\n - siqUserAcceptedTOS\n- Manage Users\n - activateduser\n - createduser\n - changedcommunitynickname\n - changedemail\n - changedfederationid\n - changedpassword\n - changedinteractionuseroffon\n - changedinteractionuseronoff\n - changedmarketinguseroffon\n - changedmarketinguseronoff\n - changedofflineuseroffon\n - changedprofileforuserstdtostd\n - changedprofileforuser\n - changedprofileforusercusttostd\n - changedprofileforuserstdtocust\n - changedroleforusertonone\n - changedroleforuser\n - changedroleforuserfromnone\n - changedUserAdminVerifiedStatusVerified\n - changedUserEmailVerifiedStatusUnverified\n - changedUserEmailVerifiedStatusVerified\n - changedknowledgeuseroffon\n - changedsfcontentuseroffon\n - changedsupportuseroffon\n - changedusername\n - changedUserPhoneNumber\n - changedUserPhoneVerifiedStatusUnverified\n - changedUserPhoneVerifiedStatusVerified\n - deactivateduser\n - deleteAuthenticatorPairing\n - deleteTwoFactorInfo2\n - deleteTwoFactorTempCode\n - frozeuser\n - insertAuthenticatorPairing\n - insertTwoFactorInfo2\n - insertTwoFactorTempCode\n - lightningloginenroll\n - PermSetAssign\n - PermSetGroupAssign\n - PermSetGroupUnassign\n - PermSetLicenseAssign\n - PermSetUnassign\n - PermSetLicenseUnassign\n - registeredUserPhoneNumber\n - resetpassword\n - suNetworkAdminLogin\n - suNetworkAdminLogout\n - suOrgAdminLogin\n - suOrgAdminLogout\n - unfrozeuser\n - useremailchangesent\n- Mobile Administration\n - assigneduserstomobileconfig\n- Reporting Snapshots\n - createdReportJob\n - deletedReportJob\n- Sandboxes\n - DeleteSandbox\n\nBy default, deployment user defined in .sfdx-hardis.yml targetUsername property will be excluded.\n\nYou can define additional users to exclude in .sfdx-hardis.yml **monitoringExcludeUsernames** property.\n\nYou can also add more sections / actions considered as not suspect using property **monitoringAllowedSectionsActions**\n\nExample:\n\n```yaml\nmonitoringExcludeUsernames:\n - deploymentuser@cloudity.com\n - marketingcloud@cloudity.com\n - integration-user@cloudity.com\n\nmonitoringAllowedSectionsActions:\n \"Some section\": [] // Will ignore all actions from such section\n \"Some other section\": [\"actionType1\",\"actionType2\",\"actionType3\"] // Will ignore only those 3 actions from section \"Some other section\". Other actions in the same section will be considered as suspect.\n```\n\n## Excel output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-excel.jpg)\n\n## Local output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-local.jpg)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-suspect-audit-trail/) and can output Grafana, Slack and MsTeams Notifications.\n",
6426
6437
  "examples": [
6427
- "$ sf hardis:org:diagnose:releaseupdates"
6438
+ "$ sf hardis:org:diagnose:audittrail",
6439
+ "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com",
6440
+ "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com,bertrand@titi.com",
6441
+ "$ sf hardis:org:diagnose:audittrail --lastndays 5"
6428
6442
  ],
6429
6443
  "flags": {
6430
6444
  "json": {
@@ -6442,6 +6456,22 @@
6442
6456
  "multiple": false,
6443
6457
  "type": "option"
6444
6458
  },
6459
+ "excludeusers": {
6460
+ "char": "e",
6461
+ "description": "Comma-separated list of usernames to exclude",
6462
+ "name": "excludeusers",
6463
+ "hasDynamicHelp": false,
6464
+ "multiple": false,
6465
+ "type": "option"
6466
+ },
6467
+ "lastndays": {
6468
+ "char": "t",
6469
+ "description": "Number of days to extract from today (included)",
6470
+ "name": "lastndays",
6471
+ "hasDynamicHelp": false,
6472
+ "multiple": false,
6473
+ "type": "option"
6474
+ },
6445
6475
  "outputfile": {
6446
6476
  "char": "f",
6447
6477
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -6488,13 +6518,13 @@
6488
6518
  },
6489
6519
  "hasDynamicHelp": true,
6490
6520
  "hiddenAliases": [],
6491
- "id": "hardis:org:diagnose:releaseupdates",
6521
+ "id": "hardis:org:diagnose:audittrail",
6492
6522
  "pluginAlias": "sfdx-hardis",
6493
6523
  "pluginName": "sfdx-hardis",
6494
6524
  "pluginType": "core",
6495
6525
  "strict": true,
6496
6526
  "enableJsonFlag": true,
6497
- "title": "Check Release Updates of an org",
6527
+ "title": "Diagnose content of Setup Audit Trail",
6498
6528
  "requiresProject": false,
6499
6529
  "isESM": true,
6500
6530
  "relativePath": [
@@ -6503,47 +6533,42 @@
6503
6533
  "hardis",
6504
6534
  "org",
6505
6535
  "diagnose",
6506
- "releaseupdates.js"
6536
+ "audittrail.js"
6507
6537
  ],
6508
6538
  "aliasPermutations": [],
6509
6539
  "permutations": [
6510
- "hardis:org:diagnose:releaseupdates",
6511
- "org:hardis:diagnose:releaseupdates",
6512
- "org:diagnose:hardis:releaseupdates",
6513
- "org:diagnose:releaseupdates:hardis",
6514
- "hardis:diagnose:org:releaseupdates",
6515
- "diagnose:hardis:org:releaseupdates",
6516
- "diagnose:org:hardis:releaseupdates",
6517
- "diagnose:org:releaseupdates:hardis",
6518
- "hardis:diagnose:releaseupdates:org",
6519
- "diagnose:hardis:releaseupdates:org",
6520
- "diagnose:releaseupdates:hardis:org",
6521
- "diagnose:releaseupdates:org:hardis",
6522
- "hardis:org:releaseupdates:diagnose",
6523
- "org:hardis:releaseupdates:diagnose",
6524
- "org:releaseupdates:hardis:diagnose",
6525
- "org:releaseupdates:diagnose:hardis",
6526
- "hardis:releaseupdates:org:diagnose",
6527
- "releaseupdates:hardis:org:diagnose",
6528
- "releaseupdates:org:hardis:diagnose",
6529
- "releaseupdates:org:diagnose:hardis",
6530
- "hardis:releaseupdates:diagnose:org",
6531
- "releaseupdates:hardis:diagnose:org",
6532
- "releaseupdates:diagnose:hardis:org",
6533
- "releaseupdates:diagnose:org:hardis"
6540
+ "hardis:org:diagnose:audittrail",
6541
+ "org:hardis:diagnose:audittrail",
6542
+ "org:diagnose:hardis:audittrail",
6543
+ "org:diagnose:audittrail:hardis",
6544
+ "hardis:diagnose:org:audittrail",
6545
+ "diagnose:hardis:org:audittrail",
6546
+ "diagnose:org:hardis:audittrail",
6547
+ "diagnose:org:audittrail:hardis",
6548
+ "hardis:diagnose:audittrail:org",
6549
+ "diagnose:hardis:audittrail:org",
6550
+ "diagnose:audittrail:hardis:org",
6551
+ "diagnose:audittrail:org:hardis",
6552
+ "hardis:org:audittrail:diagnose",
6553
+ "org:hardis:audittrail:diagnose",
6554
+ "org:audittrail:hardis:diagnose",
6555
+ "org:audittrail:diagnose:hardis",
6556
+ "hardis:audittrail:org:diagnose",
6557
+ "audittrail:hardis:org:diagnose",
6558
+ "audittrail:org:hardis:diagnose",
6559
+ "audittrail:org:diagnose:hardis",
6560
+ "hardis:audittrail:diagnose:org",
6561
+ "audittrail:hardis:diagnose:org",
6562
+ "audittrail:diagnose:hardis:org",
6563
+ "audittrail:diagnose:org:hardis"
6534
6564
  ]
6535
6565
  },
6536
- "hardis:org:diagnose:storage-stats": {
6566
+ "hardis:org:diagnose:instanceupgrade": {
6537
6567
  "aliases": [],
6538
6568
  "args": {},
6539
- "description": "**Extracts and analyzes Data Storage usage for a Salesforce org, providing detailed per-object breakdowns with flexible grouping options.**\n\nThis command provides a comprehensive overview of your Salesforce data storage consumption. It's particularly useful for:\n\n- **Storage Management:** Understanding which SObjects consume the most storage and how usage has evolved over time.\n- **Cost Optimization:** Identifying storage-heavy objects that could be candidates for data archival or cleanup strategies.\n- **Capacity Planning:** Tracking storage trends to predict when additional capacity will be needed.\n- **Compliance & Governance:** Monitoring data growth patterns to ensure alignment with data retention policies.\n\nKey functionalities:\n\n- **Storage Limits Analysis:** Retrieves and displays org data storage limits, including total capacity, used storage, remaining storage, and percentage used. Detects and alerts on over-usage scenarios.\n- **SObject Discovery & Filtering:** Automatically discovers all SObjects in the org and filters them to focus on production/custom objects (excludes metadata types, platform-only objects, and cached empty objects).\n- **Interactive Selection:** Prompts the user to select which SObjects to analyze and choose breakdown fields (date fields, RecordType, custom fields, or relationship fields).\n- **Flexible Breakdown Field:** Supports grouping by any field including:\n - Date/DateTime fields (`CreatedDate`, `LastModifiedDate`, custom date fields)\n - RecordType (`RecordType.Name`)\n - Custom fields (`Status__c`, picklists, text fields)\n - Nested relationship fields (`SBQQ__Quote__r.RecordType.Name`)\n- **Date Granularity Options:** For date/datetime fields, choose between:\n - Year-based grouping (`CALENDAR_YEAR`)\n - Month-based grouping (`CALENDAR_MONTH`)\n - Day-based grouping (exact date)\n- **WHERE Clause Filtering:** Apply SOQL WHERE conditions to filter records before calculating storage (e.g., only active records, records from the last year).\n- **Storage Estimation:** Estimates storage usage for each object using an average record size heuristic (2 KB per record) and calculates the percentage of org quota consumed.\n- **Dual CSV Reports:** Generates two CSV files: a detailed breakdown by selected field and a totals-per-object summary, both suitable for spreadsheet analysis and reporting.\n- **Empty Objects Cache:** Maintains a per-user cache of objects detected with zero records to optimize subsequent runs by skipping empty tables.\n- **Progress Tracking:** Sends WebSocket progress messages for integration with external UIs and monitoring dashboards.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Limits Retrieval:** Calls `conn.limits()` to retrieve the `DataStorageMB` object containing `Max` and `Remaining` values. Handles negative `Remaining` values (over-usage scenarios) by calculating `overUsageMB` and adjusting display values.\n- **SObject Discovery:** Uses `conn.metadata.list([{ type: 'CustomObject' }])` to get custom objects and `conn.describeGlobal()` to get all SObjects. Filters by object capabilities (`layoutable`, `queryable`, `retrieveable`, `createable`, `updateable`, `deletable`) and excludes metadata types (`__mdt` suffix) and cached empty objects.\n- **User Interaction:** Uses `prompts` for interactive multi-select of SObjects, breakdown field selection, granularity choice (for date fields), and optional WHERE conditions. All objects are pre-selected by default for user convenience.\n- **Field Validation:** Recursively validates breakdown fields including nested relationships (e.g., `SBQQ__Quote__r.RecordType.Name`) by traversing the relationship chain and checking field existence on each related object. Automatically handles special cases like `RecordType` -> `RecordTypeId` and `__r` -> `__c` conversions.\n- **Dynamic Query Generation:** Builds SOQL queries based on field type and granularity:\n - For date fields with year granularity: `SELECT CALENDAR_YEAR(<Field>) breakdown, COUNT(Id) total FROM <SObject> [WHERE ...] GROUP BY CALENDAR_YEAR(<Field>) ORDER BY CALENDAR_YEAR(<Field>)`\n - For date fields with month granularity: `SELECT CALENDAR_YEAR(<Field>) year, CALENDAR_MONTH(<Field>) month, COUNT(Id) total FROM <SObject> [WHERE ...] GROUP BY CALENDAR_YEAR(<Field>), CALENDAR_MONTH(<Field>) ORDER BY CALENDAR_YEAR(<Field>), CALENDAR_MONTH(<Field>)`\n - For non-date fields: `SELECT <Field> breakdown, COUNT(Id) total FROM <SObject> [WHERE ...] GROUP BY <Field> ORDER BY <Field>`\n- **WHERE Clause Support:** Accepts user-provided WHERE conditions via flag (`--where`) or interactive prompt. Injects the condition into all SOQL queries for consistent filtering across all objects.\n- **Storage Calculation:** Applies a conservative average record size of 2 KB (2048 bytes) to estimate storage consumption. Calculates both MB usage and percentage of org quota for each object and breakdown value.\n- **Report Generation:** Uses `generateCsvFile` and `generateReportPath` helpers to create two CSV files in the reports directory:\n - Detailed breakdown: includes all statistics per breakdown value per object (e.g., by year, by month, by RecordType)\n - Totals summary: includes only aggregate totals per object\n - File naming includes breakdown field, granularity (for date fields), and `-filtered` suffix when WHERE clause is applied\n- **Caching Mechanism:** Writes a JSON cache file per authenticated username (sanitized) in the reports directory (`<username>_empty_tables_cache.json`) containing an array of empty object names. The cache is updated after each run with newly detected empty objects.\n- **Progress & UX:** Uses `WebSocketClient` to emit start/step/end progress messages for external monitoring. Outputs summary tables with `uxLogTable` and status messages with `uxLog`.\n- **Return Value:** Returns a JSON object containing `tableStorageInfos` (all rows), `tableStorageInfosTotals` (summary rows), `storageLimits` (org limits object), and `outputFiles` (paths to generated CSV/XLSX reports).\n</details>\n\n![](https://sfdx-hardis.cloudity.com/assets/images/storage-usage-year-breakdown.png)\n\n![](https://sfdx-hardis.cloudity.com/assets/images/storage-usage-total.png)\n",
6569
+ "description": "\n## Command Behavior\n\n**Retrieves and displays the scheduled upgrade date for a Salesforce org's instance.**\n\nThis command provides crucial information about when your Salesforce instance will be upgraded to the next major release (Spring, Summer, or Winter). This is vital for release planning, testing, and ensuring compatibility with upcoming Salesforce features.\n\nKey functionalities:\n\n- **Instance Identification:** Determines the Salesforce instance name of your target org.\n- **Upgrade Date Retrieval:** Fetches the planned start time of the next major core service upgrade for that instance from the Salesforce Status API.\n- **Days Until Upgrade:** Calculates and displays the number of days remaining until the next major upgrade.\n- **Severity-Based Logging:** Adjusts the log severity (info, warning) based on the proximity of the upgrade date, providing a visual cue for urgency.\n- **Notifications:** Sends notifications to configured channels (e.g., Slack, MS Teams, Grafana) with the upgrade information, making it suitable for automated monitoring.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Query:** It first queries the `Organization` object in Salesforce to get the `InstanceName` of the target org.\n- **Salesforce Status API Integration:** It makes an HTTP GET request to the Salesforce Status API (`https://api.status.salesforce.com/v1/instances/{instanceName}/status`) to retrieve detailed information about the instance, including scheduled maintenances.\n- **Data Parsing:** It parses the JSON response from the Status API to extract the relevant major release upgrade information.\n- **Date Calculation:** Uses the `moment` library to calculate the difference in days between the current date and the planned upgrade date.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including the instance name, upgrade date, and days remaining, along with relevant metrics for monitoring dashboards.\n- **User Feedback:** Provides clear messages to the user about the upgrade status and proximity.\n</details>\n",
6540
6570
  "examples": [
6541
- "$ sf hardis:org:diagnose:storage-stats",
6542
- "$ sf hardis:org:diagnose:storage-stats --breakdown-field \"CreatedDate\"",
6543
- "$ sf hardis:org:diagnose:storage-stats -b \"RecordType.Name\"",
6544
- "$ sf hardis:org:diagnose:storage-stats --where \"CreatedDate = LAST_N_DAYS:365\"",
6545
- "$ sf hardis:org:diagnose:storage-stats -w \"Status__c = 'Active'\"",
6546
- "$ sf hardis:org:diagnose:storage-stats -b \"LastModifiedDate\" -w \"IsDeleted = false\""
6571
+ "$ sf hardis:org:diagnose:instanceupgrade"
6547
6572
  ],
6548
6573
  "flags": {
6549
6574
  "json": {
@@ -6561,30 +6586,6 @@
6561
6586
  "multiple": false,
6562
6587
  "type": "option"
6563
6588
  },
6564
- "outputfile": {
6565
- "char": "f",
6566
- "description": "Force the path and name of output report file. Must end with .csv",
6567
- "name": "outputfile",
6568
- "hasDynamicHelp": false,
6569
- "multiple": false,
6570
- "type": "option"
6571
- },
6572
- "breakdown-field": {
6573
- "char": "b",
6574
- "description": "Field to use for storage stats breakdown. Example: \"CreatedDate\", \"LastModifiedDate\", \"RecordType.Name\", or custom fields like \"Status__c\"",
6575
- "name": "breakdown-field",
6576
- "hasDynamicHelp": false,
6577
- "multiple": false,
6578
- "type": "option"
6579
- },
6580
- "where": {
6581
- "char": "w",
6582
- "description": "WHERE clause to filter records in the query (without the WHERE keyword). Example: \"CreatedDate = LAST_N_DAYS:365\" or \"Status__c = 'Active'\"",
6583
- "name": "where",
6584
- "hasDynamicHelp": false,
6585
- "multiple": false,
6586
- "type": "option"
6587
- },
6588
6589
  "debug": {
6589
6590
  "char": "d",
6590
6591
  "description": "Activate debug mode (more logs)",
@@ -6623,14 +6624,14 @@
6623
6624
  },
6624
6625
  "hasDynamicHelp": true,
6625
6626
  "hiddenAliases": [],
6626
- "id": "hardis:org:diagnose:storage-stats",
6627
+ "id": "hardis:org:diagnose:instanceupgrade",
6627
6628
  "pluginAlias": "sfdx-hardis",
6628
6629
  "pluginName": "sfdx-hardis",
6629
6630
  "pluginType": "core",
6630
6631
  "strict": true,
6631
6632
  "enableJsonFlag": true,
6632
- "title": "Extract Data Storage stats",
6633
- "requiresProject": true,
6633
+ "title": "Get Instance Upgrade date",
6634
+ "requiresProject": false,
6634
6635
  "isESM": true,
6635
6636
  "relativePath": [
6636
6637
  "lib",
@@ -6638,42 +6639,45 @@
6638
6639
  "hardis",
6639
6640
  "org",
6640
6641
  "diagnose",
6641
- "storage-stats.js"
6642
+ "instanceupgrade.js"
6642
6643
  ],
6643
6644
  "aliasPermutations": [],
6644
6645
  "permutations": [
6645
- "hardis:org:diagnose:storage-stats",
6646
- "org:hardis:diagnose:storage-stats",
6647
- "org:diagnose:hardis:storage-stats",
6648
- "org:diagnose:storage-stats:hardis",
6649
- "hardis:diagnose:org:storage-stats",
6650
- "diagnose:hardis:org:storage-stats",
6651
- "diagnose:org:hardis:storage-stats",
6652
- "diagnose:org:storage-stats:hardis",
6653
- "hardis:diagnose:storage-stats:org",
6654
- "diagnose:hardis:storage-stats:org",
6655
- "diagnose:storage-stats:hardis:org",
6656
- "diagnose:storage-stats:org:hardis",
6657
- "hardis:org:storage-stats:diagnose",
6658
- "org:hardis:storage-stats:diagnose",
6659
- "org:storage-stats:hardis:diagnose",
6660
- "org:storage-stats:diagnose:hardis",
6661
- "hardis:storage-stats:org:diagnose",
6662
- "storage-stats:hardis:org:diagnose",
6663
- "storage-stats:org:hardis:diagnose",
6664
- "storage-stats:org:diagnose:hardis",
6665
- "hardis:storage-stats:diagnose:org",
6666
- "storage-stats:hardis:diagnose:org",
6667
- "storage-stats:diagnose:hardis:org",
6668
- "storage-stats:diagnose:org:hardis"
6646
+ "hardis:org:diagnose:instanceupgrade",
6647
+ "org:hardis:diagnose:instanceupgrade",
6648
+ "org:diagnose:hardis:instanceupgrade",
6649
+ "org:diagnose:instanceupgrade:hardis",
6650
+ "hardis:diagnose:org:instanceupgrade",
6651
+ "diagnose:hardis:org:instanceupgrade",
6652
+ "diagnose:org:hardis:instanceupgrade",
6653
+ "diagnose:org:instanceupgrade:hardis",
6654
+ "hardis:diagnose:instanceupgrade:org",
6655
+ "diagnose:hardis:instanceupgrade:org",
6656
+ "diagnose:instanceupgrade:hardis:org",
6657
+ "diagnose:instanceupgrade:org:hardis",
6658
+ "hardis:org:instanceupgrade:diagnose",
6659
+ "org:hardis:instanceupgrade:diagnose",
6660
+ "org:instanceupgrade:hardis:diagnose",
6661
+ "org:instanceupgrade:diagnose:hardis",
6662
+ "hardis:instanceupgrade:org:diagnose",
6663
+ "instanceupgrade:hardis:org:diagnose",
6664
+ "instanceupgrade:org:hardis:diagnose",
6665
+ "instanceupgrade:org:diagnose:hardis",
6666
+ "hardis:instanceupgrade:diagnose:org",
6667
+ "instanceupgrade:hardis:diagnose:org",
6668
+ "instanceupgrade:diagnose:hardis:org",
6669
+ "instanceupgrade:diagnose:org:hardis"
6669
6670
  ]
6670
6671
  },
6671
- "hardis:org:diagnose:unsecure-connected-apps": {
6672
+ "hardis:org:diagnose:legacyapi": {
6672
6673
  "aliases": [],
6673
6674
  "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
+ "description": "Checks if an org uses retired or someday retired API version\n\n\nSee article below\n\n[![Handle Salesforce API versions Deprecation like a pro](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deprecated-api.jpg)](https://nicolas.vuillamy.fr/handle-salesforce-api-versions-deprecation-like-a-pro-335065f52238)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-deprecated-api-calls/) and can output Grafana, Slack and MsTeams Notifications.\n",
6675
6676
  "examples": [
6676
- "$ sf hardis:org:diagnose:unsecure-connected-apps"
6677
+ "$ sf hardis:org:diagnose:legacyapi",
6678
+ "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com",
6679
+ "$ sf hardis:org:diagnose:legacyapi --outputfile 'c:/path/to/folder/legacyapi.csv'",
6680
+ "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com --outputfile ./tmp/legacyapi.csv"
6677
6681
  ],
6678
6682
  "flags": {
6679
6683
  "json": {
@@ -6691,6 +6695,24 @@
6691
6695
  "multiple": false,
6692
6696
  "type": "option"
6693
6697
  },
6698
+ "eventtype": {
6699
+ "char": "e",
6700
+ "description": "Type of EventLogFile event to analyze",
6701
+ "name": "eventtype",
6702
+ "default": "ApiTotalUsage",
6703
+ "hasDynamicHelp": false,
6704
+ "multiple": false,
6705
+ "type": "option"
6706
+ },
6707
+ "limit": {
6708
+ "char": "l",
6709
+ "description": "Number of latest EventLogFile events to analyze",
6710
+ "name": "limit",
6711
+ "default": 999,
6712
+ "hasDynamicHelp": false,
6713
+ "multiple": false,
6714
+ "type": "option"
6715
+ },
6694
6716
  "outputfile": {
6695
6717
  "char": "f",
6696
6718
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -6734,61 +6756,60 @@
6734
6756
  "multiple": false,
6735
6757
  "type": "option"
6736
6758
  }
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"
6759
+ },
6760
+ "hasDynamicHelp": true,
6761
+ "hiddenAliases": [],
6762
+ "id": "hardis:org:diagnose:legacyapi",
6763
+ "pluginAlias": "sfdx-hardis",
6764
+ "pluginName": "sfdx-hardis",
6765
+ "pluginType": "core",
6766
+ "strict": true,
6767
+ "enableJsonFlag": true,
6768
+ "title": "Check for legacy API use",
6769
+ "requiresProject": false,
6770
+ "isESM": true,
6771
+ "relativePath": [
6772
+ "lib",
6773
+ "commands",
6774
+ "hardis",
6775
+ "org",
6776
+ "diagnose",
6777
+ "legacyapi.js"
6778
+ ],
6779
+ "aliasPermutations": [],
6780
+ "permutations": [
6781
+ "hardis:org:diagnose:legacyapi",
6782
+ "org:hardis:diagnose:legacyapi",
6783
+ "org:diagnose:hardis:legacyapi",
6784
+ "org:diagnose:legacyapi:hardis",
6785
+ "hardis:diagnose:org:legacyapi",
6786
+ "diagnose:hardis:org:legacyapi",
6787
+ "diagnose:org:hardis:legacyapi",
6788
+ "diagnose:org:legacyapi:hardis",
6789
+ "hardis:diagnose:legacyapi:org",
6790
+ "diagnose:hardis:legacyapi:org",
6791
+ "diagnose:legacyapi:hardis:org",
6792
+ "diagnose:legacyapi:org:hardis",
6793
+ "hardis:org:legacyapi:diagnose",
6794
+ "org:hardis:legacyapi:diagnose",
6795
+ "org:legacyapi:hardis:diagnose",
6796
+ "org:legacyapi:diagnose:hardis",
6797
+ "hardis:legacyapi:org:diagnose",
6798
+ "legacyapi:hardis:org:diagnose",
6799
+ "legacyapi:org:hardis:diagnose",
6800
+ "legacyapi:org:diagnose:hardis",
6801
+ "hardis:legacyapi:diagnose:org",
6802
+ "legacyapi:hardis:diagnose:org",
6803
+ "legacyapi:diagnose:hardis:org",
6804
+ "legacyapi:diagnose:org:hardis"
6783
6805
  ]
6784
6806
  },
6785
- "hardis:org:diagnose:unused-apex-classes": {
6807
+ "hardis:org:diagnose:licenses": {
6786
6808
  "aliases": [],
6787
6809
  "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",
6810
+ "description": "\n**Lists and analyzes User Licenses and Permission Set Licenses subscribed and used in a Salesforce org.**\n\nThis command provides a comprehensive overview of your Salesforce license consumption. It's particularly useful for:\n\n- **License Management:** Understanding which licenses are active, how many are available, and how many are being used.\n- **Cost Optimization:** Identifying unused or underutilized licenses that could be reallocated or decommissioned.\n- **Compliance:** Ensuring that your organization is compliant with Salesforce licensing agreements.\n- **Monitoring:** Tracking license usage trends over time.\n\nKey functionalities:\n\n- **User License Details:** Retrieves information about standard and custom User Licenses, including `MasterLabel`, `Name`, `TotalLicenses`, and `UsedLicenses`.\n- **Permission Set License Details:** Retrieves information about Permission Set Licenses, including `MasterLabel`, `PermissionSetLicenseKey`, `TotalLicenses`, and `UsedLicenses`.\n- **Used Licenses Filter:** The `--usedonly` flag allows you to filter the report to show only licenses that have at least one `UsedLicenses` count greater than zero.\n- **CSV Report Generation:** Generates a CSV file containing all the retrieved license information, suitable for detailed analysis.\n- **Notifications:** Sends notifications to configured channels (e.g., Grafana, Slack, MS Teams) with a summary of license usage, including lists of active and used licenses.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It executes SOQL queries against the `UserLicense` and `PermissionSetLicense` objects in Salesforce to retrieve license data.\n- **Data Transformation:** It processes the query results, reformatting the data to be more readable and consistent for reporting purposes (e.g., removing `Id` and `attributes`, renaming `PermissionSetLicenseKey` to `Name`).\n- **Data Aggregation:** It aggregates license information, creating a `licensesByKey` object for quick lookups and a `usedLicenses` array for a concise list of actively used licenses.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of license data.\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 clear messages to the user about the license extraction process and the used licenses.\n</details>\n",
6789
6811
  "examples": [
6790
- "$ sf hardis:org:diagnose:unused-apex-classes",
6791
- "$ sf hardis:org:diagnose:unused-apex-classes --days 700"
6812
+ "$ sf hardis:org:diagnose:licenses"
6792
6813
  ],
6793
6814
  "flags": {
6794
6815
  "json": {
@@ -6814,13 +6835,12 @@
6814
6835
  "multiple": false,
6815
6836
  "type": "option"
6816
6837
  },
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"
6838
+ "usedonly": {
6839
+ "char": "u",
6840
+ "description": "Filter to have only used licenses",
6841
+ "name": "usedonly",
6842
+ "allowNo": false,
6843
+ "type": "boolean"
6824
6844
  },
6825
6845
  "debug": {
6826
6846
  "char": "d",
@@ -6860,13 +6880,13 @@
6860
6880
  },
6861
6881
  "hasDynamicHelp": true,
6862
6882
  "hiddenAliases": [],
6863
- "id": "hardis:org:diagnose:unused-apex-classes",
6883
+ "id": "hardis:org:diagnose:licenses",
6864
6884
  "pluginAlias": "sfdx-hardis",
6865
6885
  "pluginName": "sfdx-hardis",
6866
6886
  "pluginType": "core",
6867
6887
  "strict": true,
6868
6888
  "enableJsonFlag": true,
6869
- "title": "Detect unused Apex classes in an org",
6889
+ "title": "List licenses subscribed and used in a Salesforce org",
6870
6890
  "requiresProject": false,
6871
6891
  "isESM": true,
6872
6892
  "relativePath": [
@@ -6875,42 +6895,42 @@
6875
6895
  "hardis",
6876
6896
  "org",
6877
6897
  "diagnose",
6878
- "unused-apex-classes.js"
6898
+ "licenses.js"
6879
6899
  ],
6880
6900
  "aliasPermutations": [],
6881
6901
  "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"
6902
+ "hardis:org:diagnose:licenses",
6903
+ "org:hardis:diagnose:licenses",
6904
+ "org:diagnose:hardis:licenses",
6905
+ "org:diagnose:licenses:hardis",
6906
+ "hardis:diagnose:org:licenses",
6907
+ "diagnose:hardis:org:licenses",
6908
+ "diagnose:org:hardis:licenses",
6909
+ "diagnose:org:licenses:hardis",
6910
+ "hardis:diagnose:licenses:org",
6911
+ "diagnose:hardis:licenses:org",
6912
+ "diagnose:licenses:hardis:org",
6913
+ "diagnose:licenses:org:hardis",
6914
+ "hardis:org:licenses:diagnose",
6915
+ "org:hardis:licenses:diagnose",
6916
+ "org:licenses:hardis:diagnose",
6917
+ "org:licenses:diagnose:hardis",
6918
+ "hardis:licenses:org:diagnose",
6919
+ "licenses:hardis:org:diagnose",
6920
+ "licenses:org:hardis:diagnose",
6921
+ "licenses:org:diagnose:hardis",
6922
+ "hardis:licenses:diagnose:org",
6923
+ "licenses:hardis:diagnose:org",
6924
+ "licenses:diagnose:hardis:org",
6925
+ "licenses:diagnose:org:hardis"
6906
6926
  ]
6907
6927
  },
6908
- "hardis:org:diagnose:unused-connected-apps": {
6928
+ "hardis:org:diagnose:releaseupdates": {
6909
6929
  "aliases": [],
6910
6930
  "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",
6931
+ "description": "Export Release Updates into a CSV file with selected criteria, and highlight Release Updates that should be checked.\n\nBefore publishing **Breaking Changes** ❌, Salesforce announce them in the setup menu [**Release Updates**](https://help.salesforce.com/s/articleView?id=sf.release_updates.htm&type=5)\n\n⚠️ Some of them are very important, because if you don't make the related upgrades in time (ex: before Winter 25) , your production org can crash !\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-release-updates/) and can output Grafana, Slack and MsTeams Notifications.\n",
6912
6932
  "examples": [
6913
- "$ sf hardis:org:diagnose:unused-connected-apps"
6933
+ "$ sf hardis:org:diagnose:releaseupdates"
6914
6934
  ],
6915
6935
  "flags": {
6916
6936
  "json": {
@@ -6974,30 +6994,13 @@
6974
6994
  },
6975
6995
  "hasDynamicHelp": true,
6976
6996
  "hiddenAliases": [],
6977
- "id": "hardis:org:diagnose:unused-connected-apps",
6997
+ "id": "hardis:org:diagnose:releaseupdates",
6978
6998
  "pluginAlias": "sfdx-hardis",
6979
6999
  "pluginName": "sfdx-hardis",
6980
7000
  "pluginType": "core",
6981
7001
  "strict": true,
6982
7002
  "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
- ],
7003
+ "title": "Check Release Updates of an org",
7001
7004
  "requiresProject": false,
7002
7005
  "isESM": true,
7003
7006
  "relativePath": [
@@ -7006,43 +7009,47 @@
7006
7009
  "hardis",
7007
7010
  "org",
7008
7011
  "diagnose",
7009
- "unused-connected-apps.js"
7012
+ "releaseupdates.js"
7010
7013
  ],
7011
7014
  "aliasPermutations": [],
7012
7015
  "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"
7016
+ "hardis:org:diagnose:releaseupdates",
7017
+ "org:hardis:diagnose:releaseupdates",
7018
+ "org:diagnose:hardis:releaseupdates",
7019
+ "org:diagnose:releaseupdates:hardis",
7020
+ "hardis:diagnose:org:releaseupdates",
7021
+ "diagnose:hardis:org:releaseupdates",
7022
+ "diagnose:org:hardis:releaseupdates",
7023
+ "diagnose:org:releaseupdates:hardis",
7024
+ "hardis:diagnose:releaseupdates:org",
7025
+ "diagnose:hardis:releaseupdates:org",
7026
+ "diagnose:releaseupdates:hardis:org",
7027
+ "diagnose:releaseupdates:org:hardis",
7028
+ "hardis:org:releaseupdates:diagnose",
7029
+ "org:hardis:releaseupdates:diagnose",
7030
+ "org:releaseupdates:hardis:diagnose",
7031
+ "org:releaseupdates:diagnose:hardis",
7032
+ "hardis:releaseupdates:org:diagnose",
7033
+ "releaseupdates:hardis:org:diagnose",
7034
+ "releaseupdates:org:hardis:diagnose",
7035
+ "releaseupdates:org:diagnose:hardis",
7036
+ "hardis:releaseupdates:diagnose:org",
7037
+ "releaseupdates:hardis:diagnose:org",
7038
+ "releaseupdates:diagnose:hardis:org",
7039
+ "releaseupdates:diagnose:org:hardis"
7037
7040
  ]
7038
7041
  },
7039
- "hardis:org:diagnose:unusedlicenses": {
7042
+ "hardis:org:diagnose:storage-stats": {
7040
7043
  "aliases": [],
7041
7044
  "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",
7045
+ "description": "**Extracts and analyzes Data Storage usage for a Salesforce org, providing detailed per-object breakdowns with flexible grouping options.**\n\nThis command provides a comprehensive overview of your Salesforce data storage consumption. It's particularly useful for:\n\n- **Storage Management:** Understanding which SObjects consume the most storage and how usage has evolved over time.\n- **Cost Optimization:** Identifying storage-heavy objects that could be candidates for data archival or cleanup strategies.\n- **Capacity Planning:** Tracking storage trends to predict when additional capacity will be needed.\n- **Compliance & Governance:** Monitoring data growth patterns to ensure alignment with data retention policies.\n\nKey functionalities:\n\n- **Storage Limits Analysis:** Retrieves and displays org data storage limits, including total capacity, used storage, remaining storage, and percentage used. Detects and alerts on over-usage scenarios.\n- **SObject Discovery & Filtering:** Automatically discovers all SObjects in the org and filters them to focus on production/custom objects (excludes metadata types, platform-only objects, and cached empty objects).\n- **Interactive Selection:** Prompts the user to select which SObjects to analyze and choose breakdown fields (date fields, RecordType, custom fields, or relationship fields).\n- **Flexible Breakdown Field:** Supports grouping by any field including:\n - Date/DateTime fields (`CreatedDate`, `LastModifiedDate`, custom date fields)\n - RecordType (`RecordType.Name`)\n - Custom fields (`Status__c`, picklists, text fields)\n - Nested relationship fields (`SBQQ__Quote__r.RecordType.Name`)\n- **Date Granularity Options:** For date/datetime fields, choose between:\n - Year-based grouping (`CALENDAR_YEAR`)\n - Month-based grouping (`CALENDAR_MONTH`)\n - Day-based grouping (exact date)\n- **WHERE Clause Filtering:** Apply SOQL WHERE conditions to filter records before calculating storage (e.g., only active records, records from the last year).\n- **Storage Estimation:** Estimates storage usage for each object using an average record size heuristic (2 KB per record) and calculates the percentage of org quota consumed.\n- **Dual CSV Reports:** Generates two CSV files: a detailed breakdown by selected field and a totals-per-object summary, both suitable for spreadsheet analysis and reporting.\n- **Empty Objects Cache:** Maintains a per-user cache of objects detected with zero records to optimize subsequent runs by skipping empty tables.\n- **Progress Tracking:** Sends WebSocket progress messages for integration with external UIs and monitoring dashboards.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Limits Retrieval:** Calls `conn.limits()` to retrieve the `DataStorageMB` object containing `Max` and `Remaining` values. Handles negative `Remaining` values (over-usage scenarios) by calculating `overUsageMB` and adjusting display values.\n- **SObject Discovery:** Uses `conn.metadata.list([{ type: 'CustomObject' }])` to get custom objects and `conn.describeGlobal()` to get all SObjects. Filters by object capabilities (`layoutable`, `queryable`, `retrieveable`, `createable`, `updateable`, `deletable`) and excludes metadata types (`__mdt` suffix) and cached empty objects.\n- **User Interaction:** Uses `prompts` for interactive multi-select of SObjects, breakdown field selection, granularity choice (for date fields), and optional WHERE conditions. All objects are pre-selected by default for user convenience.\n- **Field Validation:** Recursively validates breakdown fields including nested relationships (e.g., `SBQQ__Quote__r.RecordType.Name`) by traversing the relationship chain and checking field existence on each related object. Automatically handles special cases like `RecordType` -> `RecordTypeId` and `__r` -> `__c` conversions.\n- **Dynamic Query Generation:** Builds SOQL queries based on field type and granularity:\n - For date fields with year granularity: `SELECT CALENDAR_YEAR(<Field>) breakdown, COUNT(Id) total FROM <SObject> [WHERE ...] GROUP BY CALENDAR_YEAR(<Field>) ORDER BY CALENDAR_YEAR(<Field>)`\n - For date fields with month granularity: `SELECT CALENDAR_YEAR(<Field>) year, CALENDAR_MONTH(<Field>) month, COUNT(Id) total FROM <SObject> [WHERE ...] GROUP BY CALENDAR_YEAR(<Field>), CALENDAR_MONTH(<Field>) ORDER BY CALENDAR_YEAR(<Field>), CALENDAR_MONTH(<Field>)`\n - For non-date fields: `SELECT <Field> breakdown, COUNT(Id) total FROM <SObject> [WHERE ...] GROUP BY <Field> ORDER BY <Field>`\n- **WHERE Clause Support:** Accepts user-provided WHERE conditions via flag (`--where`) or interactive prompt. Injects the condition into all SOQL queries for consistent filtering across all objects.\n- **Storage Calculation:** Applies a conservative average record size of 2 KB (2048 bytes) to estimate storage consumption. Calculates both MB usage and percentage of org quota for each object and breakdown value.\n- **Report Generation:** Uses `generateCsvFile` and `generateReportPath` helpers to create two CSV files in the reports directory:\n - Detailed breakdown: includes all statistics per breakdown value per object (e.g., by year, by month, by RecordType)\n - Totals summary: includes only aggregate totals per object\n - File naming includes breakdown field, granularity (for date fields), and `-filtered` suffix when WHERE clause is applied\n- **Caching Mechanism:** Writes a JSON cache file per authenticated username (sanitized) in the reports directory (`<username>_empty_tables_cache.json`) containing an array of empty object names. The cache is updated after each run with newly detected empty objects.\n- **Progress & UX:** Uses `WebSocketClient` to emit start/step/end progress messages for external monitoring. Outputs summary tables with `uxLogTable` and status messages with `uxLog`.\n- **Return Value:** Returns a JSON object containing `tableStorageInfos` (all rows), `tableStorageInfosTotals` (summary rows), `storageLimits` (org limits object), and `outputFiles` (paths to generated CSV/XLSX reports).\n</details>\n\n![](https://sfdx-hardis.cloudity.com/assets/images/storage-usage-year-breakdown.png)\n\n![](https://sfdx-hardis.cloudity.com/assets/images/storage-usage-total.png)\n",
7043
7046
  "examples": [
7044
- "$ sf hardis:org:diagnose:unusedlicenses",
7045
- "$ sf hardis:org:diagnose:unusedlicenses --fix"
7047
+ "$ sf hardis:org:diagnose:storage-stats",
7048
+ "$ sf hardis:org:diagnose:storage-stats --breakdown-field \"CreatedDate\"",
7049
+ "$ sf hardis:org:diagnose:storage-stats -b \"RecordType.Name\"",
7050
+ "$ sf hardis:org:diagnose:storage-stats --where \"CreatedDate = LAST_N_DAYS:365\"",
7051
+ "$ sf hardis:org:diagnose:storage-stats -w \"Status__c = 'Active'\"",
7052
+ "$ sf hardis:org:diagnose:storage-stats -b \"LastModifiedDate\" -w \"IsDeleted = false\""
7046
7053
  ],
7047
7054
  "flags": {
7048
7055
  "json": {
@@ -7068,6 +7075,22 @@
7068
7075
  "multiple": false,
7069
7076
  "type": "option"
7070
7077
  },
7078
+ "breakdown-field": {
7079
+ "char": "b",
7080
+ "description": "Field to use for storage stats breakdown. Example: \"CreatedDate\", \"LastModifiedDate\", \"RecordType.Name\", or custom fields like \"Status__c\"",
7081
+ "name": "breakdown-field",
7082
+ "hasDynamicHelp": false,
7083
+ "multiple": false,
7084
+ "type": "option"
7085
+ },
7086
+ "where": {
7087
+ "char": "w",
7088
+ "description": "WHERE clause to filter records in the query (without the WHERE keyword). Example: \"CreatedDate = LAST_N_DAYS:365\" or \"Status__c = 'Active'\"",
7089
+ "name": "where",
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)",
@@ -7096,42 +7119,24 @@
7096
7119
  "char": "o",
7097
7120
  "deprecateAliases": true,
7098
7121
  "name": "target-org",
7099
- "noCacheDefault": true,
7100
- "required": true,
7101
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
7102
- "hasDynamicHelp": true,
7103
- "multiple": false,
7104
- "type": "option"
7105
- }
7106
- },
7107
- "hasDynamicHelp": true,
7108
- "hiddenAliases": [],
7109
- "id": "hardis:org:diagnose:unusedlicenses",
7110
- "pluginAlias": "sfdx-hardis",
7111
- "pluginName": "sfdx-hardis",
7112
- "pluginType": "core",
7113
- "strict": true,
7114
- "enableJsonFlag": true,
7115
- "title": "Detect unused Permission Set Licenses (beta)",
7116
- "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"
7122
+ "noCacheDefault": true,
7123
+ "required": true,
7124
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
7125
+ "hasDynamicHelp": true,
7126
+ "multiple": false,
7127
+ "type": "option"
7130
7128
  }
7131
- ],
7132
- "alwaysExcludeForActiveUsersPermissionSetLicenses": [
7133
- "IdentityConnect"
7134
- ],
7129
+ },
7130
+ "hasDynamicHelp": true,
7131
+ "hiddenAliases": [],
7132
+ "id": "hardis:org:diagnose:storage-stats",
7133
+ "pluginAlias": "sfdx-hardis",
7134
+ "pluginName": "sfdx-hardis",
7135
+ "pluginType": "core",
7136
+ "strict": true,
7137
+ "enableJsonFlag": true,
7138
+ "title": "Extract Data Storage stats",
7139
+ "requiresProject": true,
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
+ "storage-stats.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:storage-stats",
7152
+ "org:hardis:diagnose:storage-stats",
7153
+ "org:diagnose:hardis:storage-stats",
7154
+ "org:diagnose:storage-stats:hardis",
7155
+ "hardis:diagnose:org:storage-stats",
7156
+ "diagnose:hardis:org:storage-stats",
7157
+ "diagnose:org:hardis:storage-stats",
7158
+ "diagnose:org:storage-stats:hardis",
7159
+ "hardis:diagnose:storage-stats:org",
7160
+ "diagnose:hardis:storage-stats:org",
7161
+ "diagnose:storage-stats:hardis:org",
7162
+ "diagnose:storage-stats:org:hardis",
7163
+ "hardis:org:storage-stats:diagnose",
7164
+ "org:hardis:storage-stats:diagnose",
7165
+ "org:storage-stats:hardis:diagnose",
7166
+ "org:storage-stats:diagnose:hardis",
7167
+ "hardis:storage-stats:org:diagnose",
7168
+ "storage-stats:hardis:org:diagnose",
7169
+ "storage-stats:org:hardis:diagnose",
7170
+ "storage-stats:org:diagnose:hardis",
7171
+ "hardis:storage-stats:diagnose:org",
7172
+ "storage-stats:hardis:diagnose:org",
7173
+ "storage-stats:diagnose:hardis:org",
7174
+ "storage-stats:diagnose:org:hardis"
7170
7175
  ]
7171
7176
  },
7172
- "hardis:org:diagnose:unusedusers": {
7177
+ "hardis:org:diagnose:unsecure-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**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",
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:unsecure-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,13 @@
7277
7243
  },
7278
7244
  "hasDynamicHelp": true,
7279
7245
  "hiddenAliases": [],
7280
- "id": "hardis:org:diagnose:unusedusers",
7246
+ "id": "hardis:org:diagnose:unsecure-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": "Detect Unsecured Connected Apps",
7287
7253
  "requiresProject": false,
7288
7254
  "isESM": true,
7289
7255
  "relativePath": [
@@ -7292,42 +7258,43 @@
7292
7258
  "hardis",
7293
7259
  "org",
7294
7260
  "diagnose",
7295
- "unusedusers.js"
7261
+ "unsecure-connected-apps.js"
7296
7262
  ],
7297
7263
  "aliasPermutations": [],
7298
7264
  "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"
7265
+ "hardis:org:diagnose:unsecure-connected-apps",
7266
+ "org:hardis:diagnose:unsecure-connected-apps",
7267
+ "org:diagnose:hardis:unsecure-connected-apps",
7268
+ "org:diagnose:unsecure-connected-apps:hardis",
7269
+ "hardis:diagnose:org:unsecure-connected-apps",
7270
+ "diagnose:hardis:org:unsecure-connected-apps",
7271
+ "diagnose:org:hardis:unsecure-connected-apps",
7272
+ "diagnose:org:unsecure-connected-apps:hardis",
7273
+ "hardis:diagnose:unsecure-connected-apps:org",
7274
+ "diagnose:hardis:unsecure-connected-apps:org",
7275
+ "diagnose:unsecure-connected-apps:hardis:org",
7276
+ "diagnose:unsecure-connected-apps:org:hardis",
7277
+ "hardis:org:unsecure-connected-apps:diagnose",
7278
+ "org:hardis:unsecure-connected-apps:diagnose",
7279
+ "org:unsecure-connected-apps:hardis:diagnose",
7280
+ "org:unsecure-connected-apps:diagnose:hardis",
7281
+ "hardis:unsecure-connected-apps:org:diagnose",
7282
+ "unsecure-connected-apps:hardis:org:diagnose",
7283
+ "unsecure-connected-apps:org:hardis:diagnose",
7284
+ "unsecure-connected-apps:org:diagnose:hardis",
7285
+ "hardis:unsecure-connected-apps:diagnose:org",
7286
+ "unsecure-connected-apps:hardis:diagnose:org",
7287
+ "unsecure-connected-apps:diagnose:hardis:org",
7288
+ "unsecure-connected-apps:diagnose:org:hardis"
7323
7289
  ]
7324
7290
  },
7325
- "hardis:org:files:export": {
7291
+ "hardis:org:diagnose:unused-apex-classes": {
7326
7292
  "aliases": [],
7327
7293
  "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",
7294
+ "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",
7329
7295
  "examples": [
7330
- "$ sf hardis:org:files:export"
7296
+ "$ sf hardis:org:diagnose:unused-apex-classes",
7297
+ "$ sf hardis:org:diagnose:unused-apex-classes --days 700"
7331
7298
  ],
7332
7299
  "flags": {
7333
7300
  "json": {
@@ -7345,48 +7312,22 @@
7345
7312
  "multiple": false,
7346
7313
  "type": "option"
7347
7314
  },
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,
7315
+ "outputfile": {
7316
+ "char": "f",
7317
+ "description": "Force the path and name of output report file. Must end with .csv",
7318
+ "name": "outputfile",
7361
7319
  "hasDynamicHelp": false,
7362
7320
  "multiple": false,
7363
7321
  "type": "option"
7364
7322
  },
7365
- "polltimeout": {
7323
+ "days": {
7366
7324
  "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,
7325
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7326
+ "name": "days",
7379
7327
  "hasDynamicHelp": false,
7380
7328
  "multiple": false,
7381
7329
  "type": "option"
7382
7330
  },
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
7331
  "debug": {
7391
7332
  "char": "d",
7392
7333
  "description": "Activate debug mode (more logs)",
@@ -7425,57 +7366,57 @@
7425
7366
  },
7426
7367
  "hasDynamicHelp": true,
7427
7368
  "hiddenAliases": [],
7428
- "id": "hardis:org:files:export",
7369
+ "id": "hardis:org:diagnose:unused-apex-classes",
7429
7370
  "pluginAlias": "sfdx-hardis",
7430
7371
  "pluginName": "sfdx-hardis",
7431
7372
  "pluginType": "core",
7432
7373
  "strict": true,
7433
7374
  "enableJsonFlag": true,
7434
- "title": "Export files",
7375
+ "title": "Detect unused Apex classes in an org",
7435
7376
  "requiresProject": false,
7436
- "isESM": true,
7437
- "relativePath": [
7438
- "lib",
7439
- "commands",
7440
- "hardis",
7441
- "org",
7442
- "files",
7443
- "export.js"
7444
- ],
7445
- "aliasPermutations": [],
7446
- "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"
7377
+ "isESM": true,
7378
+ "relativePath": [
7379
+ "lib",
7380
+ "commands",
7381
+ "hardis",
7382
+ "org",
7383
+ "diagnose",
7384
+ "unused-apex-classes.js"
7385
+ ],
7386
+ "aliasPermutations": [],
7387
+ "permutations": [
7388
+ "hardis:org:diagnose:unused-apex-classes",
7389
+ "org:hardis:diagnose:unused-apex-classes",
7390
+ "org:diagnose:hardis:unused-apex-classes",
7391
+ "org:diagnose:unused-apex-classes:hardis",
7392
+ "hardis:diagnose:org:unused-apex-classes",
7393
+ "diagnose:hardis:org:unused-apex-classes",
7394
+ "diagnose:org:hardis:unused-apex-classes",
7395
+ "diagnose:org:unused-apex-classes:hardis",
7396
+ "hardis:diagnose:unused-apex-classes:org",
7397
+ "diagnose:hardis:unused-apex-classes:org",
7398
+ "diagnose:unused-apex-classes:hardis:org",
7399
+ "diagnose:unused-apex-classes:org:hardis",
7400
+ "hardis:org:unused-apex-classes:diagnose",
7401
+ "org:hardis:unused-apex-classes:diagnose",
7402
+ "org:unused-apex-classes:hardis:diagnose",
7403
+ "org:unused-apex-classes:diagnose:hardis",
7404
+ "hardis:unused-apex-classes:org:diagnose",
7405
+ "unused-apex-classes:hardis:org:diagnose",
7406
+ "unused-apex-classes:org:hardis:diagnose",
7407
+ "unused-apex-classes:org:diagnose:hardis",
7408
+ "hardis:unused-apex-classes:diagnose:org",
7409
+ "unused-apex-classes:hardis:diagnose:org",
7410
+ "unused-apex-classes:diagnose:hardis:org",
7411
+ "unused-apex-classes:diagnose:org:hardis"
7471
7412
  ]
7472
7413
  },
7473
- "hardis:org:files:import": {
7414
+ "hardis:org:diagnose:unused-connected-apps": {
7474
7415
  "aliases": [],
7475
7416
  "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",
7417
+ "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",
7477
7418
  "examples": [
7478
- "$ sf hardis:org:files:import"
7419
+ "$ sf hardis:org:diagnose:unused-connected-apps"
7479
7420
  ],
7480
7421
  "flags": {
7481
7422
  "json": {
@@ -7493,21 +7434,14 @@
7493
7434
  "multiple": false,
7494
7435
  "type": "option"
7495
7436
  },
7496
- "path": {
7497
- "char": "p",
7498
- "description": "Path to the file export project",
7499
- "name": "path",
7437
+ "outputfile": {
7438
+ "char": "f",
7439
+ "description": "Force the path and name of output report file. Must end with .csv",
7440
+ "name": "outputfile",
7500
7441
  "hasDynamicHelp": false,
7501
7442
  "multiple": false,
7502
7443
  "type": "option"
7503
7444
  },
7504
- "overwrite": {
7505
- "char": "f",
7506
- "description": "Override existing files (doubles the number of API calls)",
7507
- "name": "overwrite",
7508
- "allowNo": false,
7509
- "type": "boolean"
7510
- },
7511
7445
  "debug": {
7512
7446
  "char": "d",
7513
7447
  "description": "Activate debug mode (more logs)",
@@ -7546,13 +7480,30 @@
7546
7480
  },
7547
7481
  "hasDynamicHelp": true,
7548
7482
  "hiddenAliases": [],
7549
- "id": "hardis:org:files:import",
7483
+ "id": "hardis:org:diagnose:unused-connected-apps",
7550
7484
  "pluginAlias": "sfdx-hardis",
7551
7485
  "pluginName": "sfdx-hardis",
7552
7486
  "pluginType": "core",
7553
7487
  "strict": true,
7554
7488
  "enableJsonFlag": true,
7555
- "title": "Import files",
7489
+ "title": "Unused Connected Apps in an org",
7490
+ "allowedInactiveConnectedApps": [
7491
+ "Ant Migration Tool",
7492
+ "Chatter Desktop",
7493
+ "Chatter Mobile for BlackBerry",
7494
+ "Force.com IDE",
7495
+ "OIQ_Integration",
7496
+ "Salesforce CLI",
7497
+ "Salesforce Files",
7498
+ "Salesforce Mobile Dashboards",
7499
+ "Salesforce Touch",
7500
+ "Salesforce for Outlook",
7501
+ "SalesforceA",
7502
+ "SalesforceA for Android",
7503
+ "SalesforceA for iOS",
7504
+ "SalesforceDX Namespace Registry",
7505
+ "SalesforceIQ"
7506
+ ],
7556
7507
  "requiresProject": false,
7557
7508
  "isESM": true,
7558
7509
  "relativePath": [
@@ -7560,44 +7511,44 @@
7560
7511
  "commands",
7561
7512
  "hardis",
7562
7513
  "org",
7563
- "files",
7564
- "import.js"
7514
+ "diagnose",
7515
+ "unused-connected-apps.js"
7565
7516
  ],
7566
7517
  "aliasPermutations": [],
7567
7518
  "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"
7519
+ "hardis:org:diagnose:unused-connected-apps",
7520
+ "org:hardis:diagnose:unused-connected-apps",
7521
+ "org:diagnose:hardis:unused-connected-apps",
7522
+ "org:diagnose:unused-connected-apps:hardis",
7523
+ "hardis:diagnose:org:unused-connected-apps",
7524
+ "diagnose:hardis:org:unused-connected-apps",
7525
+ "diagnose:org:hardis:unused-connected-apps",
7526
+ "diagnose:org:unused-connected-apps:hardis",
7527
+ "hardis:diagnose:unused-connected-apps:org",
7528
+ "diagnose:hardis:unused-connected-apps:org",
7529
+ "diagnose:unused-connected-apps:hardis:org",
7530
+ "diagnose:unused-connected-apps:org:hardis",
7531
+ "hardis:org:unused-connected-apps:diagnose",
7532
+ "org:hardis:unused-connected-apps:diagnose",
7533
+ "org:unused-connected-apps:hardis:diagnose",
7534
+ "org:unused-connected-apps:diagnose:hardis",
7535
+ "hardis:unused-connected-apps:org:diagnose",
7536
+ "unused-connected-apps:hardis:org:diagnose",
7537
+ "unused-connected-apps:org:hardis:diagnose",
7538
+ "unused-connected-apps:org:diagnose:hardis",
7539
+ "hardis:unused-connected-apps:diagnose:org",
7540
+ "unused-connected-apps:hardis:diagnose:org",
7541
+ "unused-connected-apps:diagnose:hardis:org",
7542
+ "unused-connected-apps:diagnose:org:hardis"
7592
7543
  ]
7593
7544
  },
7594
- "hardis:org:fix:listviewmine": {
7545
+ "hardis:org:diagnose:unusedlicenses": {
7595
7546
  "aliases": [],
7596
7547
  "args": {},
7597
- "description": "Fix listviews whose scope Mine has been replaced by Everything\n\n[![Invalid scope:Mine, not allowed ? Deploy your ListViews anyway !](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-invalid-scope-mine.jpg)](https://nicolas.vuillamy.fr/invalid-scope-mine-not-allowed-deploy-your-listviews-anyway-443aceca8ac7)\n\nList of ListViews can be:\n\n- read from .sfdx-hardis.yml file in property **listViewsToSetToMine**\n- sent in argument listviews\n\nNote: property **listViewsToSetToMine** can be auto-generated by command hardis:work:save if .sfdx-hardis.yml contains the following configuration\n\n```yaml\nautoCleanTypes:\n - listViewsMine\n```\n\n- Example of sfdx-hardis.yml property `listViewsToSetToMine`:\n\n```yaml\nlistViewsToSetToMine:\n - \"force-app/main/default/objects/Operation__c/listViews/MyCurrentOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Operation__c/listViews/MyFinalizedOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/Default_Opportunity_Pipeline.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MyCurrentSubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MySubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Account/listViews/MyActivePartners.listView-meta.xml\"\n```\n\n- If manually written, this could also be:\n\n```yaml\nlistViewsToSetToMine:\n - \"Operation__c:MyCurrentOperations\"\n - \"Operation__c:MyFinalizedOperations\"\n - \"Opportunity:Default_Opportunity_Pipeline\"\n - \"Opportunity:MyCurrentSubscriptions\"\n - \"Opportunity:MySubscriptions\"\n - \"Account:MyActivePartners\"\n```\n\nTroubleshooting: if you need to run this command from an alpine-linux based docker image, use this workaround in your dockerfile:\n\n```dockerfile\n# Do not use puppeteer embedded chromium\nRUN apk add --update --no-cache chromium\nENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=\"true\"\nENV CHROMIUM_PATH=\"/usr/bin/chromium-browser\"\nENV PUPPETEER_EXECUTABLE_PATH=\"$\\{CHROMIUM_PATH}\" // remove \\ before {\n```\n",
7548
+ "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",
7598
7549
  "examples": [
7599
- "$ sf hardis:org:fix:listviewmine",
7600
- "$ sf hardis:org:fix:listviewmine --listviews Opportunity:MySubscriptions,Account:MyActivePartners"
7550
+ "$ sf hardis:org:diagnose:unusedlicenses",
7551
+ "$ sf hardis:org:diagnose:unusedlicenses --fix"
7601
7552
  ],
7602
7553
  "flags": {
7603
7554
  "json": {
@@ -7615,10 +7566,10 @@
7615
7566
  "multiple": false,
7616
7567
  "type": "option"
7617
7568
  },
7618
- "listviews": {
7619
- "char": "l",
7620
- "description": "Comma-separated list of listviews following format Object:ListViewName\nExample: Contact:MyContacts,Contact:MyActiveContacts,Opportunity:MYClosedOpportunities",
7621
- "name": "listviews",
7569
+ "outputfile": {
7570
+ "char": "f",
7571
+ "description": "Force the path and name of output report file. Must end with .csv",
7572
+ "name": "outputfile",
7622
7573
  "hasDynamicHelp": false,
7623
7574
  "multiple": false,
7624
7575
  "type": "option"
@@ -7661,59 +7612,79 @@
7661
7612
  },
7662
7613
  "hasDynamicHelp": true,
7663
7614
  "hiddenAliases": [],
7664
- "id": "hardis:org:fix:listviewmine",
7615
+ "id": "hardis:org:diagnose:unusedlicenses",
7665
7616
  "pluginAlias": "sfdx-hardis",
7666
7617
  "pluginName": "sfdx-hardis",
7667
7618
  "pluginType": "core",
7668
7619
  "strict": true,
7669
7620
  "enableJsonFlag": true,
7670
- "title": "Fix listviews with ",
7671
- "requiresProject": true,
7621
+ "title": "Detect unused Permission Set Licenses (beta)",
7622
+ "requiresProject": false,
7623
+ "additionalPermissionSetsToAlwaysGet": [
7624
+ "Sales_User"
7625
+ ],
7626
+ "permSetsPermSetLicenses": [
7627
+ {
7628
+ "permSet": "Sales_User",
7629
+ "permSetLicense": "SalesUserPsl"
7630
+ }
7631
+ ],
7632
+ "profilesPermissionSetLicenses": [
7633
+ {
7634
+ "profile": "Salesforce API Only",
7635
+ "permSetLicense": "SalesforceAPIIntegrationPsl"
7636
+ }
7637
+ ],
7638
+ "alwaysExcludeForActiveUsersPermissionSetLicenses": [
7639
+ "IdentityConnect"
7640
+ ],
7672
7641
  "isESM": true,
7673
7642
  "relativePath": [
7674
7643
  "lib",
7675
7644
  "commands",
7676
7645
  "hardis",
7677
7646
  "org",
7678
- "fix",
7679
- "listviewmine.js"
7647
+ "diagnose",
7648
+ "unusedlicenses.js"
7680
7649
  ],
7681
7650
  "aliasPermutations": [],
7682
7651
  "permutations": [
7683
- "hardis:org:fix:listviewmine",
7684
- "org:hardis:fix:listviewmine",
7685
- "org:fix:hardis:listviewmine",
7686
- "org:fix:listviewmine:hardis",
7687
- "hardis:fix:org:listviewmine",
7688
- "fix:hardis:org:listviewmine",
7689
- "fix:org:hardis:listviewmine",
7690
- "fix:org:listviewmine:hardis",
7691
- "hardis:fix:listviewmine:org",
7692
- "fix:hardis:listviewmine:org",
7693
- "fix:listviewmine:hardis:org",
7694
- "fix:listviewmine:org:hardis",
7695
- "hardis:org:listviewmine:fix",
7696
- "org:hardis:listviewmine:fix",
7697
- "org:listviewmine:hardis:fix",
7698
- "org:listviewmine:fix:hardis",
7699
- "hardis:listviewmine:org:fix",
7700
- "listviewmine:hardis:org:fix",
7701
- "listviewmine:org:hardis:fix",
7702
- "listviewmine:org:fix:hardis",
7703
- "hardis:listviewmine:fix:org",
7704
- "listviewmine:hardis:fix:org",
7705
- "listviewmine:fix:hardis:org",
7706
- "listviewmine:fix:org:hardis"
7652
+ "hardis:org:diagnose:unusedlicenses",
7653
+ "org:hardis:diagnose:unusedlicenses",
7654
+ "org:diagnose:hardis:unusedlicenses",
7655
+ "org:diagnose:unusedlicenses:hardis",
7656
+ "hardis:diagnose:org:unusedlicenses",
7657
+ "diagnose:hardis:org:unusedlicenses",
7658
+ "diagnose:org:hardis:unusedlicenses",
7659
+ "diagnose:org:unusedlicenses:hardis",
7660
+ "hardis:diagnose:unusedlicenses:org",
7661
+ "diagnose:hardis:unusedlicenses:org",
7662
+ "diagnose:unusedlicenses:hardis:org",
7663
+ "diagnose:unusedlicenses:org:hardis",
7664
+ "hardis:org:unusedlicenses:diagnose",
7665
+ "org:hardis:unusedlicenses:diagnose",
7666
+ "org:unusedlicenses:hardis:diagnose",
7667
+ "org:unusedlicenses:diagnose:hardis",
7668
+ "hardis:unusedlicenses:org:diagnose",
7669
+ "unusedlicenses:hardis:org:diagnose",
7670
+ "unusedlicenses:org:hardis:diagnose",
7671
+ "unusedlicenses:org:diagnose:hardis",
7672
+ "hardis:unusedlicenses:diagnose:org",
7673
+ "unusedlicenses:hardis:diagnose:org",
7674
+ "unusedlicenses:diagnose:hardis:org",
7675
+ "unusedlicenses:diagnose:org:hardis"
7707
7676
  ]
7708
7677
  },
7709
- "hardis:org:generate:packagexmlfull": {
7678
+ "hardis:org:diagnose:unusedusers": {
7710
7679
  "aliases": [],
7711
7680
  "args": {},
7712
- "description": "\n## Command Behavior\n\n**Generates a comprehensive `package.xml` file for a Salesforce org, including all metadata components, even managed ones.**\n\nThis command is essential for various Salesforce development and administration tasks, especially when you need a complete snapshot of an org's metadata. It goes beyond typical source tracking by including managed package components, which is crucial for understanding the full metadata footprint of an org.\n\nKey functionalities:\n\n- **Full Org Metadata Retrieval:** Connects to a specified Salesforce org (or prompts for one if not provided) and retrieves a complete list of all metadata types and their members.\n- **Managed Package Inclusion:** Unlike standard source retrieval, this command explicitly includes metadata from managed packages, providing a truly comprehensive `package.xml`.\n- **Customizable Output:** Allows you to specify the output file path for the generated `package.xml`.\n- **Interactive Org Selection:** If no target org is specified, it interactively prompts the user to choose an org. (or use --no-prompt to skip this step)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce Metadata API Interaction:** It leverages the Salesforce Metadata API to list all available metadata types and then retrieve all components for each type.\n- **`buildOrgManifest` Utility:** The core logic for querying the org's metadata and constructing the `package.xml` is encapsulated within the `buildOrgManifest` utility function.\n- **XML Generation:** It dynamically builds the XML structure of the `package.xml` file, including the `types` and `members` elements for all retrieved metadata.\n- **File System Operations:** It writes the generated `package.xml` file to the specified output path.\n- **Interactive Prompts:** Uses `promptOrgUsernameDefault` to guide the user in selecting the target Salesforce org.\n</details>\n",
7681
+ "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>",
7713
7682
  "examples": [
7714
- "$ sf hardis:org:generate:packagexmlfull",
7715
- "$ sf hardis:org:generate:packagexmlfull --outputfile /tmp/packagexmlfull.xml",
7716
- "$ sf hardis:org:generate:packagexmlfull --target-org nico@example.com"
7683
+ "$ sf hardis:org:diagnose:unusedusers",
7684
+ "$ sf hardis:org:diagnose:unusedusers --days 365",
7685
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm",
7686
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licenseidentifiers SFDC,AUL,AUL1",
7687
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm --returnactiveusers"
7717
7688
  ],
7718
7689
  "flags": {
7719
7690
  "json": {
@@ -7731,13 +7702,49 @@
7731
7702
  "multiple": false,
7732
7703
  "type": "option"
7733
7704
  },
7734
- "outputfile": {
7735
- "description": "Output package.xml file",
7736
- "name": "outputfile",
7705
+ "outputfile": {
7706
+ "char": "f",
7707
+ "description": "Force the path and name of output report file. Must end with .csv",
7708
+ "name": "outputfile",
7709
+ "hasDynamicHelp": false,
7710
+ "multiple": false,
7711
+ "type": "option"
7712
+ },
7713
+ "days": {
7714
+ "char": "t",
7715
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7716
+ "name": "days",
7717
+ "hasDynamicHelp": false,
7718
+ "multiple": false,
7719
+ "type": "option"
7720
+ },
7721
+ "licensetypes": {
7722
+ "char": "l",
7723
+ "description": "Type of licenses to check. If set, do not use licenseidentifiers option. In CI, default is all-crm",
7724
+ "name": "licensetypes",
7725
+ "hasDynamicHelp": false,
7726
+ "multiple": false,
7727
+ "options": [
7728
+ "all",
7729
+ "all-crm",
7730
+ "all-paying"
7731
+ ],
7732
+ "type": "option"
7733
+ },
7734
+ "licenseidentifiers": {
7735
+ "char": "i",
7736
+ "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",
7737
+ "name": "licenseidentifiers",
7737
7738
  "hasDynamicHelp": false,
7738
7739
  "multiple": false,
7739
7740
  "type": "option"
7740
7741
  },
7742
+ "returnactiveusers": {
7743
+ "description": "Inverts the command by returning the active users",
7744
+ "name": "returnactiveusers",
7745
+ "allowNo": false,
7746
+ "type": "boolean"
7747
+ },
7741
7748
  "debug": {
7742
7749
  "char": "d",
7743
7750
  "description": "Activate debug mode (more logs)",
@@ -7745,13 +7752,6 @@
7745
7752
  "allowNo": false,
7746
7753
  "type": "boolean"
7747
7754
  },
7748
- "no-prompt": {
7749
- "char": "n",
7750
- "description": "Do not prompt for org username, use the default one",
7751
- "name": "no-prompt",
7752
- "allowNo": false,
7753
- "type": "boolean"
7754
- },
7755
7755
  "websocket": {
7756
7756
  "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
7757
7757
  "name": "websocket",
@@ -7783,13 +7783,13 @@
7783
7783
  },
7784
7784
  "hasDynamicHelp": true,
7785
7785
  "hiddenAliases": [],
7786
- "id": "hardis:org:generate:packagexmlfull",
7786
+ "id": "hardis:org:diagnose:unusedusers",
7787
7787
  "pluginAlias": "sfdx-hardis",
7788
7788
  "pluginName": "sfdx-hardis",
7789
7789
  "pluginType": "core",
7790
7790
  "strict": true,
7791
7791
  "enableJsonFlag": true,
7792
- "title": "Generate Full Org package.xml",
7792
+ "title": "Detect unused Users in Salesforce",
7793
7793
  "requiresProject": false,
7794
7794
  "isESM": true,
7795
7795
  "relativePath": [
@@ -7797,35 +7797,35 @@
7797
7797
  "commands",
7798
7798
  "hardis",
7799
7799
  "org",
7800
- "generate",
7801
- "packagexmlfull.js"
7800
+ "diagnose",
7801
+ "unusedusers.js"
7802
7802
  ],
7803
7803
  "aliasPermutations": [],
7804
7804
  "permutations": [
7805
- "hardis:org:generate:packagexmlfull",
7806
- "org:hardis:generate:packagexmlfull",
7807
- "org:generate:hardis:packagexmlfull",
7808
- "org:generate:packagexmlfull:hardis",
7809
- "hardis:generate:org:packagexmlfull",
7810
- "generate:hardis:org:packagexmlfull",
7811
- "generate:org:hardis:packagexmlfull",
7812
- "generate:org:packagexmlfull:hardis",
7813
- "hardis:generate:packagexmlfull:org",
7814
- "generate:hardis:packagexmlfull:org",
7815
- "generate:packagexmlfull:hardis:org",
7816
- "generate:packagexmlfull:org:hardis",
7817
- "hardis:org:packagexmlfull:generate",
7818
- "org:hardis:packagexmlfull:generate",
7819
- "org:packagexmlfull:hardis:generate",
7820
- "org:packagexmlfull:generate:hardis",
7821
- "hardis:packagexmlfull:org:generate",
7822
- "packagexmlfull:hardis:org:generate",
7823
- "packagexmlfull:org:hardis:generate",
7824
- "packagexmlfull:org:generate:hardis",
7825
- "hardis:packagexmlfull:generate:org",
7826
- "packagexmlfull:hardis:generate:org",
7827
- "packagexmlfull:generate:hardis:org",
7828
- "packagexmlfull:generate:org:hardis"
7805
+ "hardis:org:diagnose:unusedusers",
7806
+ "org:hardis:diagnose:unusedusers",
7807
+ "org:diagnose:hardis:unusedusers",
7808
+ "org:diagnose:unusedusers:hardis",
7809
+ "hardis:diagnose:org:unusedusers",
7810
+ "diagnose:hardis:org:unusedusers",
7811
+ "diagnose:org:hardis:unusedusers",
7812
+ "diagnose:org:unusedusers:hardis",
7813
+ "hardis:diagnose:unusedusers:org",
7814
+ "diagnose:hardis:unusedusers:org",
7815
+ "diagnose:unusedusers:hardis:org",
7816
+ "diagnose:unusedusers:org:hardis",
7817
+ "hardis:org:unusedusers:diagnose",
7818
+ "org:hardis:unusedusers:diagnose",
7819
+ "org:unusedusers:hardis:diagnose",
7820
+ "org:unusedusers:diagnose:hardis",
7821
+ "hardis:unusedusers:org:diagnose",
7822
+ "unusedusers:hardis:org:diagnose",
7823
+ "unusedusers:org:hardis:diagnose",
7824
+ "unusedusers:org:diagnose:hardis",
7825
+ "hardis:unusedusers:diagnose:org",
7826
+ "unusedusers:hardis:diagnose:org",
7827
+ "unusedusers:diagnose:hardis:org",
7828
+ "unusedusers:diagnose:org:hardis"
7829
7829
  ]
7830
7830
  },
7831
7831
  "hardis:org:monitor:all": {
@@ -12142,6 +12142,221 @@
12142
12142
  "xml:clean:project:hardis"
12143
12143
  ]
12144
12144
  },
12145
+ "hardis:project:fix:profiletabs": {
12146
+ "aliases": [],
12147
+ "args": {},
12148
+ "description": "\n## Command Behavior\n\n**Interactively updates tab visibility settings in Salesforce profiles, addressing a common issue where tab visibilities are not correctly retrieved by `sf project retrieve start`.**\n\nThis command provides a user-friendly interface to manage tab settings within your profile XML files, ensuring that your local project accurately reflects the intended tab configurations in your Salesforce org.\n\nKey functionalities:\n\n- **Interactive Tab Selection:** Displays a multi-select menu of all available tabs in your org, allowing you to choose which tabs to update.\n- **Visibility Control:** Lets you set the visibility for the selected tabs to either `DefaultOn` (Visible) or `Hidden`.\n- **Profile Selection:** Presents a multi-select menu of all .profile-meta.xml files in your project, allowing you to apply the tab visibility changes to specific profiles.\n- **XML Updates:** Modifies the <tabVisibilities> section of the selected profile XML files to reflect the chosen tab settings. If a tab visibility setting already exists for a selected tab, it will be updated; otherwise, a new one will be added.\n- **Sorted Output:** The <tabVisibilities> in the updated profile XML files are sorted alphabetically for consistency and readability.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Queries (Tooling API):** It queries the `TabDefinition` object using `soqlQueryTooling` to retrieve a list of all available tabs in the target org.\n- **File Discovery:** Uses `glob` to find all .profile-meta.xml files within the specified project path.\n- **Interactive Prompts:** Leverages the `prompts` library to create interactive menus for selecting tabs, visibility settings, and profiles.\n- **XML Parsing and Manipulation:** Uses `parseXmlFile` to read the content of profile XML files and `writeXmlFile` to write the modified content back. It manipulates the `tabVisibilities` array within the parsed XML to add or update tab settings.\n- **Array Sorting:** Employs the `sort-array` library to sort the `tabVisibilities` alphabetically by tab name.\n- **Logging:** Provides feedback to the user about which profiles have been updated and a summary of the changes.\n</details>\n",
12149
+ "examples": [
12150
+ "$ sf hardis:project:fix:profiletabs"
12151
+ ],
12152
+ "flags": {
12153
+ "json": {
12154
+ "description": "Format output as json.",
12155
+ "helpGroup": "GLOBAL",
12156
+ "name": "json",
12157
+ "allowNo": false,
12158
+ "type": "boolean"
12159
+ },
12160
+ "flags-dir": {
12161
+ "helpGroup": "GLOBAL",
12162
+ "name": "flags-dir",
12163
+ "summary": "Import flag values from a directory.",
12164
+ "hasDynamicHelp": false,
12165
+ "multiple": false,
12166
+ "type": "option"
12167
+ },
12168
+ "path": {
12169
+ "char": "p",
12170
+ "description": "Root folder",
12171
+ "name": "path",
12172
+ "default": "/home/runner/work/sfdx-hardis/sfdx-hardis",
12173
+ "hasDynamicHelp": false,
12174
+ "multiple": false,
12175
+ "type": "option"
12176
+ },
12177
+ "debug": {
12178
+ "char": "d",
12179
+ "description": "Activate debug mode (more logs)",
12180
+ "name": "debug",
12181
+ "allowNo": false,
12182
+ "type": "boolean"
12183
+ },
12184
+ "websocket": {
12185
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
12186
+ "name": "websocket",
12187
+ "hasDynamicHelp": false,
12188
+ "multiple": false,
12189
+ "type": "option"
12190
+ },
12191
+ "skipauth": {
12192
+ "description": "Skip authentication check when a default username is required",
12193
+ "name": "skipauth",
12194
+ "allowNo": false,
12195
+ "type": "boolean"
12196
+ },
12197
+ "target-org": {
12198
+ "aliases": [
12199
+ "targetusername",
12200
+ "u"
12201
+ ],
12202
+ "char": "o",
12203
+ "deprecateAliases": true,
12204
+ "name": "target-org",
12205
+ "noCacheDefault": true,
12206
+ "required": true,
12207
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
12208
+ "hasDynamicHelp": true,
12209
+ "multiple": false,
12210
+ "type": "option"
12211
+ }
12212
+ },
12213
+ "hasDynamicHelp": true,
12214
+ "hiddenAliases": [],
12215
+ "id": "hardis:project:fix:profiletabs",
12216
+ "pluginAlias": "sfdx-hardis",
12217
+ "pluginName": "sfdx-hardis",
12218
+ "pluginType": "core",
12219
+ "strict": true,
12220
+ "enableJsonFlag": true,
12221
+ "title": "Fix profiles to add tabs that are not retrieved by SF CLI",
12222
+ "requiresProject": true,
12223
+ "isESM": true,
12224
+ "relativePath": [
12225
+ "lib",
12226
+ "commands",
12227
+ "hardis",
12228
+ "project",
12229
+ "fix",
12230
+ "profiletabs.js"
12231
+ ],
12232
+ "aliasPermutations": [],
12233
+ "permutations": [
12234
+ "hardis:project:fix:profiletabs",
12235
+ "project:hardis:fix:profiletabs",
12236
+ "project:fix:hardis:profiletabs",
12237
+ "project:fix:profiletabs:hardis",
12238
+ "hardis:fix:project:profiletabs",
12239
+ "fix:hardis:project:profiletabs",
12240
+ "fix:project:hardis:profiletabs",
12241
+ "fix:project:profiletabs:hardis",
12242
+ "hardis:fix:profiletabs:project",
12243
+ "fix:hardis:profiletabs:project",
12244
+ "fix:profiletabs:hardis:project",
12245
+ "fix:profiletabs:project:hardis",
12246
+ "hardis:project:profiletabs:fix",
12247
+ "project:hardis:profiletabs:fix",
12248
+ "project:profiletabs:hardis:fix",
12249
+ "project:profiletabs:fix:hardis",
12250
+ "hardis:profiletabs:project:fix",
12251
+ "profiletabs:hardis:project:fix",
12252
+ "profiletabs:project:hardis:fix",
12253
+ "profiletabs:project:fix:hardis",
12254
+ "hardis:profiletabs:fix:project",
12255
+ "profiletabs:hardis:fix:project",
12256
+ "profiletabs:fix:hardis:project",
12257
+ "profiletabs:fix:project:hardis"
12258
+ ]
12259
+ },
12260
+ "hardis:project:fix:v53flexipages": {
12261
+ "aliases": [],
12262
+ "args": {},
12263
+ "description": "\n## Command Behavior\n\n**Fixes Salesforce FlexiPages for compatibility with API Version 53.0 (Winter '22 release) by adding missing identifiers to component instances.**\n\nSalesforce introduced a change in API Version 53.0 that requires `identifier` tags within `componentInstance` and `fieldInstance` elements in FlexiPage metadata. If these identifiers are missing, deployments to orgs with API version 53.0 or higher will fail. This command automates the process of adding these missing identifiers, ensuring your FlexiPages remain deployable.\n\nKey functionalities:\n\n- **Targeted FlexiPage Processing:** Scans all .flexipage-meta.xml files within the specified root folder (defaults to current working directory).\n- **Identifier Injection:** Inserts a unique `identifier` tag (e.g., `SFDX_HARDIS_REPLACEMENT_ID`) into `componentInstance` and `fieldInstance` elements that lack one.\n\n**Important Note:** After running this command, ensure you update your `apiVersion` to `53.0` (or higher) in your `package.xml` and `sfdx-project.json` files.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **File Discovery:** Uses `glob` to find all .flexipage-meta.xml files.\n- **Content Reading:** Reads the XML content of each FlexiPage file.\n- **Regular Expression Replacement:** Employs a set of regular expressions to identify specific XML patterns (componentName.../componentName.../componentInstance, componentName.../componentName.../visibilityRule, fieldItem.../fieldItem.../fieldInstance) that are missing the `identifier` tag.\n- **Dynamic ID Generation:** For each match, it generates a unique identifier (e.g., `sfdxHardisIdX`) and injects it into the XML structure.\n- **File Writing:** If changes are made, the modified XML content is written back to the FlexiPage file using `fs.writeFile`.\n- **Logging:** Provides messages about which FlexiPages are being processed and a summary of the total number of identifiers added.\n</details>\n",
12264
+ "examples": [
12265
+ "$ sf hardis:project:fix:v53flexipages"
12266
+ ],
12267
+ "flags": {
12268
+ "json": {
12269
+ "description": "Format output as json.",
12270
+ "helpGroup": "GLOBAL",
12271
+ "name": "json",
12272
+ "allowNo": false,
12273
+ "type": "boolean"
12274
+ },
12275
+ "flags-dir": {
12276
+ "helpGroup": "GLOBAL",
12277
+ "name": "flags-dir",
12278
+ "summary": "Import flag values from a directory.",
12279
+ "hasDynamicHelp": false,
12280
+ "multiple": false,
12281
+ "type": "option"
12282
+ },
12283
+ "path": {
12284
+ "char": "p",
12285
+ "description": "Root folder",
12286
+ "name": "path",
12287
+ "default": "/home/runner/work/sfdx-hardis/sfdx-hardis",
12288
+ "hasDynamicHelp": false,
12289
+ "multiple": false,
12290
+ "type": "option"
12291
+ },
12292
+ "debug": {
12293
+ "char": "d",
12294
+ "description": "Activate debug mode (more logs)",
12295
+ "name": "debug",
12296
+ "allowNo": false,
12297
+ "type": "boolean"
12298
+ },
12299
+ "websocket": {
12300
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
12301
+ "name": "websocket",
12302
+ "hasDynamicHelp": false,
12303
+ "multiple": false,
12304
+ "type": "option"
12305
+ },
12306
+ "skipauth": {
12307
+ "description": "Skip authentication check when a default username is required",
12308
+ "name": "skipauth",
12309
+ "allowNo": false,
12310
+ "type": "boolean"
12311
+ }
12312
+ },
12313
+ "hasDynamicHelp": false,
12314
+ "hiddenAliases": [],
12315
+ "id": "hardis:project:fix:v53flexipages",
12316
+ "pluginAlias": "sfdx-hardis",
12317
+ "pluginName": "sfdx-hardis",
12318
+ "pluginType": "core",
12319
+ "strict": true,
12320
+ "enableJsonFlag": true,
12321
+ "title": "Fix flexipages for v53",
12322
+ "requiresProject": true,
12323
+ "isESM": true,
12324
+ "relativePath": [
12325
+ "lib",
12326
+ "commands",
12327
+ "hardis",
12328
+ "project",
12329
+ "fix",
12330
+ "v53flexipages.js"
12331
+ ],
12332
+ "aliasPermutations": [],
12333
+ "permutations": [
12334
+ "hardis:project:fix:v53flexipages",
12335
+ "project:hardis:fix:v53flexipages",
12336
+ "project:fix:hardis:v53flexipages",
12337
+ "project:fix:v53flexipages:hardis",
12338
+ "hardis:fix:project:v53flexipages",
12339
+ "fix:hardis:project:v53flexipages",
12340
+ "fix:project:hardis:v53flexipages",
12341
+ "fix:project:v53flexipages:hardis",
12342
+ "hardis:fix:v53flexipages:project",
12343
+ "fix:hardis:v53flexipages:project",
12344
+ "fix:v53flexipages:hardis:project",
12345
+ "fix:v53flexipages:project:hardis",
12346
+ "hardis:project:v53flexipages:fix",
12347
+ "project:hardis:v53flexipages:fix",
12348
+ "project:v53flexipages:hardis:fix",
12349
+ "project:v53flexipages:fix:hardis",
12350
+ "hardis:v53flexipages:project:fix",
12351
+ "v53flexipages:hardis:project:fix",
12352
+ "v53flexipages:project:hardis:fix",
12353
+ "v53flexipages:project:fix:hardis",
12354
+ "hardis:v53flexipages:fix:project",
12355
+ "v53flexipages:hardis:fix:project",
12356
+ "v53flexipages:fix:hardis:project",
12357
+ "v53flexipages:fix:project:hardis"
12358
+ ]
12359
+ },
12145
12360
  "hardis:project:deploy:notify": {
12146
12361
  "aliases": [],
12147
12362
  "args": {},
@@ -13316,221 +13531,6 @@
13316
13531
  "validate:deploy:project:hardis"
13317
13532
  ]
13318
13533
  },
13319
- "hardis:project:fix:profiletabs": {
13320
- "aliases": [],
13321
- "args": {},
13322
- "description": "\n## Command Behavior\n\n**Interactively updates tab visibility settings in Salesforce profiles, addressing a common issue where tab visibilities are not correctly retrieved by `sf project retrieve start`.**\n\nThis command provides a user-friendly interface to manage tab settings within your profile XML files, ensuring that your local project accurately reflects the intended tab configurations in your Salesforce org.\n\nKey functionalities:\n\n- **Interactive Tab Selection:** Displays a multi-select menu of all available tabs in your org, allowing you to choose which tabs to update.\n- **Visibility Control:** Lets you set the visibility for the selected tabs to either `DefaultOn` (Visible) or `Hidden`.\n- **Profile Selection:** Presents a multi-select menu of all .profile-meta.xml files in your project, allowing you to apply the tab visibility changes to specific profiles.\n- **XML Updates:** Modifies the <tabVisibilities> section of the selected profile XML files to reflect the chosen tab settings. If a tab visibility setting already exists for a selected tab, it will be updated; otherwise, a new one will be added.\n- **Sorted Output:** The <tabVisibilities> in the updated profile XML files are sorted alphabetically for consistency and readability.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Queries (Tooling API):** It queries the `TabDefinition` object using `soqlQueryTooling` to retrieve a list of all available tabs in the target org.\n- **File Discovery:** Uses `glob` to find all .profile-meta.xml files within the specified project path.\n- **Interactive Prompts:** Leverages the `prompts` library to create interactive menus for selecting tabs, visibility settings, and profiles.\n- **XML Parsing and Manipulation:** Uses `parseXmlFile` to read the content of profile XML files and `writeXmlFile` to write the modified content back. It manipulates the `tabVisibilities` array within the parsed XML to add or update tab settings.\n- **Array Sorting:** Employs the `sort-array` library to sort the `tabVisibilities` alphabetically by tab name.\n- **Logging:** Provides feedback to the user about which profiles have been updated and a summary of the changes.\n</details>\n",
13323
- "examples": [
13324
- "$ sf hardis:project:fix:profiletabs"
13325
- ],
13326
- "flags": {
13327
- "json": {
13328
- "description": "Format output as json.",
13329
- "helpGroup": "GLOBAL",
13330
- "name": "json",
13331
- "allowNo": false,
13332
- "type": "boolean"
13333
- },
13334
- "flags-dir": {
13335
- "helpGroup": "GLOBAL",
13336
- "name": "flags-dir",
13337
- "summary": "Import flag values from a directory.",
13338
- "hasDynamicHelp": false,
13339
- "multiple": false,
13340
- "type": "option"
13341
- },
13342
- "path": {
13343
- "char": "p",
13344
- "description": "Root folder",
13345
- "name": "path",
13346
- "default": "/home/runner/work/sfdx-hardis/sfdx-hardis",
13347
- "hasDynamicHelp": false,
13348
- "multiple": false,
13349
- "type": "option"
13350
- },
13351
- "debug": {
13352
- "char": "d",
13353
- "description": "Activate debug mode (more logs)",
13354
- "name": "debug",
13355
- "allowNo": false,
13356
- "type": "boolean"
13357
- },
13358
- "websocket": {
13359
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
13360
- "name": "websocket",
13361
- "hasDynamicHelp": false,
13362
- "multiple": false,
13363
- "type": "option"
13364
- },
13365
- "skipauth": {
13366
- "description": "Skip authentication check when a default username is required",
13367
- "name": "skipauth",
13368
- "allowNo": false,
13369
- "type": "boolean"
13370
- },
13371
- "target-org": {
13372
- "aliases": [
13373
- "targetusername",
13374
- "u"
13375
- ],
13376
- "char": "o",
13377
- "deprecateAliases": true,
13378
- "name": "target-org",
13379
- "noCacheDefault": true,
13380
- "required": true,
13381
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
13382
- "hasDynamicHelp": true,
13383
- "multiple": false,
13384
- "type": "option"
13385
- }
13386
- },
13387
- "hasDynamicHelp": true,
13388
- "hiddenAliases": [],
13389
- "id": "hardis:project:fix:profiletabs",
13390
- "pluginAlias": "sfdx-hardis",
13391
- "pluginName": "sfdx-hardis",
13392
- "pluginType": "core",
13393
- "strict": true,
13394
- "enableJsonFlag": true,
13395
- "title": "Fix profiles to add tabs that are not retrieved by SF CLI",
13396
- "requiresProject": true,
13397
- "isESM": true,
13398
- "relativePath": [
13399
- "lib",
13400
- "commands",
13401
- "hardis",
13402
- "project",
13403
- "fix",
13404
- "profiletabs.js"
13405
- ],
13406
- "aliasPermutations": [],
13407
- "permutations": [
13408
- "hardis:project:fix:profiletabs",
13409
- "project:hardis:fix:profiletabs",
13410
- "project:fix:hardis:profiletabs",
13411
- "project:fix:profiletabs:hardis",
13412
- "hardis:fix:project:profiletabs",
13413
- "fix:hardis:project:profiletabs",
13414
- "fix:project:hardis:profiletabs",
13415
- "fix:project:profiletabs:hardis",
13416
- "hardis:fix:profiletabs:project",
13417
- "fix:hardis:profiletabs:project",
13418
- "fix:profiletabs:hardis:project",
13419
- "fix:profiletabs:project:hardis",
13420
- "hardis:project:profiletabs:fix",
13421
- "project:hardis:profiletabs:fix",
13422
- "project:profiletabs:hardis:fix",
13423
- "project:profiletabs:fix:hardis",
13424
- "hardis:profiletabs:project:fix",
13425
- "profiletabs:hardis:project:fix",
13426
- "profiletabs:project:hardis:fix",
13427
- "profiletabs:project:fix:hardis",
13428
- "hardis:profiletabs:fix:project",
13429
- "profiletabs:hardis:fix:project",
13430
- "profiletabs:fix:hardis:project",
13431
- "profiletabs:fix:project:hardis"
13432
- ]
13433
- },
13434
- "hardis:project:fix:v53flexipages": {
13435
- "aliases": [],
13436
- "args": {},
13437
- "description": "\n## Command Behavior\n\n**Fixes Salesforce FlexiPages for compatibility with API Version 53.0 (Winter '22 release) by adding missing identifiers to component instances.**\n\nSalesforce introduced a change in API Version 53.0 that requires `identifier` tags within `componentInstance` and `fieldInstance` elements in FlexiPage metadata. If these identifiers are missing, deployments to orgs with API version 53.0 or higher will fail. This command automates the process of adding these missing identifiers, ensuring your FlexiPages remain deployable.\n\nKey functionalities:\n\n- **Targeted FlexiPage Processing:** Scans all .flexipage-meta.xml files within the specified root folder (defaults to current working directory).\n- **Identifier Injection:** Inserts a unique `identifier` tag (e.g., `SFDX_HARDIS_REPLACEMENT_ID`) into `componentInstance` and `fieldInstance` elements that lack one.\n\n**Important Note:** After running this command, ensure you update your `apiVersion` to `53.0` (or higher) in your `package.xml` and `sfdx-project.json` files.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **File Discovery:** Uses `glob` to find all .flexipage-meta.xml files.\n- **Content Reading:** Reads the XML content of each FlexiPage file.\n- **Regular Expression Replacement:** Employs a set of regular expressions to identify specific XML patterns (componentName.../componentName.../componentInstance, componentName.../componentName.../visibilityRule, fieldItem.../fieldItem.../fieldInstance) that are missing the `identifier` tag.\n- **Dynamic ID Generation:** For each match, it generates a unique identifier (e.g., `sfdxHardisIdX`) and injects it into the XML structure.\n- **File Writing:** If changes are made, the modified XML content is written back to the FlexiPage file using `fs.writeFile`.\n- **Logging:** Provides messages about which FlexiPages are being processed and a summary of the total number of identifiers added.\n</details>\n",
13438
- "examples": [
13439
- "$ sf hardis:project:fix:v53flexipages"
13440
- ],
13441
- "flags": {
13442
- "json": {
13443
- "description": "Format output as json.",
13444
- "helpGroup": "GLOBAL",
13445
- "name": "json",
13446
- "allowNo": false,
13447
- "type": "boolean"
13448
- },
13449
- "flags-dir": {
13450
- "helpGroup": "GLOBAL",
13451
- "name": "flags-dir",
13452
- "summary": "Import flag values from a directory.",
13453
- "hasDynamicHelp": false,
13454
- "multiple": false,
13455
- "type": "option"
13456
- },
13457
- "path": {
13458
- "char": "p",
13459
- "description": "Root folder",
13460
- "name": "path",
13461
- "default": "/home/runner/work/sfdx-hardis/sfdx-hardis",
13462
- "hasDynamicHelp": false,
13463
- "multiple": false,
13464
- "type": "option"
13465
- },
13466
- "debug": {
13467
- "char": "d",
13468
- "description": "Activate debug mode (more logs)",
13469
- "name": "debug",
13470
- "allowNo": false,
13471
- "type": "boolean"
13472
- },
13473
- "websocket": {
13474
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
13475
- "name": "websocket",
13476
- "hasDynamicHelp": false,
13477
- "multiple": false,
13478
- "type": "option"
13479
- },
13480
- "skipauth": {
13481
- "description": "Skip authentication check when a default username is required",
13482
- "name": "skipauth",
13483
- "allowNo": false,
13484
- "type": "boolean"
13485
- }
13486
- },
13487
- "hasDynamicHelp": false,
13488
- "hiddenAliases": [],
13489
- "id": "hardis:project:fix:v53flexipages",
13490
- "pluginAlias": "sfdx-hardis",
13491
- "pluginName": "sfdx-hardis",
13492
- "pluginType": "core",
13493
- "strict": true,
13494
- "enableJsonFlag": true,
13495
- "title": "Fix flexipages for v53",
13496
- "requiresProject": true,
13497
- "isESM": true,
13498
- "relativePath": [
13499
- "lib",
13500
- "commands",
13501
- "hardis",
13502
- "project",
13503
- "fix",
13504
- "v53flexipages.js"
13505
- ],
13506
- "aliasPermutations": [],
13507
- "permutations": [
13508
- "hardis:project:fix:v53flexipages",
13509
- "project:hardis:fix:v53flexipages",
13510
- "project:fix:hardis:v53flexipages",
13511
- "project:fix:v53flexipages:hardis",
13512
- "hardis:fix:project:v53flexipages",
13513
- "fix:hardis:project:v53flexipages",
13514
- "fix:project:hardis:v53flexipages",
13515
- "fix:project:v53flexipages:hardis",
13516
- "hardis:fix:v53flexipages:project",
13517
- "fix:hardis:v53flexipages:project",
13518
- "fix:v53flexipages:hardis:project",
13519
- "fix:v53flexipages:project:hardis",
13520
- "hardis:project:v53flexipages:fix",
13521
- "project:hardis:v53flexipages:fix",
13522
- "project:v53flexipages:hardis:fix",
13523
- "project:v53flexipages:fix:hardis",
13524
- "hardis:v53flexipages:project:fix",
13525
- "v53flexipages:hardis:project:fix",
13526
- "v53flexipages:project:hardis:fix",
13527
- "v53flexipages:project:fix:hardis",
13528
- "hardis:v53flexipages:fix:project",
13529
- "v53flexipages:hardis:fix:project",
13530
- "v53flexipages:fix:hardis:project",
13531
- "v53flexipages:fix:project:hardis"
13532
- ]
13533
- },
13534
13534
  "hardis:project:generate:bypass": {
13535
13535
  "aliases": [],
13536
13536
  "args": {},
@@ -16104,5 +16104,5 @@
16104
16104
  ]
16105
16105
  }
16106
16106
  },
16107
- "version": "6.17.2-alpha202512261745.0"
16107
+ "version": "6.17.2-alpha202512261823.0"
16108
16108
  }