Visitar URL original
Custom builders: Can no longer use an option called "target" with "enum" restriction · Issue #24511 · angular/angular-cli · GitHub
The Wayback Machine - https://web.archive.org/web/20230313044706/https://github.com/angular/angular-cli/issues/24511
Skip to content
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

Custom builders: Can no longer use an option called "target" with "enum" restriction #24511

Open
1 task done
fischeversenker opened this issue Jan 10, 2023 · 1 comment
Open
1 task done
Labels
area: angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix

Comments

@fischeversenker
Copy link
Contributor

fischeversenker commented Jan 10, 2023 •

Command

other

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

13.3.9

Description

When writing custom Angular builders I was able to specify a builder option with the name target that used the enum property in the builder's schema.json file. Starting with Angular 14 this changed. Now, I can still specify an option with this name in my builder's schema, but it must not have an enum property. Otherwise, the builder fails in what seems to be the yargs validation in the angular-cli's command-runner. Note that there is also other unexpected behavior when using a type of boolean for the target option, which throws a seemingly unrelated error.

I wasn't able to find anything regarding this in the changelog of angular or angular-cli, so it seems like it's an accidental breaking change. Instead of renaming the option in our builder(s), we figured out that it's enough to just remove the enum property from the schema.json, but eventually, it would be nice to be able to use enum again.

Minimal Reproduction

I prepared a reproduction repository here. Follow the "Quick start" section in the README.md file to reproduce the error locally.

Exception or Error

No response

Your Environment

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

Angular CLI: 14.2.10
Node: 18.12.1 (Unsupported)
Package Manager: npm 8.19.2 
OS: linux x64

Angular: 14.2.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.10
@angular-devkit/build-angular   14.2.10
@angular-devkit/core            14.2.10
@angular-devkit/schematics      14.2.10
@angular/cli                    14.2.10
@schematics/angular             14.2.10
rxjs                            7.5.7
typescript                      4.7.4

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jan 10, 2023 •

What is happening here is the the builder target option is conflict with the ng run target option.

https://github.com/angular/angular-cli/blob/59652c3f2b70d02f6ee4c87c777c9fa87d33bae0/packages/angular/cli/src/commands/run/cli.ts#L40:L47

Possible resolutions:

  • From your end
    • Change the builder option not to conflict with the built in option.
  • From our end
    • Rename the CLI target option to something else.
    • Error or warn if an option in a builder conflicts with a built in option.

@alan-agius4 alan-agius4 added area: angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix labels Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

No branches or pull requests

2 participants