Skip to content

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

Closed

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)

Activity

  1. alan-agius4 commented on Jun 22, 2022

    @alan-agius4
    Collaborator

    @jaschwartzkopf, your investigation looks good. Want to try to land a PR?

  2. added
    freq1: lowOnly reported by a handful of users who observe it rarely
    good first issueLabel noting a good first issue to be worked on by a community member
    and removed
    good first issueLabel noting a good first issue to be worked on by a community member
    on Jun 22, 2022
  3. self-assigned this
    on Jun 27, 2022
  4. added a commit that references this issue on Jun 27, 2022
    6c333e2
  5. added 2 commits that reference this issue on Jun 27, 2022
    5a012b5
    fc72c62
  6. Lipata commented on Jun 30, 2022

    @Lipata

    Hi, @alan-agius4. This is now working, thank you for the fix! Still I think there is similar problem with the ng g command:

    "ng g @custom-schematics:schematic-name --custom-schematic-property=value" is throwing

    Error: Unknown arguments: custom-schematic-property

  7. alan-agius4 commented on Jun 30, 2022

    @alan-agius4
    Collaborator

    @Lipata, that seems to be an unrelated issued.

    Please open a new issue with a minimal reproduction.

    Thanks.

  8. angular-automatic-lock-bot commented on Jul 31, 2022

    @angular-automatic-lock-bot

    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.

  9. locked and limited conversation to collaborators on Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions