Over the last year or so, I've been working a lot with AngularJS and Node. One of the biggest challenges when I started learning Angular in particular, and to a lesser extent Node poses the same challenge, is how to structure your app.
A tool that I learned about to help create apps that are structured using "best practices" is called yeoman. After using it for some time, I liked it so much, I wanted to create a yeoman generator for our free DevNet Learning Labs to make it easier for people creating them. The idea behind yeoman is to scaffold an app from a template. For the longest time, I just had a sample project, and the user would just have to copy it, rename a bunch of files (including properties inside), and usually something wouldn't turn out right. Automation to the rescue!
While you can certainly create a yeoman generator for scratch, conveniently (and not surprisingly) the folks from yeoman created a generator for creating a generator. It's called generator-generator!
The basic steps are as follows:
- Download and install node (I suggest you use nvm if you don't know about it)
- Download and install yo, which is actually yeoman, but just the alias you type on the command line (npm install -g yo).
- Finally, you should be able to run generator-generator. (Note that you prefix your generator with generator-). Hence my generator was named generator-devnet-learninglabs. Kind of a keyboard full, but alas, I wanted it to be descriptive.
You can get pretty fancy, but I stuck to a basic set of questions to generate the scaffolded Learning Lab. You can find the end result on GitHub.
Keep coding!