Generate a code file (or multiple files) in a Sails app.
sails generate <generator>
Sails ships with several generators to help you scaffold new projects, spit out boilerplate code for common files, and automate your development process.
The following core generators are bundled with Sails:
|sails generate page||Generate four pages: .ejs, .less, page script, and view action. You must add your .less file to the importer and you must set your route for your new page to work. Note:
|sails generate model||Generate api/models/Foo.js, including attributes with the specified types if provided.
|sails generate action||Generate a standalone action.|
|sails generate helper||Generate a helper at api/helpers/foo.js.|
|sails generate controller||Generate api/controllers/FooController.js, including actions with the specified names if provided.|
|sails generate hook||Generate a project hook in api/hooks/foo/.|
|sails generate generator||Generate a foo folder containing the files necessary for building a new generator.|
|sails generate response||Generate a custom response at api/responses/foo.js|
|sails generate adapter||Generate a api/adapters/foo/ folder containing the files necessary for building a new adapter.|
|sails generate sails.io.js||Generate a sails.io.js file at the specified location, overwriting the default sails.io.js if applicable.|
|sails generate api||Generate api/models/Foo.js and api/controllers/FooController.js.|
|sails generate new||Alias for
|sails generate etc||Experimental. Adds the following files to your app:
Custom / third party generators allow you to extend or override the default functionality of
sails generate (for example, by creating a generator that outputs view files for your favorite view engine).
You can also use custom generators to automate frequent tasks or generate app-specific files. For example, if you are using React, you might wire up a quick custom generator to allow you to generate React components in the appropriate folder in your project (
sails generate react component).