sf-raven
v1.0.7
Published
A custom sf plugin built by @tomcarman
Downloads
49
Maintainers
Readme
sf-raven
A plugin for the Salesforce CLI built by Tom Carman.
sf-raven now replaces sfdx-raven.
Why a new plugin?
I originally built sfdx-raven in 2020, but the Salesforce CLI landscape has changed a lot since then. Rather than attempting to migrate the original plugin from sfdx to sf, it felt cleaner to start a new project and leverage the new architecture and scaffolding tools that come with the new sf cli.
Improvements over sfdx-raven
- Built on sf not sfdx.
- Uses the latest version of oclif.
- Commands now follow the sf command structure guidelines -
<topic> <action> <resource | sub-action> [flags]
. For example:info:fields
becomesobject display fields
utils:event:listen
becomesevent subscribe
- Code now meets ESlint rules for TypeScript, including the Salesforce CLI Plugin custom rules.
- The Salesforce tooling / documentation for building custom plugins has matured a lot over the past couple years, which will make it easier to update the plugin going forward.
More commands will be ported/added over time - see Todo.
Command Quick Reference
Full details, usage, examples etc are further down, or can be accessed via --help
on the commands.
sf raven object display
- sf raven object display fields
- Show field information for a given sObject.
- sf raven object display recordtypes
- Show RecordType information for a given sObject.
sf raven audit display
- sf raven audit display
- Show recent entries in the Setup Audit Trail.
sf raven event
- sf raven event subscribe
- Subscribe to Platform Events.
Setup
Quick Install
Assuming you already have the SDFX CLI installed, just run:
sf plugins install sf-raven
Note: You'll be prompted that this is not officially code-signed by Salesforce - like any custom plugin. You can just accept this when prompted, or alternatively you can whitelist it
Updating the plugin
The plugin can be updated to the latest version using
sf plugins update
Install from source
- Install the SDFX CLI
- Clone the repository:
git clone [email protected]:tomcarman/sf-raven.git
- Install npm modules:
npm install
- Link the plugin:
sfdx plugins:link .
Compatibility
- macOS
- Plugin has been built on macOS and will always run on macOS
Todo
- Migrate remaining commands from sfdx-raven
- sfdx raven:utils:deploy:branch2org
- sfdx raven:utils:diff
- sfdx raven:utils:dashboarduser:update - tbc
- Get the sObject Type for a given Id
- Get the picklist values for a given picklist
- Clone a record
sf raven object display fields
Show field information for a given sObject.
USAGE
$ sf raven object display fields -o <value> -s <value> [--json]
FLAGS
-o, --target-org=<value> (required) Login username or alias for the target org.
-s, --sobject=<value> (required) The API name of the sObject that you want to view fields for.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Show field information for a given sObject.
FieldDefinition metadata is queried for the given sObject. The field Labels, API names, and Type are displayed.
EXAMPLES
$ sf raven object display fields --target-org dev --sobject Account
$ sf raven object display fields --target-org dev --sobject My_Custom_Object__c
OUTPUT
Name Developer Name Type
────────────────── ─────────────── ─────────────────
Account Number AccountNumber Text(40)
Account Source AccountSource Picklist
Annual Revenue AnnualRevenue Currency(18, 0)
...
sf raven object display recordtypes
Show RecordType information for a given sObject.
USAGE
$ sf raven object display recordtypes -o <value> -s <value> [--json]
FLAGS
-o, --target-org=<value> (required) Login username or alias for the target org.
-s, --sobject=<value> (required) The API name of the sObject that you want to view Record Types for.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Show RecordType information for a given sObject.
RecordType metadata is queried for the given sObject. The RecordType Name, DeveloperName, and Id are displayed.
EXAMPLES
$ sf raven object display recordtypes --target-org dev --sobject Account
$ sf raven object display recordtypes --target-org dev --sobject My_Custom_Object__c
OUTPUT
Name Developer Name Id
─────────────────── ─────────────────────── ──────────────────
Business Account Business_Account 0124J000000XXXXABC
Person Account PersonAccount 0124J000000YYYYDEF
...
sf raven audit display
Show recent entries in the Setup Audit Trail.
USAGE
$ sf raven audit display -o <value> [--json] [-u <value>] [-l <value>]
FLAGS
-l, --limit=<value> [default: 20] The number of audit trail entries to return. Maximum is 2000.
-o, --target-org=<value> (required) Login username or alias for the target org.
-u, --username=<value> Username to filter the audit trail by.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Show recent entries in the Setup Audit Trail.
Returns the 20 most recent Setup Audit Trail entries, but this can be increased up to 2000 using the optional --limit flag. The results can be filtered by a particular user using the --username flag.
EXAMPLES
$ sf raven audit display --target-org dev
$ sf raven audit display --target-org dev --limit 200
$ sf raven audit display --target-org dev --username [email protected]
$ sf raven audit display --target-org dev --limit 50 --username [email protected]
OUTPUT
Date Username Type Action Delegate User
─────────────────── ───────────── ──────────── ─────────────────────────────────────────────────────────── ────────────────────
2023-09-29 17:23:47 [email protected] Apex Trigger Changed Account Created Trigger code: AccountTrigger null
2023-09-29 17:23:43 [email protected] Apex Trigger Created Account Created Trigger code: AccountCreatedTrigger null
...
sf raven event subscribe
Subscribe to Platform Events.
USAGE
$ sf raven event subscribe -o <value> -e <value> [--json] [-r <value>] [-t <value>]
FLAGS
-e, --event=<value> (required) The name of the Platform Event that you want to subscribe with '/event/' prefix eg. /event/My_Event__e.
-o, --target-org=<value> (required) Login username or alias for the target org.
-r, --replayid=<value> The replay id to replay events from eg. 21980378.
-t, --timeout=<value> [default: 3] How long to subscribe for before timing out in minutes eg. 10. Default is 3 minutes.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Subscribe to Platform Events.
Platform Events are printed to the terminal. An optional flag can be used to relay events from a given relayid. Defaut timeout is 3 minutes, but can be extended to 30 minutes.
EXAMPLES
$ sf raven event subscribe --target-org dev --event /event/My_Event__e
$ sf raven event subscribe --target-org dev --event /event/My_Event__e --replayid 21980378
$ sf raven event subscribe --target-org dev --event /event/My_Event__e --timeout 10
$ sf raven event subscribe --target-org dev --event /event/My_Event__e --replayid 21980378 --timeout 10
OUTPUT
❯ 🔌 Connecting to org... done
❯ 📡 Listening for events...
{
"schema": "XdDXhymeO5NOxuhzFpgDJA",
"payload": {
"Some_Event_Field__c": "Hello World",
"CreatedDate": "2021-03-15T19:16:54.929Z",
},
"event": {
"replayId": 21980379
}
}