Code generator enforces conventions, saves time, avoids "decision fatigue" and makes better developer experience. See:
Tools considerations:
Yeoman - most sophisticated, needs more work to get it started but also most powerful
hygen
plop - a "micro-generator framework", looks not so sophisticated and still powerful...
cookiecuter
Quick start
hygen init self
hygen commands are generators (default, built-in) as well
Templates
header + body (name convention 'something.ejs.t'
header:
"---" + yaml + "---"
to: path of generated file, null to skip (condition rendering)
unless_exists: true // to avoid overwriting
inject: true // to inject into existing target, see document
sh: "mkdir...." // carry out shell action, see document
message: | (new line, then some messages) // document
otherVariables: otherValues
body (ejs template):
<%= variable %>
with helpers to convert cases (convention), see document
with pre-defined variables (path, action, etc.), see document
Generators (http://www.hygen.io/generators)
'hygen generator new --name something --someVariable someValue'
generator: folder + file content (ignore file name & file type)
prompting:
include "prompt.js" inside, see document
advanced prompting (ask question depending on some work and previous input, etc.) see document
Sub action:
hygen someGenerator someAction:someSubAction // will match 'someSubAction' with file names
Ecosystem
Create generators: hygen-create, create generator from project files
Packages: hygen-add to copy a published npm module into project or from github
Extensibility
special .hygen.js extends helper functions, customizing logger, template location & shell, and customize generator operations (add,inject, shell)