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.
- checksums.yaml +7 -0
- data/.controlplane/Dockerfile +49 -0
- data/.controlplane/controlplane.yml +22 -0
- data/.controlplane/gvc.yml +25 -0
- data/.controlplane/postgres.yml +33 -0
- data/.controlplane/rails.yml +49 -0
- data/.controlplane/redis.yml +18 -0
- data/.gitignore +77 -0
- data/.prettierignore +12 -0
- data/.prettierrc +19 -0
- data/.rspec +2 -0
- data/.rubocop.yml +120 -0
- data/.scss-lint.yml +205 -0
- data/CHANGELOG.md +570 -0
- data/CI_SETUP.md +502 -0
- data/CONTRIBUTING.md +376 -0
- data/Dockerfile +63 -0
- data/Gemfile +8 -0
- data/Gemfile.development_dependencies +74 -0
- data/Gemfile.loader +32 -0
- data/Gemfile.lock +527 -0
- data/LICENSE +98 -0
- data/LICENSE_SETUP.md +272 -0
- data/README.md +577 -0
- data/Rakefile +13 -0
- data/app/controllers/react_on_rails_pro/rsc_payload_controller.rb +7 -0
- data/app/helpers/react_on_rails_pro_helper.rb +360 -0
- data/app/views/react_on_rails_pro/rsc_payload.html.erb +1 -0
- data/babel.config.js +4 -0
- data/docs/bundle-caching.md +205 -0
- data/docs/caching.md +234 -0
- data/docs/code-splitting-loadable-components.md +313 -0
- data/docs/code-splitting.md +349 -0
- data/docs/configuration.md +165 -0
- data/docs/contributors-info/onboarding-customers.md +6 -0
- data/docs/contributors-info/releasing.md +40 -0
- data/docs/contributors-info/style.md +33 -0
- data/docs/home-pro.md +146 -0
- data/docs/installation.md +203 -0
- data/docs/js-memory-leaks.md +22 -0
- data/docs/node-renderer/basics.md +92 -0
- data/docs/node-renderer/debugging.md +38 -0
- data/docs/node-renderer/error-reporting-and-tracing.md +160 -0
- data/docs/node-renderer/heroku.md +102 -0
- data/docs/node-renderer/js-configuration.md +91 -0
- data/docs/node-renderer/troubleshooting.md +5 -0
- data/docs/profiling-server-side-rendering-code.md +179 -0
- data/docs/react-server-components/add-streaming-and-interactivity.md +190 -0
- data/docs/react-server-components/create-without-ssr.md +448 -0
- data/docs/react-server-components/glossary.md +102 -0
- data/docs/react-server-components/how-react-server-components-work.md +243 -0
- data/docs/react-server-components/inside-client-components.md +332 -0
- data/docs/react-server-components/purpose-and-benefits.md +243 -0
- data/docs/react-server-components/rendering-flow.md +86 -0
- data/docs/react-server-components/selective-hydration-in-streamed-components.md +75 -0
- data/docs/react-server-components/server-side-rendering.md +72 -0
- data/docs/react-server-components/tutorial.md +19 -0
- data/docs/release-notes/4.0.md +94 -0
- data/docs/release-notes/v4-react-server-components.md +66 -0
- data/docs/ruby-api.md +11 -0
- data/docs/streaming-server-rendering.md +210 -0
- data/docs/troubleshooting.md +24 -0
- data/docs/updating.md +219 -0
- data/eslint.config.mjs +220 -0
- data/lib/react_on_rails_pro/assets_precompile.rb +230 -0
- data/lib/react_on_rails_pro/cache.rb +88 -0
- data/lib/react_on_rails_pro/concerns/rsc_payload_renderer.rb +38 -0
- data/lib/react_on_rails_pro/concerns/stream.rb +103 -0
- data/lib/react_on_rails_pro/configuration.rb +228 -0
- data/lib/react_on_rails_pro/constants.rb +8 -0
- data/lib/react_on_rails_pro/engine.rb +24 -0
- data/lib/react_on_rails_pro/error.rb +14 -0
- data/lib/react_on_rails_pro/license_public_key.rb +30 -0
- data/lib/react_on_rails_pro/license_validator.rb +188 -0
- data/lib/react_on_rails_pro/prepare_node_renderer_bundles.rb +40 -0
- data/lib/react_on_rails_pro/rendering_error.rb +5 -0
- data/lib/react_on_rails_pro/request.rb +318 -0
- data/lib/react_on_rails_pro/routes.rb +13 -0
- data/lib/react_on_rails_pro/server_rendering_js_code.rb +102 -0
- data/lib/react_on_rails_pro/server_rendering_pool/node_rendering_pool.rb +133 -0
- data/lib/react_on_rails_pro/server_rendering_pool/pro_rendering.rb +117 -0
- data/lib/react_on_rails_pro/stream_cache.rb +61 -0
- data/lib/react_on_rails_pro/stream_request.rb +170 -0
- data/lib/react_on_rails_pro/utils.rb +222 -0
- data/lib/react_on_rails_pro/v8_log_processor.rb +50 -0
- data/lib/react_on_rails_pro/version.rb +6 -0
- data/lib/react_on_rails_pro.rb +23 -0
- data/package-scripts.yml +109 -0
- data/package.json +159 -0
- data/rakelib/dummy_apps.rake +22 -0
- data/rakelib/lint.rake +32 -0
- data/rakelib/public_key_management.rake +155 -0
- data/rakelib/rbs.rake +47 -0
- data/rakelib/run_rspec.rake +81 -0
- data/rakelib/task_helpers.rb +45 -0
- data/rakelib/yard.rake +20 -0
- data/react_on_rails_pro.gemspec +47 -0
- data/readme-gen-docs.md +1 -0
- data/script/bootstrap +33 -0
- data/script/preinstall.js +31 -0
- data/script/setup +23 -0
- data/script/test +38 -0
- data/sig/react_on_rails_pro/cache.rbs +13 -0
- data/sig/react_on_rails_pro/configuration.rbs +100 -0
- data/sig/react_on_rails_pro/error.rbs +4 -0
- data/sig/react_on_rails_pro/utils.rbs +7 -0
- data/sig/react_on_rails_pro.rbs +5 -0
- data/yarn.lock +7599 -0
- metadata +319 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# require "English"
|
|
4
|
+
# require "open3"
|
|
5
|
+
# require "rainbow"
|
|
6
|
+
# require "active_support"
|
|
7
|
+
# require "active_support/core_ext/string"
|
|
8
|
+
|
|
9
|
+
module ReactOnRailsPro
|
|
10
|
+
module Utils
|
|
11
|
+
###########################################################
|
|
12
|
+
# PUBLIC API
|
|
13
|
+
###########################################################
|
|
14
|
+
|
|
15
|
+
def self.rorp_puts(message)
|
|
16
|
+
puts "[ReactOnRailsPro] #{message}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# RSC Configuration Utility Methods
|
|
20
|
+
# These methods were moved from ReactOnRails::Utils as they are Pro-only features
|
|
21
|
+
|
|
22
|
+
def self.rsc_bundle_js_file_path
|
|
23
|
+
return @rsc_bundle_path if @rsc_bundle_path && !Rails.env.development?
|
|
24
|
+
|
|
25
|
+
bundle_name = ReactOnRailsPro.configuration.rsc_bundle_js_file
|
|
26
|
+
@rsc_bundle_path = ReactOnRails::Utils.bundle_js_file_path(bundle_name)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.react_client_manifest_file_path
|
|
30
|
+
return @react_client_manifest_path if @react_client_manifest_path && !Rails.env.development?
|
|
31
|
+
|
|
32
|
+
file_name = ReactOnRailsPro.configuration.react_client_manifest_file
|
|
33
|
+
@react_client_manifest_path = ReactOnRails::PackerUtils.asset_uri_from_packer(file_name)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# React Server Manifest is generated by the server bundle.
|
|
37
|
+
# So, it will never be served from the dev server.
|
|
38
|
+
def self.react_server_client_manifest_file_path
|
|
39
|
+
return @react_server_manifest_path if @react_server_manifest_path && !Rails.env.development?
|
|
40
|
+
|
|
41
|
+
asset_name = ReactOnRailsPro.configuration.react_server_client_manifest_file
|
|
42
|
+
if asset_name.nil?
|
|
43
|
+
raise ReactOnRailsPro::Error,
|
|
44
|
+
"react_server_client_manifest_file is nil, ensure it is set in your configuration"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
@react_server_manifest_path = ReactOnRails::Utils.bundle_js_file_path(asset_name)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.rsc_support_enabled?
|
|
51
|
+
ReactOnRailsPro.configuration.enable_rsc_support
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Validates the license and raises an exception if invalid.
|
|
55
|
+
#
|
|
56
|
+
# @return [Boolean] true if license is valid
|
|
57
|
+
# @raise [ReactOnRailsPro::Error] if license is invalid
|
|
58
|
+
def self.validated_license_data!
|
|
59
|
+
LicenseValidator.validated_license_data!
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.copy_assets
|
|
63
|
+
return if ReactOnRailsPro.configuration.assets_to_copy.blank?
|
|
64
|
+
|
|
65
|
+
ReactOnRailsPro::Request.upload_assets
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# takes an array of globs, removes excluded_dependency_globs & returns a digest
|
|
69
|
+
def self.digest_of_globs(globs)
|
|
70
|
+
# NOTE: Dir.glob is not stable between machines, even with same OS. So we must sort.
|
|
71
|
+
# .uniq was added to remove redundancies in the case digest_of_globs is used on a union of
|
|
72
|
+
# dependency_globs & source code in order to create a cache key for production bundles
|
|
73
|
+
# We've tested it to make sure that it adds less than a second even in the case of thousands of files
|
|
74
|
+
files = Dir.glob(globs).uniq
|
|
75
|
+
excluded_dependency_globs = ReactOnRailsPro.configuration.excluded_dependency_globs
|
|
76
|
+
if excluded_dependency_globs.present?
|
|
77
|
+
excluded_files = Dir.glob(excluded_dependency_globs).uniq
|
|
78
|
+
files -= excluded_files
|
|
79
|
+
end
|
|
80
|
+
files.sort!
|
|
81
|
+
|
|
82
|
+
digest = Digest::MD5.new
|
|
83
|
+
files.each { |f| digest.file(f) unless File.directory?(f) }
|
|
84
|
+
digest
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Returns a string which should be used as a component in any cache key for
|
|
88
|
+
# react_component or react_component_hash when server rendering. This value is either
|
|
89
|
+
# the server bundle filename with the hash from webpack or an MD5 digest of the
|
|
90
|
+
# entire bundle.
|
|
91
|
+
def self.bundle_hash
|
|
92
|
+
return @bundle_hash if @bundle_hash && !(Rails.env.development? || Rails.env.test?)
|
|
93
|
+
|
|
94
|
+
server_bundle_js_file_path = ReactOnRails::Utils.server_bundle_js_file_path
|
|
95
|
+
|
|
96
|
+
return @bundle_hash if @bundle_hash && bundle_mtime_same?(server_bundle_js_file_path)
|
|
97
|
+
|
|
98
|
+
@bundle_hash = calc_bundle_hash(server_bundle_js_file_path)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def self.rsc_bundle_hash
|
|
102
|
+
return @rsc_bundle_hash if @rsc_bundle_hash && !(Rails.env.development? || Rails.env.test?)
|
|
103
|
+
|
|
104
|
+
server_rsc_bundle_js_file_path = rsc_bundle_js_file_path
|
|
105
|
+
|
|
106
|
+
return @rsc_bundle_hash if @rsc_bundle_hash && bundle_mtime_same?(server_rsc_bundle_js_file_path)
|
|
107
|
+
|
|
108
|
+
@rsc_bundle_hash = calc_bundle_hash(server_rsc_bundle_js_file_path)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Returns the hashed file name when using Shakapacker. Useful for creating cache keys.
|
|
112
|
+
def self.bundle_file_name(bundle_name)
|
|
113
|
+
# bundle_js_uri_from_packer can return a file path or a HTTP URL (for files served from the dev server)
|
|
114
|
+
# Pathname can handle both cases
|
|
115
|
+
full_path = ReactOnRails::PackerUtils.bundle_js_uri_from_packer(bundle_name)
|
|
116
|
+
pathname = Pathname.new(full_path)
|
|
117
|
+
pathname.basename.to_s
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Returns the hashed file name of the server bundle when using Shakapacker.
|
|
121
|
+
# Necessary for fragment-caching keys.
|
|
122
|
+
def self.server_bundle_file_name
|
|
123
|
+
return @server_bundle_hash if @server_bundle_hash && !Rails.env.development?
|
|
124
|
+
|
|
125
|
+
@server_bundle_hash = begin
|
|
126
|
+
server_bundle_name = ReactOnRails.configuration.server_bundle_js_file
|
|
127
|
+
bundle_file_name(server_bundle_name)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def self.calc_bundle_hash(server_bundle_js_file_path)
|
|
132
|
+
if Rails.env.development? || Rails.env.test?
|
|
133
|
+
@test_dev_server_bundle_mtime = File.mtime(server_bundle_js_file_path)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
server_bundle_basename = Pathname.new(server_bundle_js_file_path).basename.to_s
|
|
137
|
+
|
|
138
|
+
if contains_hash?(server_bundle_basename)
|
|
139
|
+
server_bundle_basename
|
|
140
|
+
else
|
|
141
|
+
"#{Digest::MD5.file(server_bundle_js_file_path)}-#{Rails.env}"
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.bundle_mtime_same?(server_bundle_js_file_path)
|
|
146
|
+
@test_dev_server_bundle_mtime == File.mtime(server_bundle_js_file_path)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def self.contains_hash?(server_bundle_basename)
|
|
150
|
+
# TODO: Need to consider if the configuration value has the ".js" on the end.
|
|
151
|
+
ReactOnRails.configuration.server_bundle_js_file != server_bundle_basename &&
|
|
152
|
+
ReactOnRailsPro.configuration.rsc_bundle_js_file != server_bundle_basename
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def self.with_trace(message = nil)
|
|
156
|
+
return yield unless ReactOnRailsPro.configuration.tracing && Rails.logger.info?
|
|
157
|
+
|
|
158
|
+
start = Time.current
|
|
159
|
+
result = yield
|
|
160
|
+
finish = Time.current
|
|
161
|
+
|
|
162
|
+
caller_method = caller(1..1).first[/[`'][^']*'/][1..-2]
|
|
163
|
+
timing = "#{((finish - start) * 1_000).round(1)}ms"
|
|
164
|
+
Rails.logger.info "[ReactOnRailsPro] PID:#{Process.pid} #{caller_method}: #{[message, timing].compact.join(', ')}"
|
|
165
|
+
|
|
166
|
+
result
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def self.common_form_data
|
|
170
|
+
dependencies = if ReactOnRailsPro.configuration.enable_rsc_support
|
|
171
|
+
pool = ReactOnRailsPro::ServerRenderingPool::NodeRenderingPool
|
|
172
|
+
[pool.rsc_bundle_hash, pool.server_bundle_hash]
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
{
|
|
176
|
+
"gemVersion" => ReactOnRailsPro::VERSION,
|
|
177
|
+
"protocolVersion" => ReactOnRailsPro::PROTOCOL_VERSION,
|
|
178
|
+
"password" => ReactOnRailsPro.configuration.renderer_password,
|
|
179
|
+
"dependencyBundleTimestamps" => dependencies,
|
|
180
|
+
"railsEnv" => Rails.env.to_s
|
|
181
|
+
}
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def self.mine_type_from_file_name(filename)
|
|
185
|
+
extension = File.extname(filename)
|
|
186
|
+
Rack::Mime.mime_type(extension)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# TODO: write test
|
|
190
|
+
def self.printable_cache_key(cache_key)
|
|
191
|
+
cache_key.map do |key|
|
|
192
|
+
if key.is_a?(Enumerable)
|
|
193
|
+
printable_cache_key(key)
|
|
194
|
+
elsif key.respond_to?(:cache_key_with_version)
|
|
195
|
+
key.cache_key_with_version
|
|
196
|
+
elsif key.respond_to?(:cache_key)
|
|
197
|
+
key.cache_key
|
|
198
|
+
else
|
|
199
|
+
key.to_s
|
|
200
|
+
end
|
|
201
|
+
end.join("_").underscore
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Generates the Pro-specific HTML attribution comment based on license status
|
|
205
|
+
# Called by React on Rails helper to generate license-specific attribution
|
|
206
|
+
def self.pro_attribution_comment
|
|
207
|
+
base = "Powered by React on Rails Pro (c) ShakaCode"
|
|
208
|
+
|
|
209
|
+
# Check if in grace period
|
|
210
|
+
grace_days = ReactOnRailsPro::LicenseValidator.grace_days_remaining
|
|
211
|
+
comment = if grace_days
|
|
212
|
+
"#{base} | Licensed (Expired - Grace Period: #{grace_days} day(s) remaining)"
|
|
213
|
+
elsif ReactOnRailsPro::LicenseValidator.evaluation?
|
|
214
|
+
"#{base} | Evaluation License"
|
|
215
|
+
else
|
|
216
|
+
"#{base} | Licensed"
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
"<!-- #{comment} -->"
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ReactOnRailsPro
|
|
4
|
+
module V8LogProcessor
|
|
5
|
+
def self.process_v8_logs(keep_files, output_dir)
|
|
6
|
+
FileUtils.mkdir_p(output_dir)
|
|
7
|
+
log_files = Dir.glob("isolate-*.log")
|
|
8
|
+
return unless user_confirms_processing(log_files)
|
|
9
|
+
|
|
10
|
+
move_files(log_files, output_dir)
|
|
11
|
+
processed_count = process_each_file(log_files, output_dir)
|
|
12
|
+
delete_files(log_files, output_dir) unless keep_files
|
|
13
|
+
puts "#{processed_count} files have been processed."
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.move_files(log_files, log_dir)
|
|
17
|
+
log_files.each { |file| FileUtils.mv(file, log_dir) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Processes each log file into a separate JSON profile and logs progress.
|
|
21
|
+
# Returns the number of files processed.
|
|
22
|
+
def self.process_each_file(log_files, log_dir)
|
|
23
|
+
total_files = log_files.length
|
|
24
|
+
log_files.each_with_index do |file, index|
|
|
25
|
+
filename = File.basename(file, ".log")
|
|
26
|
+
json_filename = "#{filename}.profile.v8log.json"
|
|
27
|
+
Dir.chdir(log_dir) do
|
|
28
|
+
system("node --prof-process --preprocess -j #{File.basename(file)} > #{json_filename}")
|
|
29
|
+
end
|
|
30
|
+
puts "Processed file #{index + 1} of #{total_files} (#{((index + 1).to_f / total_files * 100).round(2)}%)"
|
|
31
|
+
end
|
|
32
|
+
total_files # Return the number of processed files
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.delete_files(log_files, log_dir)
|
|
36
|
+
log_files.each { |file| FileUtils.rm(File.join(log_dir, File.basename(file))) }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Warns if many files and asks for user confirmation to proceed.
|
|
40
|
+
def self.user_confirms_processing(log_files)
|
|
41
|
+
if log_files.count > 100
|
|
42
|
+
puts "Warning: There are many log files (#{log_files.count}), this may take some time."
|
|
43
|
+
puts "Do you want to continue? [y/N]: "
|
|
44
|
+
response = $stdin.gets.chomp.downcase
|
|
45
|
+
return response == "y"
|
|
46
|
+
end
|
|
47
|
+
true
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails"
|
|
4
|
+
|
|
5
|
+
require "react_on_rails_pro/request"
|
|
6
|
+
require "react_on_rails_pro/version"
|
|
7
|
+
require "react_on_rails_pro/constants"
|
|
8
|
+
require "react_on_rails_pro/engine"
|
|
9
|
+
require "react_on_rails_pro/error"
|
|
10
|
+
require "react_on_rails_pro/utils"
|
|
11
|
+
require "react_on_rails_pro/configuration"
|
|
12
|
+
require "react_on_rails_pro/license_public_key"
|
|
13
|
+
require "react_on_rails_pro/license_validator"
|
|
14
|
+
require "react_on_rails_pro/cache"
|
|
15
|
+
require "react_on_rails_pro/stream_cache"
|
|
16
|
+
require "react_on_rails_pro/server_rendering_pool/pro_rendering"
|
|
17
|
+
require "react_on_rails_pro/server_rendering_pool/node_rendering_pool"
|
|
18
|
+
require "react_on_rails_pro/server_rendering_js_code"
|
|
19
|
+
require "react_on_rails_pro/assets_precompile"
|
|
20
|
+
require "react_on_rails_pro/prepare_node_renderer_bundles"
|
|
21
|
+
require "react_on_rails_pro/concerns/stream"
|
|
22
|
+
require "react_on_rails_pro/concerns/rsc_payload_renderer"
|
|
23
|
+
require "react_on_rails_pro/routes"
|
data/package-scripts.yml
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
scripts:
|
|
2
|
+
test:
|
|
3
|
+
default:
|
|
4
|
+
description: Run all JS tests
|
|
5
|
+
script: jest packages/node-renderer
|
|
6
|
+
ci:
|
|
7
|
+
description: Run all JS tests in CI mode
|
|
8
|
+
# https://circleci.com/docs/collect-test-data/#jest
|
|
9
|
+
script: jest --ci --runInBand --reporters=default --reporters=jest-junit -- packages/node-renderer
|
|
10
|
+
debug:
|
|
11
|
+
description: Debug all JS tests
|
|
12
|
+
script: ndb jest --runInBand packages/node-renderer
|
|
13
|
+
check:
|
|
14
|
+
description: Run all checks
|
|
15
|
+
script: nps lint && nps format.listDifferent && nps test && nps check-typescript
|
|
16
|
+
check-typescript:
|
|
17
|
+
description: Check for TypeScript errors
|
|
18
|
+
script: nps "build --noEmit" && tsc --project packages/node-renderer/tests && cd spec/dummy && yarn run tsc -p ./tsconfig.json --noEmit
|
|
19
|
+
fix:
|
|
20
|
+
description: Run all code fixes before committing
|
|
21
|
+
script: nps eslint.fix && nps format
|
|
22
|
+
node-renderer:
|
|
23
|
+
default:
|
|
24
|
+
description:
|
|
25
|
+
script: nps build && node --enable-source-maps packages/node-renderer/dist/default-node-renderer.js
|
|
26
|
+
debug:
|
|
27
|
+
description: Debug Node Renderer
|
|
28
|
+
script: rm -rf /tmp/react-on-rails-pro-node-renderer-bundles && nps build && RENDERER_LOG_LEVEL=info NODE_DEBUG=ROR node --enable-source-maps packages/node-renderer/dist/default-node-renderer.js
|
|
29
|
+
lint:
|
|
30
|
+
description: Run all linters
|
|
31
|
+
script: concurrently --prefix "[{name}]" --names "ESLINT, RUBOCOP, PRETTIER" -c "blue,yellow,magenta,orange" "nps eslint" "bundle exec rubocop" "nps format.listDifferent"
|
|
32
|
+
|
|
33
|
+
build:
|
|
34
|
+
default:
|
|
35
|
+
description: Build the project
|
|
36
|
+
script: echo "building the project" && rm -rf packages/node-renderer/dist && tsc --project packages/node-renderer/src
|
|
37
|
+
prepack:
|
|
38
|
+
description: Build the project in the prepack/prepare scripts
|
|
39
|
+
# This is necessary when used as a Git dependency since we don't have the dist directory in the repo.
|
|
40
|
+
# Depending on the package manager, `prepack`, `prepare`, or both may be run.
|
|
41
|
+
# They may also be run when publishing or in other cases, so we want to cover all of them.
|
|
42
|
+
# 1. If the project is already built, do nothing;
|
|
43
|
+
# 2. Build the project but ignore TypeScript errors from missing devDependencies;
|
|
44
|
+
# 3. Check if the project is built now;
|
|
45
|
+
# 4. If it failed, print an error message (still follow https://docs.npmjs.com/cli/v8/using-npm/scripts#best-practices).
|
|
46
|
+
script: >
|
|
47
|
+
[ -f packages/node-renderer/dist/ReactOnRailsProNodeRenderer.js ] ||
|
|
48
|
+
(nps build >/dev/null 2>&1 || true) &&
|
|
49
|
+
[ -f packages/node-renderer/dist/ReactOnRailsProNodeRenderer.js ] ||
|
|
50
|
+
{ echo 'Building react-on-rails-pro-node-renderer seems to have failed!'; }
|
|
51
|
+
|
|
52
|
+
clean:
|
|
53
|
+
description: Clean the project
|
|
54
|
+
script: rm -rf packages/node-renderer/dist
|
|
55
|
+
|
|
56
|
+
eslint:
|
|
57
|
+
default:
|
|
58
|
+
description: Run eslint.
|
|
59
|
+
script: eslint . --report-unused-disable-directives
|
|
60
|
+
fix:
|
|
61
|
+
description: Run eslint and auto-fix.
|
|
62
|
+
script: nps "eslint --fix"
|
|
63
|
+
debug:
|
|
64
|
+
description: Run eslint in debug mode.
|
|
65
|
+
script: DEBUG=eslint:cli-engine nps eslint
|
|
66
|
+
|
|
67
|
+
format:
|
|
68
|
+
default:
|
|
69
|
+
description: Format files using prettier.
|
|
70
|
+
script: concurrently --prefix "[{name}]" --names "js,ts,json" -c "yellow,magenta,green" "nps format.js" "nps format.ts" "nps format.json"
|
|
71
|
+
listDifferent:
|
|
72
|
+
description: Check that all files were formatted using prettier.
|
|
73
|
+
script: |
|
|
74
|
+
concurrently \
|
|
75
|
+
--prefix "[{name}]" \
|
|
76
|
+
--names "js,ts,json" \
|
|
77
|
+
-c "yellow,magenta,green" \
|
|
78
|
+
"nps format.js.listDifferent" \
|
|
79
|
+
"nps format.ts.listDifferent" \
|
|
80
|
+
"nps format.json.listDifferent"
|
|
81
|
+
js:
|
|
82
|
+
default:
|
|
83
|
+
description: Run prettier on JS.
|
|
84
|
+
script: prettier "**/*.@(js|jsx|mjs)" --write
|
|
85
|
+
listDifferent:
|
|
86
|
+
description: Check if any JS files would change by running prettier.
|
|
87
|
+
script: prettier "**/*.@(js|jsx|mjs)" --list-different
|
|
88
|
+
ts:
|
|
89
|
+
default:
|
|
90
|
+
description: Run prettier on TS.
|
|
91
|
+
script: prettier "**/*.@(ts|tsx)" --write
|
|
92
|
+
listDifferent:
|
|
93
|
+
description: Check if any TS files would change by running prettier.
|
|
94
|
+
script: prettier "**/*.@(ts|tsx)" --list-different
|
|
95
|
+
json:
|
|
96
|
+
default:
|
|
97
|
+
description: Run prettier on JSON files.
|
|
98
|
+
script: rm -rf packages/node-renderer/tests/tmp && prettier "**/*.json" --write
|
|
99
|
+
listDifferent:
|
|
100
|
+
description: Check if any JSON files would change by running prettier.
|
|
101
|
+
script: prettier "**/*.json" --list-different
|
|
102
|
+
|
|
103
|
+
renderer:
|
|
104
|
+
default:
|
|
105
|
+
description: Starts the node renderer.
|
|
106
|
+
script: nps build && RENDERER_PORT=3800 RENDERER_SUPPORT_MODULES=TRUE node ./packages/node-renderer/dist/default-node-renderer.js
|
|
107
|
+
debug:
|
|
108
|
+
description: Starts the node renderer with debugging enabled. See Node.js V8 --inspector Manager (NiM)
|
|
109
|
+
script: nps build && RENDERER_WORKERS_COUNT=1 RENDERER_PORT=3800 RENDERER_SUPPORT_MODULES=TRUE ndb ./packages/node-renderer/dist/default-node-renderer.js
|
data/package.json
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-on-rails-pro-node-renderer",
|
|
3
|
+
"version": "16.2.0-beta.8",
|
|
4
|
+
"protocolVersion": "2.0.0",
|
|
5
|
+
"description": "react-on-rails-pro JavaScript for react_on_rails_pro Ruby gem",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./packages/node-renderer/dist/ReactOnRailsProNodeRenderer.d.ts",
|
|
9
|
+
"default": "./packages/node-renderer/dist/ReactOnRailsProNodeRenderer.js"
|
|
10
|
+
},
|
|
11
|
+
"./integrations/*": {
|
|
12
|
+
"types": "./packages/node-renderer/dist/integrations/*.d.ts",
|
|
13
|
+
"default": "./packages/node-renderer/dist/integrations/*.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"react-on-rails-pro-node-renderer": "packages/node-renderer/dist/default-node-renderer.js"
|
|
19
|
+
},
|
|
20
|
+
"directories": {
|
|
21
|
+
"doc": "docs"
|
|
22
|
+
},
|
|
23
|
+
"resolutions": {
|
|
24
|
+
"sentry-testkit/body-parser": "npm:empty-npm-package@1.0.0",
|
|
25
|
+
"sentry-testkit/express": "npm:empty-npm-package@1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@fastify/formbody": "^7.4.0 || ^8.0.2",
|
|
29
|
+
"@fastify/multipart": "^8.3.1 || ^9.0.3",
|
|
30
|
+
"fastify": "^4.29.0 || ^5.2.1",
|
|
31
|
+
"fs-extra": "^11.2.0",
|
|
32
|
+
"jsonwebtoken": "^9.0.2",
|
|
33
|
+
"lockfile": "^1.0.4"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@babel/core": "^7.26.10",
|
|
37
|
+
"@babel/eslint-parser": "^7.27.0",
|
|
38
|
+
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|
|
39
|
+
"@babel/preset-env": "^7.26.9",
|
|
40
|
+
"@babel/preset-react": "^7.26.3",
|
|
41
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
42
|
+
"@eslint/compat": "^1.2.8",
|
|
43
|
+
"@honeybadger-io/js": "^6.10.1",
|
|
44
|
+
"@sentry/node": "^7.120.0",
|
|
45
|
+
"@tsconfig/node14": "^14.1.2",
|
|
46
|
+
"@types/fs-extra": "^11.0.4",
|
|
47
|
+
"@types/jest": "^29.5.12",
|
|
48
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
49
|
+
"@types/lockfile": "^1.0.4",
|
|
50
|
+
"@types/touch": "^3.1.5",
|
|
51
|
+
"babel-jest": "^29.7.0",
|
|
52
|
+
"concurrently": "^9.1.0",
|
|
53
|
+
"eslint": "^9.24.0",
|
|
54
|
+
"eslint-config-prettier": "^10.1.1",
|
|
55
|
+
"eslint-config-shakacode": "^19.0.0",
|
|
56
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
57
|
+
"eslint-import-resolver-typescript": "^4.3.2",
|
|
58
|
+
"eslint-plugin-import": "^2.31.0",
|
|
59
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
60
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
61
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
62
|
+
"eslint-plugin-react": "^7.37.5",
|
|
63
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
64
|
+
"form-auto-content": "^3.2.1",
|
|
65
|
+
"form-data": "^4.0.1",
|
|
66
|
+
"globals": "^16.0.0",
|
|
67
|
+
"husky": "^4.3.6",
|
|
68
|
+
"jest": "^29.7.0",
|
|
69
|
+
"jest-junit": "^16.0.0",
|
|
70
|
+
"jsdom": "^16.5.0",
|
|
71
|
+
"ndb": "^1.1.5",
|
|
72
|
+
"node-html-parser": "^7.0.1",
|
|
73
|
+
"nps": "^5.9.12",
|
|
74
|
+
"pino-pretty": "^13.0.0",
|
|
75
|
+
"prettier": "^3.2.5",
|
|
76
|
+
"react-on-rails": "link:.yalc/react-on-rails",
|
|
77
|
+
"redis": "^5.0.1",
|
|
78
|
+
"sentry-testkit": "^5.0.6",
|
|
79
|
+
"touch": "^3.1.0",
|
|
80
|
+
"typescript": "^5.4.3",
|
|
81
|
+
"typescript-eslint": "^8.29.1",
|
|
82
|
+
"yalc": "^1.0.0-pre.53"
|
|
83
|
+
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"@honeybadger-io/js": ">=4.0.0",
|
|
86
|
+
"@sentry/node": ">=5.0.0 <9.0.0",
|
|
87
|
+
"@sentry/tracing": ">=5.0.0"
|
|
88
|
+
},
|
|
89
|
+
"peerDependenciesMeta": {
|
|
90
|
+
"@honeybadger-io/js": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"@sentry/node": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"@sentry/tracing": {
|
|
97
|
+
"optional": true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"files": [
|
|
101
|
+
"packages/node-renderer/dist",
|
|
102
|
+
"script/preinstall.js"
|
|
103
|
+
],
|
|
104
|
+
"scripts": {
|
|
105
|
+
"preinstall": "node ./script/preinstall.js",
|
|
106
|
+
"postinstall": "test -f post-yarn-install.local && ./post-yarn-install.local || true",
|
|
107
|
+
"link-source": "cd ../packages/react-on-rails && yarn && yalc publish",
|
|
108
|
+
"test": "nps test",
|
|
109
|
+
"prepack": "nps build.prepack",
|
|
110
|
+
"prepare": "nps build.prepack",
|
|
111
|
+
"prepublishOnly": "nps build",
|
|
112
|
+
"start": "nps",
|
|
113
|
+
"developing": "nps node-renderer.debug",
|
|
114
|
+
"eslint": "eslint .",
|
|
115
|
+
"check": "nps lint && nps format && nps test"
|
|
116
|
+
},
|
|
117
|
+
"repository": {
|
|
118
|
+
"type": "git",
|
|
119
|
+
"url": "git+https://github.com/shakacode/react_on_rails.git"
|
|
120
|
+
},
|
|
121
|
+
"keywords": [
|
|
122
|
+
"react",
|
|
123
|
+
"webpack",
|
|
124
|
+
"JavaScript",
|
|
125
|
+
"Ruby",
|
|
126
|
+
"on",
|
|
127
|
+
"Rails"
|
|
128
|
+
],
|
|
129
|
+
"author": "justin@shakacode.com",
|
|
130
|
+
"license": "UNLICENSED",
|
|
131
|
+
"bugs": {
|
|
132
|
+
"url": "https://github.com/shakacode/react_on_rails/issues"
|
|
133
|
+
},
|
|
134
|
+
"homepage": "https://github.com/shakacode/react_on_rails/tree/master/react_on_rails_pro#readme",
|
|
135
|
+
"jest": {
|
|
136
|
+
"clearMocks": true,
|
|
137
|
+
"collectCoverageFrom": [
|
|
138
|
+
"packages/node-renderer/tests/**/*.{js,jsx,ts,tsx}"
|
|
139
|
+
],
|
|
140
|
+
"coverageReporters": [
|
|
141
|
+
"lcov"
|
|
142
|
+
],
|
|
143
|
+
"resetModules": true,
|
|
144
|
+
"resetMocks": true,
|
|
145
|
+
"setupFiles": [
|
|
146
|
+
"./packages/node-renderer/tests/helper.ts"
|
|
147
|
+
],
|
|
148
|
+
"testEnvironment": "node",
|
|
149
|
+
"transform": {
|
|
150
|
+
"^.+\\.[jt]sx?$": "babel-jest"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"husky": {
|
|
154
|
+
"hooks": {
|
|
155
|
+
"pre-commit": "yalc check"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
159
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "task_helpers"
|
|
4
|
+
|
|
5
|
+
# rubocop:disable Style/MixinUsage
|
|
6
|
+
include ReactOnRailsPro::TaskHelpers
|
|
7
|
+
# rubocop:enable Style/MixinUsage
|
|
8
|
+
|
|
9
|
+
namespace :dummy_app do
|
|
10
|
+
task :yarn_install do
|
|
11
|
+
yarn_install_cmd = "yarn install --frozen-lockfile --mutex network"
|
|
12
|
+
sh_in_dir(dummy_app_dir, yarn_install_cmd)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
task dummy_app: [:yarn_install] do
|
|
16
|
+
dummy_app_dir = File.join(gem_root, "spec/dummy")
|
|
17
|
+
bundle_install_in(dummy_app_dir)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "Prepares dummy app by installing dependencies"
|
|
22
|
+
task dummy_app: ["dummy_app:dummy_app"]
|
data/rakelib/lint.rake
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "task_helpers"
|
|
4
|
+
|
|
5
|
+
# rubocop:disable Style/MixinUsage
|
|
6
|
+
include ReactOnRailsPro::TaskHelpers
|
|
7
|
+
# rubocop:enable Style/MixinUsage
|
|
8
|
+
|
|
9
|
+
namespace :lint do
|
|
10
|
+
desc "Run Rubocop as shell"
|
|
11
|
+
task :rubocop do
|
|
12
|
+
sh_in_dir(gem_root, "bundle exec rubocop .")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "Run scss-lint as shell"
|
|
16
|
+
task :scss do
|
|
17
|
+
sh_in_dir(gem_root, "bundle exec scss-lint spec/dummy/app/assets/stylesheets/")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc "Run eslint as shell"
|
|
21
|
+
task :eslint do
|
|
22
|
+
sh_in_dir(gem_root, "yarn run eslint")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "Run all eslint, rubocop linters. Skip ruby-lint and scss"
|
|
26
|
+
task lint: %i[eslint rubocop] do
|
|
27
|
+
puts "Completed all linting"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
desc "Runs all linters. Run `rake -D lint` to see all available lint options"
|
|
32
|
+
task lint: ["lint:lint"]
|