Creating a Plugin for the Salesforce CLI

Mar 31, 2017 | 2 minutes read

This post is valid for the Salesforce DX (SFDX) pilot. Please note that details may change and I’ll do my best to update accordingly.

Recently I highlighted a neat way to use open source software with Salesforce DX. Since then I’ve used Appiphony’s custom base components many, many times in demos and apps I’ve built.

It didn’t take long for me to get tired of removing the Git details when pulling the OSS from Github. So I created sfdx-oss-plugin. With this command, you can run sfdx wadewegner:source:oss -r wadewegner/Strike-Components -p . to grab all the source listed in the SFDX oss manifest into whatever directory you specify. It also makes it really easy to create a SFDX oss manifest file with the command sfdx wadewegner:source:create -p ., which creates the JSON file for everything in the specified path.

Pretty nifty, eh? To try it out:

  1. Install the SDFX CLI.

  2. Clone the repo: git clone

  3. Install npm modules: npm install

  4. Link the plugin: sfdx plugins:link .

(Perhaps I’ll publish this at somepoint.)

This highlights one of the advantages building our Salesforce CLI on the Heroku CLI. Not only do we get to take advantage of frequent updates (both for features and security) of the Heroku CLI, but we can also take advantage of plugin extensibility.

For the most part, building a plugin for the Salesforce CLI is exactly the same as building a plugin for the Heroku CLI. I think you’ll find sfdx-oss-plugin a very good reference.

One significant change we’ve made is the introduction of a namespace. You can see it on index.js#L16 and in the following sample:

exports.namespace = {
    name: 'wadewegner',
    description: 'commands from Wade Wegner'

This organizes all the commands in my plugin under sfdx wadewegner.

Overtime, things will change. I’ll be sure to update this post accordingly.

I hope you’ve found this post useful and that you’re enjoying the Salesforce DX pilot! To add yourself to the Salesforce DX pilot waitlist, enter your info here:

comments powered by Disqus