react_on_rails 13.4.0 → 14.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -2
  3. data/Gemfile.development_dependencies +10 -9
  4. data/Gemfile.lock +434 -0
  5. data/README.md +25 -17
  6. data/lib/generators/react_on_rails/base_generator.rb +3 -2
  7. data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
  8. data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +1 -1
  9. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +2 -2
  10. data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +1 -1
  11. data/lib/react_on_rails/configuration.rb +39 -25
  12. data/lib/react_on_rails/git_utils.rb +3 -3
  13. data/lib/react_on_rails/helper.rb +3 -4
  14. data/lib/react_on_rails/json_output.rb +0 -17
  15. data/lib/react_on_rails/locales/base.rb +4 -4
  16. data/lib/react_on_rails/locales/to_js.rb +1 -1
  17. data/lib/react_on_rails/packs_generator.rb +5 -6
  18. data/lib/react_on_rails/react_component/render_options.rb +1 -1
  19. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +9 -9
  20. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +3 -3
  21. data/lib/react_on_rails/test_helper.rb +2 -2
  22. data/lib/react_on_rails/utils.rb +2 -8
  23. data/lib/react_on_rails/version.rb +1 -1
  24. data/lib/react_on_rails/version_checker.rb +2 -2
  25. data/lib/react_on_rails/webpacker_utils.rb +6 -0
  26. data/lib/tasks/assets.rake +1 -1
  27. data/react_on_rails.gemspec +4 -4
  28. metadata +5 -132
  29. data/.bookignore +0 -15
  30. data/.circleci/config.yml +0 -338
  31. data/.coveralls.yml +0 -1
  32. data/.dockerignore +0 -2
  33. data/.eslintignore +0 -17
  34. data/.eslintrc +0 -53
  35. data/.github/FUNDING.yml +0 -1
  36. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
  37. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  38. data/.github/PULL_REQUEST_TEMPLATE.md +0 -19
  39. data/.github/workflows/lint-js-and-ruby.yml +0 -54
  40. data/.github/workflows/main.yml +0 -183
  41. data/.github/workflows/package-js-tests.yml +0 -35
  42. data/.github/workflows/rspec-package-specs.yml +0 -46
  43. data/.gitignore +0 -33
  44. data/.npmignore +0 -22
  45. data/.prettierignore +0 -14
  46. data/.prettierrc +0 -20
  47. data/.rspec +0 -2
  48. data/.rubocop.yml +0 -134
  49. data/.scss-lint.yml +0 -205
  50. data/.travis.yml +0 -61
  51. data/book.json +0 -18
  52. data/docs/additional-details/generator-details.md +0 -56
  53. data/docs/additional-details/manual-installation-overview.md +0 -30
  54. data/docs/additional-details/migrating-from-react-rails.md +0 -17
  55. data/docs/additional-details/recommended-project-structure.md +0 -69
  56. data/docs/additional-details/tips-for-usage-with-sp6.md +0 -15
  57. data/docs/additional-details/updating-dependencies.md +0 -31
  58. data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +0 -10
  59. data/docs/api/javascript-api.md +0 -99
  60. data/docs/api/redux-store-api.md +0 -102
  61. data/docs/api/view-helpers-api.md +0 -133
  62. data/docs/contributor-info/errors-with-hooks.md +0 -45
  63. data/docs/contributor-info/generator-testing.md +0 -11
  64. data/docs/contributor-info/linters.md +0 -68
  65. data/docs/contributor-info/pull-requests.md +0 -42
  66. data/docs/contributor-info/releasing.md +0 -76
  67. data/docs/deployment/elastic-beanstalk.md +0 -63
  68. data/docs/deployment/heroku-deployment.md +0 -39
  69. data/docs/getting-started.md +0 -196
  70. data/docs/guides/client-vs-server-rendering.md +0 -27
  71. data/docs/guides/configuration.md +0 -289
  72. data/docs/guides/deployment.md +0 -5
  73. data/docs/guides/file-system-based-automated-bundle-generation.md +0 -197
  74. data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +0 -104
  75. data/docs/guides/how-react-on-rails-works.md +0 -44
  76. data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +0 -40
  77. data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +0 -98
  78. data/docs/guides/i18n.md +0 -87
  79. data/docs/guides/installation-into-an-existing-rails-app.md +0 -66
  80. data/docs/guides/minitest-configuration.md +0 -31
  81. data/docs/guides/rails-webpacker-react-integration-options.md +0 -213
  82. data/docs/guides/react-on-rails-overview.md +0 -29
  83. data/docs/guides/react-server-rendering.md +0 -32
  84. data/docs/guides/render-functions-and-railscontext.md +0 -205
  85. data/docs/guides/rspec-configuration.md +0 -73
  86. data/docs/guides/tutorial.md +0 -371
  87. data/docs/guides/upgrading-react-on-rails.md +0 -304
  88. data/docs/guides/webpack-configuration.md +0 -42
  89. data/docs/home.md +0 -23
  90. data/docs/javascript/angular-js-integration-migration.md +0 -28
  91. data/docs/javascript/asset-pipeline.md +0 -12
  92. data/docs/javascript/capistrano-deployment.md +0 -18
  93. data/docs/javascript/code-splitting.md +0 -165
  94. data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +0 -10
  95. data/docs/javascript/credits.md +0 -10
  96. data/docs/javascript/foreman-issues.md +0 -15
  97. data/docs/javascript/images.md +0 -57
  98. data/docs/javascript/node-dependencies-and-npm.md +0 -19
  99. data/docs/javascript/react-and-redux.md +0 -36
  100. data/docs/javascript/react-helmet.md +0 -100
  101. data/docs/javascript/react-router.md +0 -90
  102. data/docs/javascript/server-rendering-tips.md +0 -55
  103. data/docs/javascript/troubleshooting-when-using-shakapacker.md +0 -77
  104. data/docs/javascript/troubleshooting-when-using-webpacker.md +0 -90
  105. data/docs/javascript/webpack-v1-notes.md +0 -23
  106. data/docs/javascript/webpack.md +0 -22
  107. data/docs/misc/articles.md +0 -20
  108. data/docs/misc/code_of_conduct.md +0 -13
  109. data/docs/misc/doctrine.md +0 -77
  110. data/docs/misc/style.md +0 -33
  111. data/docs/misc/tips.md +0 -10
  112. data/docs/outdated/deferred-rendering.md +0 -39
  113. data/docs/outdated/rails-assets-relative-paths.md +0 -195
  114. data/docs/outdated/rails-assets.md +0 -77
  115. data/docs/outdated/rails3.md +0 -9
  116. data/docs/rails/convert-rails-5-api-only-app.md +0 -19
  117. data/docs/rails/rails-engine-integration.md +0 -32
  118. data/docs/rails/rails_view_rendering_from_inline_javascript.md +0 -36
  119. data/docs/rails/turbolinks.md +0 -124
  120. data/docs/react-on-rails-pro/react-on-rails-pro.md +0 -43
  121. data/docs/testimonials/hvmn.md +0 -25
  122. data/docs/testimonials/resortpass.md +0 -13
  123. data/docs/testimonials/testimonials.md +0 -28
  124. data/jest.config.js +0 -4
  125. data/package-scripts.yml +0 -49
  126. data/package.json +0 -96
  127. data/rakelib/docker.rake +0 -26
  128. data/rakelib/dummy_apps.rake +0 -30
  129. data/rakelib/example_type.rb +0 -96
  130. data/rakelib/examples.rake +0 -64
  131. data/rakelib/examples_config.yml +0 -14
  132. data/rakelib/lint.rake +0 -30
  133. data/rakelib/node_package.rake +0 -15
  134. data/rakelib/release.rake +0 -92
  135. data/rakelib/run_rspec.rake +0 -103
  136. data/rakelib/task_helpers.rb +0 -62
  137. data/script/bootstrap +0 -33
  138. data/script/release +0 -3
  139. data/script/setup +0 -23
  140. data/script/test +0 -38
  141. data/webpackConfigLoader.js +0 -71
  142. data/yarn.lock +0 -7010
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "../rails_helper"
4
4
 
