Skip to content

A collection of bash scripts for my daily work with Salesforce

License

Notifications You must be signed in to change notification settings

thomd/salesforce-cli-tools

Repository files navigation

Salesforce CLI Tools

A collection of bash scripts for my daily work with Salesforce. The scripts are basically wrappers around the sf cli tool from Salesforce.

Caution

These scripts were created to fit my personal needs. They might not fit your needs. They might not work on your machine. They might not work with your project setup.

Install

Set symlinks to ~/bin/ folder with

make

Alternatively symlink to custom folders like this example:

make BINDIR=/usr/local/bin/ COMPLETIONSDIR=/etc/bash_completions.d

Dependencies

The tools depend on the following non-standard CLI tools:

  • sf: npm install -g @salesforce/cli
  • jq: brew install jq
  • VisiData: brew install saulpw/vd/visidata
  • daff: npm install -g daff
  • csvtk: brew install csvtk
  • graph-easy: brew install cpanminus; cpan Graph::Easy
  • watchexec-cli: brew install watchexec
  • XMLStarlet: brew install xmlstarlet

Usage

Run --help or -h option to get a description of the tool and how to use it.

Export environment valiable DEBUG to print the underlying call with sf like

export DEBUG=1
sf-deploy

or

DEBUG=1 sf-deploy

Commands

  1. sf-data downloads all data of Salesforce objects as csv files from an org.

  2. sf-deploy builds, deploys and publishes a full project or deploys single entities from the git index in watch mode for ease of development.

  3. sf-inspect inspect local custom-labels and their translations as well as permissions from profiles and permission-sets in a tabular manner.

  4. sf-log creates or updates the debug log for a given debug-log user and streams log to console.

  5. sf-metadata downloads all or specific metadata from an org.

  6. sf-rel extracts and displays relations of a given object-id to other objects.

  7. sf-tooldata downloads all data as csv files from an org using the Tooling API.

  8. sf-validate validate a full project against an org and runs unit tests.

Some Use Cases

Compare Data between Orgs

sf-data -o org1 -d .data1 -s Account
sf-data -o org2 -d .data2 -s Account
daff --www .data1/Account.csv .data2/Account.csv

Download & Inspect Data in VisiData

To automatically open retrieved data in VisiData without downloading into your local folder, use the -v option:

sf-data -v Account

Inspect Relations of a given Object with other Objects of Interest

Supposed you are interested in the realations of an Account, e.g. 0019O00000Dc70zQAB, with User, Contact and AccountContactRelation:

sf-data -s Account -s User -s Contact -s AccountContactRelation
cd .data
sf-rel 0019O00000Dc70zQAB

Deploy Files from Git Index to Org

Only deploying the files you are working on is way faster that always deploying the full project.

File changes are detected automatically and deployed on change in watch-mode for ease of development.

sf-deploy

About

A collection of bash scripts for my daily work with Salesforce

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published