Reputation: 619
I am working on an angular project. I am interested in creating a generator in Yeoman that allows me to generate 'Widgets'.
Basically I would like to have a scenario where I call a command like:
yo angular:widget pieChart
and this would generate a folder in app/scripts/widgets with an js file called pieChart.js and also generate some test code in test/spec/widgets.
Would anyone have any pointers on where to start with this?
Many thanks,
kSeudo
Upvotes: 0
Views: 754
Reputation: 1366
I did something similar to want you want. I would recommend starting with angular-generator. Then you need to add a new file to the templates folder called widget that contains the widget template. Create a new folder on same level as the directive folder called widget and give it an index.js. Then you can pretty much copy the index.js from the directive folder and make necessary changes. You would also just create a widget.js template in the templates/javascript/spec folder as well
Upvotes: 1
Reputation: 1771
There is official generator-generator
It's quite easy to create your own generator, just follow official tutorial http://yeoman.io/authoring/
Upvotes: 1
Reputation: 9476
Writing your own Yeoman generators is fairly straightforward if you are already familiar with tools like Grunt and Bower.
I'd recommend starting with the official tutorial here. The Yeoman generator-generator is fairly straightforward to use and will create a simple skeleton for your generator.
EDIT: Also, if an existing generator does at least some of what you want, it might be worth using that as a starting point.
Upvotes: 1