Skip to content

Commit 55e928a

Browse files
committed
Hide legacy Redux install generator path
1 parent c7b54be commit 55e928a

6 files changed

Lines changed: 109 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ After a release, run `/update-changelog` in Claude Code to analyze commits, writ
4141

4242
#### Changed
4343

44+
- **Redux is now hidden from the V17 install generator path**: The `react_on_rails:install --redux` option is no longer shown in install generator help or usage text, and recovery guidance no longer recommends `--redux` for new installs. The hidden legacy path and direct `react_on_rails:react_with_redux` generator now warn that Redux scaffolding is legacy while keeping runtime Redux APIs available. Closes [Issue 4272](https://github.com/shakacode/react_on_rails/issues/4272) and [Issue 4273](https://github.com/shakacode/react_on_rails/issues/4273). [PR 4277](https://github.com/shakacode/react_on_rails/pull/4277) by [justin808](https://github.com/justin808).
45+
4446
- **`create-react-on-rails-app` now defaults to Pro for React 19.2 support**: Running
4547
`npx create-react-on-rails-app my-app` no longer asks setup questions and generates the recommended
4648
React on Rails Pro scaffold by default. Automation note: non-TTY environments, including CI and piped

react_on_rails/lib/generators/USAGE

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ Description:
22

33
The react_on_rails:install generator integrates a React frontend, including SSR, with Rails.
44

5-
* Redux (Optional)
6-
7-
Passing the --redux generator option causes the generated Hello World example
8-
to integrate the Redux state container framework. The necessary node modules
9-
will be automatically included for you.
10-
115
* Tailwind CSS v4 (Optional)
126

137
Passing the --tailwind generator option installs Tailwind CSS v4, configures

react_on_rails/lib/generators/react_on_rails/base_generator.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ class BaseGenerator < Rails::Generators::Base
1717
Rails::Generators.hide_namespace(namespace)
1818
source_root(File.expand_path("templates", __dir__))
1919

20-
# --redux
20+
# Internal hidden legacy Redux plumbing for install_generator.
2121
class_option :redux,
2222
type: :boolean,
2323
default: false,
24-
desc: "Install Redux package and Redux version of Hello World Example",
25-
aliases: "-R"
24+
desc: "Internal legacy Redux scaffolding flag",
25+
aliases: "-R",
26+
hide: true
2627

2728
# --rspack / --no-rspack (Rspack is the default on fresh installs; --no-rspack selects Webpack)
2829
# IMPORTANT: do NOT add a `default:` here. The absence of a default is load-bearing — Thor

react_on_rails/lib/generators/react_on_rails/install_generator.rb

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ class InstallGenerator < Rails::Generators::Base
3232
# fetch USAGE file for details generator description
3333
source_root(File.expand_path(__dir__))
3434

35-
# --redux
35+
# Hidden legacy --redux escape hatch for existing scripted installs.
3636
class_option :redux,
3737
type: :boolean,
3838
default: false,
39-
desc: "Install Redux package and Redux version of Hello World Example. Default: false",
40-
aliases: "-R"
39+
desc: "Deprecated legacy Redux install path; use react_on_rails:react_with_redux directly.",
40+
aliases: "-R",
41+
hide: true
4142

4243
# --typescript
4344
class_option :typescript,
@@ -195,6 +196,7 @@ def run_generators
195196
# This is inherited by all invoked generators and persists through Rails initialization
196197
# See lib/react_on_rails/engine.rb for the validation skip logic
197198
ENV["REACT_ON_RAILS_SKIP_VALIDATION"] = "true"
199+
add_legacy_redux_install_warning
198200

199201
if installation_prerequisites_met? || options.ignore_warnings?
200202
invoke_generators
@@ -252,9 +254,9 @@ def invoke_generators
252254
end
253255

254256
# Component generator logic:
255-
# - --rsc without --redux: Skip HelloWorld, HelloServer will be generated in setup_rsc
256-
# - --rsc with --redux: Generate HelloWorldApp (user explicitly wants Redux) + HelloServer
257-
# - Without --rsc: Normal behavior (HelloWorld or HelloWorldApp based on --redux)
257+
# - --rsc without hidden legacy Redux: Skip HelloWorld; setup_rsc generates HelloServer.
258+
# - Hidden legacy --redux: Generate HelloWorldApp as a one-major escape hatch.
259+
# - Without --rsc: Generate the default HelloWorld example unless the legacy flag is present.
258260
if options.redux?
259261
invoke "react_on_rails:react_with_redux", [], { typescript: options.typescript?,
260262
tailwind: use_tailwind?,
@@ -781,6 +783,33 @@ def shakapacker_setup_incomplete?
781783
@shakapacker_setup_incomplete == true
782784
end
783785

786+
def add_legacy_redux_install_warning
787+
return unless options.redux?
788+
789+
legacy_guidance, legacy_command =
790+
if use_tailwind?
791+
[
792+
"Existing apps that need Redux with Tailwind should keep using the hidden install path:",
793+
"bundle exec rails generate react_on_rails:install --redux --tailwind"
794+
]
795+
else
796+
[
797+
"Existing apps that need the legacy Redux scaffold can run:",
798+
"bundle exec rails generate react_on_rails:react_with_redux"
799+
]
800+
end
801+
802+
GeneratorMessages.add_warning(<<~MSG.strip)
803+
The install --redux option is a hidden legacy Redux generator path and is not recommended
804+
for new React on Rails apps.
805+
Use the default install generator for new apps. #{legacy_guidance}
806+
807+
#{legacy_command}
808+
809+
Runtime Redux APIs such as redux_store remain supported.
810+
MSG
811+
end
812+
784813
def recovery_install_command
785814
flags = []
786815
flags << "--redux" if options.redux?

react_on_rails/lib/generators/react_on_rails/react_with_redux_generator.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ class ReactWithReduxGenerator < Rails::Generators::Base
1313

1414
Rails::Generators.hide_namespace(namespace)
1515
source_root(File.expand_path("templates", __dir__))
16+
LEGACY_REDUX_GENERATOR_WARNING = <<~MSG.strip
17+
The react_on_rails:react_with_redux generator is a hidden legacy Redux generator path and is not
18+
recommended for new React on Rails apps.
19+
New apps should use the default React on Rails installer without Redux. Runtime Redux APIs such as
20+
redux_store remain supported.
21+
MSG
1622

1723
class_option :typescript,
1824
type: :boolean,
@@ -131,13 +137,14 @@ def add_redux_npm_dependencies
131137
def add_redux_specific_messages
132138
return if options.invoked_by_install?
133139

134-
# Append Redux-specific post-install instructions
140+
GeneratorMessages.add_warning(LEGACY_REDUX_GENERATOR_WARNING)
135141
GeneratorMessages.add_info(
136142
GeneratorMessages.helpful_message_after_installation(component_name: "HelloWorldApp", route: "hello_world",
137143
pro: Gem.loaded_specs.key?("react_on_rails_pro"),
138144
tailwind: use_tailwind?,
139145
app_root: destination_root)
140146
)
147+
print_generator_messages
141148
end
142149

143150
private
@@ -152,9 +159,13 @@ def unsupported_standalone_tailwind?
152159
Tailwind setup requires the base React on Rails installer so it can create the
153160
react_on_rails_tailwind pack, stylesheet, dependencies, and webpack/Rspack config.
154161
155-
Use the install generator for Redux + Tailwind setup:
162+
Use the hidden legacy installer path if you intentionally need the Redux scaffold with Tailwind:
156163
157-
rails generate react_on_rails:install --redux --tailwind
164+
bundle exec rails generate react_on_rails:install --redux --tailwind
165+
166+
For new apps, run the default installer without Redux:
167+
168+
bundle exec rails generate react_on_rails:install --tailwind
158169
MSG
159170
true
160171
end

react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,25 @@ def repo_pinned_pnpm_version
349349
end
350350
end
351351

352+
describe "Redux generator policy" do
353+
it "hides the install --redux option from public help and usage text" do
354+
redux_option = described_class.class_options.fetch(:redux)
355+
356+
expect(redux_option.hide).to be(true)
357+
358+
usage_text = File.read(File.expand_path("../../../lib/generators/USAGE", __dir__))
359+
expect(usage_text).not_to include("--redux")
360+
expect(usage_text).not_to include("Redux (Optional)")
361+
end
362+
363+
it "marks the base generator Redux option as internal legacy plumbing" do
364+
redux_option = ReactOnRails::Generators::BaseGenerator.class_options.fetch(:redux)
365+
366+
expect(redux_option.hide).to be(true)
367+
expect(redux_option.description).to include("legacy")
368+
end
369+
end
370+
352371
describe "manual generator fixtures" do
353372
it "keep CI workflow generation inside the generator spec destination" do
354373
prepare_destination
@@ -4485,6 +4504,27 @@ class ActiveSupport::TestCase
44854504
expect(output_text).to include("Re-run: rails generate react_on_rails:install --redux --typescript")
44864505
end
44874506

4507+
specify "hidden install --redux emits a legacy warning" do
4508+
install_generator = install_generator_fixture(redux: true)
4509+
4510+
install_generator.send(:add_legacy_redux_install_warning)
4511+
output_text = GeneratorMessages.messages.join("\n")
4512+
4513+
expect(output_text).to include("legacy Redux generator path")
4514+
expect(output_text).to include("bundle exec rails generate react_on_rails:react_with_redux")
4515+
end
4516+
4517+
specify "hidden install --redux --tailwind warning stays on the install path" do
4518+
install_generator = install_generator_fixture(redux: true, tailwind: true)
4519+
4520+
install_generator.send(:add_legacy_redux_install_warning)
4521+
output_text = GeneratorMessages.messages.join("\n")
4522+
4523+
expect(output_text).to include("Redux with Tailwind")
4524+
expect(output_text).to include("bundle exec rails generate react_on_rails:install --redux --tailwind")
4525+
expect(output_text).not_to include("react_on_rails:react_with_redux")
4526+
end
4527+
44884528
specify "shakapacker gemfile error preserves original install flags" do
44894529
# ignore_warnings: true is required so handle_shakapacker_gemfile_error logs
44904530
# the error instead of raising Thor::Error, which lets this example inspect output.
@@ -4643,7 +4683,8 @@ class ActiveSupport::TestCase
46434683
expect(error_text).to include(
46444684
"standalone react_on_rails:react_with_redux generator does not support --tailwind"
46454685
)
4646-
expect(error_text).to include("rails generate react_on_rails:install --redux --tailwind")
4686+
expect(error_text).to include("bundle exec rails generate react_on_rails:install --redux --tailwind")
4687+
expect(error_text).to include("bundle exec rails generate react_on_rails:install --tailwind")
46474688
end
46484689

46494690
it "allows Redux Tailwind setup when invoked by the install generator" do
@@ -4655,6 +4696,18 @@ class ActiveSupport::TestCase
46554696
"standalone react_on_rails:react_with_redux generator does not support --tailwind"
46564697
)
46574698
end
4699+
4700+
it "warns that direct standalone Redux generation is legacy" do
4701+
redux_generator = redux_generator_fixture
4702+
allow(redux_generator).to receive(:print_generator_messages)
4703+
4704+
redux_generator.add_redux_specific_messages
4705+
4706+
message_text = GeneratorMessages.messages.join("\n")
4707+
expect(message_text).to include("legacy Redux generator path")
4708+
expect(message_text).to match(/not\s+recommended for new React on Rails apps/)
4709+
expect(redux_generator).to have_received(:print_generator_messages)
4710+
end
46584711
end
46594712

46604713
describe "#create_css_module_types" do

0 commit comments

Comments
 (0)