feat(@angular/cli): add support for multiple schematics collections - #22860
Merged
Conversation
alan-agius4
marked this pull request as ready for review
March 17, 2022 13:32
alan-agius4
commented
Mar 17, 2022
dgp1130
reviewed
Mar 17, 2022
dgp1130
approved these changes
Mar 18, 2022
dgp1130
approved these changes
Mar 21, 2022
…s` to allow returning hidden schematics. The return value of `listSchematicNames` will include hidden schematics when is invoked with true as first parameter. By default, hidden schematics are not returned.
alxhub
pushed a commit
to angular/angular
that referenced
this pull request
Mar 21, 2022
`defaultCollection` has deprecated in favor of `schematicCollections`. Related to angular/angular-cli#22860 PR Close #45406
clydin
requested changes
Mar 22, 2022
The `schematicCollections` can be placed under the `cli` option in the global `.angular.json` configuration, at the root or at project level in `angular.json` .
```jsonc
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"schematicCollections": ["@schematics/angular", "@angular/material"]
}
// ...
}
```
**Rationale**
When this option is not configured and a user would like to run a schematic which is not part of `@schematics/angular`,
the collection name needs to be provided to `ng generate` command in the form of `[collection-name:schematic-name]`. This make the `ng generate` command too verbose for repeated usages.
This is where `schematicCollections` comes handle. When adding `@angular/material` to the list of `schematicCollections`, the generate command will try to locate the schematic in the specified collections.
```
ng generate navigation
```
is equivalent to:
```
ng generate @angular/material:navigation
```
**Conflicting schematic names**
When multiple collections have a schematic with the same name. Both `ng generate` and `ng new` will run the first schematic matched based on the ordering (as specified) of `schematicCollections`.
DEPRECATED:
The `defaultCollection` workspace option has been deprecated in favor of `schematicCollections`.
Before
```json
"defaultCollection": "@angular/material"
```
After
```json
"schematicCollections": ["@angular/material"]
```
Closes #12157
clydin
approved these changes
Mar 22, 2022
josmar-crwdstffng
pushed a commit
to josmar-crwdstffng/angular
that referenced
this pull request
Apr 8, 2022
…r#45406) `defaultCollection` has deprecated in favor of `schematicCollections`. Related to angular/angular-cli#22860 PR Close angular#45406
2 tasks
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
schematicCollectionscan be placed under theclioption in the global.angular.jsonconfiguration, at the root or at project level inangular.json.{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "cli": { "schematicCollections": ["@schematics/angular", "@angular/material"] } // ... }Rationale
When this option is not configured and a user would like to run a schematic which is not part of
@schematics/angular,the collection name needs to be provided to
ng generatecommand in the form of[collection-name:schematic-name]. This make theng generatecommand too verbose for repeated usages.This is where
schematicCollectionscomes handle. When adding@angular/materialto the list ofschematicCollections, the generate command will try to locate the schematic in the specified collections.is equivalent to:
Conflicting schematic names
When multiple collections have a schematic with the same name. Both
ng generateandng newwill run the first schematic matched based on the ordering (as specified) ofschematicCollections.DEPRECATED:
The
defaultCollectionworkspace option has been deprecated in favor ofschematicCollections.Before
After
Closes #12157