Skip to content

Hardis Group Logo

sfdx-hardis

Version Downloads/week Downloads/total Docker Pulls GitHub stars GitHub contributors Mega-Linter Secured with Trivy License PRs Welcome

Toolbox for Salesforce DX, by Hardis-Group

It will allow you to:

  • Easily automate development & configuration in scratch orgs or sandbox orgs
  • Smart deploy from CI/CD pipelines
  • Do with simple commands what could be done manually in minutes/hours

Please see the full list of commands in Online documentation

sfdx-hardis commands are also available with UI in SFDX Hardis Visual Studio Code Extension

Installation

SFDX Plugin

Pre-requisites

  • Install Node.js (recommended version)
  • Install Salesforce DX by running npm install sfdx-cli --global command line

Plugin installation

sfdx plugins:install sfdx-hardis

For advanced use, please also install dependencies

sfdx plugins:install sfdmu sfdx-git-delta sfdx-essentials sfpowerkit shane-sfdx-plugins texei-sfdx-plugin

With IDE

You can install Visual Studio Code extension VsCode SFDX Hardis

Once installed, click on Hardis Group button in VsCode left bar, and follow the additional installation instructions

VsCode SFDX Hardis

Docker

You can use sfdx-hardis docker images to run in CI

See Dockerfile

Usage

sfdx hardis:<COMMAND> <OPTIONS>

Use sfdx-hardis in CI

You can use sfdx-hardis within CI scripts

To do that, you need to configure authentication. This will create/update:

  • .sfdx-hardis.yml configuration file (repo)
  • Self signed certificate (repo)
  • Connected App (uploaded to org via metadata api)
  • SFDX_CLIENT_ID variable (manually set in a CI variable)

Initialize a Hardis-style sfdx-project

Run sfdx hardis:project:create and follow instructions

Configure authentication for CI jobs

You need openssl installed on your computer (available in Git bash)

Run the following command and follow instructions

sfdx hardis:project:configure:auth

Alternative for DevHub

sfdx hardis:project:configure:auth --devhub

Authentication within CI jobs

Call sfdx hardis:login at the root of the repository where you configured authentication

sfdx hardis:auth:login
sfdx hardis:org:purge:flow --no-prompt

Alternative for DevHub

sfdx hardis:auth:login --devhub

MsTeams notifications

In case suspiscious results are found (failures, critical updates to come...), sfdx-hardis can send notifications to Microsoft Teams channels.

You can define hooks using env variables:

  • MS_TEAMS_WEBHOOK_URL
  • MS_TEAMS_WEBHOOK_URL_CRITICAL
  • MS_TEAMS_WEBHOOK_URL_SEVERE
  • MS_TEAMS_WEBHOOK_URL_WARNING
  • MS_TEAMS_WEBHOOK_URL_INFO

Ex: MS_TEAMS_WEBHOOK_URL_CRITICAL=https://mycompany.webhook.office.com/webhookb2/f49c28c6-d10b-412c-b961-fge456bd@c1a7fa9b-90b3-49ab-b5e2-345HG88c/IncomingWebhook/b43c20SDSGFG56712d848bc1cebb17/53ee2e22-a867-4e74-868a-F3fs3935

Articles

Here are some articles with examples of use of sfdx-hardis

  • English

Assisted solving of Salesforce deployments errors Handle Salesforce API versions Deprecation like a pro How to mass download notes and attachments files from a Salesforce org How to freeze / unfreeze users during a Salesforce deployment How to detect bad words in Salesforce records using SFDX Data Loader and sfdx-hardis Reactivate all the sandbox users with .invalid emails in 3 clicks Invalid scope:Mine, not allowed ? Deploy your ListViews anyway !

Contributing

Anyone is welcome to contribute to this sfdx-hardis

  • Install Node.js (recommended version)
  • Install typescript by running npm install typescript --global
  • Install yarn by running npm install yarn --global
  • Install Salesforce DX by running npm install sfdx-cli --global command line
  • Fork this repo and clone it (or just clone if you are an internal contributor)
  • At the root of the repository:
    • Run yarn to install dependencies
    • Run sfdx plugins:link to link the local sfdx-hardis to SFDX CLI
    • Run tsc --watch to transpile typescript into js everytime you update a TS file
  • Debug commands using NODE_OPTIONS=--inspect-brk sfdx hardis:somecommand -someparameter somevalue

Dependencies

sfdx-hardis partially relies on the following SFDX Open-Source packages

Commands

hardis:auth

Command Title
hardis:auth:login Login

hardis:config

Command Title
hardis:config:get Deploy metadata sources to org

