hardis:config:org-init
Description
Returns how the project initializes its scratch orgs and sandboxes, without connecting to any org.
Command Behavior (Beta)
This command is currently in Beta. Please report any issues or feedback on the sfdx-hardis GitHub repository.
Gives configuration UIs (e.g. the Org Initialization panel of the VS Code sfdx-hardis extension) everything they need to show and edit the org initialization steps, so they never rebuild the list themselves.
The payload contains:
steps[]: the initialization steps in their run order, with their defaults filled (enabled,orgTypes,allowFailure,runAtPoolFill).source:orgInitStepswhen the project defines the key,legacywhen the list is built from the older keys (initPermissionSets,scratchOrgInitApexScripts,sandboxOrgInitApexScripts,installedPackages,dataPackageswithimportInSandboxOrgs, and thescripts/data/ScratchInitandscripts/data/SandboxInitfolders).legacyKeys[]: the older keys still present in.sfdx-hardis.yml.definitionErrors[]: what prevents a step from running (unknown type, missing parameter, sources deployed to a sandbox...).stepTypes[]: the step types an org initialization accepts, with the org types each one can run on.scratchDef: the content ofconfig/project-scratch-def.jsonand its validation issues.scratchOrgDurationandscratchDefHints(editions, features and settings names known by Salesforce CLI).
With --validate-scratch-def, the scratch org definition is read from that file instead, so a UI can validate a definition before writing it.
Three options read values from an org (--source-org, else the default Dev Hub, else the default org) so a UI can fill the definition from it:
--org-valuesaddsorgValues: the languages and countries of its users, and its API versions with their release names (current, previous, and the next one forpreview).--import-settings accountSettings,lightningExperienceSettingsaddsimportedSettings: those settings read with the Metadata API, written as a scratch org definition expects them.--list-org-shapesaddsorgShapes: the active org shapes of the connected orgs. TheorgIdof one of them is the value ofscratchOrgShape, the org shape new scratch orgs are created from (SCRATCH_ORG_SHAPEwins over it). A definition used with an org shape needs noedition;--scratch-org-shapevalidates a definition with another shape than the configured one.--import-features-from-shapecreates an org shape of the org and addsimportedShapewith its features. Org Shape must be enabled in that org.
Run hardis:org:init to run the steps on an org.
Agent Mode
Supports non-interactive execution with --agent:
sf hardis:config:org-init --agent --json
The command has no prompt: agent mode behaves the same.
Technical explanations
- The steps come from
getOrgInitSteps()(src/common/utils/orgInitUtils.ts), the same functionhardis:scratch:create,hardis:org:createandhardis:org:inituse. - The scratch org definition is validated with
ScratchOrgDefSchemafrom@salesforce/core, then eachsettingsentry is checked against the settings names of the Salesforce CLI JSON schema. - Without the org options, the command is read-only and needs no org.
--import-features-from-shaperunssf org create shapeand waits for theShapeRepresentationrecord to be active.
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 | Import flag values from a directory. | |||
| import-features-from-shape | boolean | Create an org shape of the source org and return its features | |||
| import-settings | option | Comma-separated settings names of a scratch org definition (accountSettings...) to read from the source org | |||
| json | boolean | Format output as json. | |||
| list-org-shapes | boolean | Add the active org shapes of the connected orgs | |||
| org-values | boolean | Add the languages, countries and releases of the source org | |||
| scratch-org-shape | option | With --validate-scratch-def: org id of the org shape the definition is used with, "none" for no shape. Default: scratchOrgShape | |||
| skipauth | boolean | Skip authentication check when a default username is required | |||
| source-org | option | Alias or username of the org to read values from. Default: the default Dev Hub, else the default org | |||
| validate-scratch-def | option | Scratch org definition file to validate instead of config/project-scratch-def.json | |||
| websocket | option | Websocket host:port for VsCode SFDX Hardis UI integration |
Examples
$ sf hardis:config:org-init --json
$ sf hardis:config:org-init --validate-scratch-def ./tmp/project-scratch-def.json --json
$ sf hardis:config:org-init --org-values --json
$ sf hardis:config:org-init --import-settings accountSettings,securitySettings --source-org my-org --json
$ sf hardis:config:org-init --import-features-from-shape --source-org my-org --json
$ sf hardis:config:org-init --list-org-shapes --json
$ sf hardis:config:org-init --agent --json