Skip to content

Upgrade transient deps during upgrades. #4636

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

Merged
merged 7 commits into from
Oct 11, 2017

Conversation

rally25rs
Copy link
Contributor

Summary

Fixes #4476

Due to the changes made to upgrade for v1, we inadvertently stopped upgrading transient dependencies.

This happend for 2 reasons:

  • because the existing lockfile is left in-place, so transient deps were already at a locked version
  • only direct dependencies that were actually out of date were upgraded (for performance reasons)

This change will now clear dependencies to be upgraded, recursively, from the lockfile. This lets transient deps get upgrade as well. In the case that all packages are being upgraded, the lockfile is just removed and rebuilt.

I also found a bug in upgrade in yarn v1.0 and fixed that while in here...

in Yarn v1.0 if you yarn upgrade some-package then it will possibly upgrade some-package if there is a new version, but the transient deps underneath some-package would not be upgraded (because of the entries in the lockfile, mentioned above). With this update those transient deps will be upgraded.

Test plan

Added 2 additional unit tests that check transient deps.

@buildsize
Copy link

buildsize bot commented Oct 5, 2017

This change will increase the build size from 9.92 MB to 9.93 MB, an increase of 8.17 KB (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 858.23 KB 858.9 KB 678 bytes (0%)
yarn-[version].js 3.78 MB 3.78 MB 3.14 KB (0%)
yarn-legacy-[version].js 3.83 MB 3.83 MB 3.24 KB (0%)
yarn-v[version].tar.gz 863.97 KB 864.63 KB 674 bytes (0%)
yarn_[version]all.deb 653.25 KB 653.72 KB 478 bytes (0%)

@@ -31,6 +31,11 @@ const expectInstalledDevDependency = async (config, name, range, expectedVersion
await _expectDependency('devDependencies', config, name, range, expectedVersion);
};

const expectInstalledTransientDependency = async (config, name, range, expectedVersion) => {
Copy link
Contributor

@bdwain bdwain Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think transient is not the right word here. It should be transitive. same goes for other usages of transient in the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoopsies 😆 thanks for noticing that.

@bdwain
Copy link
Contributor

bdwain commented Oct 5, 2017

I'm running this locally and it seems to ignore my .yarnrc file in my project. it Points to an internal registry, but yarn upgrade --verbose logs calls to registry.yarnpkg.com. I'm not sure if it's related to running locally or not, but yarn install did not have the same issue.

overall though it looks like it works. Thanks!

@rally25rs
Copy link
Contributor Author

@bdwain is this .yarnrc registry thing a new error in this PR, or did it not work in v1.0 either? I'll try to set something up here to reproduce the error...

@rally25rs
Copy link
Contributor Author

rally25rs commented Oct 5, 2017

Hmm, OK so yeah I see the same error as @bdwain if I have a registry "http://localhost:4873/" set in my .yarnrc

With Yarn v1.0:

$ yarn upgrade --verbose
...
verbose 0.401 Performing "GET" request to "http://localhost:4873/strip-ansi".
verbose 0.402 Performing "GET" request to "http://localhost:4873/array-union".
verbose 0.485 Request "http://localhost:4873/array-union" finished with status code 200.
verbose 0.49 Request "http://localhost:4873/strip-ansi" finished with status code 200.
[1/4] 🔍  Resolving packages...
...

With this PR:

$ yarn upgrade --verbose
...
verbose 0.752 Performing "GET" request to "https://registry.yarnpkg.com/strip-ansi".
verbose 0.753 Performing "GET" request to "https://registry.yarnpkg.com/array-union".
verbose 0.878 Request "https://registry.yarnpkg.com/array-union" finished with status code 200.
verbose 0.88 Request "https://registry.yarnpkg.com/strip-ansi" finished with status code 200.
...

that's very weird. I have no clue what I would have changed that would have affected that. Well, I'll start digging in...


edit:

This is broken in master, not by my PR changes. I merged master into this branch before PR'ing it to resolve some conflicts. I'll raise the concern in the development Slack channel ☎️

edit2:

Tracked the registry error that @bdwain reported to #4238

@arcanis
Copy link
Member

arcanis commented Oct 5, 2017

This change will now clear dependencies to be upgraded, recursively, from the lockfile.

I'm not convinced this is the right behavior. Let's say with have:

If I run yarn update A, I don't expect B to also be updated to 1.0.1.

@arcanis arcanis self-assigned this Oct 5, 2017
@rally25rs
Copy link
Contributor Author

@arcanis hmm, interesting case. Maybe direct dependencies get excluded from that recursion?

@rally25rs
Copy link
Contributor Author

@arcanis I added a test for the case you mentioned. (also fixed merge conflicts and added some verbose logging to the upgrade process)

@arcanis
Copy link
Member

arcanis commented Oct 10, 2017

Thanks @rally25rs! I just merged #4654 which should ship with fixes to a few commands that include upgrade and upgrade-interactive, do you mind rebasing and checking if it makes your tests pass as well?

@voxpelli
Copy link
Contributor

Tried this PR on a larger project of mine and it correctly produced the same yarn.lock that was produced by removing the yarn.lock and starting over from scratch. 👌 Thanks!

@rally25rs
Copy link
Contributor Author

@voxpelli Thank you for taking the time to try this out!

@arcanis Merged master and resolved conflicts.

@arcanis
Copy link
Member

arcanis commented Oct 11, 2017

Thank you both!

@arcanis arcanis merged commit 5e564c6 into yarnpkg:master Oct 11, 2017
@bdwain
Copy link
Contributor

bdwain commented Oct 13, 2017

thanks again!

joaolucasl pushed a commit to joaolucasl/yarn that referenced this pull request Oct 27, 2017
* [yarnpkg#4476] Upgrade transient deps during upgrades.

* Rename 'transient' to 'transitive'

* dont upgrade direct deps unless requested, add verbose upgrade logging

* upgrade-interactive reuse lockfile cleaning from upgrade.js
@vkrol
Copy link
Contributor

vkrol commented Nov 5, 2017

@rally25rs if I run the upgrade command with the latest flag (for example yarn upgrade package-name --latest) then the transitive dependencies won’t be upgraded. I think that it is the wrong behavior. What do you think about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yarn Upgrade not changing yarn.lock since v1.0
5 participants