hygen icon indicating copy to clipboard operation
hygen copied to clipboard

Use hygen to generate entire projects

Open misha-erm opened this issue 3 years ago • 5 comments

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

misha-erm avatar Jun 06 '21 18:06 misha-erm

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)

mjansen-dc avatar Jun 10 '21 14:06 mjansen-dc

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

misha-erm avatar Jun 21 '21 10:06 misha-erm

@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.

mjansen-dc avatar Jun 21 '21 13:06 mjansen-dc

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

jondot avatar Feb 21 '22 08:02 jondot

You might be interested in projen instead.

moltar avatar Mar 02 '22 08:03 moltar