jondot /hygen

The simple, fast, and scalable code generator that lives in your project.

★ 5,926⑂ 275👁 52⑃ 175● 280▤ 62
JavaScriptMITCreated 2017-08-13www.hygen.io
下载:v6.2.11v6.2.11 ↓6.2.112022-09-07
+1
日增长
5,926
stars
275
forks
52
watchers
175
prs
280
issues
62
releases

README

hygen is the simple, fast, and scalable code generator that lives _in_ your project.


  



 Features

- ✅ Build ad-hoc generators quickly and full on project scaffolds.
- ✅ Local generators per project (and global, if you must)
- ✅ Built-in scaffolds to quickly create generators
- ✅ Full logic templates and rendering
- ✅ Prompts and flows for taking in arguments
- ✅ Automatic CLI arguments
- ✅ Adding new files
- ✅ Injecting into existing files
- ✅ Running shell commands
- ✅ Super fast, constantly optimized for speed


 New in hygen v4.0.0: a positional NAME parameter.
 Now you can use $ hygen component new MyComponent instead of $ hygen component new --name MyComponent.

 Used By

                       
             
        
                                            
  
 









 Quick Start

Hygen can be used to supercharge your workflow with Redux, React Native, Express and more, by allowing you avoid manual work and generate, add, inject and perform custom operations on your codebase.

If you're on macOS and have Homebrew:


$ brew tap jondot/tap
$ brew install hygen


If you have node.js installed, you can install globally with npm (or Yarn):


$ npm i -g hygen


If you like a no-strings-attached approach, you can use npx without installing globally:


$ npx hygen ...


For other platforms, see releases.

Initialize hygen in your project (do this once per project):


$ cd your-project
$ hygen init self


Build your first generator, called mygen:


$ hygen generator new mygen

Loaded templates: _templates
       added: _templates/mygen/new/hello.ejs.t


Now you can use it:


$ hygen mygen new

Loaded templates: _templates
       added: app/hello.js


You've generated content into the current working directory in app/. To see how the generator is built, look at _templates (which you should check-in to your project from now on, by the way).

You can build a generator that uses an interactive prompt to fill in a variable:


$ hygen generator with-prompt mygen

Loaded templates: _templates
       added: _templates/mygen/with-prompt/hello.ejs.t
       added: _templates/mygen/with-prompt/prompt.js


Done! Now let's use mygen:


$ hygen mygen with-prompt
? What's your message? hello

Loaded templates: _templates
       added: app/hello.js


 Use a template repo

Want to start from a repo?


$ hygen init repo antfu/vitesse --to my-folder


Want to start from an existing repo on an existing project?


$ mkdir your-project && cd your-project
$ hygen init repo antfu/vitesse



 What's Next?

Go to the documentation to get to know the rest of Hygen and generators.

If you're in a hurry:

 To learn how to edit generator templates, look here
 To see how to use generators look here
 Take a look at the ecosystem and tooling built around Hygen.

 A Different Kind of a Generator

hygen 

Top issues

Latest release

v6.2.11 v6.2.11 2022-09-07

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON