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

fix(info): Use version from latest dist-tag instead of the highest one #4797

Merged
merged 4 commits into from
Oct 31, 2017

Conversation

neonowy
Copy link
Contributor

@neonowy neonowy commented Oct 29, 2017

Summary

Fixes #3947. By default, package version was set by sorting all the versions and getting the highest one. Now it's provided via package latest dist-tag.

Test plan

Before:
yarn info ui-select | grep version: 
  version: '0.20.0',
After:
$ yarn info ui-select | grep version:
   version: '0.19.8',

I've also added a test case for it in __tests__/commands/info.js.
Although, I'm not sure if using a specific package like ui-select (from #3947) is a proper way to do it, because it'll break with the new release.

Could we add it to the __tests__/fixtures/request-cache/, so the package manifest won't change? Or do you have some other idea how can I write this test better?

@buildsize
Copy link

buildsize bot commented Oct 29, 2017

This change will decrease the build size from 9.94 MB to 9.94 MB, a decrease of 213 bytes (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 859.9 KB 859.84 KB -68 bytes (0%)
yarn-[version].js 3.78 MB 3.78 MB -31 bytes (0%)
yarn-legacy-[version].js 3.83 MB 3.83 MB -31 bytes (0%)
yarn-v[version].tar.gz 865.16 KB 865.15 KB -15 bytes (0%)
yarn_[version]all.deb 654.41 KB 654.35 KB -68 bytes (0%)

1 similar comment
@buildsize
Copy link

buildsize bot commented Oct 29, 2017

This change will decrease the build size from 9.94 MB to 9.94 MB, a decrease of 213 bytes (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 859.9 KB 859.84 KB -68 bytes (0%)
yarn-[version].js 3.78 MB 3.78 MB -31 bytes (0%)
yarn-legacy-[version].js 3.83 MB 3.83 MB -31 bytes (0%)
yarn-v[version].tar.gz 865.16 KB 865.15 KB -15 bytes (0%)
yarn_[version]all.deb 654.41 KB 654.35 KB -68 bytes (0%)

@rally25rs
Copy link
Contributor

I think we need to combine this with a fix for #3560 as well, otherwise info and add commands will select different versions.

@arcanis
Copy link
Member

arcanis commented Oct 30, 2017

@neonowy Great work, thanks! Can you check to add this logic to the install process as well?

As for the tests, the fixtures should get added to the folder after you run your tests. You then only have to add them to the commit, and it should be fine 👍

@rally25rs
Copy link
Contributor

@neonowy @arcanis - I'm working on the install half of this too. Getting some unit tests in place to reproduce the issue... Can hold off to see if I get it fixed on the install side. Might come in the form of a 2nd PR though...

@arcanis
Copy link
Member

arcanis commented Oct 30, 2017

Great, thanks! :)

@rally25rs
Copy link
Contributor

Pushed #4804 to tackle the add side of this.

@arcanis arcanis self-assigned this Oct 30, 2017
Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -72,7 +72,7 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
const versions = result.versions;
// $FlowFixMe
result.versions = Object.keys(versions).sort(semver.compareLoose);
result.version = version || result.versions[result.versions.length - 1];
result.version = version || result['dist-tags'].latest;
Copy link
Member

Choose a reason for hiding this comment

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

Are we always guaranteed to have dist-tags and ['dist-tags'].latest?

Copy link
Member

Choose a reason for hiding this comment

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

Who knows, it's entirely up to the npm server implementation :/ For now I think we can make this assumption, and revisit if needed.

@@ -72,7 +72,7 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
const versions = result.versions;
// $FlowFixMe
result.versions = Object.keys(versions).sort(semver.compareLoose);
result.version = version || result.versions[result.versions.length - 1];
result.version = version || result['dist-tags'].latest;
Copy link
Member

Choose a reason for hiding this comment

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

Who knows, it's entirely up to the npm server implementation :/ For now I think we can make this assumption, and revisit if needed.

@arcanis
Copy link
Member

arcanis commented Oct 31, 2017

@neonowy Can you rebase this PR? I tried to do it on my own, but Github denied me the permission to do so (have you unchecked the checkbox that gives us permission to update the PR?)

Fixes yarnpkg#3947. By default, package `version` was set by sorting all the versions and getting the highest
one. Now it's provided via package `latest` dist-tag.
@neonowy neonowy force-pushed the info-latest-version-tag branch from 4a3c0cf to 54cb658 Compare October 31, 2017 18:53
@neonowy
Copy link
Contributor Author

neonowy commented Oct 31, 2017

@arcanis Rebased! :shipit:

Sorry for the trouble with edit permission, apparently I've unchecked it when creating this PR.

@arcanis arcanis merged commit 262d7d8 into yarnpkg:master Oct 31, 2017
@arcanis
Copy link
Member

arcanis commented Oct 31, 2017

np, thanks!

calvinhuang pushed a commit to calvinhuang/yarn that referenced this pull request Nov 9, 2017
…one (yarnpkg#4797)

* fix(info): Use version from `latest` dist-tag instead of the highest one

Fixes yarnpkg#3947. By default, package `version` was set by sorting all the versions and getting the highest
one. Now it's provided via package `latest` dist-tag.

* Fix linter issues by shortening the test description

* Manually mock request

* Add scenario comment from yarnpkg#4804
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.

The version of ui-select package is wrong in yarn CLI
4 participants