Yeoman generators for Angular 1 that follow the John Papa code style.
-
Install Yeoman using npm (we assume you have pre-installed node.js).
npm install -g yo
-
Checkout this project using Git
-
Run
npm link
from the project's folder, which makes the yeoman generators available on your command line anywhere. In the future you can pull in commits to this project and they'll be instantly available when you run the generator.
In any project, navigate to the folder where you'd like to add files. Then run one of these actions from the command line.
Yeoman generators:
yo jp:module <name>
: generates an Angular module in its own file, per the John Papa code styleyo jp:controller <name>
: generates an Angular controller per the John Papa code styleyo jp:directive <name>
: generates an Angular directive which includes a HTML template in the John Papa code styleyo jp:service <name>
: generates an Angular service/factory per the John Papa code style
You can specify the name of the thing to create as part of the command (e.g. yo jp:service myNewService
), but by
specifying it later, you'll get tips about naming conventions.
Creating a generator
- If this is the first time you've done this, run
npm install -g generator-generator
- From the root of this project, run
yo generator:subgenerator <name>
- A sub-generator is created under generators/<name> which users can run using
yo jp:<name>
- Add your generator to the list of generators above
Testing & Usage
To test out your new generator (or changes to an existing generator), run npm link
from the root of this project if
you haven't already. That command makes yo jp:<name>
available.