Skip to content

hardis:org:retrieve:packageconfig

Description

Retrieves the installed package configuration from a Salesforce org and optionally updates the local project configuration.

This command is useful for maintaining an accurate record of installed packages within your Salesforce project, which is crucial for managing dependencies and ensuring consistent deployments across environments.

Key functionalities:

  • Package Listing: Connects to a specified Salesforce org (or prompts for one if not provided) and retrieves a list of all installed packages.
  • Configuration Update: Offers the option to update your local project's configuration with the retrieved list of installed packages. This can be beneficial for automating package installations during environment setup or CI/CD processes.
Technical explanations

The command's technical implementation involves:

  • Org Connection: It establishes a connection to the target Salesforce org using the provided or prompted username.
  • Metadata Retrieval: It utilizes MetadataUtils.listInstalledPackages to query the Salesforce org and obtain details about the installed packages.
  • Interactive Prompt: It uses the prompts library to ask the user whether they want to update their local project configuration with the retrieved package list.
  • Configuration Management: If the user confirms, it calls managePackageConfig to update the project's configuration file (likely .sfdx-hardis.yml) with the new package information.
  • User Feedback: Provides clear messages to the user about the success of the package retrieval and configuration update.

Agent Mode

Use --agent to disable all prompts. Typical usage:

sf hardis:org:retrieve:packageconfig --agent --packages "MyPackage,OtherPackage" --target-org myOrg
sf hardis:org:retrieve:packageconfig --agent --update-all-config --target-org myOrg

In agent mode:

  • Without --packages, --update-existing-config, or --update-all-config, the command only lists packages (no config update).
  • Use --packages to update config only for the specified packages (comma-separated names or subscriber package IDs).
  • Use --update-existing-config to update only packages that are already present in the project config (version upgrade).
  • Use --update-all-config to update config with all retrieved packages.

Parameters

Name Type Description Default Required Options
agent boolean Run in non-interactive mode for agents and automation
debug
-d
boolean Activate debug mode (more logs)
flags-dir option undefined
json boolean Format output as json.
packages option Comma-separated list of package names or subscriber package IDs to update in the project config. Used in agent mode.
skipauth boolean Skip authentication check when a default username is required
target-org
-o
option undefined
update-all-config boolean Update config with all retrieved packages (existing and new).
update-existing-config boolean Update only packages already present in the project config (version upgrade). Useful in agent mode.
websocket option Websocket host:port for VsCode SFDX Hardis UI integration

Examples

$ sf hardis:org:retrieve:packageconfig
sf hardis:org:retrieve:packageconfig -u myOrg
$ sf hardis:org:retrieve:packageconfig --agent --packages "MyPackage,OtherPkg"
$ sf hardis:org:retrieve:packageconfig --agent --update-existing-config
$ sf hardis:org:retrieve:packageconfig --agent --update-all-config