react_on_rails 16.0.1.rc.0 → 16.0.1.rc.4

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -1
  3. data/CLAUDE.md +34 -1
  4. data/CODING_AGENTS.md +1 -0
  5. data/CONTRIBUTING.md +12 -6
  6. data/Gemfile.development_dependencies +1 -0
  7. data/Gemfile.lock +3 -1
  8. data/NEWS.md +1 -1
  9. data/README.md +15 -8
  10. data/bin/lefthook/check-trailing-newlines +38 -0
  11. data/bin/lefthook/get-changed-files +26 -0
  12. data/bin/lefthook/prettier-format +26 -0
  13. data/bin/lefthook/ruby-autofix +26 -0
  14. data/bin/lefthook/ruby-lint +27 -0
  15. data/eslint.config.ts +7 -0
  16. data/lib/generators/react_on_rails/base_generator.rb +59 -51
  17. data/lib/generators/react_on_rails/install_generator.rb +139 -1
  18. data/lib/generators/react_on_rails/react_with_redux_generator.rb +9 -10
  19. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +11 -2
  20. data/lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt +3 -2
  21. data/lib/react_on_rails/configuration.rb +63 -50
  22. data/lib/react_on_rails/json_parse_error.rb +6 -1
  23. data/lib/react_on_rails/packer_utils.rb +39 -52
  24. data/lib/react_on_rails/packs_generator.rb +3 -0
  25. data/lib/react_on_rails/prerender_error.rb +4 -0
  26. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +5 -3
  27. data/lib/react_on_rails/system_checker.rb +6 -6
  28. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
  29. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +1 -2
  30. data/lib/react_on_rails/test_helper.rb +2 -3
  31. data/lib/react_on_rails/utils.rb +84 -41
  32. data/lib/react_on_rails/version.rb +1 -1
  33. data/lib/tasks/doctor.rake +0 -3
  34. data/lib/tasks/generate_packs.rake +19 -5
  35. metadata +6 -2
  36. data/package-lock.json +0 -11984
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6df96f164d23050adbea7f31bb61ab36a092fbad393d2d1d0e8a307f5c6a41d0
4
- data.tar.gz: e6e4b7e5c65175310edc4e1c7a01df8ffdfc8cdb9ca7fc1b5012988db174d360
3
+ metadata.gz: 1866bb608bf6b62df70e1ebb9e708596b59f620d08311ea8116e534bdb1180be
4
+ data.tar.gz: bc7ad5c8cca569395d3da1db1e3ee3d9a0f3a986ac8777eadae28b06d8514e6a
5
5
  SHA512:
6
- metadata.gz: bf0ae04e65fe1225e159154df70a1043a447e15c058fe62a743e99fd4e8ef489b61b64766da0516d93faec781ed4d968e5b3bce85228e560f5c2c3a3646518ee
7
- data.tar.gz: e604837b4b5182504ca2c2c38acbcdb8cf2dbea6f8fd94310fcedc28e4e8f4fe072048fdce21bed26317b0147d5712fb4a530a4c1fb3ae9bf52f47c05fa63a00
6
+ metadata.gz: 5d5651560869dc69bb9a7ce4f1d5666b7cc10c3fa84827087aa9c1c2c7afb20100eee674ca2b906ca3fec49ca4558af111c38558104976ad49290e07a0751b9a
7
+ data.tar.gz: 1cabd8aea0ef8545861f325494c6c051550a463ec73d9e206dfb8548060db0c8fe78bde5359e1ce921d787c9d99ad3961858e9a5ab81d7ae9e490b150ed32cd2
data/CHANGELOG.md CHANGED
@@ -23,6 +23,62 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th
23
23
 
24
24
  Changes since the last non-beta release.
25
25
 
