Skip to content

Regression on command line arguments parser #23397

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
1 of 15 tasks
JohannesHoppe opened this issue Jun 17, 2022 · 3 comments · Fixed by #23405
Closed
1 of 15 tasks

Regression on command line arguments parser #23397

JohannesHoppe opened this issue Jun 17, 2022 · 3 comments · Fixed by #23405
Assignees
Labels
area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix

Comments

@JohannesHoppe
Copy link
Contributor

JohannesHoppe commented Jun 17, 2022

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

This worked in v13 of the CLI

Description

We are working on updating our ng deploy schematic for Angular 14, unfortunately some command line arguments are no longer detected correctly. Arguments like noBuild, noSilent, noDotFiles no longer work, but buildTarget and dryRun do. I assume this is related with #22778 and the fact that Yargs supports --no-flags. In the past, the word no had no meaning, now it has one: https://github.com/yargs/yargs/blob/main/docs/tricks.md#negate

In Angular 13 i was able write no-build as an argument and it was used as it-is, but now this is interpreted as the negation of build – which is an unknown argument. This breaks a couple of builders that all share some code/ideas and use the same argument called no-build.

🔬 Minimal Reproduction

Please follow our README for contributors, which is essentially:

  1. Clone the project

    git clone https://github.com/angular-schule/angular-cli-ghpages.git
    cd angular-cli-ghpages
  2. Install the dependencies

    cd src
    npm install
  3. Build the project:

    npm run build
  4. Create a local npm link:

    cd dist
    npm link
  5. Go to a new folder and create a fresh angular project:

    ng new test
    cd test
  6. Add the local version of angular-cli-ghpages.

    npm link angular-cli-ghpages
  7. Now execute the ng-add schematic.

    ng add angular-cli-ghpages
  8. This will work, but will complain about a missing git configuration (which is fine here)

    ng deploy
    ng deploy --dry-run
  9. But this will NOT work, same for all other arguments with a "no" in the name

    ng deploy --no-build

🔥 Exception or Error

ng deploy --no-build
Error: Unknown argument: build

🌍 Your Environment

Angular CLI: 14.0.2
Node: 16.15.1
Package Manager: npm 8.11.0
OS: darwin arm64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1400.2
@angular-devkit/build-angular   14.0.2
@angular-devkit/core            14.0.2
@angular-devkit/schematics      14.0.2
@schematics/angular             14.0.2
rxjs                            7.5.5
typescript                      4.7.4
@alan-agius4
Copy link
Collaborator

Negation was always possible with boolean options even prior to version 14. This can also be seen in older versions of the docs https://v8.angular.io/cli#boolean-and-enumerated-options

In this case, the option was named noBuild and while it worked previously, the semantics of this seemed to be flawed as this option could also be negated --no-no-build.

The correct to define that option would be

"build": {
  "type": "boolean",
  "default": true,
  "description": "Build process during deployment."
 }

We could add a middleware to handle options which are defined with no. This would need some further discussions with the team to discuss if we'd want to issue a warning when using this behaviour.

@JohannesHoppe
Copy link
Contributor Author

From my point of view, this is a breaking change. Therefore, I would be happy if the old behaviour would be restored and a warning would be displayed. For the next version of Angular you could then drop this workaround.

alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jun 20, 2022
…d with `no`

With this commit we introduce an interm solution for options prefixed with `no` in `schema.json`

Previously, such options were handled as normal boolean option, but yargs handles options prefixed with `no` as negatations of the original option. Example with yargs, an option `noWatch` is will registered as `watch`.

Closes angular#23397
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jun 20, 2022
…d with `no`

With this commit we introduce an interim solution for options prefixed with `no` in `schema.json`

Previously, such options were handled as normal boolean option, but yargs handles options prefixed with `no` as negatations of the original option. Example with yargs, an option `noWatch` is will registered as `watch`.

Closes angular#23397
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jun 21, 2022
…xed with `no`

With this commit we introduce an interim solution for options prefixed with `no` in `schema.json`

Previously, such options were handled as normal boolean option, but yargs handles options prefixed with `no` as negatations of the original option. Example with yargs, an option `noWatch` is will registered as `watch`.

Closes angular#23397
dgp1130 pushed a commit that referenced this issue Jun 21, 2022
…xed with `no`

With this commit we introduce an interim solution for options prefixed with `no` in `schema.json`

Previously, such options were handled as normal boolean option, but yargs handles options prefixed with `no` as negatations of the original option. Example with yargs, an option `noWatch` is will registered as `watch`.

Closes #23397
dgp1130 pushed a commit that referenced this issue Jun 21, 2022
…xed with `no`

With this commit we introduce an interim solution for options prefixed with `no` in `schema.json`

Previously, such options were handled as normal boolean option, but yargs handles options prefixed with `no` as negatations of the original option. Example with yargs, an option `noWatch` is will registered as `watch`.

Closes #23397

(cherry picked from commit ba3f671)
@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 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
2 participants