react_on_rails_pro 16.2.0.beta.8

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 (109) hide show
  1. checksums.yaml +7 -0
  2. data/.controlplane/Dockerfile +49 -0
  3. data/.controlplane/controlplane.yml +22 -0
  4. data/.controlplane/gvc.yml +25 -0
  5. data/.controlplane/postgres.yml +33 -0
  6. data/.controlplane/rails.yml +49 -0
  7. data/.controlplane/redis.yml +18 -0
  8. data/.gitignore +77 -0
  9. data/.prettierignore +12 -0
  10. data/.prettierrc +19 -0
  11. data/.rspec +2 -0
  12. data/.rubocop.yml +120 -0
  13. data/.scss-lint.yml +205 -0
  14. data/CHANGELOG.md +570 -0
  15. data/CI_SETUP.md +502 -0
  16. data/CONTRIBUTING.md +376 -0
  17. data/Dockerfile +63 -0
  18. data/Gemfile +8 -0
  19. data/Gemfile.development_dependencies +74 -0
  20. data/Gemfile.loader +32 -0
  21. data/Gemfile.lock +527 -0
  22. data/LICENSE +98 -0
  23. data/LICENSE_SETUP.md +272 -0
  24. data/README.md +577 -0
  25. data/Rakefile +13 -0
  26. data/app/controllers/react_on_rails_pro/rsc_payload_controller.rb +7 -0
  27. data/app/helpers/react_on_rails_pro_helper.rb +360 -0
  28. data/app/views/react_on_rails_pro/rsc_payload.html.erb +1 -0
  29. data/babel.config.js +4 -0
  30. data/docs/bundle-caching.md +205 -0
  31. data/docs/caching.md +234 -0
  32. data/docs/code-splitting-loadable-components.md +313 -0
  33. data/docs/code-splitting.md +349 -0
  34. data/docs/configuration.md +165 -0
  35. data/docs/contributors-info/onboarding-customers.md +6 -0
  36. data/docs/contributors-info/releasing.md +40 -0
  37. data/docs/contributors-info/style.md +33 -0
  38. data/docs/home-pro.md +146 -0
  39. data/docs/installation.md +203 -0
  40. data/docs/js-memory-leaks.md +22 -0
  41. data/docs/node-renderer/basics.md +92 -0
  42. data/docs/node-renderer/debugging.md +38 -0
  43. data/docs/node-renderer/error-reporting-and-tracing.md +160 -0
  44. data/docs/node-renderer/heroku.md +102 -0
  45. data/docs/node-renderer/js-configuration.md +91 -0
  46. data/docs/node-renderer/troubleshooting.md +5 -0
  47. data/docs/profiling-server-side-rendering-code.md +179 -0
  48. data/docs/react-server-components/add-streaming-and-interactivity.md +190 -0
  49. data/docs/react-server-components/create-without-ssr.md +448 -0
  50. data/docs/react-server-components/glossary.md +102 -0
  51. data/docs/react-server-components/how-react-server-components-work.md +243 -0
  52. data/docs/react-server-components/inside-client-components.md +332 -0
  53. data/docs/react-server-components/purpose-and-benefits.md +243 -0
  54. data/docs/react-server-components/rendering-flow.md +86 -0
  55. data/docs/react-server-components/selective-hydration-in-streamed-components.md +75 -0
  56. data/docs/react-server-components/server-side-rendering.md +72 -0
  57. data/docs/react-server-components/tutorial.md +19 -0
  58. data/docs/release-notes/4.0.md +94 -0
  59. data/docs/release-notes/v4-react-server-components.md +66 -0
  60. data/docs/ruby-api.md +11 -0
  61. data/docs/streaming-server-rendering.md +210 -0
  62. data/docs/troubleshooting.md +24 -0
  63. data/docs/updating.md +219 -0
  64. data/eslint.config.mjs +220 -0
  65. data/lib/react_on_rails_pro/assets_precompile.rb +230 -0
  66. data/lib/react_on_rails_pro/cache.rb +88 -0
  67. data/lib/react_on_rails_pro/concerns/rsc_payload_renderer.rb +38 -0
  68. data/lib/react_on_rails_pro/concerns/stream.rb +103 -0
  69. data/lib/react_on_rails_pro/configuration.rb +228 -0
  70. data/lib/react_on_rails_pro/constants.rb +8 -0
  71. data/lib/react_on_rails_pro/engine.rb +24 -0
  72. data/lib/react_on_rails_pro/error.rb +14 -0
  73. data/lib/react_on_rails_pro/license_public_key.rb +30 -0
  74. data/lib/react_on_rails_pro/license_validator.rb +188 -0
  75. data/lib/react_on_rails_pro/prepare_node_renderer_bundles.rb +40 -0
  76. data/lib/react_on_rails_pro/rendering_error.rb +5 -0
  77. data/lib/react_on_rails_pro/request.rb +318 -0
  78. data/lib/react_on_rails_pro/routes.rb +13 -0
  79. data/lib/react_on_rails_pro/server_rendering_js_code.rb +102 -0
  80. data/lib/react_on_rails_pro/server_rendering_pool/node_rendering_pool.rb +133 -0
  81. data/lib/react_on_rails_pro/server_rendering_pool/pro_rendering.rb +117 -0
  82. data/lib/react_on_rails_pro/stream_cache.rb +61 -0
  83. data/lib/react_on_rails_pro/stream_request.rb +170 -0
  84. data/lib/react_on_rails_pro/utils.rb +222 -0
  85. data/lib/react_on_rails_pro/v8_log_processor.rb +50 -0
  86. data/lib/react_on_rails_pro/version.rb +6 -0
  87. data/lib/react_on_rails_pro.rb +23 -0
  88. data/package-scripts.yml +109 -0
  89. data/package.json +159 -0
  90. data/rakelib/dummy_apps.rake +22 -0
  91. data/rakelib/lint.rake +32 -0
  92. data/rakelib/public_key_management.rake +155 -0
  93. data/rakelib/rbs.rake +47 -0
  94. data/rakelib/run_rspec.rake +81 -0
  95. data/rakelib/task_helpers.rb +45 -0
  96. data/rakelib/yard.rake +20 -0
  97. data/react_on_rails_pro.gemspec +47 -0
  98. data/readme-gen-docs.md +1 -0
  99. data/script/bootstrap +33 -0
  100. data/script/preinstall.js +31 -0
  101. data/script/setup +23 -0
  102. data/script/test +38 -0
  103. data/sig/react_on_rails_pro/cache.rbs +13 -0
  104. data/sig/react_on_rails_pro/configuration.rbs +100 -0
  105. data/sig/react_on_rails_pro/error.rbs +4 -0
  106. data/sig/react_on_rails_pro/utils.rbs +7 -0
  107. data/sig/react_on_rails_pro.rbs +5 -0
  108. data/yarn.lock +7599 -0
  109. metadata +319 -0
