Skip to content

Commit de05f09

Browse files
justin808claude
andcommitted
fix: Clean up error messages and update CHANGELOG
Address code review feedback: - Update CHANGELOG.md placeholder with PR #2051 - Simplify error warning messages - remove misleading comments about shakapacker dependency since failures can occur for multiple reasons (network errors, permissions, etc.) - Remove redundant puts statement in add_package rescue block since calling methods already add appropriate warnings These changes improve code clarity and user-facing error messages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3d89001 commit de05f09

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Changes since the last non-beta release.
5757

5858
- **Generator Configuration Modernization**: Updated the generator to enable recommended configurations by default for new applications. `config.build_test_command` is now uncommented and set to `"RAILS_ENV=test bin/shakapacker"` by default, enabling automatic asset building during tests for better integration test reliability. `config.auto_load_bundle = true` is now set by default, enabling automatic loading of component bundles. `config.components_subdirectory = "ror_components"` is now set by default, organizing React components in a dedicated subdirectory. **Note:** These changes only affect newly generated applications. Existing applications are unaffected and do not need to make any changes. If you want to adopt these settings in an existing app, you can manually add them to your `config/initializers/react_on_rails.rb` file. [PR 2039](https://github.com/shakacode/react_on_rails/pull/2039) by [justin808](https://github.com/justin808).
5959

60-
- **Removed Babel Dependency Installation**: The generator no longer installs `@babel/preset-react` or `@babel/preset-typescript` packages. Shakapacker handles JavaScript transpiler configuration (Babel, SWC, or esbuild) via the `javascript_transpiler` setting in `shakapacker.yml`. SWC is now the default transpiler and includes built-in support for React and TypeScript. Users who explicitly choose Babel will need to manually install and configure the required presets. This change reduces unnecessary dependencies and aligns with Shakapacker's modular transpiler approach. [PR <PLACEHOLDER>](https://github.com/shakacode/react_on_rails/pull/<PLACEHOLDER>) by [justin808](https://github.com/justin808).
60+
- **Removed Babel Dependency Installation**: The generator no longer installs `@babel/preset-react` or `@babel/preset-typescript` packages. Shakapacker handles JavaScript transpiler configuration (Babel, SWC, or esbuild) via the `javascript_transpiler` setting in `shakapacker.yml`. SWC is now the default transpiler and includes built-in support for React and TypeScript. Users who explicitly choose Babel will need to manually install and configure the required presets. This change reduces unnecessary dependencies and aligns with Shakapacker's modular transpiler approach. [PR 2051](https://github.com/shakacode/react_on_rails/pull/2051) by [justin808](https://github.com/justin808).
6161

6262
#### Documentation
6363

lib/generators/react_on_rails/js_dependency_manager.rb

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,9 @@ def add_react_on_rails_package
132132
puts "Installing React on Rails package..."
133133
return if add_package(react_on_rails_pkg)
134134

135-
# This should not happen since package_json is always available via shakapacker
136135
GeneratorMessages.add_warning(<<~MSG.strip)
137-
⚠️ Failed to add react-on-rails package via package_json gem.
136+
⚠️ Failed to add react-on-rails package.
138137
139-
This indicates shakapacker dependency may not be properly installed.
140138
You can install it manually by running:
141139
npm install #{react_on_rails_pkg}
142140
MSG
@@ -153,11 +151,9 @@ def add_react_dependencies
153151
puts "Installing React dependencies..."
154152
return if add_packages(REACT_DEPENDENCIES)
155153

156-
# This should not happen since package_json is always available via shakapacker
157154
GeneratorMessages.add_warning(<<~MSG.strip)
158-
⚠️ Failed to add React dependencies via package_json gem.
155+
⚠️ Failed to add React dependencies.
159156
160-
This indicates shakapacker dependency may not be properly installed.
161157
You can install them manually by running:
162158
npm install #{REACT_DEPENDENCIES.join(' ')}
163159
MSG
@@ -174,11 +170,9 @@ def add_css_dependencies
174170
puts "Installing CSS handling dependencies..."
175171
return if add_packages(CSS_DEPENDENCIES)
176172

177-
# This should not happen since package_json is always available via shakapacker
178173
GeneratorMessages.add_warning(<<~MSG.strip)
179-
⚠️ Failed to add CSS dependencies via package_json gem.
174+
⚠️ Failed to add CSS dependencies.
180175
181-
This indicates shakapacker dependency may not be properly installed.
182176
You can install them manually by running:
183177
npm install #{CSS_DEPENDENCIES.join(' ')}
184178
MSG
@@ -195,11 +189,9 @@ def add_rspack_dependencies
195189
puts "Installing Rspack core dependencies..."
196190
return if add_packages(RSPACK_DEPENDENCIES)
197191

198-
# This should not happen since package_json is always available via shakapacker
199192
GeneratorMessages.add_warning(<<~MSG.strip)
200-
⚠️ Failed to add Rspack dependencies via package_json gem.
193+
⚠️ Failed to add Rspack dependencies.
201194
202-
This indicates shakapacker dependency may not be properly installed.
203195
You can install them manually by running:
204196
npm install #{RSPACK_DEPENDENCIES.join(' ')}
205197
MSG
@@ -216,11 +208,9 @@ def add_typescript_dependencies
216208
puts "Installing TypeScript dependencies..."
217209
return if add_packages(TYPESCRIPT_DEPENDENCIES, dev: true)
218210

219-
# This should not happen since package_json is always available via shakapacker
220211
GeneratorMessages.add_warning(<<~MSG.strip)
221-
⚠️ Failed to add TypeScript dependencies via package_json gem.
212+
⚠️ Failed to add TypeScript dependencies.
222213
223-
This indicates shakapacker dependency may not be properly installed.
224214
You can install them manually by running:
225215
npm install --save-dev #{TYPESCRIPT_DEPENDENCIES.join(' ')}
226216
MSG
@@ -245,11 +235,9 @@ def add_dev_dependencies
245235

246236
return if add_packages(dev_deps, dev: true)
247237

248-
# This should not happen since package_json is always available via shakapacker
249238
GeneratorMessages.add_warning(<<~MSG.strip)
250-
⚠️ Failed to add development dependencies via package_json gem.
239+
⚠️ Failed to add development dependencies.
251240
252-
This indicates shakapacker dependency may not be properly installed.
253241
You can install them manually by running:
254242
npm install --save-dev #{dev_deps.join(' ')}
255243
MSG
@@ -284,8 +272,8 @@ def add_package(package, dev: false)
284272
pj.manager.add(packages_array, exact: true)
285273
end
286274
true
287-
rescue StandardError => e
288-
puts "Warning: Could not add #{package} via package_json gem: #{e.message}"
275+
rescue StandardError
276+
# Return false to trigger warning in calling method
289277
false
290278
end
291279
end

0 commit comments

Comments
 (0)