- Download SF CLI:
npm install @salesforce/cli --global
- Install sfdx scanner for static code analysis:
sf plugins install @salesforce/sfdx-scanner
- Install VS Code Salesforce Extension Pack
- Download and setup Java
Scratch Orgs are temporary Salesforce environments that are used for development. They are spun up based on a configuration file and contain no metadata upon creation.
- Authenticate Salesforce environment (devhub):
sf org login web -a [alias] -s -d -r [url]
- Create a Scratch Org:
make scratch NAME=[alias]
orsf org create scratch -f config/project-scratch-def.json -a [alias] -d -w 30
- Open default org:
make start
orsf org open
- Push local metadata to org:
make push
orsf project deploy start
- Ideally, you'll do this during setup to get all metadata from sfdc repo into the scratch org
- Implements workflows from k-capehart/sfdc-github-actions
- .github/workflows/main.yml validates the package when a PR is opened
- .github/workflows/release.yml deploys the package when a Release is published
- Salesforce authorization URL is stored in Github Repository Secret
- sfdx auth url is generated by running following command while authenticated:
sf org display --verbose
- authorization is completed by piping the sfdx url into the command:
sf org login sfdx-url --sfdx-url-stdin
- sfdx auth url is generated by running following command while authenticated:
- Implements trigger framework from k-capehart/sfdc-trigger-framework
- forked from kevinohara80/sfdc-trigger-framework
- Modified to include additional virtual methods
isDisabled()
: If true, skips trigger methods. Implemented through Custom Settings for easy toggling org wide.applyDefaults()
: Executes before beforeInsert().validate()
: Executes before afterInsert() and afterUpdate().
- Set DEVHUB property inside Make file to alias of authenticated dev hub
Command | Description |
---|---|
make start |
Attempt to open default org, if it fails then create a new scratch org. |
make scratch |
Make scratch org, if it fails then create org shape, then try again. |
make push |
Deploy local changes. |
make pull |
Retrieve changes from org. |
make diff |
Display diff between local and org. |
make test |
Run apex tests and output results to test-results/ |
make scan |
Scan code using sfdx-scanner and output results to scan-results/ |
make apex_trigger TARGET=[Comma separated list of SObjects] |
Create Apex trigger, handler class, helper class, test class, and custom setting |
Command | Description |
---|---|
sf org open |
Open your default org in a browser. |
sf project deploy preview |
Preview a deployment to see what will deploy to the org, the potential conflicts, and the ignored files. |
sf project retrieve preview |
Preview a retrieval to see what will be retrieved from the org, the potential conflicts, and the ignored files. |
sf project deploy start |
Deploy source to an org. |
sf project retrieve start |
Retrieve source from an org. |
sf project deploy validate |
Validate a metadata deployment without actually executing it. |
sf search |
Search for a command. |
sf scanner run |
Scan a codebase with a selection of rules |
sf org create shape |
Create a scratch org configuration (shape) based on the specified source org. |
sf org list shape |
List all org shapes you’ve created. |
sf org login web |
Log in to a Salesforce org using the web server flow. |
sf org login sfdx-url |
Authorize and org using a SFdX Authorization URl in a file or through stdin. |
sf org create scratch |
Create a scratch org. |
sf org delete scratch |
Delete a scratch org. |
sf org display |
Display information about an org. Use --verbose to display the sfdxAuthUrl property. |
sf apex run test |
Invoke Apex tests in an org. |