Respect dependency ranges on Package page #117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to subissue mentioned in #115.
Currently, dependency links use the first version listed in the range. However, this can be a nonexistent version (while still being a valid range). For example, if something depends on evaera/promise
>=3.0.0 <4.0.0
the package only has3.1.0
,3.2.0
,3.2.1
, &4.0.0
versions published, so three of those versions match the range but the first version listed in the range itself actually does not exist, and was therefore leading to an invalid version page.This PR remedies that problem by utilizing npm's node-semver package to actually parse and utilize the dependency range to find the best matching version from the existing versions. In the above example, it would give us
3.2.1
. (Note: adding a new package, semver, requires me to update the package-lock file. Since it was very out of date and an old format, the diff is large but the only "real" change is adding semver as a dependency.)Before:
After: