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

v12 ng update fixes #22223

Merged
merged 3 commits into from
Nov 24, 2021
Merged

v12 ng update fixes #22223

merged 3 commits into from
Nov 24, 2021

Conversation

alan-agius4
Copy link
Collaborator

Back-porting of #22033, #21986 and #22200

@alan-agius4 alan-agius4 added the target: lts This PR is targeting a version currently in long-term support label Nov 24, 2021
@google-cla google-cla bot added the cla: yes label Nov 24, 2021
With #21986 we now error when updating `@angular/` and `@nguniversal/` packages across multiple major versions. With this change we update `ng update` output to show the correct instructions.

Before
```
$ ng update --next

 We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cli                       12.2.12 -> 13.0.0-rc.2   ng update @angular/cli --next
      @angular/core                      11.2.14 -> 13.0.0-rc.2   ng update @angular/core --next
```

Now
```
$ ng update --next

 We analyzed your package.json, there are some packages to update:

      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cli                       12.2.12 -> 13.0.0-rc.2   ng update @angular/cli --next
      @angular/core                      11.2.14 -> 12.2.9        ng update @angular/core@12
```

Closes #19381

(cherry picked from commit 9b32066)
…major migrations

With this change we show an error message when users try to update `@angular/` and `@nguniversal/` packages across multiple major versions.

(cherry picked from commit d60d374)
@alan-agius4 alan-agius4 marked this pull request as ready for review November 24, 2021 11:43
@alan-agius4 alan-agius4 requested a review from clydin November 24, 2021 12:17
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Nov 24, 2021
…LI is to be download during `ng update`

Previously, when using an older version of the Angular CLI, during `ng update`, we download the temporary `latest` version to run the update. The ensured that when running that the runner used to run the update contains the latest bug fixes and improvements.

This however, can be problematic in some cases. Such as when there are API breaking changes, when running a relatively old schematic with the latest CLI can cause runtime issues, especially since those schematics were never meant to be executed on a CLI X major versions in the future.

With this change, we improve the logic to determine which version of the Angular CLI should be used to run the update.

Below is a summarization of this.

- When using the `--next` command line argument, the `@next` version of the CLI will be used to run the update.
- When updating an `@angular/` or `@nguniversal/` package, the target version will be used to run the update. Example: `ng update @angular/core@12`,  the update will run on most recent patch version of `@angular/cli` of that major version `@12.2.6`.
- When updating an `@angular/` or `@nguniversal/` and no target version is specified. Example: `ng update @angular/core` the update will run on most latest version of the `@angular/cli`.
- When updating a third-party package, the most recent patch version of the installed `@angular/cli` will be used to run the update. Example if `13.0.0` is installed and `13.1.1` is available on NPM, the latter will be used.

(cherry picked from commit 4632f1f)
@alan-agius4 alan-agius4 merged commit e07bd05 into angular:12.2.x Nov 24, 2021
@alan-agius4 alan-agius4 deleted the update-fixes-back-port branch November 24, 2021 16:11
@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 Dec 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: lts This PR is targeting a version currently in long-term support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants