Skip to content

ng update does not check package.json versions #17599

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 task done
dgp1130 opened this issue May 2, 2020 · 3 comments
Closed
1 task done

ng update does not check package.json versions #17599

dgp1130 opened this issue May 2, 2020 · 3 comments
Milestone

Comments

@dgp1130
Copy link
Collaborator

dgp1130 commented May 2, 2020

🐞 Bug report

Command

  • update

Is this a regression?

Dunno.

Description

When ng update checks for the current version of packages, I believe it uses the version installed in node_modules/ and ignores the text in package.json. This can cause missed updates in circumstances where a user updates a package, resets the update via VCS, then re-runs the update. Since node_modules/ is not cleared, the subsequent ng update run believes the package was already updated. Deleting node_modules/ appears to fix the problem (though I have to run with ng update --all or else I hit some peer dep issues, but I think that's a separate problem).

🔬 Minimal Reproduction

Fortunately I still have the logs from my terminal (with some inline comments about my reasonsing):

Migration log
# Wanted to update, so I run `ng update`.

douglasparker@basilisk (~/Source/Chatter)
[20-05-01 16:43:19]$ (cd services/ng-frontend/ && ng update)
Your global Angular CLI version (9.1.0-rc.0) is greater than your local
version (9.0.0-rc.10). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
The installed Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 33 dependencies.
    We analyzed your package.json, there are some packages to update:
    
      Name                               Version                  Command to update
     --------------------------------------------------------------------------------
      @angular/cdk                       8.2.3 -> 9.2.2           ng update @angular/cdk
      @angular/cli                       9.0.0-rc.10 -> 9.1.4     ng update @angular/cli
      @angular/core                      9.0.0-rc.9 -> 9.1.4      ng update @angular/core
      @angular/material                  8.2.3 -> 9.2.2           ng update @angular/material
      rxjs                               6.5.4 -> 6.5.5           ng update rxjs

# I realize I need to provide specific packages.
# In the past I just did `@angular/core` and `@angular/cli`,
# so I'll do that without thinking about it too hard.

douglasparker@basilisk (~/Source/Chatter)
[20-05-01 16:43:56]$ (cd services/ng-frontend/ && ng update @angular/core @angular/cli)
Your global Angular CLI version (9.1.0-rc.0) is greater than your local
version (9.0.0-rc.10). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
The installed Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 33 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/cli @ "9.1.4" (was "9.0.0-rc.10")...
    Updating package.json with dependency @angular/core @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular-devkit/build-angular @ "0.901.4" (was "0.900.0-rc.10")...
    Updating package.json with dependency @angular/language-service @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular/common @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular/forms @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular/compiler-cli @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular/platform-browser @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular/compiler @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency zone.js @ "0.10.3" (was "0.10.2")...
    Updating package.json with dependency @angular/animations @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "9.1.4" (was "9.0.0-rc.9")...
    Updating package.json with dependency @angular/router @ "9.1.4" (was "9.0.0-rc.9")...
UPDATE package.json (1575 bytes)
✔ Packages installed successfully.
** Executing migrations of package '@angular/cli' **

▸ Replace deprecated 'styleext' and 'spec' Angular schematic options.
  Migration completed.

# Looking at `package.json`, I realized some other packages weren't updated.
# Decide that I should update them as well.

douglasparker@basilisk (~/Source/Chatter)
[20-05-01 16:45:06]$ (cd services/ng-frontend/ && ng update @angular/material @angular/cdk rxjs)
Repository is not clean. Please commit or stash any changes before updating.

# There's probably a `--run-even-though-repo-is-dirty` flag, but I'm too lazy to find it.
# I'll just revert everything and re-update.

douglasparker@basilisk (~/Source/Chatter)
[20-05-01 16:45:36]$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   services/ng-frontend/package-lock.json
        modified:   services/ng-frontend/package.json

no changes added to commit (use "git add" and/or "git commit -a")
douglasparker@basilisk (~/Source/Chatter)
[20-05-01 16:45:42]$ git restore .

# Update everything again.

douglasparker@basilisk (~/Source/Chatter)
[20-05-01 16:45:48]$ (cd services/ng-frontend/ && ng update @angular/core @angular/cli @angular/material @angular/cdk rxjs)
Using package manager: 'npm'
Collecting installed dependencies...
Found 33 dependencies.
Fetching dependency metadata from registry...
Package '@angular/core' is already up to date.  # <--- Wrong.
Package '@angular/cli' is already up to date.  # <--- Wrong.
    Updating package.json with dependency @angular/cdk @ "9.2.2" (was "8.2.3")...
    Updating package.json with dependency @angular/material @ "9.2.2" (was "8.2.3")...
    Updating package.json with dependency rxjs @ "6.5.5" (was "6.5.4")...
UPDATE package.json (1637 bytes)
✔ Packages installed successfully.
** Executing migrations of package '@angular/cdk' **

▸ Updates the Angular CDK to v9
    
      ✓  Updated Angular CDK to version 9
    
  Migration completed.

** Executing migrations of package '@angular/material' **

▸ Updates Angular Material to v9
    
    ⚠  General notice: The HammerJS v9 migration for Angular Components is not able to migrate tests. Please manually clean up tests in your project if they rely on HammerJS.
    Read more about migrating tests: https://git.io/ng-material-v9-hammer-migrate-tests
    
      ✓  Updated Angular Material to version 9
    
UPDATE src/app/app.module.ts (681 bytes)
UPDATE src/main.ts (373 bytes)
UPDATE src/app/app.component.spec.ts (964 bytes)
UPDATE package.json (1611 bytes)
✔ Packages installed successfully.
  Migration completed.

# I noticed that @angular/core and @angular/cli are not updated in package.json.
# It seems that they are considered already up-to-date due to the previous update attempt.
@dgp1130 dgp1130 added this to the Backlog milestone May 2, 2020
@ngbot ngbot bot modified the milestones: Backlog, needsTriage May 2, 2020
dgp1130 added a commit to dgp1130/chatter that referenced this issue May 2, 2020
I'm hoping this will address some of the security warnings issued by GitHub.

Generated this commit by running:
$ (cd services/ng-frontend/ && ng update --all)

This actually took a couple attempts, due to a bug in the CLI. Filed angular/angular-cli#17599 to look into it further.
@alan-agius4
Copy link
Collaborator

I am not sure if this was by design or an oversight. @clydin would know more. I do believe that we should check the package.json as well.

To re-run the migration you don’t need to delete the node_modules. You can use the —migrate-only option, without the need to delete node_modules.

Example

ng update @angular/cli —-migrate-only —-from=8 —-to=9

@alan-agius4
Copy link
Collaborator

Duplicate of #16020

@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 Jun 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants