-
-
Notifications
You must be signed in to change notification settings - Fork 349
fix: fix tag issue and sort tagged versions #2105
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,38 @@ export function getPrereleaseChannel(version: string): string { | |
| return match ? match[1]!.toLowerCase() : '' | ||
| } | ||
|
|
||
| /** | ||
| * Priority order for well-known dist-tags. | ||
| * Lower number = higher priority in display order. | ||
| * Unknown tags fall back to Infinity and are sorted by publish date descending. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was reading through the code and wondering how it's possible that "latest" is not a well-known tag. It might be worth having a comment here explaining that it's handled manually elsewhere :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nice point, thanks for bringing it up! I reconsidered |
||
| */ | ||
| export const TAG_PRIORITY: Record<string, number> = { | ||
| latest: 0, | ||
| stable: 1, | ||
| rc: 2, | ||
| beta: 3, | ||
| next: 4, | ||
| alpha: 5, | ||
| canary: 6, | ||
| nightly: 7, | ||
| experimental: 8, | ||
| legacy: 9, | ||
| } | ||
|
|
||
| /** | ||
| * Get the display priority for a dist-tag. | ||
| * Uses fuzzy matching so e.g. "v2-legacy" matches "legacy". | ||
| * @param tag - The tag name (e.g., "beta", "v2-legacy") | ||
| * @returns Numeric priority (lower = higher priority); Infinity for unknown tags | ||
| */ | ||
| export function getTagPriority(tag: string | undefined): number { | ||
| if (!tag) return Infinity | ||
| for (const [key, priority] of Object.entries(TAG_PRIORITY)) { | ||
| if (tag.toLowerCase().includes(key)) return priority | ||
| } | ||
| return Infinity | ||
| } | ||
|
|
||
| /** | ||
| * Sort tags with 'latest' first, then alphabetically | ||
| * @param tags - Array of tag names | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.