Skip to content
Home » Blog » Why oclif is a good idea for Salesforce ci/cd?

Why oclif is a good idea for Salesforce ci/cd?

When you are setting up an advanced Salesforce build pipeline, you normally write some scripts that are then placed or called from the CI engine (Bamboo, Jenkins, etc.). After some time the complexity of your build pipeline setup increases and is no longer easy to maintain or test the changes you need to make.

A good CLI framework can help to avoid the mess. You could create you own framework from scratch but, why reinvent the wheel if frameworks like oclif are available for free and really easy to work with?.

oclif is a framework for building CLIs in Node. It can be used like a simple flag parser but is capable of much more. It’s designed to be extensible so that you can easily add plugins such as the update warning plugin or build your own for users to install at runtime.

From: oclif introduction

Benefits

  • A framework like oclif, provides you with the base to build your application, saving you a lot of time and enforcing best practices.
  • Have all the code used in your build pipeline in one place and organized by topics.
  • Test coverage: the command generator automatically create scaffolded tests.
With a single instruction, the whole structure of your new command is created automatically for you, including the test files.
  • Node.js: Most tools in the Salesforce ecosystem use Node.js and JavaScript, including the official sfdx-cli and other useful libraries like jsforce.
    The benefits of using Node.js and npm libraries (node package manager) can be found with a simple Google search but the summary is that you have over 350,000 packages available for you to do practically everything you need, saving a lot of time.
  • You could also create a sfdx plugin which cli is, as mentioned before, using oclif.

Some interesting links:

Building a CLI Application with oclif (Salesforce)
Experience from Adobe:
How to Easily Create CLIs Using OCLIF (and How We Did It for the Adobe I/O CLI)
TrailheadDX video conference:
Open CLI Framework: Create Command Line Tools Your Users Love
Salesforce CLI Plugins:
Salesforce CLI Plug-In Developer Guide
Create Your First Salesforce CLI Plugin