Search code examples
node.jsyeomanyeoman-generator

Creating a Yeoman generator and have it be version controlled


I'm wrapping my head around creating a Yeoman generator, so that Yeoman can generate our boilerplate whenever a new project is started.

The building blocks of this boilerplate should be version controlled. So I assume the generator (which will contain the rules for creating the boilerplate) should be hosted on github.

Which leads me to the question: if the generator itself is hosted on github, how will Yeoman save me any time? Because in order to use the latest version of the generator I would have to pull it off off github anyhow (which I could just as well do with the boilerplate itself, if it were hosted on github).

Or am I misunderstanding where a Yeoman generator is located? Because as I understand it you have to have it locally, or use one of the generators from the public repo.


Solution

  • You can quite easily publish it to npm using the command npm publish. Then you can install and upgrade it just like any other npm module. I did it myself for my first Yeoman generator and it's pretty straightforward.

    This is a good place to start.