Description
Discussion on AngularAir today regarding 3rd party libraries (https://plus.google.com/events/c7m79d5o04nom5eednk5ecqtebk) brought up an interesting thought.
See also: angular/angular#5503
If 3rd party libs all adhered to a certain naming convention and style when exporting necessary services, directives, pipes, etc., it would be incredibly helpful if this CLI could auto-annotate the src code files with the necessary directives
, providers
, pipes
, etc.
Consider the following scenario:
- User wants to use
ng2-image-lazy-load
(https://github.com/NathanWalker/ng2-image-lazy-load) - Since it followed certain conventions,
IMAGELAZYLOAD_PROVIDERS
, the CLI might provide an additional helpful aid (command can be whatever, just usingadd-lib
for example):
ng add-lib ng2-image-lazy-load
It would proceed to run npm install ng2-image-lazy-load
, then prompt with a couple questions:
$ Would you like this provider as part of the bootstrap? (y/n)
If "y":
$ Please provide the path to the src file which bootstraps your app:
$ src/bootstrap.ts
It would add the import statements and append the aptly named [lib_prefix]_PROVIDERS
in the user's app bootstrap.
If the lib contained no constants with PROVIDERS
in the name, it would modify nothing.
If "n":
$ Please provide the path of the component you would like the providers added to:
$ src/components/main.component.ts
It would add the import statements and append the libraries aptly named PROVIDERS
in the viewProviders
of the component.
Similar scenarios would apply for DIRECTIVES
, PIPES
, etc.
If this were possible, every 3rd party lib could suggest using the CLI as the first option to install, followed by manual npm install.
/cc @jvandemo, @gdi2290, @valorkin, @ocombe, @jeffwhelpley, @PascalPrecht, @mgechev, @ludohenin, @robwormald