Build your own dev tools with salesforce cli plugin generator
1. Build your own DEV tools
with Salesforce CLI Plugin
Generator
Mohith Shrivastava
Salesforce MVP
Technical Architect @Codescience
Twitter @msrivastav13
3. Agenda
• Introduction To Salesforce CLI
• Salesforce CLI Architecture
• Introduction To SalesforceDX Plugin
• Why Build a Custom Plugin ?
• Generating a Custom Plugin
• Accessing Salesforce APIs In Custom Plugin
• Test , Debug and Release Custom Plugins
• Additional Reading
4. Introduction To Salesforce CLI
• Salesforce CLI is based on Open Source Heroku Oclif Project
• Oclif is a framework for Building Command Line Interface
Using Nodejs framework
• Install SFDX CLI depending on Operating System using npm or
from developer site
• To find the version you are on run below
sfdx --version
6. Introduction To SalesforceDX Plugin
• list all plugins using sfdx plugins
• salesforcedx plugin provides commands to create scratch
orgs , authenticate to any orgs , work with salesforce
metadata (retrieve , deploy , convert to dx source format)
and many more
• Docs for every command are part of CLI .You can help of any
command with --help
• Provides command to generate a custom plugin
7. Why Build a Custom Plugin?
• While salesforce covers common use cases there might be
one of requirements specific to your need for CI pipeline.
• Useful if you want to automate multiple salesforce provided
commands in one single command
• Handy if you want to build a command that involves
operations with multiple orgs
• Build your own developer tools using metadata and tooling
apis (Desktop tools using Electron or Tools for Editors like
VScode)
8. Generating a Custom Plugin
• sfdx plugins:generate - Provides ability to scaffold a custom
plugin project
• Let’s create one now
• Link using sfdx plugins:link
10. Accessing Salesforce APIs In Custom
Plugin
• One can access Salesforce metadata , tooling , analytics , ui ,
soap and rest using jsforce library provided by the CLI
• The custom plugins can use session from the cli or establish
new connections using
• sfdx-core npm provides utilities for establishing
connection,manage orgs
• sfdx Command npm provides the utilities like table
rendering , spinners
11. Test, Debug and Release
• Compile code using yarn prepack
• We can debug using vscode node debugger .Run the
command and use followed by <command> --dev-suspend
• Release a plugin using npm publish