5
- describe "Hello World", js: true do
5
+ describe "Hello World", :js do
6
6
  it "the hello world example works" do
7
7
  visit "/hello_world"
8
8
  expect(heading).to have_text("Hello World")
@@ -137,35 +137,23 @@ module ReactOnRails
137
137
  end
138
138
 
139
139
  def adjust_precompile_task
140
- skip_react_on_rails_precompile = %w[no false n f].include?(ENV["REACT_ON_RAILS_PRECOMPILE"])
140
+ skip_react_on_rails_precompile = %w[no false n f].include?(ENV.fetch("REACT_ON_RAILS_PRECOMPILE", nil))
141
141
 
142
142
  return if skip_react_on_rails_precompile || build_production_command.blank?
143
143
 
144
- if Webpacker.config.webpacker_precompile?
145
- msg = <<~MSG
146
-
147
- React on Rails and Shakapacker error in configuration!
148
- In order to use config/react_on_rails.rb config.build_production_command,
149
- you must edit config/webpacker.yml to include this value in the default configuration:
150
- 'webpacker_precompile: false'
151
-
152
- Alternatively, remove the config/react_on_rails.rb config.build_production_command and the
153
- default bin/webpacker script will be used for assets:precompile.
154
-
155
- MSG
156
- raise ReactOnRails::Error, msg
157
- end
144
+ raise(ReactOnRails::Error, compile_command_conflict_message) if shakapacker_precompile?
158
145
 
