From 33e033c593aa0caf26b7aad47770f35d5d6ca305 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sun, 16 Nov 2025 18:15:20 -1000 Subject: [PATCH 1/2] Apply PR 2039 changes: modernize generator config and workflow updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change yalc publish to yarn yalc publish in examples.yml - Enable build_test_command and add auto_load_bundle config - Add REACT_ON_RAILS_SKIP_VALIDATION wrapper for generator commands - Add generate_packs step after npm install in examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/examples.yml | 2 +- .../base/base/config/initializers/react_on_rails.rb.tt | 4 +++- rakelib/shakapacker_examples.rake | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 294f2dab70..6b79ef8d7e 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -130,7 +130,7 @@ jobs: yarn install --no-progress --no-emoji ${{ matrix.dependency-level == 'latest' && '--frozen-lockfile' || '' }} sudo yarn global add yalc - name: yalc publish for react-on-rails - run: yalc publish + run: yarn yalc publish - name: Install Ruby Gems for package run: | bundle lock --add-platform 'x86_64-linux' diff --git a/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt b/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt index 8015f38971..e063171d21 100644 --- a/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +++ b/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt @@ -26,8 +26,10 @@ ReactOnRails.configure do |config| # - Requires adding ReactOnRails::TestHelper to spec/rails_helper.rb # - See: https://github.com/shakacode/react_on_rails/blob/master/docs/guides/testing-configuration.md # - # config.build_test_command = "RAILS_ENV=test bin/shakapacker" + config.build_test_command = "RAILS_ENV=test bin/shakapacker" + config.auto_load_bundle = true + config.components_subdirectory = "ror_components" ################################################################################ # Advanced Configuration ################################################################################ diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 165bbfc0d2..f43ef45260 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -36,8 +36,13 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '>= 8.2.0'\" >> #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") - sh_in_dir(example_type.dir, example_type.generator_shell_commands) + # TODO: Remove REACT_ON_RAILS_SKIP_VALIDATION after generators start using next release + generator_commands = example_type.generator_shell_commands.map do |cmd| + "REACT_ON_RAILS_SKIP_VALIDATION=true #{cmd}" + end + sh_in_dir(example_type.dir, generator_commands) sh_in_dir(example_type.dir, "npm install") + sh_in_dir(example_type.dir, "bundle exec rake react_on_rails:generate_packs") end end From 5a193d77daeb8466e571a352b79a6c98a3105775 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sun, 16 Nov 2025 18:58:17 -1000 Subject: [PATCH 2/2] Add documentation and CHANGELOG for generator modernization changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add explanatory comments for yarn yalc publish workflow command - Document REACT_ON_RAILS_SKIP_VALIDATION usage in example generation - Add CHANGELOG entry for new generator configuration defaults - Clarify that changes only affect newly generated applications 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/workflows/examples.yml | 2 ++ CHANGELOG.md | 10 ++++++++++ rakelib/shakapacker_examples.rake | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 6b79ef8d7e..36355f6df3 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -130,6 +130,8 @@ jobs: yarn install --no-progress --no-emoji ${{ matrix.dependency-level == 'latest' && '--frozen-lockfile' || '' }} sudo yarn global add yalc - name: yalc publish for react-on-rails + # Use yarn workspace script to publish all workspace packages to yalc + # Runs the "yalc:publish" script defined in each workspace's package.json run: yarn yalc publish - name: Install Ruby Gems for package run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dc964af1d..704408d359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,16 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th Changes since the last non-beta release. +#### Changed + +- **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). + ### [16.2.0.beta.4] - 2025-11-12 #### Added diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index f43ef45260..5f5f1bb864 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -36,12 +36,19 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '>= 8.2.0'\" >> #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") - # TODO: Remove REACT_ON_RAILS_SKIP_VALIDATION after generators start using next release + # Skip validation when running generators on example apps during development. + # The generator validates that certain config options exist in the initializer, + # but during example generation, we're often testing against the current gem + # codebase which may have new config options not yet in the released version. + # This allows examples to be generated without validation errors while still + # testing the generator functionality. generator_commands = example_type.generator_shell_commands.map do |cmd| "REACT_ON_RAILS_SKIP_VALIDATION=true #{cmd}" end sh_in_dir(example_type.dir, generator_commands) sh_in_dir(example_type.dir, "npm install") + # Generate the component packs after running the generator to ensure all + # auto-bundled components have corresponding pack files created sh_in_dir(example_type.dir, "bundle exec rake react_on_rails:generate_packs") end end