Quick Start
You can have plenty of ways to run hygen
. Pick one of the following:
On macOS and Homebrew:
Globally with npm (or yarn):
Or, if you like a no-strings-attached approach, use
with npx
Should any of these be confusing to you, check out the binary releases where you'll find a binary for every major platform.
With this done, let's use a hygen
generator.
To use a generator, we supply a GENERATOR ACTION
pair like so (here mailer
and new
are examples).
[[info]]
| New in hygen 4.0.0: a positional NAME
parameter to save a bit of typing. With versions prior to 4.0.0 you still have to use --name NAME
.
Here's a quick run-down to get to your own generator:
To see the generator
help, you could always do:
Finally, use --dry
to do a test-run of your generators.
Congratz! you've made a new generator called awesome-generator
!
Let's walk through what we just did.
[[info]]
| You can also install hygen
from Homebrew or download a standalone binary. For more, see standalone.
Bootstrapping Your Project
Use hygen init self
to start using it in your own project. hygen
comes with two pre-built generators that helps you build your own - although it was built to ease the boilerplate fatigue for React, Redux, and Node.js it can be use for any technology really.
This creates a project-local _templates
folder for you at your source root with two helper generators that saves you time:
hygen generator new generatorName
- builds a new generator for youhygen generator with-prompt new generatorName
- the same as before, only this one will be prompt driven.
[[info]] |###### Template Locality |On multi-team projects, each team can have their own templates right there in the shared repo.
Still in your project root, let's create a new generator now:
And let's use it:
[[info]]
|###### Did You Notice?
|Instead of bundling the hygen generator new
command in hygen
, we chose to copy it to your local templates folder.
|
|
|In this way you can even tweak the way hygen
generates new generators. It scales to a set up with different teams, each with its own preference.
That's it! we've done a basic walkthrough of hygen
. Next up is a detailed overview of templates and generators.
Invoking Generators
There are more ways to play with a generator after you've built it:
You made it to the end! nice! Now check out templates and generators.