hardis:doc

Command Title
hardis:doc:extract:permsetgroups Generate project documentation
hardis:doc:plugin:generate Generate SFDX Plugin Documentation

hardis:mdapi

Command Title
hardis:mdapi:deploy sfdx-hardis wrapper for sfdx force:mdapi:deploy that displays tips to solve deployment errors.

hardis:misc

Command Title
hardis:misc:toml2csv TOML to CSV

hardis:org

Command Title
hardis:org:configure:data Configure Data project
hardis:org:configure:files Configure File export project
hardis:org:configure:monitoring Configure org monitoring
hardis:org:connect Connect to an org
hardis:org:create Create sandbox org
hardis:org:data:delete Delete data
hardis:org:data:export Export data
hardis:org:data:import Import data
hardis:org:diagnose:legacyapi Check for legacy API use
hardis:org:files:export Export files
hardis:org:fix:listviewmine Fix listviews with
hardis:org:purge:apexlog Purge Apex Logs
hardis:org:purge:flow Purge Flow versions
hardis:org:retrieve:packageconfig Retrieve package configuration from an org
hardis:org:retrieve:sources:dx Retrieve sfdx sources from org
hardis:org:retrieve:sources:dx2 Retrieve sfdx sources from org (2)
hardis:org:retrieve:sources:metadata Retrieve sfdx sources from org
hardis:org:retrieve:sources:retrofit Retrofit changes from an org
hardis:org:select Select org
hardis:org:test:apex Run apex tests
hardis:org:user:activateinvalid Reactivate sandbox invalid users
hardis:org:user:freeze Freeze user logins
hardis:org:user:unfreeze Unfreeze user logins

hardis:package

Command Title
hardis📦create Create a new package
hardis📦install Install packages in an org
hardis📦mergexml Merge package.xml files
hardis📦version:create Create a new version of a package
hardis📦version:list Create a new version of a package
hardis📦version:promote Promote new versions of package(s)

hardis:project

Command Title
hardis:project:audit:apiversion Audit Metadatas API Version
hardis:project:audit:callincallout Audit CallIns and CallOuts
hardis:project:audit:duplicatefiles Find duplicate sfdx files
hardis:project:audit:remotesites Audit Remote Sites
hardis:project:clean:emptyitems Clean retrieved empty items in dx sources
hardis:project:clean:hiddenitems Clean retrieved hidden items in dx sources
hardis:project:clean:listviews Replace Mine by Everything in ListViews
hardis:project:clean:manageditems Clean retrieved managed items in dx sources
hardis:project:clean:minimizeprofiles Clean profiles of Permission Set attributes
hardis:project:clean:orgmissingitems Clean SFDX items using target org definition
hardis:project:clean:references Clean references in dx sources
hardis:project:clean:retrievefolders Retrieve dashboards, documents and report folders in DX sources
hardis:project:clean:standarditems Clean retrieved standard items in dx sources
hardis:project:clean:systemdebug Clean System debug
hardis:project:clean:xml Clean retrieved empty items in dx sources
hardis:project:configure:auth Configure authentication
hardis:project:convert:profilestopermsets Convert Profiles into Permission Sets
hardis:project:create Login
hardis:project:deploy:sources:dx Deploy sfdx sources to org
hardis:project:deploy:sources:metadata Deploy metadata sources to org
hardis:project:fix:v53flexipages Fix flexipages for v53
hardis:project:generate:gitdelta Generate Git Delta
hardis:project:lint Lint

hardis:scratch

Command Title
hardis:scratch:create Create and initialize scratch org
hardis:scratch:delete Delete scratch orgs(s)
hardis:scratch:pool:create Create and configure scratch org pool
hardis:scratch:pool:localauth Authenticate locally to scratch org pool
hardis:scratch:pool:refresh Refresh scratch org pool
hardis:scratch:pool:reset Reset scratch org pool
hardis:scratch:pool:view View scratch org pool info
hardis:scratch:pull Scratch PULL
hardis:scratch:push Scratch PUSH

hardis:source

Command Title
hardis:source:deploy sfdx-hardis wrapper for sfdx force:source:deploy that displays tips to solve deployment errors.
hardis:source:push sfdx-hardis wrapper for sfdx force:source:push that displays tips to solve deployment errors.
hardis:source:retrieve sfdx-hardis wrapper for sfdx force:source:retrieve

hardis:work

Command Title
hardis:work:new New work task
hardis:work:refresh Refresh work task
hardis:work:resetselection Select again
hardis:work:save Save work task
hardis:work:ws WebSocket operations