Skip to content

feat(@angular/cli): add support for multiple schematics collections - #22860

Merged
dgp1130 merged 2 commits into
angular:masterfrom
alan-agius4:default-collection
Mar 22, 2022
Merged

dgp1130 merged 2 commits into
angular:masterfrom
alan-agius4:default-collection

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Mar 17, 2022 •

Copy link
Copy Markdown
Collaborator

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 .

{
  "$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

"defaultCollection": "@angular/material"

After

"schematicCollections": ["@angular/material"]

Closes #12157

@alan-agius4
alan-agius4 requested review from clydin and dgp1130 March 17, 2022 13:32
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release labels Mar 17, 2022
@alan-agius4
alan-agius4 marked this pull request as ready for review March 17, 2022 13:32
…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
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
@alan-agius4
alan-agius4 requested a review from clydin March 22, 2022 14:30
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 22, 2022
@dgp1130
dgp1130 merged commit 366cabc into angular:master Mar 22, 2022
@alan-agius4
alan-agius4 deleted the default-collection branch March 22, 2022 17:01
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
@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker flag: deprecation target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specify multiple default collections

3 participants