Introducing Generator-SFDC

Why I built a Yeoman generator for Salesforce (Generator-SFDC), what problem it solves, and what it can scaffold for you.

Introducing Generator-SFDC

My last post was about understanding the fundamentals of Yeoman. This one is about Generator-SFDC, the Yeoman generator I built to apply what I learned.

The goal was simple: create an easy-to-use tool that does more than spit out one-off files with boilerplate I’d just have to delete or rewrite.

To start, go to the repo for the latest code and installation instructions so you can follow along.

Yeoman + Salesforce?

There are many options for templating/scaffolding in the Salesforce ecosystem, but here’s why I chose Yeoman.

It’s just JavaScript

Using JavaScript means the code is easy to start and simple to write. Yeoman runs on Node.js, which means you can use the npm ecosystem (and other registries) to pull in whatever you need.

It’s opinionated and feature-complete. While there are other JavaScript scaffolding libraries, Yeoman has a well-known structure and a clear “happy path,” which makes it a less mentally taxing starting point.

There’s an established community. Because Yeoman generators can compose with other generators, you can leverage work the community has already built and integrate real functionality with relatively little effort.

Fantastic, I’m sold. Now what does it do?

Goals for Generator-SFDC

  • Scaffold Salesforce-specific files: Apex controllers, triggers, Visualforce pages, and components
  • Scaffold SPAs for Angular, Angular 2, React, and Ember
  • Generate a DAL (data access layer) for an SObject (selector/message/service classes)
  • Create a MavensMate project for easier integration with Atom and Sublime Text
  • Create VS Code config for integrating with the ForceCode extension
  • Ultimately: a single project that can generate the files you need for Salesforce development by using Salesforce metadata as input