-
-
Notifications
You must be signed in to change notification settings - Fork 252
feat(ui): add input to filter package versions by any semver range #1405
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
+523
−22
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| --- | ||
| title: Semver Ranges | ||
| description: Learn how to use semver ranges to filter package versions on npmx.dev | ||
| navigation: | ||
| icon: i-lucide-filter | ||
| --- | ||
|
|
||
| npm uses [semantic versioning](https://semver.org/) (semver) to manage package versions. A **semver range** is a string that describes a set of version numbers. On npmx, you can type a semver range into the version filter input on any package page to quickly find matching versions. | ||
|
|
||
| ## Version format | ||
|
|
||
| Every npm version follows the format **MAJOR.MINOR.PATCH**, for example `3.2.1`: | ||
|
|
||
| - **MAJOR** - incremented for breaking changes | ||
| - **MINOR** - incremented for new features (backwards-compatible) | ||
| - **PATCH** - incremented for bug fixes (backwards-compatible) | ||
|
|
||
| Some versions also include a **prerelease** tag, such as `4.0.0-beta.1`. | ||
|
|
||
| ## Common range syntax | ||
|
|
||
| | Range | Meaning | Example matches | | ||
| | ---------------- | ------------------------------------------------- | -------------------- | | ||
| | `*` | Any version | 0.0.2, 3.1.0, 3.2.6 | | ||
| | `^3.0.0` | Compatible with 3.x (same major) | 3.0.0, 3.1.0, 3.9.5 | | ||
| | `~3.2.0` | At least 3.2.0, same major.minor | 3.2.0, 3.2.1, 3.2.99 | | ||
| | `3.2.x` | At least 3.2.0, same major.minor | 3.2.0, 3.2.1, 3.2.99 | | ||
| | `>=2.0.0 <3.0.0` | At least 2.0.0 but below 3.0.0 | 2.0.0, 2.5.3, 2.99.0 | | ||
| | `1.2.3` | Exactly this version | 1.2.3 | | ||
| | `=1.2.3` | Exactly this version | 1.2.3 | | ||
| | `^0.3.1` | At least 0.3.1, same major.minor (0.x is special) | 0.3.1, 0.3.2 | | ||
| | `^0.0.4` | Exactly 0.0.4 (0.0.x is special) | 0.0.4 (only) | | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Find all 3.x versions | ||
|
|
||
| Type `^3.0.0` to see every version compatible with major version 3. | ||
|
|
||
| ### Find patch releases for a specific minor | ||
|
|
||
| Type `~2.4.0` to see only 2.4.x patch releases (2.4.0, 2.4.1, 2.4.2, etc.). | ||
|
|
||
| ### Find versions in a specific range | ||
|
|
||
| Type `>=1.0.0 <2.0.0` to see all 1.x stable releases. | ||
|
|
||
| ### Find a specific version | ||
|
|
||
| Type the exact version number, like `5.3.1`, to check if it exists. | ||
|
|
||
| ### Find prerelease versions | ||
|
|
||
| Type `>=3.0.0-alpha.0` to find alpha, beta, and release candidate versions for a major release. | ||
|
|
||
| ## Learn more | ||
|
|
||
| The full semver range specification is documented at [node-semver](https://github.com/npm/node-semver#ranges). |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid showing “No versions match” when the range is invalid.
Right now an invalid range triggers both the error message and the no‑matches banner, which is confusing. Gate the banner on a valid range (and, optionally, after full load).
Suggested fix
const hasNoFilterMatches = computed(() => { if (!isFilterActive.value) return false + if (isInvalidRange.value) return false return ( visibleTagRows.value.length === 0 && hiddenTagRows.value.length === 0 && filteredOtherMajorGroups.value.length === 0 ) })There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks fine, but open to thoughts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serhalp, totally understood! The double message could actually help some users understand that the filter just isn't working yet—I can see the logic there. Thanks for considering it! 🙂( o.o )
> ^