A big part of Sails, like any framework, is to automate repetitive tasks. Generators are no exception-- they're what power the Sails command-line interface any time it generates new files for your Sails projects. In fact, you or someone on your team probably used a generator to create your latest Sails project.
When you type
sails new my-project
sails uses its built-in "new" generator to prompt you for your app template of choice, then spits out the initial folder structure for a Sails app:
my-project ├── api/ │ ├─ controllers/ │ ├─ helpers/ │ └─ models/ ├── assets/ │ └─ … ├── config/ │ └─ … ├── views/ │ └─ … ├── .gitignore … ├── package.json └── README.md
This conventional folder structure is one of the big advantages of using a framework. But it's usually also one of the trade-offs. (What if your team or organization has made firm commitments to a different set of conventions?)
Fortunately since Sails v0.11, generators are extensible and easy to check in to a project repository or publish on NPM for re-use.
Sails' generators allow you to completely customize what happens when you run
sails new and
sails generate from the command-line. By augmenting new apps and newly-generated modules, custom generators can be used to do all sorts of cool things:
sails generate jquery)
sails generate componentor
sails generate ng-module)
If you are interested in making custom generators, the best place to start is by checking out the introduction to custom generators. You also might check out open-source generators from the community, in case something already out there will save you some time.