Skip to content

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

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

Closed
14 tasks
jaschwartzkopf opened this issue Jun 22, 2022 · 4 comments · Fixed by #23440
Closed
14 tasks

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

jaschwartzkopf opened this issue Jun 22, 2022 · 4 comments · Fixed by #23440
Assignees
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix

Comments

@jaschwartzkopf
Copy link

🐞 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)

@alan-agius4
Copy link
Collaborator

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

@alan-agius4 alan-agius4 self-assigned this Jun 27, 2022
@alan-agius4 alan-agius4 added the 2022Q3 Fixit Candidates for the Q3 2022 fix-it label Jun 27, 2022
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jun 27, 2022
Previously, this option was ignored due to an incorrect deconstruction.

Closes angular#23414
clydin pushed a commit that referenced this issue Jun 27, 2022
Previously, this option was ignored due to an incorrect deconstruction.

Closes #23414
clydin pushed a commit that referenced this issue Jun 27, 2022
Previously, this option was ignored due to an incorrect deconstruction.

Closes #23414

(cherry picked from commit 5a012b5)
@Lipata
Copy link

Lipata commented Jun 30, 2022

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

@alan-agius4
Copy link
Collaborator

@Lipata, that seems to be an unrelated issued.

Please open a new issue with a minimal reproduction.

Thanks.

@angular-automatic-lock-bot
Copy link

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 Jul 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants