Skip to content

Commit bc4159c

Browse files
committed
Merge remote-tracking branch 'origin/master' into justin808/ci-docs-guard
* origin/master: Fix Knip configuration after monorepo restructure (#2041) Fix Pro package RuboCop violations (#2038) Fix CI to always run full test suite on master branch (#2035) # Conflicts: # .github/workflows/examples.yml # .github/workflows/gem-tests.yml # .github/workflows/integration-tests.yml # .github/workflows/lint-js-and-ruby.yml # .github/workflows/package-js-tests.yml # .github/workflows/playwright.yml # .github/workflows/pro-integration-tests.yml # .github/workflows/pro-lint.yml # .github/workflows/pro-test-package-and-gem.yml
2 parents 9e6e3e6 + 97d4414 commit bc4159c

File tree

23 files changed

+154
-135
lines changed

23 files changed

+154
-135
lines changed

.github/workflows/pro-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
docs-only: ${{ steps.detect.outputs.docs_only }}
6666
previous-sha: ${{ github.event.before }}
6767

68-
lint-js-and-ruby:
68+
pro-lint-js-and-ruby:
6969
needs: detect-changes
7070
if: |
7171
!(
@@ -160,7 +160,7 @@ jobs:
160160
run: cd spec/dummy && bundle exec rake react_on_rails:generate_packs
161161

162162
- name: Lint Ruby
163-
run: bundle exec rubocop
163+
run: bundle exec rubocop --ignore-parent-exclusion
164164

165165
- name: Validate RBS type signatures
166166
run: bundle exec rake rbs:validate

.gitignore

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,7 @@ tmp/
2020

2121
node_modules
2222

23-
/packages/*/lib
24-
25-
# TypeScript build artifacts in src (shouldn't be there, but just in case)
26-
/packages/*/src/**/*.js
27-
/packages/*/src/**/*.d.ts
28-
/packages/*/src/**/*.d.cts
29-
/packages/*/src/**/*.cjs
30-
/packages/*/src/**/*.map
31-
!/packages/*/src/**/*.test.js
32-
!/packages/*/src/**/*.spec.js
23+
/node_package/lib
3324

3425
yarn-debug.*
3526
yarn-error.*
@@ -75,8 +66,4 @@ ssr-generated
7566

7667
# Claude Code local settings
7768
.claude/settings.local.json
78-
.claude/.fuse_hidden*
79-
80-
# Playwright test artifacts (from cypress-on-rails gem)
81-
/spec/dummy/e2e/playwright-report/
82-
/spec/dummy/test-results/
69+
packages/

knip.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ const config: KnipConfig = {
55
workspaces: {
66
// Root workspace - manages the monorepo and global tooling
77
'.': {
8-
entry: ['eslint.config.ts'],
8+
entry: ['eslint.config.ts', 'jest.config.base.js'],
99
project: ['*.{js,mjs,ts}'],
1010
ignoreBinaries: [
1111
// Has to be installed globally
1212
'yalc',
13-
// Used in package.json scripts (devDependency, so unlisted in production mode)
14-
'nps',
1513
// Pro package binaries used in Pro workflows
1614
'playwright',
1715
'e2e-test',
@@ -41,6 +39,17 @@ const config: KnipConfig = {
4139
// SWC transpiler dependencies used in dummy apps
4240
'@swc/core',
4341
'swc-loader',
42+
// Test dependencies used by child workspaces (packages/react-on-rails, packages/react-on-rails-pro)
43+
'@testing-library/dom',
44+
'@testing-library/jest-dom',
45+
'@testing-library/react',
46+
'@types/react-dom',
47+
'create-react-class',
48+
'jest-fetch-mock',
49+
'prop-types',
50+
'react',
51+
'react-dom',
52+
'redux',
4453
],
4554
},
4655

@@ -89,6 +98,11 @@ const config: KnipConfig = {
8998
'src/RSCRoute.tsx:RSCRouteProps',
9099
'src/streamServerRenderedReactComponent.ts:StreamingTrackers',
91100
],
101+
ignoreDependencies: [
102+
// Test dependencies used only in tests
103+
'@types/mock-fs',
104+
'mock-fs',
105+
],
92106
},
93107
'spec/dummy': {
94108
entry: [
@@ -124,9 +138,6 @@ const config: KnipConfig = {
124138
'bin/.*',
125139
],
126140
ignoreDependencies: [
127-
// Build-time dependencies not detected by Knip in any mode
128-
'@babel/runtime',
129-
'mini-css-extract-plugin',
130141
// There's no ReScript plugin for Knip
131142
'@rescript/react',
132143
// The Babel plugin fails to detect it
@@ -136,13 +147,10 @@ const config: KnipConfig = {
136147
'node-libs-browser',
137148
// The below dependencies are not detected by the Webpack plugin
138149
// due to the config issue.
139-
'css-loader',
140150
'expose-loader',
141151
'file-loader',
142152
'imports-loader',
143153
'null-loader',
144-
'sass',
145-
'sass-loader',
146154
'sass-resources-loader',
147155
'style-loader',
148156
'url-loader',

react_on_rails_pro/lib/react_on_rails_pro/license_public_key.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ module LicensePublicKey
1616
# TODO: Add a prepublish check to ensure this key matches the latest public key from the API.
1717
# This should be implemented after publishing the API endpoint on the ShakaCode website.
1818
KEY = OpenSSL::PKey::RSA.new(<<~PEM.strip.strip_heredoc)
19-
-----BEGIN PUBLIC KEY-----
20-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzcS/fpHz5CbnTQxb4Zot
21-
khjzXu7xNS+Y9VKfapMaHOMzNoCMfy1++hxHJatRedr+YQfZRCjfiN168Cpe+dhe
22-
yfNtOoLU9/+/5jTsxH+WQJWNRswyKms5HNajlIMN1GEYdZmZbvOPaZvh6ENsT+EV
23-
HnhjJtsHl7qltBoL0ul7rONxaNHCzJcKk4lf3B2/1j1wpA91MKz4bbQVh4/6Th0E
24-
/39f0PWvvBXzQS+yt1qaa1DIX5YL6Aug5uEpb1+6QWcN3hCzqSPBv1HahrG50rsD
25-
gf8KORV3X2N9t6j6iqPmRqfRcTBKtmPhM9bORtKiSwBK8LsIUzp2/UUmkdHnkyzu
26-
NQIDAQAB
27-
-----END PUBLIC KEY-----
19+
-----BEGIN PUBLIC KEY-----
20+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzcS/fpHz5CbnTQxb4Zot
21+
khjzXu7xNS+Y9VKfapMaHOMzNoCMfy1++hxHJatRedr+YQfZRCjfiN168Cpe+dhe
22+
yfNtOoLU9/+/5jTsxH+WQJWNRswyKms5HNajlIMN1GEYdZmZbvOPaZvh6ENsT+EV
23+
HnhjJtsHl7qltBoL0ul7rONxaNHCzJcKk4lf3B2/1j1wpA91MKz4bbQVh4/6Th0E
24+
/39f0PWvvBXzQS+yt1qaa1DIX5YL6Aug5uEpb1+6QWcN3hCzqSPBv1HahrG50rsD
25+
gf8KORV3X2N9t6j6iqPmRqfRcTBKtmPhM9bORtKiSwBK8LsIUzp2/UUmkdHnkyzu
26+
NQIDAQAB
27+
-----END PUBLIC KEY-----
2828
PEM
2929
end
3030
end

react_on_rails_pro/lib/react_on_rails_pro/request.rb

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def common_form_data
217217
ReactOnRailsPro::Utils.common_form_data
218218
end
219219

220-
def create_connection
220+
def create_connection # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
221221
url = ReactOnRailsPro.configuration.renderer_url
222222
Rails.logger.info do
223223
"[ReactOnRailsPro] Setting up Node Renderer connection to #{url}"
@@ -229,28 +229,37 @@ def create_connection
229229
# https://honeyryderchuck.gitlab.io/httpx/wiki/Persistent
230230
.plugin(
231231
:retries, max_retries: 1,
232-
retry_change_requests: true,
233-
# Official HTTPx docs says that we should use the retry_on option to decide if teh request should be retried or not
234-
# However, HTTPx assumes that connection errors such as timeout error should be retried by default and it doesn't consider retry_on block at all at that case
235-
# So, we have to do the following trick to avoid retries when a Timeout error happens while streaming a component
236-
# If the streamed component returned any chunks, it shouldn't retry on errors, as it would cause page duplication
237-
# The SSR-generated html will be written to the page two times in this case
238-
retry_after: ->(request, response) do
239-
if (request.stream.instance_variable_get(:@react_on_rails_received_first_chunk))
240-
e = response.error
241-
raise ReactOnRailsPro::Error, "An error happened during server side render streaming of a component.\n" \
242-
"Original error:\n#{e}\n#{e.backtrace}"
243-
end
244-
245-
Rails.logger.info do
246-
"[ReactOnRailsPro] An error happneding while making a request to the Node Renderer.\n" \
247-
"Error: #{response.error}.\n" \
248-
"Retrying by HTTPX \"retries\" plugin..."
249-
end
250-
# The retry_after block expects to return a delay to wait before retrying the request
251-
# nil means no waiting delay
252-
nil
253-
end
232+
retry_change_requests: true,
233+
# Official HTTPx docs says that we should use the retry_on option to decide if the
234+
# request should be retried or not
235+
# However, HTTPx assumes that connection errors such as timeout error should be retried
236+
# by default and it doesn't consider retry_on block at all at that case
237+
# So, we have to do the following trick to avoid retries when a Timeout error happens
238+
# while streaming a component
239+
# If the streamed component returned any chunks, it shouldn't retry on errors, as it
240+
# would cause page duplication
241+
# The SSR-generated html will be written to the page two times in this case
242+
retry_after: lambda do |request, response|
243+
if request.stream.instance_variable_get(:@react_on_rails_received_first_chunk)
244+
e = response.error
245+
raise(
246+
ReactOnRailsPro::Error,
247+
"An error happened during server side render streaming " \
248+
"of a component.\nOriginal error:\n#{e}\n#{e.backtrace}"
249+
)
250+
end
251+
252+
Rails.logger.info do
253+
"[ReactOnRailsPro] An error occurred while making " \
254+
"a request to the Node Renderer.\n" \
255+
"Error: #{response.error}.\n" \
256+
"Retrying by HTTPX \"retries\" plugin..."
257+
end
258+
# The retry_after block expects to return a delay to wait before
259+
# retrying the request
260+
# nil means no waiting delay
261+
nil
262+
end
254263
)
255264
.plugin(:stream)
256265
# See https://www.rubydoc.info/gems/httpx/1.3.3/HTTPX%2FOptions:initialize for the available options

react_on_rails_pro/lib/react_on_rails_pro/stream_request.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ def handle_chunk(chunk, position)
5151
end
5252
end
5353

54-
def each_chunk(&block)
54+
def each_chunk(&block) # rubocop:disable Metrics/CyclomaticComplexity
5555
return enum_for(:each_chunk) unless block
5656

5757
first_chunk = true
5858
@component.each_chunk do |chunk|
5959
position = first_chunk ? :first : :middle
6060
modified_chunk = handle_chunk(chunk, position)
61-
block.call(modified_chunk)
61+
yield(modified_chunk)
6262
first_chunk = false
6363
end
6464

6565
# The last chunk contains the append content after the transformation
6666
# All transformations are applied to the append content
6767
last_chunk = handle_chunk("", :last)
68-
block.call(last_chunk) unless last_chunk.empty?
69-
rescue StandardError => err
70-
current_error = err
68+
yield(last_chunk) unless last_chunk.empty?
69+
rescue StandardError => e
70+
current_error = e
7171
rescue_block_index = 0
7272
while current_error.present? && (rescue_block_index < @rescue_blocks.size)
7373
begin

react_on_rails_pro/rakelib/public_key_management.rake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ require "uri"
1313
# rake react_on_rails_pro:verify_public_key # Verify current configuration
1414
# rake react_on_rails_pro:public_key_help # Show help
1515

16-
namespace :react_on_rails_pro do
16+
namespace :react_on_rails_pro do # rubocop:disable Metrics/BlockLength
1717
desc "Update the public key for React on Rails Pro license validation"
18-
task :update_public_key, [:source] do |_task, args|
18+
task :update_public_key, [:source] do |_task, args| # rubocop:disable Metrics/BlockLength
1919
source = args[:source] || "production"
2020

2121
# Determine the API URL based on the source
@@ -68,7 +68,7 @@ namespace :react_on_rails_pro do
6868
# ShakaCode's public key for React on Rails Pro license verification
6969
# The private key corresponding to this public key is held by ShakaCode
7070
# and is never committed to the repository
71-
# Last updated: #{Time.now.utc.strftime("%Y-%m-%d %H:%M:%S UTC")}
71+
# Last updated: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S UTC')}
7272
# Source: #{api_url}
7373
#
7474
# You can update this public key by running the rake task:
@@ -86,12 +86,13 @@ namespace :react_on_rails_pro do
8686
puts "✅ Updated Ruby public key: #{ruby_file_path}"
8787

8888
# Update Node/TypeScript public key file
89-
node_file_path = File.join(File.dirname(__FILE__), "..", "packages", "node-renderer", "src", "shared", "licensePublicKey.ts")
89+
node_file_path = File.join(File.dirname(__FILE__), "..", "packages", "node-renderer", "src", "shared",
90+
"licensePublicKey.ts")
9091
node_content = <<~TYPESCRIPT
9192
// ShakaCode's public key for React on Rails Pro license verification
9293
// The private key corresponding to this public key is held by ShakaCode
9394
// and is never committed to the repository
94-
// Last updated: #{Time.now.utc.strftime("%Y-%m-%d %H:%M:%S UTC")}
95+
// Last updated: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S UTC')}
9596
// Source: #{api_url}
9697
//
9798
// You can update this public key by running the rake task:

react_on_rails_pro/spec/dummy/app/controllers/pages_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class PagesController < ApplicationController
3+
class PagesController < ApplicationController # rubocop:disable Metrics/ClassLength
44
include ReactOnRailsPro::RSCPayloadRenderer
55
include RscPostsPageOverRedisHelper
66

@@ -85,8 +85,8 @@ def redis_receiver
8585
ensure
8686
begin
8787
redis&.close
88-
rescue StandardError => close_err
89-
Rails.logger.warn "Failed to close Redis: #{close_err.message}"
88+
rescue StandardError => e
89+
Rails.logger.warn "Failed to close Redis: #{e.message}"
9090
end
9191
end
9292

react_on_rails_pro/spec/dummy/config.ru

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
# This file is used by Rack-based servers to start the application.
44

5-
require ::File.expand_path("config/environment", __dir__)
5+
require File.expand_path("config/environment", __dir__)
66

77
run Rails.application

react_on_rails_pro/spec/dummy/config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
config.active_support.deprecation = :notify
7070

7171
# Use default logging formatter so that PID and timestamp are not suppressed.
72-
config.log_formatter = ::Logger::Formatter.new
72+
config.log_formatter = Logger::Formatter.new
7373

7474
# Use a different logger for distributed setups.
7575
# require 'syslog/logger'

0 commit comments

Comments
 (0)