Open bebraw opened 10 years ago
@bebraw yes, will definitely have to do that! PR's are welcome! (sorry for the late response, been on a holiday)
We should define some basic logic for this. I've prepared some initial spec for you below based on the last example at Angular Best Practices.
slush angular:directive pane
-> Creates pane
directory, module (pane.js), directive (pane-directive.js) and a test (pane-directive_test.js)slush angular:filter ransomnote
-> Creates ransomnote
directory, filter (ransomnote-filter.js) and a test (ransomnote-filter_test.js). Note that module is not created in this case. Also the naming differs from the Google case given I use the same note for the directory and the filter. It's hard to envision how other that could work given we provide only one parameter (filter name).slush angular:service request
-> Same as filter except for naming (request-service.js etc.).We'll need to generate module definition for controllers at least and then make sure modules get hooked up at app.js
automatically to make it nice. In addition it probably should be possible to generate components within existing directories/modules.
I am sure this won't cover every possible case but perhaps a scheme like this would serve as a starting point? Any particular ideas?
Like your ideas!
I wonder why you chose not to create a module in the filter
or service
case though?
What if we add a prompt for what module to put the file to be created in? If the module already exists it's used, if not both a folder and a module definition file are created. The module prompt defaults to the given name.
E.g:
slush angular:directive pane
[?] Which module should the directive be put in? (pane)
And the same behavior goes for each Angular file type.
Another subgenerator that would be great to have would be one that generates a module folder, a definition, a controller with a test file, a template and a route injected into app.js
.
What do you think?
I wonder why you chose not to create a module in the filter or service case though?
I modeled it after that Google example. Now that I think of it maybe we should create the module if it doesn't exist already and hook it up with app.js
.
What if we add a prompt for what module to put the file to be created in? If the module already exists it's used, if not both a folder and a module definition file are created. The module prompt defaults to the given name.
Yeah, that could be nice. Let's go with that.
Another subgenerator that would be great to have would be one that generates a module folder, a definition, a controller with a test file, a template and a route injected into app.js.
I wonder what to call this. The TODO app demo could probably depend on it (simplifies things).
Hey,
I went ahead and created the slush-angular-gulp with support for all sub-generators with more inputs from angular-style-guide. Please review the same and provide some suggestions that can improve the generator.
Thanks @joakimbeng for this inspiring writeup that made me write this generator.
Ie.
to quote https://github.com/yeoman/generator-angular .