Commit 463a31f
Fix beta/RC version handling in generator (#2066)
## Summary
Fixes version mismatch errors when using beta, RC, or alpha versions of
react_on_rails by updating the version detection regex in the generator.
## Problem
When running the generator with a pre-release version (e.g.,
`16.2.0-beta.10`), the version check regex only matched stable versions
like `16.2.0`. This caused the generator to install `react-on-rails`
(latest stable from npm) instead of `[email protected]`,
leading to version mismatch errors:
```
Package: 16.1.2 (latest stable from npm)
Gem: 16.2.0.beta.10 (current beta version)
```
## Root Cause
In `lib/generators/react_on_rails/js_dependency_manager.rb`, the regex
was:
```ruby
major_minor_patch_only = /\A\d+\.\d+\.\d+\z/
```
This only matched stable versions (e.g., `16.2.0`) and rejected
pre-release versions (e.g., `16.2.0-beta.10`).
When the regex didn't match, the code would install `"react-on-rails"`
without a version specifier, which installs the latest stable version
from npm instead of the beta version.
## Solution
Updated the regex to also match pre-release versions:
```ruby
version_with_optional_prerelease = /\A\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?\z/
```
This now matches:
- ✅ Stable: `16.2.0`
- ✅ Beta: `16.2.0-beta.10`
- ✅ RC: `16.1.0-rc.1`
- ✅ Alpha: `16.0.0-alpha.5`
- ✅ Complex pre-releases: `1.2.3-pre.release.1`
## Changes
- Updated regex to include optional pre-release identifier:
`(-[a-zA-Z0-9.]+)?`
- Improved comments explaining what versions are matched and why
- Enhanced warning message when version format is unrecognized
## Testing
Verified the regex matches all expected version formats:
- Stable versions: `16.2.0`, `16.1.2`
- Beta versions: `16.2.0-beta.10`
- RC versions: `16.1.0-rc.1`
- Alpha versions: `16.0.0-alpha.5`
- Invalid formats correctly rejected: `invalid`, `16.2`, `16.2.0.1`
## Impact
This fix ensures that:
- Beta/RC versions work correctly during development and CI
- The exact gem version matches the exact npm package version
- No more version mismatch errors when using pre-release versions
- Example generation in CI passes with beta versions
## Related
This fixes the CI failure shown in the error log where shakapacker
examples failed with version mismatch errors during beta releases.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added an alias command (/run-skipped-tests) that triggers the same
test run behavior as /run-skipped-ci.
* **Bug Fixes**
* Enhanced version parsing so pre-release react-on-rails versions
(alpha, beta, rc) are recognized and pinned correctly; clearer warning
for unrecognized formats.
* **Documentation**
* Updated docs and CI help/examples to include the new alias and clarify
usage.
* **Tests**
* Expanded tests to cover pre-release version handling and
invalid-version warnings.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude <[email protected]>1 parent ac0d175 commit 463a31f
File tree
3 files changed
+83
-8
lines changed- analysis
- lib/generators/react_on_rails
- spec/react_on_rails/generators
3 files changed
+83
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| 105 | + | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
| |||
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
| 120 | + | |
115 | 121 | | |
116 | 122 | | |
117 | 123 | | |
| |||
120 | 126 | | |
121 | 127 | | |
122 | 128 | | |
| 129 | + | |
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
| |||
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
| 138 | + | |
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
132 | 153 | | |
133 | | - | |
| 154 | + | |
| 155 | + | |
134 | 156 | | |
135 | 157 | | |
136 | 158 | | |
| |||
Lines changed: 46 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
214 | 250 | | |
215 | 251 | | |
216 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
217 | 262 | | |
218 | 263 | | |
219 | 264 | | |
| |||
0 commit comments