Commit f5f052d
Fix doctor command false version mismatch for beta/prerelease versions
Fixes #2063
## Problem
The doctor command incorrectly reported version mismatches for beta/alpha/rc
versions even when gem and NPM package versions were identical. For example:
- Gem: 16.2.0.beta.10
- NPM: 16.2.0-beta.10
Would trigger a false "version mismatch" warning.
## Root Cause
The original code (from PR #1787) stripped all non-numeric/non-dot characters
from the NPM version for comparison:
```ruby
clean_npm_version = npm_version.gsub(/[^0-9.]/, "") # "16.2.0-beta.10" → "16.2.0.10"
gem_version = ReactOnRails::VERSION # "16.2.0.beta.10"
```
This removed both the dash AND "beta", turning "16.2.0-beta.10" into "16.2.0.10",
which would never match "16.2.0.beta.10".
Note: CodeRabbit caught this bug during the original PR review but the
suggestion was not implemented.
## Solution
Use the existing VersionSyntaxConverter.npm_to_rubygem utility which properly
converts NPM semver format (dash separator) to Ruby gem format (dot separator):
- "16.2.0-beta.10" → "16.2.0.beta.10"
- "^16.2.0-beta.10" → "16.2.0.beta.10"
- Handles all prerelease formats: beta, alpha, rc, pre
## Testing
Verified with test app using both gem and NPM at 16.2.0.beta.10:
- ✅ Matching versions: No false warning
- ✅ Caret/tilde prefixes: Handled correctly
- ✅ Real mismatches: Still detected properly
- ✅ All edge cases: 16/16 test scenarios pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent beb70f0 commit f5f052d
1 file changed
+7
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | | - | |
| 223 | + | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
226 | | - | |
| 229 | + | |
227 | 230 | | |
228 | 231 | | |
229 | 232 | | |
| |||
0 commit comments