Commit 1d976f8
Fix two version-comparison bugs in
Bug 1: alpha.10 < alpha.2
compareVersions used String#localeCompare on the full prerelease
string, so "alpha.10" sorts before "alpha.2" alphabetically. SemVer
2.0.0 specifies dot-separated identifiers, with numeric ones compared
numerically. Adds a comparePrerelease helper that splits on "." and
applies the SemVer rules:
- all-digit identifiers compared numerically
- mixed/letter identifiers compared lexically
- numeric identifiers always have lower precedence than non-numeric
- longer-prefix-matching set wins
Bug 2: fetchLatestRelease relied on GitHub's created_at order
GitHub returns /releases sorted by created_at desc, which usually
matches version order — but a hot-fix tag pushed after a newer
release inverts that. Now sorts the filtered cli-v* list by version
(highest first) using the now-correct compareVersions, so the latest
is always the highest version regardless of publication order.
Verified with a 9-case matrix covering: alpha.10 vs alpha.2 both
directions, equality, release vs prerelease both directions, minor
bumps, alpha vs beta vs rc, and longer-prefix prereleases. typecheck
and build are clean.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>cryptohopper upgrade (#7)1 parent bc2bc9b commit 1d976f8
1 file changed
Lines changed: 44 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
52 | | - | |
| 57 | + | |
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
| |||
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
67 | | - | |
| 72 | + | |
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
74 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
0 commit comments