159
146
  precompile_tasks = lambda {
160
147
  Rake::Task["react_on_rails:generate_packs"].invoke
161
148
  Rake::Task["react_on_rails:assets:webpack"].invoke
162
- puts "Invoking task webpacker:clean from React on Rails"
163
149
 
164
150
  # VERSIONS is per the shakacode/shakapacker clean method definition.
165
151
  # We set it very big so that it is not used, and then clean just
166
152
  # removes files older than 1 hour.
167
153
  versions = 100_000
168
- Rake::Task["webpacker:clean"].invoke(versions)
154
+
155
+ puts "Invoking task #{shakapacker_clean_task} from React on Rails"
156
+ Rake::Task[shakapacker_clean_task].invoke(versions)
169
157
  }
170
158
 
171
159
  if Rake::Task.task_defined?("assets:precompile")
@@ -187,7 +175,7 @@ module ReactOnRails
187
175
  webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
188
176
 
189
177
  if File.expand_path(generated_assets_dir) == webpacker_public_output_path.to_s
190
- Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` "\
178
+ Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \
191
179
  "with Webpacker. Remove this line from your configuration file.")
192
180
  else
193
181
  msg = <<~MSG
@@ -225,20 +213,20 @@ module ReactOnRails
225
213
 
226
214
  if ReactOnRails::WebpackerUtils.using_webpacker?
227
215
  webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
228
- Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the "\
229
- "generated_assets_dirs no the generated_assets_dir when using Webpacker. This is defined by "\
230
- "public_output_path specified in webpacker.yml = #{webpacker_public_output_path}."
216
+ Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the " \
217
+ "generated_assets_dirs no the generated_assets_dir when using Webpacker. This is defined " \
218
+ "by public_output_path specified in webpacker.yml = #{webpacker_public_output_path}."
231
219
  return
232
220
  end
233
221
 
234
- Rails.logger.warn "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than "\
222
+ Rails.logger.warn "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than " \
235
223
  "generated_assets_dirs"
236
224
  if generated_assets_dir.blank?
237
225
  self.generated_assets_dir = generated_assets_dirs
238
226
  else
239
- Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and "\
240
- "generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Webpacker"\
241
- " and define neither if using Webpacker"
227
+ Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and " \
228
+ "generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Webpacker " \
229
+ "and define neither if using Webpacker"
242
230
  end
243
231
  end
244
232
 
@@ -266,6 +254,32 @@ module ReactOnRails
266
254
 
267
255
  raise ReactOnRails::Error, msg
268
256
  end
257
+
258
+ def shakapacker_precompile?
259
+ return Webpacker.config.webpacker_precompile? if ReactOnRails::WebpackerUtils.using_shakapacker_6?
260
+
261
+ Webpacker.config.shakapacker_precompile?
262
+ end
263
+
264
+ def shakapacker_clean_task
265
+ ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker:clean" : "shakapacker:clean"
266
+ end
267
+
268
+ def compile_command_conflict_message
269
+ packer = ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker" : "shakapacker"
270
+
271
+ <<~MSG
272
+
273
+ React on Rails and Shakapacker error in configuration!
274
+ In order to use config/react_on_rails.rb config.build_production_command,
275
+ you must edit config/#{packer}.yml to include this value in the default configuration:
276
+ '#{packer}_precompile: false'
277
+
278
+ Alternatively, remove the config/react_on_rails.rb config.build_production_command and the
279
+ default bin/#{packer} script will be used for assets:precompile.
280
+
281
+ MSG
282
+ end
269
283
  end
270
284
  end
271
285
  # rubocop:enable Metrics/ClassLength
@@ -4,13 +4,13 @@ require "English"
4
4
 
5
5
  module ReactOnRails
6
6
  module GitUtils
7
- def self.uncommitted_changes?(message_handler)
7
+ def self.uncommitted_changes?(message_handler, git_installed: true)
8
8
  return false if ENV["COVERAGE"] == "true"
9
9
 
10
10
  status = `git status --porcelain`
11
- return false if $CHILD_STATUS.success? && status.empty?
11
+ return false if git_installed && status&.empty?
12
12
 
13
- error = if $CHILD_STATUS.success?
13
+ error = if git_installed
14
14
  "You have uncommitted code. Please commit or stash your changes before continuing"
15
15
  else
16
16
  "You do not have Git installed. Please install Git, and commit your changes before continuing"
@@ -155,7 +155,7 @@ module ReactOnRails
155
155
  if defer
156
156
  @registered_stores_defer_render ||= []
157
157
  @registered_stores_defer_render << redux_store_data
158
- "YOU SHOULD NOT SEE THIS ON YOUR VIEW -- Uses as a code block, like <% redux_store %> "\
158
+ "YOU SHOULD NOT SEE THIS ON YOUR VIEW -- Uses as a code block, like <% redux_store %> " \
159
159
  "and not <%= redux store %>"
160
160
  else
161
161
  @registered_stores ||= []
@@ -245,7 +245,7 @@ module ReactOnRails
245
245
  return "{}" if hash_or_string.nil?
246
246
 
247
247
  unless hash_or_string.is_a?(String) || hash_or_string.is_a?(Hash)
248
- raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument "\
248
+ raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument " \
249
249
  "(#{hash_or_string.class} given)."
250
250
  end
251
251
 
@@ -441,11 +441,10 @@ module ReactOnRails
441
441
  "data-trace" => (render_options.trace ? true : nil),
442
442
  "data-dom-id" => render_options.dom_id)
443
443
 
444
+ load_pack_for_generated_component(react_component_name, render_options)
444
445
  # Create the HTML rendering part
445
446
  result = server_rendered_react_component(render_options)
446
447
 
447
- load_pack_for_generated_component(react_component_name, render_options)
448
-
449
448
  {
450
449
  render_options: render_options,
451
450
  tag: component_specification_tag,
@@ -4,25 +4,8 @@ require "active_support/core_ext/string/output_safety"
4
4
 
5
5
  module ReactOnRails
6
6
  class JsonOutput
7
- ESCAPE_REPLACEMENT = {
8
- "&" => '\u0026',
9
- ">" => '\u003e',
10
- "<" => '\u003c',
11
- "\u2028" => '\u2028',
12
- "\u2029" => '\u2029'
13
- }.freeze
14
- ESCAPE_REGEXP = /[\u2028\u2029&><]/u.freeze
15
-
16
7
  def self.escape(json)
17
- return escape_without_erb_util(json) if Utils.rails_version_less_than_4_1_1
18
-
19
8
  ERB::Util.json_escape(json)
20
9
  end
21
-
22
- def self.escape_without_erb_util(json)
23
- # https://github.com/rails/rails/blob/60257141462137331387d0e34931555cf0720886/activesupport/lib/active_support/core_ext/string/output_safety.rb#L113
24
-
25
- json.to_s.gsub(ESCAPE_REGEXP, ESCAPE_REPLACEMENT)
26
- end
27
10
  end
28
11
  end
@@ -100,14 +100,14 @@ module ReactOnRails
100
100
 
101
101
  def convert
102
102
  file_names.each do |name|
103
- template = send("template_#{name}")
103
+ template = send(:"template_#{name}")
104
104
  path = file(name)
105
105
  generate_file(template, path)
106
106
  end
107
107
  end
108
108
 
109
109
  def generate_file(template, path)
110
- result = ERB.new(template).result()
110
+ result = ERB.new(template).result
111
111
  File.write(path, result)
112
112
  end
113
113
 
@@ -138,7 +138,7 @@ module ReactOnRails
138
138
  def flatten(translations)
139
139
  translations.each_with_object({}) do |(k, v), h|
140
140
  if v.is_a? Hash
141
- flatten(v).map { |hk, hv| h["#{k}.#{hk}".to_sym] = hv }
141
+ flatten(v).map { |hk, hv| h[:"#{k}.#{hk}"] = hv }
142
142
  elsif v.is_a?(String)
143
143
  h[k] = v.gsub("%{", "{")
144
144
  elsif !v.is_a?(Array)
@@ -157,7 +157,7 @@ module ReactOnRails
157
157
  <<-JS.strip_heredoc
158
158
  import { defineMessages } from 'react-intl';
159
159
 
160
- const defaultLocale = \'#{default_locale}\';
160
+ const defaultLocale = '#{default_locale}';
161
161
 
162
162
  const defaultMessages = defineMessages(#{@defaults});
163
163
 
@@ -21,7 +21,7 @@ module ReactOnRails
21
21
  <<-JS.strip_heredoc
22
22
  import { defineMessages } from 'react-intl';
23
23
 
24
- const defaultLocale = \'#{default_locale}\';
24
+ const defaultLocale = '#{default_locale}';
25
25
 
26
26
  const defaultMessages = defineMessages(#{@defaults});
27
27
 
@@ -5,7 +5,7 @@ require "fileutils"
5
5
  module ReactOnRails
6
6
  # rubocop:disable Metrics/ClassLength
7
7
  class PacksGenerator
8
- CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/.freeze
8
+ CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/
9
9
  MINIMUM_SHAKAPACKER_VERSION = [6, 5, 1].freeze
10
10
 
11
11
  def self.instance
@@ -15,6 +15,7 @@ module ReactOnRails
15
15
  def generate_packs_if_stale
16
16
  return unless ReactOnRails.configuration.auto_load_bundle
17
17
 
18
+ add_generated_pack_to_server_bundle
18
19
  are_generated_files_present_and_up_to_date = Dir.exist?(generated_packs_directory_path) &&
19
20
  File.exist?(generated_server_bundle_file_path) &&
20
21
  !stale_or_missing_packs?
@@ -99,8 +100,8 @@ module ReactOnRails
99
100
  def generated_server_bundle_file_path
100
101
  return server_bundle_entrypoint if ReactOnRails.configuration.make_generated_server_bundle_the_entrypoint
101
102
 
102
- generated_server_bundle_file_path = server_bundle_entrypoint.sub(".js", "-generated.js")
103
- generated_server_bundle_file_name = component_name(generated_server_bundle_file_path)
103
+ generated_interim_server_bundle_path = server_bundle_entrypoint.sub(".js", "-generated.js")
104
+ generated_server_bundle_file_name = component_name(generated_interim_server_bundle_path)
104
105
  source_entrypoint_parent = Pathname(ReactOnRails::WebpackerUtils.webpacker_source_entry_path).parent
105
106
  generated_nonentrypoints_path = "#{source_entrypoint_parent}/generated"
106
107
 
@@ -155,9 +156,7 @@ module ReactOnRails
155
156
  end
156
157
 
157
158
  def common_component_to_path
158
- common_components_paths = Dir.glob("#{components_search_path}/*").reject do |f|
159
- CONTAINS_CLIENT_OR_SERVER_REGEX.match?(f)
160
- end
159
+ common_components_paths = Dir.glob("#{components_search_path}/*").grep_v(CONTAINS_CLIENT_OR_SERVER_REGEX)
161
160
  component_name_to_path(common_components_paths)
162
161
  end
163
162
 
@@ -35,7 +35,7 @@ module ReactOnRails
35
35
  props.clone)
36
36
  end
37
37
 
38
- raise ReactOnRails::Error, "ReactOnRails: your rendering_props_extension module is missing the "\
38
+ raise ReactOnRails::Error, "ReactOnRails: your rendering_props_extension module is missing the " \
39
39
  "required adjust_props_for_client_side_hydration method & can not be used"
40
40
  end
41
41
  props
@@ -7,7 +7,6 @@ module ReactOnRails
7
7
  module ServerRenderingPool
8
8
  # rubocop:disable Metrics/ClassLength
9
9
  class RubyEmbeddedJavaScript
10
- # rubocop:enable Metrics/ClassLength
11
10
  class << self
12
11
  def reset_pool
13
12
  options = {
@@ -125,8 +124,8 @@ module ReactOnRails
125
124
  File.read(server_js_file)
126
125
  end
127
126
  rescue StandardError => e
128
- msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be "\
129
- "read. You may set the server_bundle_js_file in your configuration to be \"\" to "\
127
+ msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be " \
128
+ "read. You may set the server_bundle_js_file in your configuration to be \"\" to " \
130
129
  "avoid this warning.\nError is: #{e}"
131
130
  raise ReactOnRails::Error, msg
132
131
  end
@@ -145,15 +144,15 @@ module ReactOnRails
145
144
  begin
146
145
  if ReactOnRails.configuration.trace
147
146
  Rails.logger.info do
148
- "[react_on_rails] Created JavaScript context with file "\
147
+ "[react_on_rails] Created JavaScript context with file " \
149
148
  "#{ReactOnRails::Utils.server_bundle_js_file_path}"
150
149
  end
151
150
  end
152
151
  ExecJS.compile(base_js_code)
153
152
  rescue StandardError => e
154
- msg = "ERROR when compiling base_js_code! "\
155
- "See file #{file_name} to "\
156
- "correlate line numbers of error. Error is\n\n#{e.message}"\
153
+ msg = "ERROR when compiling base_js_code! " \
154
+ "See file #{file_name} to " \
155
+ "correlate line numbers of error. Error is\n\n#{e.message}" \
157
156
  "\n\n#{e.backtrace.join("\n")}"
158
157
  Rails.logger.error(msg)
159
158
  trace_js_code_used("Error when compiling JavaScript code for the context.", base_js_code,
@@ -192,8 +191,8 @@ module ReactOnRails
192
191
 
193
192
  def undefined_for_exec_js_logging(function_name)
194
193
  if ReactOnRails.configuration.trace
195
- "console.error('[React on Rails Rendering] #{function_name} is not defined for server rendering.');\n"\
196
- " console.error(getStackTrace().join('\\n'));"
194
+ "console.error('[React on Rails Rendering] #{function_name} is not defined for server rendering.');\n " \
195
+ "console.error(getStackTrace().join('\\n'));"
197
196
  else
198
197
  ""
199
198
  end
@@ -235,6 +234,7 @@ module ReactOnRails
235
234
  raise ReactOnRails::Error, msg
236
235
  end
237
236
  end
237
+ # rubocop:enable Metrics/ClassLength
238
238
  end
239
239
  end
240
240
  end
@@ -62,10 +62,10 @@ module ReactOnRails
62
62
  else
63
63
  file_list = make_file_list(make_globs(generated_assets_full_path)).to_ary
64
64
  puts "V" * 80
65
- puts "Please define config.webpack_generated_files (array) so the test helper knows "\
66
- "which files are required. If you are using webpacker, you typically need to only "\
65
+ puts "Please define config.webpack_generated_files (array) so the test helper knows " \
66
+ "which files are required. If you are using webpacker, you typically need to only " \
67
67
  "include 'manifest.json'."
68
- puts "Detected the possible following files to check for webpack compilation in "\
68
+ puts "Detected the possible following files to check for webpack compilation in " \
69
69
  "#{generated_assets_full_path}"
70
70
  puts file_list.join("\n")
71
71
  puts "^" * 80
@@ -80,8 +80,8 @@ module ReactOnRails
80
80
 
81
81
  unless @printed_once
82
82
  puts
83
- puts "====> React On Rails: Checking files in "\
84
- "#{webpack_assets_status_checker.generated_assets_full_path} for "\
83
+ puts "====> React On Rails: Checking files in " \
84
+ "#{webpack_assets_status_checker.generated_assets_full_path} for " \
85
85
  "outdated/missing bundles based on source_path #{source_path}"
86
86
  puts
87
87
  @printed_once = true
@@ -118,12 +118,6 @@ module ReactOnRails
118
118
  end
119
119
  end
120
120
 
121
- # rubocop:disable Naming/VariableNumber
122
- def self.rails_version_less_than_4_1_1
123
- rails_version_less_than("4.1.1")
124
- end
125
- # rubocop:enable Naming/VariableNumber
126
-
127
121
  module Required
128
122
  def required(arg_name)
129
123
  raise ReactOnRails::Error, "#{arg_name} is required"
@@ -195,13 +189,13 @@ module ReactOnRails
195
189
  to_remove = str.length - max_length
196
190
  lstrip = (to_remove / 2.0).ceil
197
191
  rstrip = to_remove - lstrip
198
- str[0..(midpoint - lstrip - 1)] + TRUNCATION_FILLER + str[(midpoint + rstrip)..-1]
192
+ str[0..(midpoint - lstrip - 1)] + TRUNCATION_FILLER + str[(midpoint + rstrip)..]
199
193
  end
200
194
 
201
195
  def self.find_most_recent_mtime(files)
202
196
  files.reduce(1.year.ago) do |newest_time, file|
203
197
  mt = File.mtime(file)
204
- mt > newest_time ? mt : newest_time
198
+ [mt, newest_time].max
205
199
  end
206
200
  end
207
201
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "13.4.0"
4
+ VERSION = "14.0.1"
5
5
  end
@@ -6,7 +6,7 @@ module ReactOnRails
6
6
  class VersionChecker
7
7
  attr_reader :node_package_version
8
8
 
9
- MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)/.freeze
9
+ MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)/
10
10
 
11
11
  def self.build
12
12
  new(NodePackageVersion.build)
@@ -52,7 +52,7 @@ module ReactOnRails
52
52
  end
53
53
 
54
54
  def raise_node_semver_version_warning
55
- msg = "**ERROR** ReactOnRails: Your node package version for react-on-rails contains a "\
55
+ msg = "**ERROR** ReactOnRails: Your node package version for react-on-rails contains a " \
56
56
  "^ or ~\n#{common_error_msg}"
57
57
  raise ReactOnRails::Error, msg
58
58
  end
@@ -141,5 +141,11 @@ module ReactOnRails
141
141
  def self.semver_to_string(ary)
142
142
  "#{ary[0]}.#{ary[1]}.#{ary[2]}"
143
143
  end
144
+
145
+ def self.using_shakapacker_6?
146
+ shakapacker_major_version = shakapacker_version_as_array[0]
147
+
148
+ shakapacker_major_version == 6
149
+ end
144
150
  end
145
151
  end
@@ -18,7 +18,7 @@ namespace :react_on_rails do
18
18
  elsif build_production_command.methods.include?(:call)
19
19
  build_production_command.call
20
20
  else
21
- msg = "ReactonRails.configuration.build_production_command is improperly configured. "\
21
+ msg = "ReactonRails.configuration.build_production_command is improperly configured. " \
22
22
  "Value = #{build_production_command} with class #{build_production_command.class}"
23
23
  puts Rainbow(msg).red
24
24
  exit!(1)
@@ -16,14 +16,15 @@ Gem::Specification.new do |s|
16
16
  s.homepage = "https://github.com/shakacode/react_on_rails"
17
17
  s.license = "MIT"
18
18
 
19
- s.files = `git ls-files -z`.split("\x0").reject do |f|
20
- f.match(%r{^(test|spec|features|gen-examples|tmp|node_modules|node_package|coverage)/})
19
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(docs|test|spec|features|gen-examples|tmp|node_modules|node_package|coverage|rakelib|script)/}) ||
21
+ f.match(%r{^(jest\.config\.js|book\.json|package\.json|package-scripts\.yml|yarn\.lock|\..*)})
21
22
  end
22
23
  s.bindir = "exe"
23
24
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
25
  s.require_paths = ["lib"]
25
26
 
26
- s.required_ruby_version = ">= 2.7.0"
27
+ s.required_ruby_version = ">= 3.0.0"
27
28
 
28
29
  s.add_dependency "addressable"
29
30
  s.add_dependency "connection_pool"
@@ -31,7 +32,6 @@ Gem::Specification.new do |s|
31
32
  s.add_dependency "rails", ">= 5.2"
32
33
  s.add_dependency "rainbow", "~> 3.0"
33
34
 
34
- s.add_development_dependency "bundler", "~> 2"
35
35
  s.add_development_dependency "gem-release"
36
36
  s.post_install_message = '
37
37
  --------------------------------------------------------------------------------