26
+ #### Breaking Changes
27
+
28
+ - **Removed `generated_assets_dirs` configuration**: The legacy `config.generated_assets_dirs` option is no longer supported and will raise an error if used. Since Shakapacker is now required, asset paths are automatically determined from `shakapacker.yml` configuration. Remove any `config.generated_assets_dirs` from your `config/initializers/react_on_rails.rb` file. Use `public_output_path` in `config/shakapacker.yml` to customize asset output location instead. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798)
29
+
30
+ #### New Features
31
+
32
+ - **Server Bundle Security**: Added new configuration options for enhanced server bundle security and organization:
33
+
34
+ - `server_bundle_output_path`: Configurable directory (relative to the Rails root) for server bundle output (default: "ssr-generated"). If set to `nil`, the server bundle will be loaded from the same public directory as client bundles.
35
+ - `enforce_private_server_bundles`: When enabled, ensures server bundles are only loaded from private directories outside the public folder (default: false for backward compatibility)
36
+
37
+ - **Improved Bundle Path Resolution**: Bundle path resolution for server bundles now works as follows:
38
+ - If `server_bundle_output_path` is set, the server bundle is loaded from that directory.
39
+ - If `server_bundle_output_path` is not set, the server bundle falls back to the client bundle directory (typically the public output path).
40
+ - If `enforce_private_server_bundles` is enabled:
41
+ - The server bundle will only be loaded from the private directory specified by `server_bundle_output_path`.
42
+ - If the bundle is not found there, it will _not_ fall back to the public directory.
43
+ - If `enforce_private_server_bundles` is not enabled and the bundle is not found in the private directory, it will fall back to the public directory.
44
+ - This logic ensures that, when strict enforcement is enabled, server bundles are never loaded from public directories, improving security and clarity of bundle resolution.
45
+
46
+ #### API Improvements
47
+
48
+ - **Method Naming Clarification**: Added `public_bundles_full_path` method to clarify bundle path handling:
49
+ - `public_bundles_full_path`: New method specifically for webpack bundles in public directories
50
+ - `generated_assets_full_path`: Now deprecated (backwards-compatible alias)
51
+ - This eliminates confusion between webpack bundles and general Rails public assets
52
+
53
+ #### Security Enhancements
54
+
55
+ - **Private Server Bundle Enforcement**: When `enforce_private_server_bundles` is enabled, server bundles bypass public directory fallbacks and are only loaded from designated private locations
56
+ - **Path Validation**: Added validation to ensure `server_bundle_output_path` points to private directories when enforcement is enabled
57
+
58
+ #### Bug Fixes
59
+
60
+ - **Non-Packer Environment Compatibility**: Fixed potential NoMethodError when using bundle path resolution in environments without Shakapacker
61
+ - **Shakapacker version requirements**: Fixed inconsistent version requirements between basic pack generation (6.5.1+) and advanced auto-bundling features (7.0.0+). Added backward compatibility for users on Shakapacker 6.5.1-6.9.x while providing clear upgrade guidance for advanced features. Added new constants `MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING` and improved version checking performance with caching. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798)
62
+
63
+ ### [16.0.1-rc.2] - 2025-09-20
64
+
65
+ #### Bug Fixes
66
+
67
+ - **Packs generator**: Fixed error when `server_bundle_js_file` configuration is empty (default). Added safety check to prevent attempting operations on invalid file paths when server-side rendering is not configured. [PR 1802](https://github.com/shakacode/react_on_rails/pull/1802)
68
+
69
+ ### [16.0.1-rc.2] - 2025-09-20
70
+
71
+ #### Bug Fixes
72
+
73
+ - **Doctor rake task**: Fixed LoadError in `rake react_on_rails:doctor` when using packaged gem. The task was trying to require excluded `rakelib/task_helpers` file. [PR 1795](https://github.com/shakacode/react_on_rails/pull/1795)
74
+ - **Shakapacker version requirements**: Fixed inconsistent version requirements between basic pack generation (6.5.1+) and advanced auto-registration features (7.0.0+). Added backward compatibility for users on Shakapacker 6.5.1-6.9.x while providing clear upgrade guidance for advanced features. Added new constants `MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION` and improved version checking performance with caching. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798)
75
+
76
+ #### Code Cleanup
77
+
78
+ - **PackerUtils abstraction removal**: Removed unnecessary `PackerUtils.packer` abstraction method and replaced all calls with direct `::Shakapacker` usage. This simplifies the codebase by eliminating an abstraction layer that was originally created to support multiple webpack tools but is no longer needed since we only support Shakapacker. All tests updated accordingly. [PR 1798](https://github.com/shakacode/react_on_rails/pull/1798) by [claude-code](https://claude.ai/code)
79
+
80
+ ### [16.0.1-rc.0] - 2025-09-19
81
+
26
82
  #### Pro License Structure Implementation
27
83
 
28
84
  **🔐 License Architecture**
@@ -1646,7 +1702,9 @@ such as:
1646
1702
 
1647
1703
  - Fix several generator-related issues.
1648
1704
 
1649
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/16.0.0...master
1705
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/16.0.1-rc.2...master
1706
+ [16.0.1-rc.2]: https://github.com/shakacode/react_on_rails/compare/16.0.1-rc.0...16.0.1-rc.2
1707
+ [16.0.1-rc.0]: https://github.com/shakacode/react_on_rails/compare/16.0.0...16.0.1-rc.0
1650
1708
  [16.0.0]: https://github.com/shakacode/react_on_rails/compare/14.2.0...16.0.0
1651
1709
  [14.2.0]: https://github.com/shakacode/react_on_rails/compare/14.1.1...14.2.0
1652
1710
  [14.1.1]: https://github.com/shakacode/react_on_rails/compare/14.1.0...14.1.1
data/CLAUDE.md CHANGED
@@ -9,9 +9,16 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
9
9
  1. **ALWAYS run `bundle exec rubocop` and fix ALL violations**
10
10
  2. **ALWAYS ensure files end with a newline character**
11
11
  3. **NEVER push without running full lint check first**
12
+ 4. **ALWAYS let Prettier and RuboCop handle ALL formatting - never manually format**
12
13
 
13
14
  These requirements are non-negotiable. CI will fail if not followed.
14
15
 
16
+ **🚀 AUTOMATIC: Git hooks are installed automatically during setup**
17
+
18
+ Git hooks will automatically run linting on **all changed files (staged + unstaged + untracked)** before each commit - making it fast while preventing CI failures!
19
+
20
+ **Note:** Git hooks are for React on Rails gem developers only, not for users who install the gem.
21
+
15
22
  ## Development Commands
16
23
 
17
24
  ### Essential Commands
@@ -32,6 +39,32 @@ These requirements are non-negotiable. CI will fail if not followed.
32
39
  - **Build**: `yarn run build` (compiles TypeScript to JavaScript in node_package/lib)
33
40
  - **Type checking**: `yarn run type-check`
34
41
  - **⚠️ MANDATORY BEFORE GIT PUSH**: `bundle exec rubocop` and fix ALL violations + ensure trailing newlines
42
+ - Never run `npm` commands, only equivalent Yarn Classic ones
43
+
44
+ ## ⚠️ FORMATTING RULES
45
+
46
+ **Prettier is the SOLE authority for formatting non-Ruby files, and RuboCop for formatting Ruby files. NEVER manually format code.**
47
+
48
+ ### Standard Workflow
49
+ 1. Make code changes
50
+ 2. Run `rake autofix` or `yarn start format`
51
+ 3. Commit changes
52
+
53
+ ### Merge Conflict Resolution Workflow
54
+ **CRITICAL**: When resolving merge conflicts, follow this exact sequence:
55
+
56
+ 1. **Resolve logical conflicts only** - don't worry about formatting
57
+ 2. **Add resolved files**: `git add .` (or specific files)
58
+ 3. **Auto-fix everything**: `rake autofix`
59
+ 4. **Add any formatting changes**: `git add .`
60
+ 5. **Continue rebase/merge**: `git rebase --continue` or `git commit`
61
+
62
+ **❌ NEVER manually format during conflict resolution** - this causes formatting wars between tools.
63
+
64
+ ### Debugging Formatting Issues
65
+ - Check current formatting: `yarn start format.listDifferent`
66
+ - Fix all formatting: `rake autofix`
67
+ - If CI fails on formatting, always run automated fixes, never manual fixes
35
68
 
36
69
  ### Development Setup Commands
37
70
 
@@ -88,10 +121,10 @@ This project maintains both a Ruby gem and an NPM package:
88
121
  ## Important Notes
89
122
 
90
123
  - Use `yalc` for local development when testing with external apps
91
- - The project supports both Webpacker and Shakapacker
92
124
  - Server-side rendering uses isolated Node.js processes
93
125
  - React Server Components support available in Pro version
94
126
  - Generated examples are in `gen-examples/` (ignored by git)
127
+ - Only use `yarn` as the JS package manager, never `npm`
95
128
 
96
129
  ## IDE Configuration
97
130
 
data/CODING_AGENTS.md CHANGED
@@ -30,6 +30,7 @@ cd spec/dummy && foreman start # Start dummy app with webpack
30
30
  - [ ] No trailing whitespace
31
31
  - [ ] Line length ≤120 characters
32
32
  - [ ] Security violations properly scoped with disable comments
33
+ - [ ] No `package-lock.json` or other non-Yarn lock files (except `Gemfile.lock`)
33
34
 
34
35
  ## Development Patterns for AI Contributors
35
36
 
data/CONTRIBUTING.md CHANGED
@@ -7,6 +7,10 @@
7
7
  ## Prerequisites
8
8
 
9
9
  - [Yalc](https://github.com/whitecolor/yalc) must be installed globally for most local development.
10
+ - **Git hooks setup** (automatic during normal setup):
11
+
12
+ Git hooks are installed automatically when you run the standard setup commands. They will run automatic linting on **all changed files (staged + unstaged + untracked)** - making commits fast while preventing CI failures.
13
+
10
14
  - After updating code via Git, to prepare all examples:
11
15
 
12
16
  ```sh
@@ -457,7 +461,9 @@ This approach:
457
461
 
458
462
  ## Pre-Commit Requirements
459
463
 
460
- **CRITICAL**: Before committing any changes, always run the following commands to ensure code quality:
464
+ **AUTOMATED**: If you've set up Lefthook (see Prerequisites), linting runs automatically on changed files before each commit.
465
+
466
+ **MANUAL OPTION**: If you need to run linting manually:
461
467
 
462
468
  ```bash
463
469
  # Navigate to the main react_on_rails directory
@@ -476,14 +482,14 @@ rake lint:rubocop
476
482
  rake lint
477
483
  ```
478
484
 
479
- **Automated checks:**
485
+ **Git hooks automatically run:**
480
486
 
481
- - Format all JavaScript/TypeScript files with Prettier
487
+ - Format JavaScript/TypeScript files with Prettier (on changed files only)
482
488
  - Check and fix linting issues with ESLint
483
- - Check and fix Ruby style issues with RuboCop
484
- - Ensure all tests pass before pushing
489
+ - Check and fix Ruby style issues with RuboCop (on all changed files)
490
+ - Ensure trailing newlines on all files
485
491
 
486
- **Tip**: Set up your IDE to run these automatically on save to catch issues early.
492
+ **Setup**: Automatic during normal development setup
487
493
 
488
494
  ## 🤖 Best Practices for AI Coding Agents
489
495
 
@@ -38,6 +38,7 @@ group :development, :test do
38
38
  gem "rubocop-rspec", "~>2.26", require: false
39
39
  gem "scss_lint", require: false
40
40
  gem "spring", "~> 4.0"
41
+ gem "lefthook", require: false
41
42
  end
42
43
 
43
44
  group :test do
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (16.0.0)
4
+ react_on_rails (16.0.1.rc.4)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
@@ -156,6 +156,7 @@ GEM
156
156
  launchy (3.0.1)
157
157
  addressable (~> 2.8)
158
158
  childprocess (~> 5.0)
159
+ lefthook (1.13.1)
159
160
  listen (3.9.0)
160
161
  rb-fsevent (~> 0.10, >= 0.10.3)
161
162
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -412,6 +413,7 @@ DEPENDENCIES
412
413
  jbuilder
413
414
  jquery-rails
414
415
  launchy
416
+ lefthook
415
417
  listen
416
418
  package_json
417
419
  pry
data/NEWS.md CHANGED
@@ -21,7 +21,7 @@ _A history of the news. A few bullets at the top will also show on the [README.m
21
21
  - 2017-04-09: 8.0.0 beta work to include webpacker_lite gem has begun. See [#786](https://github.com/shakacode/react_on_rails/issues/786).
22
22
  - 2017-04-03: 6.9.3 Released! Props rendered in JSON script tag. Page size is smaller now due to less escaping!
23
23
  - 2017-03-06: Updated to Webpack v2!
24
- - 2017-03-02: Demo of internationalization (i18n) is live at [reactrails.com](https://www.reactrails.com/). Docs [here](docs/guides/i18n.md).
24
+ - 2017-03-02: Demo of internationalization (i18n) is live at [reactrails.com](https://reactrails.com/). Docs [here](docs/guides/i18n.md).
25
25
  - 2017-02-28: See [discussions here on Webpacker](https://github.com/rails/webpacker/issues/139) regarding how Webpacker will allow React on Rails to avoid using the asset pipeline in the near future.
26
26
  - 2017-02-28: Upgrade to Webpack v2 or use the `--bail` option in your Webpack script for test and production builds. See the discussion on [PR #730](https://github.com/shakacode/react_on_rails/pull/730).
27
27
  - 2016-11-03: Spoke at [LA Ruby: "React on Rails: Why, What, and How?"](http://www.meetup.com/laruby/events/234825187/). [Video and pictures in this article](https://blog.shakacode.com/my-react-on-rails-talk-at-the-la-ruby-rails-meetup-november-10-2016-eaaa83aff800#.ej6h4eglp).
data/README.md CHANGED
@@ -140,16 +140,21 @@ _Requires creating a free account._
140
140
  - Node.js >= 20 (CI tested: 20 - 22)
141
141
  - A JavaScript package manager (npm, yarn, pnpm, or bun)
142
142
 
143
- # Support
143
+ # 🆘 Get Help & Support
144
144
 
145
- - [Click to join **React + Rails Slack**](https://join.slack.com/t/reactrails/shared_invite/zt-38oicm9d0-OO0V~bdg4aYNuZuUbRFSXg).
145
+ **Need immediate help?** Here are your options, ordered by response time:
146
146
 
147
- - [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases of React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials.
148
- - [Discussions](https://github.com/shakacode/react_on_rails/discussions): Post your questions regarding React on Rails
149
- - **[forum.shakacode.com](https://forum.shakacode.com)**: Other discussions
150
- - **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
151
- - _See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time._
152
- - See [Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) using and [KUDOS](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
147
+ - 🚀 **Professional Support**: [react_on_rails@shakacode.com](mailto:react_on_rails@shakacode.com) - Fastest resolution for bugs, upgrades, and consulting
148
+ - 💬 **React + Rails Slack**: [Join our community](https://invite.reactrails.com) - Chat with other developers
149
+ - 🆓 **GitHub Issues**: [Report bugs](https://github.com/shakacode/react_on_rails/issues) - Community support
150
+ - 📖 **Discussions**: [Ask questions](https://github.com/shakacode/react_on_rails/discussions) - General help
151
+
152
+ **Additional Resources:**
153
+
154
+ - [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases and tutorials
155
+ - **[forum.shakacode.com](https://forum.shakacode.com)** - Development discussions
156
+ - **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)** - Updates and tips
157
+ - [Projects using React on Rails](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) - Submit yours!
153
158
 
154
159
  ## Contributing
155
160
 
@@ -163,6 +168,8 @@ ShakaCode is **[hiring passionate software engineers](http://www.shakacode.com/c
163
168
 
164
169
  The gem is available as open source under the terms of the [MIT License](https://github.com/shakacode/react_on_rails/tree/master/LICENSE.md).
165
170
 
171
+ Note, some features are available only with a React on Rails Pro subscription. See [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/) for more information.
172
+
166
173
  # Supporters
167
174
 
168
175
  The following companies support our open-source projects, and ShakaCode uses their products!
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env bash
2
+ # Check for trailing newlines on all changed files
3
+ set -euo pipefail
4
+
5
+ CONTEXT="${1:-staged}"
6
+ files="$(bin/lefthook/get-changed-files "$CONTEXT" '.*')"
7
+
8
+ if [ -z "$files" ]; then
9
+ echo "✅ No files to check for trailing newlines"
10
+ exit 0
11
+ fi
12
+
13
+ if [ "$CONTEXT" = "all-changed" ]; then
14
+ echo "🔍 Checking trailing newlines on all changed files..."
15
+ else
16
+ echo "🔍 Checking trailing newlines on $CONTEXT files..."
17
+ fi
18
+
19
+ failed_files=""
20
+ for file in $files; do
21
+ if [ -f "$file" ] && [ -s "$file" ]; then
22
+ if ! tail -c 1 "$file" | grep -q '^$'; then
23
+ echo "❌ Missing trailing newline: $file"
24
+ failed_files="$failed_files $file"
25
+ fi
26
+ fi
27
+ done
28
+
29
+ if [ -n "$failed_files" ]; then
30
+ echo ""
31
+ echo "❌ Trailing newline check failed!"
32
+ echo "💡 Add trailing newlines to:$failed_files"
33
+ echo "🔧 Quick fix: for file in$failed_files; do echo >> \"\$file\"; done"
34
+ echo "🚫 Skip hook: git commit --no-verify"
35
+ exit 1
36
+ fi
37
+
38
+ echo "✅ All files have proper trailing newlines"
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # Get changed files based on context (staged, branch, or all)
3
+ set -euo pipefail
4
+
5
+ CONTEXT="${1:-staged}"
6
+ PATTERN="${2:-.*}"
7
+
8
+ case "$CONTEXT" in
9
+ staged)
10
+ git diff --cached --name-only --diff-filter=ACM | grep -E "$PATTERN" || true
11
+ ;;
12
+ all-changed)
13
+ # Get all changed files (staged + unstaged + untracked) vs working directory
14
+ (git diff --cached --name-only --diff-filter=ACM; git diff --name-only --diff-filter=ACM; git ls-files --others --exclude-standard) | sort -u | grep -E "$PATTERN" || true
15
+ ;;
16
+ branch)
17
+ # Find base branch (prefer main over master)
18
+ base="origin/main"
19
+ git rev-parse --verify --quiet "$base" >/dev/null || base="origin/master"
20
+ git diff --name-only --diff-filter=ACM "$base"...HEAD | grep -E "$PATTERN" || true
21
+ ;;
22
+ *)
23
+ echo "Usage: $0 {staged|all-changed|branch} [pattern]" >&2
24
+ exit 1
25
+ ;;
26
+ esac
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # Format JS/TS/JSON/MD files with Prettier
3
+ set -euo pipefail
4
+
5
+ CONTEXT="${1:-staged}"
6
+ files="$(bin/lefthook/get-changed-files "$CONTEXT" '\.(js|jsx|ts|tsx|json|md|yml|yaml)$')"
7
+
8
+ if [ -z "$files" ]; then
9
+ echo "✅ No files to format with Prettier"
10
+ exit 0
11
+ fi
12
+
13
+ if [ "$CONTEXT" = "all-changed" ]; then
14
+ echo "💅 Prettier on all changed files:"
15
+ else
16
+ echo "💅 Prettier on $CONTEXT files:"
17
+ fi
18
+ printf " %s\n" $files
19
+
20
+ yarn run prettier --write $files
21
+
22
+ # Re-stage files if running on staged or all-changed context
23
+ if [ "$CONTEXT" = "staged" ] || [ "$CONTEXT" = "all-changed" ]; then
24
+ echo $files | xargs -r git add
25
+ echo "✅ Re-staged formatted files"
26
+ fi
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # Auto-fix Ruby files using rake autofix
3
+ set -euo pipefail
4
+
5
+ CONTEXT="${1:-staged}"
6
+ files="$(bin/lefthook/get-changed-files "$CONTEXT" '\.(rb|rake|ru)$')"
7
+
8
+ if [ -z "$files" ]; then
9
+ echo "✅ No Ruby files to autofix"
10
+ exit 0
11
+ fi
12
+
13
+ if [ "$CONTEXT" = "all-changed" ]; then
14
+ echo "🎨 Autofix on all changed Ruby files:"
15
+ else
16
+ echo "🎨 Autofix on $CONTEXT Ruby files:"
17
+ fi
18
+ printf " %s\n" $files
19
+
20
+ bundle exec rake autofix
21
+
22
+ # Re-stage files if running on staged or all-changed context
23
+ if [ "$CONTEXT" = "staged" ] || [ "$CONTEXT" = "all-changed" ]; then
24
+ echo $files | xargs -r git add
25
+ echo "✅ Re-staged formatted files"
26
+ fi
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+ # Lint Ruby files with RuboCop
3
+ set -euo pipefail
4
+
5
+ CONTEXT="${1:-staged}"
6
+ files="$(bin/lefthook/get-changed-files "$CONTEXT" '\.(rb|rake|ru)$')"
7
+
8
+ if [ -z "$files" ]; then
9
+ echo "✅ No Ruby files to lint"
10
+ exit 0
11
+ fi
12
+
13
+ if [ "$CONTEXT" = "all-changed" ]; then
14
+ echo "🔍 RuboCop on all changed Ruby files:"
15
+ else
16
+ echo "🔍 RuboCop on $CONTEXT Ruby files:"
17
+ fi
18
+ printf " %s\n" $files
19
+
20
+ if ! bundle exec rubocop --force-exclusion --display-cop-names -- $files; then
21
+ echo ""
22
+ echo "❌ RuboCop check failed!"
23
+ echo "💡 Auto-fix: bundle exec rubocop --auto-correct --force-exclusion -- $files"
24
+ echo "🚫 Skip hook: git commit --no-verify"
25
+ exit 1
26
+ fi
27
+ echo "✅ RuboCop checks passed for Ruby files"
data/eslint.config.ts CHANGED
@@ -159,6 +159,13 @@ const config = tsEslint.config([
159
159
  'react/prop-types': 'off',
160
160
  },
161
161
  },
162
+ {
163
+ files: ['spec/dummy/**/*'],
164
+ rules: {
165
+ // The dummy app dependencies are managed separately and may not be installed
166
+ 'import/no-unresolved': 'off',
167
+ },
168
+ },
162
169
  {
163
170
  files: ['**/*.ts{x,}', '**/*.[cm]ts'],
164
171
 
@@ -24,7 +24,7 @@ module ReactOnRails
24
24
  end
25
25
 
26
26
  def create_react_directories
27
- # Create auto-registration directory structure for non-Redux components only
27
+ # Create auto-bundling directory structure for non-Redux components only
28
28
  # Redux components handle their own directory structure
29
29
  return if options.redux?
30
30
 
@@ -41,7 +41,7 @@ module ReactOnRails
41
41
  base_templates = %w[config/initializers/react_on_rails.rb]
42
42
  base_files.each { |file| copy_file("#{base_path}#{file}", file) }
43
43
  base_templates.each do |file|
44
- template("#{base_path}/#{file}.tt", file, { packer_type: ReactOnRails::PackerUtils.packer_type })
44
+ template("#{base_path}/#{file}.tt", file)
45
45
  end
46
46
  end
47
47
 
@@ -95,55 +95,22 @@ module ReactOnRails
95
95
  run "bundle"
96
96
  end
97
97
 
98
- def add_js_dependencies
99
- add_react_on_rails_package
100
- add_react_dependencies
101
- add_css_dependencies
102
- add_dev_dependencies
103
- end
104
-
105
- def install_js_dependencies
106
- # Detect which package manager to use
107
- success = if File.exist?(File.join(destination_root, "yarn.lock"))
108
- system("yarn", "install")
109
- elsif File.exist?(File.join(destination_root, "pnpm-lock.yaml"))
110
- system("pnpm", "install")
111
- elsif File.exist?(File.join(destination_root, "package-lock.json")) ||
112
- File.exist?(File.join(destination_root, "package.json"))
113
- # Use npm for package-lock.json or as default fallback
114
- system("npm", "install")
115
- else
116
- true # No package manager detected, skip
117
- end
118
-
119
- unless success
120
- GeneratorMessages.add_warning(<<~MSG.strip)
121
- ⚠️ JavaScript dependencies installation failed.
122
-
123
- This could be due to network issues or missing package manager.
124
- You can install dependencies manually later by running:
125
- • npm install (if using npm)
126
- • yarn install (if using yarn)
127
- • pnpm install (if using pnpm)
128
- MSG
129
- end
130
-
131
- success
132
- end
133
-
134
98
  def update_gitignore_for_auto_registration
135
99
  gitignore_path = File.join(destination_root, ".gitignore")
136
100
  return unless File.exist?(gitignore_path)
137
101
 
138
102
  gitignore_content = File.read(gitignore_path)
139
- return if gitignore_content.include?("**/generated/**")
140
103
 
141
- append_to_file ".gitignore" do
142
- <<~GITIGNORE
104
+ additions = []
105
+ additions << "**/generated/**" unless gitignore_content.include?("**/generated/**")
106
+ additions << "ssr-generated" unless gitignore_content.include?("ssr-generated")
107
+
108
+ return if additions.empty?
143
109
 
144
- # Generated React on Rails packs
145
- **/generated/**
146
- GITIGNORE
110
+ append_to_file ".gitignore" do
111
+ lines = ["\n# Generated React on Rails packs"]
112
+ lines.concat(additions)
113
+ "#{lines.join("\n")}\n"
147
114
  end
148
115
  end
149
116
 
@@ -157,6 +124,28 @@ module ReactOnRails
157
124
  end
158
125
  end
159
126
 
127
+ CONFIGURE_RSPEC_TO_COMPILE_ASSETS = <<-STR.strip_heredoc
128
+ RSpec.configure do |config|
129
+ # Ensure that if we are running js tests, we are using latest webpack assets
130
+ # This will use the defaults of :js and :server_rendering meta tags
131
+ ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
132
+ end
133
+ STR
134
+
135
+ private
136
+
137
+ def setup_js_dependencies
138
+ add_js_dependencies
139
+ install_js_dependencies
140
+ end
141
+
142
+ def add_js_dependencies
143
+ add_react_on_rails_package
144
+ add_react_dependencies
145
+ add_css_dependencies
146
+ add_dev_dependencies
147
+ end
148
+
160
149
  def add_react_on_rails_package
161
150
  major_minor_patch_only = /\A\d+\.\d+\.\d+\z/
162
151
 
@@ -219,15 +208,34 @@ module ReactOnRails
219
208
  handle_npm_failure("development dependencies", dev_deps, dev: true) unless success
220
209
  end
221
210
 
222
- CONFIGURE_RSPEC_TO_COMPILE_ASSETS = <<-STR.strip_heredoc
223
- RSpec.configure do |config|
224
- # Ensure that if we are running js tests, we are using latest webpack assets
225
- # This will use the defaults of :js and :server_rendering meta tags
226
- ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
211
+ def install_js_dependencies
212
+ # Detect which package manager to use
213
+ success = if File.exist?(File.join(destination_root, "yarn.lock"))
214
+ system("yarn", "install")
215
+ elsif File.exist?(File.join(destination_root, "pnpm-lock.yaml"))
216
+ system("pnpm", "install")
217
+ elsif File.exist?(File.join(destination_root, "package-lock.json")) ||
218
+ File.exist?(File.join(destination_root, "package.json"))
219
+ # Use npm for package-lock.json or as default fallback
220
+ system("npm", "install")
221
+ else
222
+ true # No package manager detected, skip
223
+ end
224
+
225
+ unless success
226
+ GeneratorMessages.add_warning(<<~MSG.strip)
227
+ ⚠️ JavaScript dependencies installation failed.
228
+
229
+ This could be due to network issues or missing package manager.
230
+ You can install dependencies manually later by running:
231
+ • npm install (if using npm)
232
+ • yarn install (if using yarn)
233
+ • pnpm install (if using pnpm)
234
+ MSG
227
235
  end
228
- STR
229
236
 
230
- private
237
+ success
238
+ end
231
239
 
232
240
  def handle_npm_failure(dependency_type, packages, dev: false)
233
241
  install_command = dev ? "npm install --save-dev" : "npm install"