data/CI_SETUP.md ADDED
@@ -0,0 +1,502 @@
1
+ # React on Rails Pro - CI/CD Setup Guide
2
+
3
+ This guide explains how to configure React on Rails Pro licenses for CI/CD environments.
4
+
5
+ ## Quick Start
6
+
7
+ **All CI/CD environments require a valid license!**
8
+
9
+ 1. Get a FREE 3-month license at [shakacode.com/react-on-rails-pro](https://shakacode.com/react-on-rails-pro)
10
+ 2. Add `REACT_ON_RAILS_PRO_LICENSE` to your CI environment variables
11
+ 3. Done! Your tests will run with a valid license
12
+
13
+ **⚠️ Important: The free 3-month evaluation license is intended for personal, educational, and evaluation purposes only (including CI/CD testing). It should NOT be used for production deployments. Production use requires a paid license.**
14
+
15
+ ## Getting a License for CI
16
+
17
+ You have two options:
18
+
19
+ ### Option 1: Use a Team Member's License
20
+ - Any developer's FREE license works for CI
21
+ - Share it via CI secrets/environment variables
22
+ - Easy and quick
23
+
24
+ ### Option 2: Create a Dedicated CI License
25
+ - Register with `ci@yourcompany.com` or similar
26
+ - Get a FREE 3-month evaluation license (for personal, educational, and evaluation purposes only)
27
+ - Renew every 3 months (or use a paid license for production)
28
+
29
+ ## Configuration by CI Provider
30
+
31
+ ### GitHub Actions
32
+
33
+ **Step 1: Add License to Secrets**
34
+
35
+ 1. Go to your repository settings
36
+ 2. Navigate to: Settings → Secrets and variables → Actions
37
+ 3. Click "New repository secret"
38
+ 4. Name: `REACT_ON_RAILS_PRO_LICENSE`
39
+ 5. Value: Your complete JWT license token (starts with `eyJ...`)
40
+
41
+ **Step 2: Use in Workflow**
42
+
43
+ ```yaml
44
+ # .github/workflows/test.yml
45
+ name: Tests
46
+
47
+ on: [push, pull_request]
48
+
49
+ jobs:
50
+ test:
51
+ runs-on: ubuntu-latest
52
+
53
+ env:
54
+ REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.REACT_ON_RAILS_PRO_LICENSE }}
55
+
56
+ steps:
57
+ - uses: actions/checkout@v3
58
+
59
+ - name: Set up Ruby
60
+ uses: ruby/setup-ruby@v1
61
+ with:
62
+ ruby-version: 3.3
63
+ bundler-cache: true
64
+
65
+ - name: Set up Node
66
+ uses: actions/setup-node@v3
67
+ with:
68
+ node-version: '18'
69
+ cache: 'yarn'
70
+
71
+ - name: Install dependencies
72
+ run: |
73
+ bundle install
74
+ yarn install
75
+
76
+ - name: Run tests
77
+ run: bundle exec rspec
78
+ ```
79
+
80
+ ### GitLab CI/CD
81
+
82
+ **Step 1: Add License to CI/CD Variables**
83
+
84
+ 1. Go to your project
85
+ 2. Navigate to: Settings → CI/CD → Variables
86
+ 3. Click "Add variable"
87
+ 4. Key: `REACT_ON_RAILS_PRO_LICENSE`
88
+ 5. Value: Your license token
89
+ 6. ✅ Check "Protect variable" (optional)
90
+ 7. ✅ Check "Mask variable" (recommended)
91
+
92
+ **Step 2: Use in Pipeline**
93
+
94
+ ```yaml
95
+ # .gitlab-ci.yml
96
+ image: ruby:3.3
97
+
98
+ variables:
99
+ RAILS_ENV: test
100
+ NODE_ENV: test
101
+
102
+ before_script:
103
+ - gem install bundler
104
+ - bundle install --jobs $(nproc)
105
+ - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
106
+ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
107
+ - apt-get update && apt-get install -y nodejs yarn
108
+ - yarn install
109
+
110
+ test:
111
+ script:
112
+ - bundle exec rspec
113
+ # License is automatically available from CI/CD variables
114
+ ```
115
+
116
+ ### CircleCI
117
+
118
+ **Step 1: Add License to Environment Variables**
119
+
120
+ 1. Go to your project settings
121
+ 2. Navigate to: Project Settings → Environment Variables
122
+ 3. Click "Add Environment Variable"
123
+ 4. Name: `REACT_ON_RAILS_PRO_LICENSE`
124
+ 5. Value: Your license token
125
+
126
+ **Step 2: Use in Config**
127
+
128
+ ```yaml
129
+ # .circleci/config.yml
130
+ version: 2.1
131
+
132
+ jobs:
133
+ test:
134
+ docker:
135
+ - image: cimg/ruby:3.3-node
136
+
137
+ steps:
138
+ - checkout
139
+
140
+ - restore_cache:
141
+ keys:
142
+ - gem-cache-{{ checksum "Gemfile.lock" }}
143
+ - yarn-cache-{{ checksum "yarn.lock" }}
144
+
145
+ - run:
146
+ name: Install dependencies
147
+ command: |
148
+ bundle install --path vendor/bundle
149
+ yarn install
150
+
151
+ - save_cache:
152
+ key: gem-cache-{{ checksum "Gemfile.lock" }}
153
+ paths:
154
+ - vendor/bundle
155
+
156
+ - save_cache:
157
+ key: yarn-cache-{{ checksum "yarn.lock" }}
158
+ paths:
159
+ - node_modules
160
+
161
+ - run:
162
+ name: Run tests
163
+ command: bundle exec rspec
164
+ # License is automatically available from environment variables
165
+
166
+ workflows:
167
+ version: 2
168
+ test:
169
+ jobs:
170
+ - test
171
+ ```
172
+
173
+ ### Travis CI
174
+
175
+ **Step 1: Add License to Environment Variables**
176
+
177
+ 1. Go to your repository settings on Travis CI
178
+ 2. Navigate to: More options → Settings → Environment Variables
179
+ 3. Name: `REACT_ON_RAILS_PRO_LICENSE`
180
+ 4. Value: Your license token
181
+ 5. ✅ Check "Display value in build log": **NO** (keep it secret)
182
+
183
+ **Step 2: Use in Config**
184
+
185
+ ```yaml
186
+ # .travis.yml
187
+ language: ruby
188
+ rvm:
189
+ - 3.3
190
+
191
+ node_js:
192
+ - 18
193
+
194
+ cache:
195
+ bundler: true
196
+ yarn: true
197
+
198
+ before_install:
199
+ - nvm install 18
200
+ - node --version
201
+ - yarn --version
202
+
203
+ install:
204
+ - bundle install
205
+ - yarn install
206
+
207
+ script:
208
+ - bundle exec rspec
209
+ # License is automatically available from environment variables
210
+ ```
211
+
212
+ ### Jenkins
213
+
214
+ **Step 1: Add License to Credentials**
215
+
216
+ 1. Go to Jenkins → Manage Jenkins → Manage Credentials
217
+ 2. Select appropriate domain
218
+ 3. Add Credentials → Secret text
219
+ 4. Secret: Your license token
220
+ 5. ID: `REACT_ON_RAILS_PRO_LICENSE`
221
+ 6. Description: "React on Rails Pro License"
222
+
223
+ **Step 2: Use in Jenkinsfile**
224
+
225
+ ```groovy
226
+ // Jenkinsfile
227
+ pipeline {
228
+ agent any
229
+
230
+ environment {
231
+ RAILS_ENV = 'test'
232
+ NODE_ENV = 'test'
233
+ }
234
+
235
+ stages {
236
+ stage('Setup') {
237
+ steps {
238
+ // Load license from credentials
239
+ withCredentials([string(credentialsId: 'REACT_ON_RAILS_PRO_LICENSE', variable: 'REACT_ON_RAILS_PRO_LICENSE')]) {
240
+ sh 'echo "License loaded"'
241
+ }
242
+ }
243
+ }
244
+
245
+ stage('Install Dependencies') {
246
+ steps {
247
+ sh 'bundle install'
248
+ sh 'yarn install'
249
+ }
250
+ }
251
+
252
+ stage('Test') {
253
+ steps {
254
+ withCredentials([string(credentialsId: 'REACT_ON_RAILS_PRO_LICENSE', variable: 'REACT_ON_RAILS_PRO_LICENSE')]) {
255
+ sh 'bundle exec rspec'
256
+ }
257
+ }
258
+ }
259
+ }
260
+ }
261
+ ```
262
+
263
+ ### Bitbucket Pipelines
264
+
265
+ **Step 1: Add License to Repository Variables**
266
+
267
+ 1. Go to Repository settings
268
+ 2. Navigate to: Pipelines → Repository variables
269
+ 3. Name: `REACT_ON_RAILS_PRO_LICENSE`
270
+ 4. Value: Your license token
271
+ 5. ✅ Check "Secured" (recommended)
272
+
273
+ **Step 2: Use in Pipeline**
274
+
275
+ ```yaml
276
+ # bitbucket-pipelines.yml
277
+ image: ruby:3.3
278
+
279
+ definitions:
280
+ caches:
281
+ bundler: vendor/bundle
282
+ yarn: node_modules
283
+
284
+ pipelines:
285
+ default:
286
+ - step:
287
+ name: Test
288
+ caches:
289
+ - bundler
290
+ - yarn
291
+ script:
292
+ - apt-get update && apt-get install -y nodejs npm
293
+ - npm install -g yarn
294
+ - bundle install --path vendor/bundle
295
+ - yarn install
296
+ - bundle exec rspec
297
+ # License is automatically available from repository variables
298
+ ```
299
+
300
+ ### Generic CI (Environment Variable)
301
+
302
+ For any CI system that supports environment variables:
303
+
304
+ **Step 1: Export Environment Variable**
305
+
306
+ ```bash
307
+ export REACT_ON_RAILS_PRO_LICENSE="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
308
+ ```
309
+
310
+ **Step 2: Run Tests**
311
+
312
+ ```bash
313
+ bundle install
314
+ yarn install
315
+ bundle exec rspec
316
+ ```
317
+
318
+ The license will be automatically picked up from the environment variable.
319
+
320
+ ## Docker-based CI
321
+
322
+ If using Docker in CI:
323
+
324
+ ```dockerfile
325
+ # Dockerfile
326
+ FROM ruby:3.3-node
327
+
328
+ # ... other setup ...
329
+
330
+ # License will be passed at runtime via environment variable
331
+ # DO NOT COPY license file into image
332
+ ENV REACT_ON_RAILS_PRO_LICENSE=""
333
+
334
+ CMD ["bundle", "exec", "rspec"]
335
+ ```
336
+
337
+ **Run with license:**
338
+
339
+ ```bash
340
+ docker run -e REACT_ON_RAILS_PRO_LICENSE="$REACT_ON_RAILS_PRO_LICENSE" your-image
341
+ ```
342
+
343
+ ## Verification
344
+
345
+ License validation happens automatically when Rails starts.
346
+
347
+ ✅ **If your CI tests run, your license is valid**
348
+ ❌ **If license is invalid, Rails fails to start immediately**
349
+
350
+ **No verification step needed** - the application won't start without a valid license.
351
+
352
+ ### Debug License Issues
353
+
354
+ If Rails fails to start in CI with license errors:
355
+
356
+ ```bash
357
+ # Check if license environment variable is set (show first 20 chars only)
358
+ echo "License set: ${REACT_ON_RAILS_PRO_LICENSE:0:20}..."
359
+
360
+ # Decode the license to check expiration
361
+ bundle exec rails runner "
362
+ require 'jwt'
363
+ payload = JWT.decode(ENV['REACT_ON_RAILS_PRO_LICENSE'], nil, false).first
364
+ puts 'Email: ' + payload['sub']
365
+ puts 'Expires: ' + Time.at(payload['exp']).to_s
366
+ puts 'Expired: ' + (Time.now.to_i > payload['exp']).to_s
367
+ "
368
+ ```
369
+
370
+ **Common issues:**
371
+ - License not set in CI environment variables
372
+ - License truncated when copying (should be 500+ characters)
373
+ - License expired (get a new FREE license at https://shakacode.com/react-on-rails-pro)
374
+
375
+ ## Security Best Practices
376
+
377
+ 1. ✅ **Always use secrets/encrypted variables** - Never commit licenses to code
378
+ 2. ✅ **Mask license in logs** - Most CI systems support this
379
+ 3. ✅ **Limit license access** - Only give to necessary jobs/pipelines
380
+ 4. ✅ **Rotate regularly** - Get new FREE license every 3 months
381
+ 5. ✅ **Use organization secrets** - Share across repositories when appropriate
382
+
383
+ ## Troubleshooting
384
+
385
+ ### Error: "No license found" in CI
386
+
387
+ **Checklist:**
388
+ - ✅ License added to CI environment variables
389
+ - ✅ Variable name is exactly `REACT_ON_RAILS_PRO_LICENSE`
390
+ - ✅ License value is complete (not truncated)
391
+ - ✅ License is accessible in the job/step
392
+
393
+ **Debug:**
394
+ ```bash
395
+ # Check if variable exists (don't print full value!)
396
+ if [ -n "$REACT_ON_RAILS_PRO_LICENSE" ]; then
397
+ echo "✅ License environment variable is set"
398
+ else
399
+ echo "❌ License environment variable is NOT set"
400
+ fi
401
+ ```
402
+
403
+ ### Error: "License has expired"
404
+
405
+ **Solution:**
406
+ 1. Get a new FREE 3-month license from [shakacode.com/react-on-rails-pro](https://shakacode.com/react-on-rails-pro)
407
+ 2. Update the `REACT_ON_RAILS_PRO_LICENSE` variable in your CI settings
408
+ 3. Done! No code changes needed
409
+
410
+ ### Tests Pass Locally But Fail in CI
411
+
412
+ **Common causes:**
413
+ - License not set in CI environment
414
+ - Wrong variable name
415
+ - License truncated when copying
416
+
417
+ **Solution:**
418
+ Compare local and CI environments:
419
+
420
+ ```bash
421
+ # Local
422
+ echo $REACT_ON_RAILS_PRO_LICENSE | wc -c # Should be ~500+ characters
423
+
424
+ # In CI (add debug step)
425
+ echo $REACT_ON_RAILS_PRO_LICENSE | wc -c # Should match local
426
+ ```
427
+
428
+ ## Multiple Environments
429
+
430
+ ### Separate Licenses for Different Environments
431
+
432
+ If you want different licenses per environment:
433
+
434
+ ```yaml
435
+ # GitHub Actions example
436
+ jobs:
437
+ test:
438
+ env:
439
+ REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.CI_LICENSE }}
440
+
441
+ staging-deploy:
442
+ env:
443
+ REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.STAGING_LICENSE }}
444
+
445
+ production-deploy:
446
+ env:
447
+ REACT_ON_RAILS_PRO_LICENSE: ${{ secrets.PRODUCTION_LICENSE }}
448
+ ```
449
+
450
+ ### When to Use Different Licenses
451
+
452
+ - **CI/Test**: FREE evaluation license (for personal, educational, and evaluation purposes - renew every 3 months)
453
+ - **Staging**: Can use FREE evaluation license for non-production testing or paid license
454
+ - **Production**: Paid license (required - free licenses are NOT for production use)
455
+
456
+ ## License Renewal
457
+
458
+ ### Setting Up Renewal Reminders
459
+
460
+ FREE evaluation licenses (for personal, educational, and evaluation purposes only) expire every 3 months. Set a reminder:
461
+
462
+ 1. **Calendar reminder**: 2 weeks before expiration
463
+ 2. **CI notification**: Tests will fail when expired
464
+ 3. **Email**: We'll send renewal reminders
465
+
466
+ ### Renewal Process
467
+
468
+ 1. Visit [shakacode.com/react-on-rails-pro](https://shakacode.com/react-on-rails-pro)
469
+ 2. Log in with your email
470
+ 3. Get new FREE license (or upgrade to paid)
471
+ 4. Update `REACT_ON_RAILS_PRO_LICENSE` in CI settings
472
+ 5. Done! No code changes needed
473
+
474
+ ## Support
475
+
476
+ Need help with CI setup?
477
+
478
+ - **Documentation**: [LICENSE_SETUP.md](./LICENSE_SETUP.md)
479
+ - **Get FREE License**: [shakacode.com/react-on-rails-pro](https://shakacode.com/react-on-rails-pro)
480
+ - **Email Support**: support@shakacode.com
481
+ - **CI Issues**: Include your CI provider name and error message
482
+
483
+ ## License Management
484
+
485
+ **Centralized License Management** (for teams):
486
+
487
+ 1. **1Password/Vault**: Store license in team vault
488
+ 2. **CI Variables**: Sync from secrets manager
489
+ 3. **Documentation**: Keep renewal dates in team wiki
490
+ 4. **Automation**: Script license updates across environments
491
+
492
+ ```bash
493
+ # Example: Update license across multiple CI systems
494
+ ./update-ci-license.sh "new-license-token"
495
+ ```
496
+
497
+ ---
498
+
499
+ **Quick Links:**
500
+ - 🎁 [Get FREE License](https://shakacode.com/react-on-rails-pro)
501
+ - 📚 [General Setup](./LICENSE_SETUP.md)
502
+ - 📧 [Support](mailto:support@shakacode.com)