Build your own DEV tools
with Salesforce CLI Plugin
Generator
Mohith Shrivastava
Salesforce MVP
Technical Architect @Codescience
Twitter @msrivastav13
Thanks to our
Sponsors!
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
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
Salesforce CLI Architecture
Credits - Salesforce Developer Evangelist Team (https://developer.salesforce.com/blogs/2018/05/create-your-first-
salesforce-cli-plugin.html)
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
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)
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
DEMO
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
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
DEMO MO-DX-PLUGIN & DX CODE
COMPANIONS
Additional Reading
Plugin development developer guide
Salesforce Plugin Generator Project
Salesforce Command NPM
Salesforce Core NPM
Dreamforce 2018 Talk
Q & A
Thank You

Build your own dev tools with salesforce cli plugin generator

  • 1.
    Build your ownDEV tools with Salesforce CLI Plugin Generator Mohith Shrivastava Salesforce MVP Technical Architect @Codescience Twitter @msrivastav13
  • 2.
  • 3.
    Agenda • Introduction ToSalesforce 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 SalesforceCLI • 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
  • 5.
    Salesforce CLI Architecture Credits- Salesforce Developer Evangelist Team (https://developer.salesforce.com/blogs/2018/05/create-your-first- salesforce-cli-plugin.html)
  • 6.
    Introduction To SalesforceDXPlugin • 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 aCustom 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 CustomPlugin • sfdx plugins:generate - Provides ability to scaffold a custom plugin project • Let’s create one now • Link using sfdx plugins:link
  • 9.
  • 10.
    Accessing Salesforce APIsIn 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 andRelease • 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
  • 12.
    DEMO MO-DX-PLUGIN &DX CODE COMPANIONS
  • 13.
    Additional Reading Plugin developmentdeveloper guide Salesforce Plugin Generator Project Salesforce Command NPM Salesforce Core NPM Dreamforce 2018 Talk
  • 14.
  • 15.