feat: Add support for prerelease tags (i.e. beta, alpha, etc) while maintaining explicit tag support & default of ‘latest’#22
Open
ghost wants to merge 1 commit intobeshanoe:masterfrom
Open
Conversation
…aintaining explicit tag support & default of ‘latest’
Owner
|
hey @stevekanter for some reason I missed the notification for your PR :( Great job! I'll take a look soon |
beshanoe
reviewed
Jun 29, 2023
|
|
||
| if (!tag) { | ||
| // Get the minimum version for the package using semver (e.g. ^1.0.0 -> 1.0.0) | ||
| const minVersionForPackageSemver = semver.minVersion(version); |
Owner
There was a problem hiding this comment.
let's wrap it in trycatch cause some packages might not use semver and this call throws in such cases
beshanoe
reviewed
Jun 29, 2023
| const minVersionForPackageSemver = semver.minVersion(version); | ||
|
|
||
| // If a prerelease tag was found, use it as the tag | ||
| if (minVersionForPackageSemver && typeof minVersionForPackageSemver.prerelease[0] === 'string') { |
Owner
There was a problem hiding this comment.
I think it can be simplified using ?.
typeof minVersionForPackageSemver?.prerelease?.[0] === 'string'
Owner
|
Good job @stevekanter ! Left some comments. One think to note is that the word found in the version doesn't necessarily corresponds to tag, but it most cases it does. But I guess it's pretty safe to assume so |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I often have beta or alpha packages installed in my projects and using update-by-scope til now has wiped those out. This will allow any prerelease tag that already existed in my package.json to be respected while maintaining full backwards compatibility and support for existing explicit tag overrides.