An open API service indexing awesome lists of open source software.

https://github.com/k-capehart/sfdc-dev-org

SFDC Dev Org for testing configuration and code
https://github.com/k-capehart/sfdc-dev-org

apex salesforce sfdx

Last synced: 8 months ago
JSON representation

SFDC Dev Org for testing configuration and code

Awesome Lists containing this project

README

          

# Salesforce Dev Org

## Prerequisites
- Download SF CLI: `npm install @salesforce/cli --global`
- [More information on installation](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_install_cli.htm#sfdx_setup_install_cli_macos)
- [Moving from SFDX CLI to SF CLI](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_move_to_sf_v2.htm)
- Install sfdx scanner for static code analysis: `sf plugins install @salesforce/sfdx-scanner`
- Install [VS Code Salesforce Extension Pack](https://developer.salesforce.com/tools/vscode)
- Download and setup [Java](https://developer.salesforce.com/tools/vscode/en/vscode-desktop/java-setup)

## Create scratch org
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]` or
- `sf org create scratch -f config/project-scratch-def.json -a [alias] -d -w 30`
- Open default org:
- `make start` or
- `sf org open`
- Push local metadata to org:
- `make push` or
- `sf project deploy start`
- Ideally, you'll do this during setup to get all metadata from sfdc repo into the scratch org

## Validate and Deploy
- Implements workflows from [k-capehart/sfdc-github-actions](https://github.com/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`

## Trigger Framework
- Implements trigger framework from [k-capehart/sfdc-trigger-framework](https://github.com/k-capehart/sfdc-trigger-framework)
- forked from [kevinohara80/sfdc-trigger-framework](https://github.com/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().

## Makefile
- 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

## sf cli commands
| 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.