angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Enable user-defined blueprints/templates

Open thorstenschaefer opened this issue 10 years ago • 4 comments

Currently Angular2 CLI provides a fixed set of blueprints to generate. A reoccurring pattern I have seen while using CLI is that I create a service using "ng g service MyService", get the stub which is pretty empty, and then perform similar modifications every time.

For instance, if we create services for REST CRUD operations, they follow a certain pattern:

  • we have a constant for the URL
  • we need to import Observable and Http
  • we have methods like gets, delete, create, etc.

Is there something like a plugin-model/extension point where I can provide my own blueprints to generate and register them to CLI, so I could perform the command "ng g crud-service MyCrudService" in the example above?

thorstenschaefer avatar Apr 28 '16 21:04 thorstenschaefer

Well, angular-cli actually uses ember-cli which is very extensible and would allow for that. For now though, we haven't plugged it in such as way as to be very extensible but you could hypothetically do that right now with an ember-cli plugin.

I just can't guarantee that it'd be well supported - or supported at all - in the future. Check out the extending bit of http://ember-cli.com/.

filipesilva avatar Apr 28 '16 23:04 filipesilva

@thorstenschaefer, couldn't you modify the name.service.ts file to put the changes you want to always be there?

billfranklin avatar May 10 '16 15:05 billfranklin

@billfranklin: I'm not sure if I understand your suggestion: are you recommending changing the blue print file? If so, it would probably be possible for the use case above, but imagine I have 3 kinds of services (the regular one, services that use REST APIs and old school web services), I'd have to choose between a single service template. User-defined additions would enable users to add n templates depending on their needs.

thorstenschaefer avatar May 10 '16 20:05 thorstenschaefer

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.