jondot / hygen

The simple, fast, and scalable code generator that lives in your project.
http://www.hygen.io
MIT License
5.66k stars 253 forks source link

Use hygen to generate entire projects #330

Open misha-erm opened 3 years ago

misha-erm commented 3 years ago

Hello,

I'm wondering what are the best practices or is it even possible to generate entire projects? We tend to create a lot of node.js projects so I want to share some basic templates with my team.

Currently I use self-written package to generate projects from ejs templates, like this npx @org/generator -n new-app.

I can't figure out how to do the same with hygen except keeping up-to-date templates folder on each local machine. Is there any way to point to remote templates folder?

Thanks in advance for any insights

mjansen-dc commented 3 years ago

I solved this problem by making my own CLI package and embedding hygen within it as stated in the readme. Basically copying the bin file used by hygen and making it point to your own set of generators to generate a project (instead of the default init self set).

You can even take note of how the init self generators were made and use it to generate the project structure with additional templates to scaffold things like components within it. (aka, generating generators)

misha-erm commented 3 years ago

@mjansen-dc thanks for the tip👍🏻 Btw, is your solution open-sourced? I'd love to see it

mjansen-dc commented 3 years ago

@MikeYermolayev I can't share the solution I was referring to in my original comment, but I quickly made a stripped down version which is available over here.

jondot commented 2 years ago

Thanks @mjansen-dc and @MikeYermolayev For v7 I'm planning easy (and smart) cloning for template repositories, which I think can help even further!

moltar commented 2 years ago

You might be interested in projen instead.