-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(@angular/cli): specify multiple default collections #8723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(@angular/cli): specify multiple default collections #8723
Conversation
@@ -19,10 +18,7 @@ export interface SchematicAvailableOptions { | |||
|
|||
export default Task.extend({ | |||
run: function (options: SchematicGetOptions): Promise<SchematicAvailableOptions[]> { | |||
const collectionName = options.collectionName || | |||
CliConfig.getValue('defaults.schematics.collection'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to retrieve config value from multiple places. Now it's always responsibility of the caller.
@@ -72,15 +72,14 @@ export default Task.extend({ | |||
}); | |||
|
|||
const cwd = this.project.root; | |||
const schematicName = CliConfig.fromGlobal().get('defaults.schematics.newApp'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to retrieve config value from multiple places. Now it's always responsibility of the caller.
output.push(cyan('Available collections & schematics:')); | ||
const collections = getCollectionNames() | ||
.map((collectionName: string) => getCollection(collectionName)); | ||
collections.forEach((collection: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List schematics per collection
408f960
to
aa93830
Compare
aa93830
to
84b4bec
Compare
@clydin a bit meta question, how does it work with this repo, is it ok to always mention main guys in PR to let them know something was created or do they check PRs themselves, don't want to spam. |
@tomastrajan we monitor all the PRs but if you think a PR should be reviewed by a particular team member, there's no harm in mentioning them. Also, thank you for contributions to the project and spending the time to help make the CLI better. Bug fixes and required features take priority so please don't feel discouraged if it takes a little while to hear back. |
Is this necessary in order to, say, use default Angular schematics and the new ngrx schematics in the same project? |
@bmayen @hansl No, you can use any collection with passing its name to collection flag like This PR is about being able to just run |
Certainly much more convenient being able to define, only once in angular-cli.json, all of the collections you'll be using for a project. I do think more thought needs to go into name collisions. Currently the first one encountered wins. This is fine when the intent is always to override, but we can't assume that. It's possible that two separate collections define |
I see your point. The way this was intended to work is that you get override behaviour by default but you can always execute for specific collection in the same fashion like befote by passing Besides from what I saw in But this then only works nicely if you use ONE other schematics which delegates all the calls to underlying default. It doesnt help if you want to use more smaller / single purpose schematics from multiple libraries. |
This would be my main concern. It requires some knowledge of the implementation or behavior could be unexpected. |
Just sharing my pre-conceived notion on how this was going to work. When I saw it was prefixed with @schematics, I thought it was going to be similar to how @types is managed by DefintelyTyped. Package owners create a PR to merge schematics for their package into the main repo which is then auto-published after approval. This would solve the naming conflicts and it would be nice to just see them all available schematics listed in NPM under @schematics but I'm not sure how much overhead it really takes those Microsoft guys to manage it that way. Just a thought. |
Closing this PR as it is too old and does not merge properly anymore. The work has been tracked locally in #12157 (which is a transfer from the issue from devkit). It's something we want to support but needed to do some cleanup first. Now that 7.0 is out and that cleanup is done, we'll track it in our internal Jira and expect updates on the issue #12157. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hi 😉
This PR is related to issue posted on
angular/devkit
repository by @jeffbcross . It looks like the whole implementation of executing schematics belongs to@angular/cli
itself so that's the reason for creating PR against this repo.The proposed solution adds possibility to specify additional
collections
property in defaults ofschematics
inangular-cli.json
. That way app has base collection which defaults to@schematics/angular
(but could be overridden too) and potential to add unlimited additional collections. Execution priority is that the first collection containing requested schematics wins.the additional
collections
property should make this solution backwards compatible.This is initial working implementation. Review of someone who knows that part would be highly appreciated. Also some guidance on how to test this is very welcome.
Check out screenshot of working solutions.