Skip to content

ng new ignores --collection for checking schematic options #23414

@jaschwartzkopf

Description

@jaschwartzkopf

🐞 Bug report

Command (mark with an x)

  • [x ] new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, before you could use --collection to run a custom schematic for ng new.

Description

The schematic in --collection is ran, but options are based on @schematics/angular:ng-new instead of --colleciton.

The issue is how collectionNameFromArgs is extracted from the options:
https://github.com/angular/angular-cli/blob/main/packages/angular/cli/src/commands/new/cli.ts#L48

const {
      options: { collectionNameFromArgs },
    } = this.context.args;

If this line is changed to:

const {
      options: { collection: collectionNameFromArgs },
    } = this.context.args;

The options from --collection are used correctly.

🔬 Minimal Reproduction

Try to use ng new --collection with a collection that has arguments not in @schematics/angular:ng-new

🔥 Exception or Error

Only options for @shematics/angular:ng-new are recognized.

Error: Unknown arguments: ngrx, mock-api, snap-oauth, mock-oauth

🌍 Your Environment




```
$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 14.0.1
Node: 16.13.1
Package Manager: yarn 1.22.17
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1400.1 (cli-only)
@angular-devkit/core         14.0.1 (cli-only)
@angular-devkit/schematics   14.0.1 (cli-only)
@schematics/angular          14.0.1 (cli-only)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions