react_on_rails 16.3.0 → 16.4.0.rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Steepfile +1 -0
- data/lib/generators/react_on_rails/dev_tests_generator.rb +10 -3
- data/lib/generators/react_on_rails/install_generator.rb +15 -11
- data/lib/generators/react_on_rails/templates/base/base/bin/dev +49 -0
- data/lib/generators/react_on_rails/templates/base/base/bin/shakapacker-precompile-hook +5 -0
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +3 -3
- data/lib/react_on_rails/configuration.rb +14 -4
- data/lib/react_on_rails/dev/database_checker.rb +168 -0
- data/lib/react_on_rails/dev/server_manager.rb +72 -16
- data/lib/react_on_rails/doctor.rb +2 -2
- data/lib/react_on_rails/helper.rb +53 -2
- data/lib/react_on_rails/locales/base.rb +15 -0
- data/lib/react_on_rails/packer_utils.rb +37 -5
- data/lib/react_on_rails/packs_generator.rb +141 -11
- data/lib/react_on_rails/smart_error.rb +26 -0
- data/lib/react_on_rails/test_helper.rb +1 -1
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +11 -3
- data/lib/tasks/generate_packs.rake +7 -3
- data/rakelib/dummy_apps.rake +3 -3
- data/rakelib/node_package.rake +3 -3
- data/rakelib/rbs.rake +1 -1
- data/rakelib/shakapacker_examples.rake +14 -6
- data/sig/react_on_rails/configuration.rbs +2 -0
- data/sig/react_on_rails/dev/database_checker.rbs +27 -0
- data/sig/react_on_rails/packer_utils.rbs +5 -1
- metadata +4 -2
|
@@ -25,6 +25,8 @@ module ReactOnRails
|
|
|
25
25
|
component_not_registered_solution
|
|
26
26
|
when :missing_auto_loaded_bundle
|
|
27
27
|
missing_auto_loaded_bundle_solution
|
|
28
|
+
when :missing_auto_loaded_store_bundle
|
|
29
|
+
missing_auto_loaded_store_bundle_solution
|
|
28
30
|
when :hydration_mismatch
|
|
29
31
|
hydration_mismatch_solution
|
|
30
32
|
when :server_rendering_error
|
|
@@ -64,6 +66,8 @@ module ReactOnRails
|
|
|
64
66
|
"Component '#{component_name}' Not Registered"
|
|
65
67
|
when :missing_auto_loaded_bundle
|
|
66
68
|
"Auto-loaded Bundle Missing"
|
|
69
|
+
when :missing_auto_loaded_store_bundle
|
|
70
|
+
"Auto-loaded Store Bundle Missing"
|
|
67
71
|
when :hydration_mismatch
|
|
68
72
|
"Hydration Mismatch"
|
|
69
73
|
when :server_rendering_error
|
|
@@ -93,6 +97,11 @@ module ReactOnRails
|
|
|
93
97
|
Component '#{component_name}' is configured for auto-loading but its bundle is missing.
|
|
94
98
|
Expected location: #{additional_context[:expected_path]}
|
|
95
99
|
DESC
|
|
100
|
+
when :missing_auto_loaded_store_bundle
|
|
101
|
+
<<~DESC
|
|
102
|
+
Redux store '#{component_name}' is configured for auto-loading but its bundle is missing.
|
|
103
|
+
Expected location: #{additional_context[:expected_path]}
|
|
104
|
+
DESC
|
|
96
105
|
when :hydration_mismatch
|
|
97
106
|
<<~DESC
|
|
98
107
|
The server-rendered HTML doesn't match what React rendered on the client.
|
|
@@ -182,6 +191,23 @@ module ReactOnRails
|
|
|
182
191
|
SOLUTION
|
|
183
192
|
end
|
|
184
193
|
|
|
194
|
+
def missing_auto_loaded_store_bundle_solution
|
|
195
|
+
<<~SOLUTION
|
|
196
|
+
1. Run the pack generation task:
|
|
197
|
+
#{Rainbow('bundle exec rake react_on_rails:generate_packs').cyan}
|
|
198
|
+
|
|
199
|
+
2. Ensure your store is in a directory matching stores_subdirectory under packer_source_path:
|
|
200
|
+
#{Rainbow("#{ReactOnRails::PackerUtils.packer_source_path}/**/#{ReactOnRails.configuration.stores_subdirectory || 'ror_stores'}/#{component_name}.js").cyan}
|
|
201
|
+
|
|
202
|
+
3. Check that the store file follows naming conventions:
|
|
203
|
+
- Store file: #{Rainbow("#{component_name}.js").cyan} or #{Rainbow("#{component_name}.ts").cyan}
|
|
204
|
+
- Must export default a store generator function
|
|
205
|
+
|
|
206
|
+
4. Verify stores_subdirectory is configured:
|
|
207
|
+
#{Rainbow("config.stores_subdirectory = 'ror_stores'").cyan}
|
|
208
|
+
SOLUTION
|
|
209
|
+
end
|
|
210
|
+
|
|
185
211
|
def hydration_mismatch_solution
|
|
186
212
|
<<~SOLUTION
|
|
187
213
|
Common causes and solutions:
|
|
@@ -26,7 +26,7 @@ module ReactOnRails
|
|
|
26
26
|
# faster. The helper looks for these processes and will abort recompiling if it finds them
|
|
27
27
|
# to be running.
|
|
28
28
|
#
|
|
29
|
-
# See docs/
|
|
29
|
+
# See docs/building-features/testing-configuration.md for more info
|
|
30
30
|
#
|
|
31
31
|
# Params:
|
|
32
32
|
# config - config for rspec
|
|
@@ -154,7 +154,8 @@ module ReactOnRails
|
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
def validate_exact_version!
|
|
157
|
-
return if node_package_version.raw.nil? || node_package_version.local_path_or_url?
|
|
157
|
+
return if node_package_version.raw.nil? || node_package_version.local_path_or_url? ||
|
|
158
|
+
node_package_version.workspace_protocol?
|
|
158
159
|
|
|
159
160
|
return unless node_package_version.semver_wildcard?
|
|
160
161
|
|
|
@@ -178,7 +179,8 @@ module ReactOnRails
|
|
|
178
179
|
end
|
|
179
180
|
|
|
180
181
|
def validate_version_match!
|
|
181
|
-
return if node_package_version.raw.nil? || node_package_version.local_path_or_url?
|
|
182
|
+
return if node_package_version.raw.nil? || node_package_version.local_path_or_url? ||
|
|
183
|
+
node_package_version.workspace_protocol?
|
|
182
184
|
|
|
183
185
|
return if node_package_version.parts == gem_version_parts
|
|
184
186
|
|
|
@@ -324,8 +326,14 @@ module ReactOnRails
|
|
|
324
326
|
!raw.nil? && raw.include?("/") && !raw.start_with?("npm:")
|
|
325
327
|
end
|
|
326
328
|
|
|
329
|
+
def workspace_protocol?
|
|
330
|
+
# pnpm workspace protocol: workspace:* or workspace:^
|
|
331
|
+
# Used for monorepo internal dependencies
|
|
332
|
+
!raw.nil? && raw.start_with?("workspace:")
|
|
333
|
+
end
|
|
334
|
+
|
|
327
335
|
def parts
|
|
328
|
-
return if local_path_or_url?
|
|
336
|
+
return if local_path_or_url? || workspace_protocol?
|
|
329
337
|
|
|
330
338
|
match = raw.match(VERSION_PARTS_REGEX)
|
|
331
339
|
unless match
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
# rubocop:disable Metrics/BlockLength
|
|
4
4
|
namespace :react_on_rails do
|
|
5
5
|
desc <<~DESC
|
|
6
|
-
If there is a file inside any directory matching config.components_subdirectory
|
|
6
|
+
If there is a file inside any directory matching config.components_subdirectory or
|
|
7
|
+
config.stores_subdirectory, this command generates corresponding packs.
|
|
7
8
|
|
|
8
9
|
This task will:
|
|
9
10
|
- Clean out existing generated directories (javascript/generated and javascript/packs/generated)
|
|
10
11
|
- List all files being deleted for transparency
|
|
11
|
-
- Generate new pack files for discovered React components
|
|
12
|
+
- Generate new pack files for discovered React components and Redux stores
|
|
12
13
|
- Skip generation if files are already up to date
|
|
13
14
|
|
|
14
15
|
Generated directories:
|
|
15
|
-
- app/javascript/packs/generated/ (client pack files)
|
|
16
|
+
- app/javascript/packs/generated/ (client pack files for components and stores)
|
|
16
17
|
- app/javascript/generated/ (server bundle files)
|
|
17
18
|
DESC
|
|
18
19
|
|
|
@@ -23,6 +24,9 @@ namespace :react_on_rails do
|
|
|
23
24
|
puts Rainbow("🚀 Starting React on Rails pack generation...").bold
|
|
24
25
|
puts Rainbow("📁 Auto-load bundle: #{ReactOnRails.configuration.auto_load_bundle}").cyan
|
|
25
26
|
puts Rainbow("📂 Components subdirectory: #{ReactOnRails.configuration.components_subdirectory}").cyan
|
|
27
|
+
if ReactOnRails.configuration.stores_subdirectory.present?
|
|
28
|
+
puts Rainbow("📂 Stores subdirectory: #{ReactOnRails.configuration.stores_subdirectory}").cyan
|
|
29
|
+
end
|
|
26
30
|
puts ""
|
|
27
31
|
end
|
|
28
32
|
|
data/rakelib/dummy_apps.rake
CHANGED
|
@@ -6,9 +6,9 @@ namespace :dummy_apps do
|
|
|
6
6
|
include ReactOnRails::TaskHelpers
|
|
7
7
|
|
|
8
8
|
task :pnpm_install do
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
sh_in_dir(
|
|
9
|
+
# Dummy apps are now part of the pnpm workspace, so install must run from the workspace root.
|
|
10
|
+
# Running `pnpm install` from a workspace member directory doesn't resolve other workspace packages.
|
|
11
|
+
sh_in_dir(monorepo_root, "pnpm install")
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
task dummy_app: [:pnpm_install] do
|
data/rakelib/node_package.rake
CHANGED
|
@@ -6,10 +6,10 @@ namespace :node_package do
|
|
|
6
6
|
include ReactOnRails::TaskHelpers
|
|
7
7
|
|
|
8
8
|
task :build do
|
|
9
|
-
puts "Building Node Package
|
|
10
|
-
sh "pnpm run build
|
|
9
|
+
puts "Building Node Package"
|
|
10
|
+
sh "pnpm run build"
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
desc "Prepares node_package by building
|
|
14
|
+
desc "Prepares node_package by building the TypeScript to JavaScript"
|
|
15
15
|
task node_package: "node_package:build"
|
data/rakelib/rbs.rake
CHANGED
|
@@ -18,7 +18,7 @@ namespace :rbs do
|
|
|
18
18
|
# spawned shell commands via Open3.capture3() do NOT inherit bundle context
|
|
19
19
|
# Wrap in Timeout to prevent hung processes in CI environments (60 second timeout)
|
|
20
20
|
stdout, stderr, status = Timeout.timeout(60) do
|
|
21
|
-
Open3.capture3("bundle exec rbs -I sig validate")
|
|
21
|
+
Open3.capture3("bundle exec rbs -I sig -r pathname validate")
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
if status.success?
|
|
@@ -49,7 +49,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
|
|
|
49
49
|
# automatically included as a dependency in older Shakapacker versions
|
|
50
50
|
dev_deps["@babel/plugin-transform-runtime"] = "^7.24.0" if dev_deps
|
|
51
51
|
|
|
52
|
-
# Add npm overrides to force specific React version, preventing
|
|
52
|
+
# Add npm overrides to force specific React version, preventing
|
|
53
53
|
# react-on-rails from pulling in React 19 as a transitive dependency
|
|
54
54
|
package_json["overrides"] = {
|
|
55
55
|
"react" => react_version,
|
|
@@ -87,7 +87,9 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
|
|
|
87
87
|
"echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}")
|
|
88
88
|
# Shakapacker is automatically included as a dependency via react_on_rails.gemspec (>= 6.0)
|
|
89
89
|
bundle_install_in(example_type.dir)
|
|
90
|
-
|
|
90
|
+
# Use unbundled_sh_in_dir to ensure we're using the generated app's Gemfile
|
|
91
|
+
# and gem versions, not the parent workspace's bundle context.
|
|
92
|
+
unbundled_sh_in_dir(example_type.dir, "bundle exec rake shakapacker:install")
|
|
91
93
|
# Skip validation when running generators on example apps during development.
|
|
92
94
|
# The generator validates that certain config options exist in the initializer,
|
|
93
95
|
# but during example generation, we're often testing against the current gem
|
|
@@ -97,7 +99,9 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
|
|
|
97
99
|
generator_commands = example_type.generator_shell_commands.map do |cmd|
|
|
98
100
|
"REACT_ON_RAILS_SKIP_VALIDATION=true #{cmd}"
|
|
99
101
|
end
|
|
100
|
-
|
|
102
|
+
# Use unbundled_sh_in_dir to ensure the generator uses the example app's
|
|
103
|
+
# gem versions, not the parent workspace's cached bundle context.
|
|
104
|
+
unbundled_sh_in_dir(example_type.dir, generator_commands)
|
|
101
105
|
# Re-run bundle install since dev_tests generator adds rspec-rails and coveralls to Gemfile
|
|
102
106
|
bundle_install_in(example_type.dir)
|
|
103
107
|
|
|
@@ -109,14 +113,18 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
|
|
|
109
113
|
# Run npm install BEFORE shakapacker:binstubs to ensure the npm shakapacker version
|
|
110
114
|
# matches the gem version. The binstubs task loads the Rails environment which
|
|
111
115
|
# validates version matching between gem and npm package.
|
|
112
|
-
# Use --legacy-peer-deps to avoid peer dependency conflicts when
|
|
116
|
+
# Use --legacy-peer-deps to avoid peer dependency conflicts when
|
|
113
117
|
# react-on-rails expects newer React versions
|
|
114
|
-
|
|
118
|
+
# Use --install-links to copy file: dependencies instead of symlinking,
|
|
119
|
+
# preventing duplicate React instances from webpack resolving through symlinks
|
|
120
|
+
sh_in_dir(example_type.dir, "npm install --legacy-peer-deps --install-links")
|
|
115
121
|
# Regenerate Shakapacker binstubs after downgrading from 9.x to 8.2.x
|
|
116
122
|
# The binstub format may differ between major versions
|
|
117
123
|
unbundled_sh_in_dir(example_type.dir, "bundle exec rake shakapacker:binstubs")
|
|
118
124
|
else
|
|
119
|
-
|
|
125
|
+
# Use --install-links to copy file: dependencies instead of symlinking,
|
|
126
|
+
# preventing duplicate React instances from webpack resolving through symlinks
|
|
127
|
+
sh_in_dir(example_type.dir, "npm install --install-links")
|
|
120
128
|
end
|
|
121
129
|
# Generate the component packs after running the generator to ensure all
|
|
122
130
|
# auto-bundled components have corresponding pack files created.
|
|
@@ -14,6 +14,7 @@ module ReactOnRails
|
|
|
14
14
|
attr_accessor generated_assets_dirs: Array[String]?
|
|
15
15
|
attr_accessor generated_assets_dir: String
|
|
16
16
|
attr_accessor components_subdirectory: String?
|
|
17
|
+
attr_accessor stores_subdirectory: String?
|
|
17
18
|
attr_accessor webpack_generated_files: Array[String]
|
|
18
19
|
attr_accessor rendering_extension: String?
|
|
19
20
|
attr_accessor build_test_command: String
|
|
@@ -65,6 +66,7 @@ module ReactOnRails
|
|
|
65
66
|
?server_render_method: String?,
|
|
66
67
|
?rendering_props_extension: String?,
|
|
67
68
|
?components_subdirectory: String?,
|
|
69
|
+
?stores_subdirectory: String?,
|
|
68
70
|
?auto_load_bundle: bool?,
|
|
69
71
|
?immediate_hydration: bool?,
|
|
70
72
|
?component_registry_timeout: Integer?,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module ReactOnRails
|
|
2
|
+
module Dev
|
|
3
|
+
class DatabaseChecker
|
|
4
|
+
# Result of a database check.
|
|
5
|
+
# - :ok — database is accessible and ready
|
|
6
|
+
# - :error — database is missing, inaccessible, or misconfigured
|
|
7
|
+
# - :not_rails_app — bin/rails was not found (non-Rails project)
|
|
8
|
+
# - :unknown_error — an unexpected exception occurred during the check
|
|
9
|
+
type check_result = { status: Symbol, error?: String }
|
|
10
|
+
|
|
11
|
+
def self.check_database: (?skip: bool) -> bool
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def self.should_skip_check?: (bool) -> bool
|
|
16
|
+
def self.run_database_check: () -> check_result
|
|
17
|
+
def self.parse_check_result: (String, String, Process::Status) -> check_result
|
|
18
|
+
def self.check_pending_migrations: () -> void
|
|
19
|
+
def self.print_checking_message: () -> void
|
|
20
|
+
def self.print_database_ok: () -> void
|
|
21
|
+
def self.print_skipped_message: (String) -> void
|
|
22
|
+
def self.print_pending_migrations_warning: () -> void
|
|
23
|
+
def self.print_database_error: (String?) -> void
|
|
24
|
+
def self.truncate_error: (String) -> String
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -5,8 +5,12 @@ module ReactOnRails
|
|
|
5
5
|
def self.nested_entries?: () -> bool
|
|
6
6
|
def self.packer_public_output_path: () -> String
|
|
7
7
|
def self.precompile?: () -> bool
|
|
8
|
+
def self.extract_precompile_hook: () -> String?
|
|
9
|
+
def self.hook_contains_generate_packs?: (String? hook_value) -> bool
|
|
8
10
|
def self.shakapacker_precompile_hook_configured?: () -> bool
|
|
9
|
-
def self.shakapacker_precompile_hook_value: () -> String
|
|
11
|
+
def self.shakapacker_precompile_hook_value: () -> String?
|
|
12
|
+
def self.hook_script_has_self_guard?: (String? hook_value) -> bool
|
|
13
|
+
def self.resolve_hook_script_path: (String? hook_value) -> Pathname?
|
|
10
14
|
def self.raise_shakapacker_version_incompatible_for_autobundling: () -> void
|
|
11
15
|
def self.raise_nested_entries_disabled: () -> void
|
|
12
16
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: react_on_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 16.
|
|
4
|
+
version: 16.4.0.rc.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Gordon
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -191,6 +191,7 @@ files:
|
|
|
191
191
|
- lib/react_on_rails/configuration.rb
|
|
192
192
|
- lib/react_on_rails/controller.rb
|
|
193
193
|
- lib/react_on_rails/dev.rb
|
|
194
|
+
- lib/react_on_rails/dev/database_checker.rb
|
|
194
195
|
- lib/react_on_rails/dev/file_manager.rb
|
|
195
196
|
- lib/react_on_rails/dev/pack_generator.rb
|
|
196
197
|
- lib/react_on_rails/dev/process_manager.rb
|
|
@@ -244,6 +245,7 @@ files:
|
|
|
244
245
|
- sig/react_on_rails.rbs
|
|
245
246
|
- sig/react_on_rails/configuration.rbs
|
|
246
247
|
- sig/react_on_rails/controller.rbs
|
|
248
|
+
- sig/react_on_rails/dev/database_checker.rbs
|
|
247
249
|
- sig/react_on_rails/dev/file_manager.rbs
|
|
248
250
|
- sig/react_on_rails/dev/pack_generator.rbs
|
|
249
251
|
- sig/react_on_rails/dev/process_manager.rbs
|