react_on_rails 12.0.3 → 12.0.4

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ca3650879f76d12748c0bb421da2d776fec62e7599e23552de09b21d19e8bff
4
- data.tar.gz: b1e30785a72bc83dd0671ddcb26f768bacfc2cb2ccc9293e93be36286848d281
3
+ metadata.gz: cbc3d5e5e388d5f126ac4629c9716ab1e0bbad148617aae2aa0b29a1b8728bf8
4
+ data.tar.gz: e7890cf4cd11ddc3c1301d4ec3d7b085335e73964498d554c9a6bd67a6155e9c
5
5
  SHA512:
6
- metadata.gz: 1ee2dcd8f08ac5cb3a7980639673b06a38a6bd29aa9b0e3e7956a8e45a262b3ffd036fbea5d387be8f025a96cb2f8af2592bbb08b4a34edb6114df4554a7d74d
7
- data.tar.gz: 1a21c1642097dc08f081b75e1dd9542128227a3464c76b4188e1e7e1471466a0273ef72151ca662272b08be7bec254085e7d6eb8287059baa60c6303b138f1cb
6
+ metadata.gz: 012bd1f23efd28c306541db16d630ff8732aaeb50828f2c2d595d18d3600c359778a7177943d1331b9a7c24b3c03fc79542098cb166a721d54816f680410db1d
7
+ data.tar.gz: 1b35e5642aaa762ac451d3098e6250b7b42a2ef100680b235500212269d8d2459d23360b82ee60fa881e8e7ff4d44a3150d435eb015904b00df6ab09b2aa07a5
data/.eslintrc CHANGED
@@ -1,4 +1,3 @@
1
- ---
2
1
  extends:
3
2
  - eslint-config-shakacode
4
3
  - prettier
@@ -2,6 +2,7 @@
2
2
  # Check out: https://github.com/bbatsov/rubocop
3
3
 
4
4
  AllCops:
5
+ NewCops: enable
5
6
  DisplayCopNames: true
6
7
  TargetRubyVersion: 2.5
7
8
 
@@ -13,35 +14,33 @@ AllCops:
13
14
  - '**/*.rake'
14
15
 
15
16
  Exclude:
16
- - 'vendor/**/*'
17
- - 'spec/fixtures/**/*'
18
- - 'node_modules/**/.*'
19
- - 'node_modules/**/*'
17
+ <% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
18
+ - <%= path.sub(/^!! /, '') %>
19
+ <% end %>
20
+ - '**/*.js'
21
+ - '**/log/**/*'
22
+ - '**/node_modules/**/*'
23
+ - '**/public/**/*'
24
+ - '**/tmp/**/*'
25
+ - '.git/**/*'
26
+ - 'bin/**/*'
20
27
  - 'coverage/**/*'
21
28
  - 'db/**/*'
22
29
  - 'db/schema.rb'
23
30
  - 'db/seeds.rb'
24
- - 'client/node_modules/**/*.*'
25
- - 'client/node_modules/**/.*'
26
- - 'bin/**/*'
27
- - !ruby/regexp /old_and_unused\.rb$/
28
- - 'spec/react_on_rails/dummy-for-generators/**/*'
29
- - 'spec/dummy/Procfile.*'
30
- - 'spec/dummy/bin/**/*'
31
- - 'spec/dummy/node_modules/**/*'
32
- - 'spec/dummy/node_modules/**/.*'
33
- - 'gen-examples/examples/**/.*'
34
31
  - 'gen-examples/examples/**/*'
32
+ - 'node_modules/**/*'
33
+ - 'spec/dummy/bin/*'
34
+ - 'spec/fixtures/**/*'
35
+ - 'spec/react_on_rails/dummy-for-generators/**/*'
36
+ - 'tmp/**/*'
37
+ - 'vendor/**/*'
35
38
 
36
39
  Naming/FileName:
37
40
  Exclude:
38
41
  - 'Gemfile'
39
42
  - 'spec/dummy/Gemfile'
40
43
 
41
- # Turn off until we require 2.3 ruby
42
- Style/SafeNavigation:
43
- Enabled: false
44
-
45
44
  Layout/LineLength:
46
45
  Max: 120
47
46
 
@@ -97,25 +96,3 @@ Naming/RescuedExceptionsVariableName:
97
96
  Style/GlobalVars:
98
97
  Exclude:
99
98
  - 'spec/dummy/config/environments/development.rb'
100
-
101
- Style/FrozenStringLiteralComment:
102
- EnforcedStyle: always
103
-
104
- Layout/EmptyLinesAroundAttributeAccessor:
105
- Enabled: true
106
-
107
- Layout/SpaceAroundMethodCallOperator:
108
- Enabled: true
109
-
110
- Lint/RaiseException:
111
- Enabled: true
112
-
113
- Lint/StructNewOverride:
114
- Enabled: true
115
-
116
- Style/ExponentialNotation:
117
- Enabled: true
118
-
119
- Style/SlicingWithRange:
120
- Enabled: true
121
-
@@ -16,6 +16,9 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
16
16
  Changes since last non-beta release.
17
17
 
18
18
  *Please add entries here for your pull requests that are not yet released.*
19
+ ### [12.0.4] - 2020-11-14
20
+ #### Fixed
21
+ - Install generator now specifies the version. Fixes [React on Rails Generator installs the older npm package #1336](https://github.com/shakacode/react_on_rails/issues/1336). [PR 1338Fix Generator to use Exact NPM Version](https://github.com/shakacode/react_on_rails/pull/1338) by by [justin808](https://github.com/justin808).
19
22
 
20
23
  ### [12.0.3] - 2020-09-20
21
24
  #### Fixed
@@ -943,7 +946,8 @@ Best done with Object destructing:
943
946
  ##### Fixed
944
947
  - Fix several generator related issues.
945
948
 
946
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.0.3...master
949
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.0.4...master
950
+ [12.0.4]: https://github.com/shakacode/react_on_rails/compare/12.0.3...12.0.4
947
951
  [12.0.3]: https://github.com/shakacode/react_on_rails/compare/12.0.2...12.0.3
948
952
  [12.0.2]: https://github.com/shakacode/react_on_rails/compare/12.0.1...12.0.2
949
953
  [12.0.1]: https://github.com/shakacode/react_on_rails/compare/12.0.0...12.0.1
data/Gemfile CHANGED
@@ -5,36 +5,4 @@ source "https://rubygems.org"
5
5
  # Specify your gem"s dependencies in react_on_rails.gemspec
6
6
  gemspec
7
7
 
8
- # The following gems are dependencies of the gem's dummy/example apps, not the gem itself.
9
- # They must be defined here because of the way Travis CI works, in that it will only
10
- # bundle install from a single Gemfile. Therefore, all gems that we will need for any dummy/example
11
- # app have to be manually added to this file.
12
- gem "bootsnap", ">= 1.1.0", require: false
13
- gem "bootstrap-sass"
14
- gem "jbuilder"
15
- gem "jquery-rails"
16
- gem "mini_racer"
17
- gem "puma"
18
- gem "rails_12factor"
19
- gem "ruby-lint", require: false
20
- gem "sass-rails"
21
- gem "scss_lint", require: false
22
- gem "sdoc", group: :doc
23
- gem "spring"
24
- gem "sprockets", "~>3.0"
25
- gem "sqlite3", "~> 1.3.6"
26
- gem "turbolinks"
27
- gem "uglifier"
28
- gem "web-console", group: :development
29
-
30
- # below are copied from spec/dummy/Gemfile
31
- gem "capybara"
32
- gem "capybara-screenshot"
33
- gem "launchy"
34
- gem "rspec-rails"
35
- gem "rspec-retry"
36
- gem "selenium-webdriver"
37
- gem "webpacker", ">= 4.0.0"
38
-
39
- gem "equivalent-xml", github: "mbklein/equivalent-xml"
40
- gem "rainbow"
8
+ eval_gemfile File.expand_path("./Gemfile.development_dependencies", __dir__)
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ # We'll revert this before the final merge.
5
+ # gem "webpacker", git: 'https://github.com/rails/webpacker.git'
6
+ gem "webpacker"
7
+ gem "bootsnap", ">= 1.1.0", require: false
8
+ gem "rails"
9
+ gem "sqlite3"
10
+ gem "sass-rails"
11
+ gem "uglifier"
12
+ gem "jquery-rails"
13
+ gem "puma"
14
+
15
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
16
+ gem "turbolinks" if ENV["DISABLE_TURBOLINKS"].nil? || ENV["DISABLE_TURBOLINKS"].strip.empty?
17
+
18
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
19
+ gem "jbuilder"
20
+ # bundle exec rake doc:rails generates the API under doc/api.
21
+ gem "sdoc", group: :doc
22
+
23
+ gem "sprockets"
24
+
25
+ # Use Capistrano for deployment
26
+ # gem 'capistrano-rails', group: :development
27
+ gem "awesome_print"
28
+ gem "mini_racer"
29
+
30
+ group :development, :test do
31
+ gem "listen"
32
+ gem "pry"
33
+ gem "pry-byebug"
34
+ gem "pry-doc"
35
+ gem "pry-rails"
36
+ gem "pry-rescue"
37
+ gem "rubocop", "1.2.0", require: false
38
+ gem "scss_lint", require: false
39
+ gem "spring"
40
+ end
41
+
42
+ group :test do
43
+ gem "capybara"
44
+ gem "capybara-screenshot"
45
+ gem "coveralls", require: false
46
+ gem "equivalent-xml"
47
+ gem "generator_spec"
48
+ gem "launchy"
49
+ gem "rspec_junit_formatter"
50
+ gem "rspec-rails"
51
+ gem "rspec-retry"
52
+ gem "selenium-webdriver"
53
+ gem "webdrivers", "~> 3.0"
54
+ end
data/README.md CHANGED
@@ -14,6 +14,13 @@
14
14
  *These are the docs for React on Rails 12. To see the version 11 docs, [click here](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
15
15
 
16
16
  #### News
17
+
18
+ **October 14, 2020**: [RUBY ROGUES
19
+ RR 474: React on Rails V12 – Don’t Shave That Yak! with Justin Gordon](https://devchat.tv/ruby-rogues/rr-474-react-on-rails-v12-dont-shave-that-yak-with-justin-gordon/).
20
+
21
+ **October 1, 2020**: See the [spec/dummy](./spec/dummy) example repo for a simple configuration of webpack via the rails/webpacker gem
22
+ that supports SSR.
23
+
17
24
  **August 2, 2020**: See the example repo of [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh) for a new way to setup the creation of your SSR bundle with `rails/webpacker`.
18
25
 
19
26
  **July 8, 2020**: Release v12 of React on Rails.
@@ -29,10 +36,8 @@ Be sure to see the [CHANGELOG.md](./CHANGELOG.md) and read the upgrade instructi
29
36
  [docs/basics/upgrading-react-on-rails](./docs/basics/upgrading-react-on-rails.md#upgrading-to-v12).
30
37
 
31
38
  * See Justin's RailsConf talk: [Webpacker, It-Just-Works, But How?](http://railsconf.com/2020/video/justin-gordon-webpacker-it-just-works-but-how).
32
- * Are you interested in support for React on Rails? If so check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
39
+ * Are you interested in support for React on Rails? Do you want to use Node.js to do your server-side rendering so libraries like Emotion and Loadable Components just work, as compared to rendering via Ruby embedded JS? If so check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro).
33
40
  * HMR is working with [Loadable Components](https://loadable-components.com) for a both amazing hot-reloading developer experience and great runtime performance. Please [email me](mailto:justin@shakacode.com) if you'd like to use [Loadable Components Code Splitting](https://loadable-components.com/docs/code-splitting/) to speed up your app by reducing your bundle sizes and lazily loading the code that's needed.
34
- * `react_on_rails` fully supports `rails/webpacker`. The example test app in `spec/dummy` was recently converted over to use rails/webpacker v4+. It's a good example of how to leverage rails/webpacker's webpack configuration.
35
-
36
41
  ---
37
42
 
38
43
  #### About
@@ -64,7 +69,7 @@ Given that `rails/webpacker` gem already provides basic React integration, why w
64
69
  1. Server-Side Rendering (SSR), often used for SEO crawler indexing and UX performance, is not offered by `rails/webpacker`.
65
70
  1. [Redux](https://github.com/reactjs/redux) and [React Router](https://github.com/ReactTraining/react-router#readme) integration with server-side-rendering.
66
71
  1. [Internationalization (I18n) and (localization)](https://github.com/shakacode/react_on_rails/blob/master/docs/basics/i18n.md)
67
- 1. A supportive community. This [web search shows how live public sites are using React on Rails](https://publicwww.com/websites/%22react-on-rails%22++-undeveloped.com/).
72
+ 1. A supportive community. This [web search shows how live public sites are using React on Rails](https://publicwww.com/websites/%22react-on-rails%22++-undeveloped.com+depth%3Aall/).
68
73
  1. [Reason ML Support](https://github.com/shakacode/reason-react-on-rails-example).
69
74
 
70
75
  See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
@@ -1,13 +1,13 @@
1
1
  # Upgrading React on Rails
2
2
 
3
3
  ## Need Help Migrating?
4
- If you would like help in migrating between React on Rails versions or help with implementing server rendering, please contact [justin@shakacode.com](mailto:justin@shakacode.com) for information about our [ShakaCode Pro Support](https://www.shakacode.com/work/shakacode-pro-support.pdf).
4
+ If you would like help in migrating between React on Rails versions or help with implementing server rendering, please contact [justin@shakacode.com](mailto:justin@shakacode.com) for more information about our [React on Rails Pro Support](https://www.shakacode.com/react-on-rails-pro).
5
5
 
6
- We specialize in helping companies to quickly and efficiently move from versions before 9 to current. The older versions use the Rails asset pipeline to package client assets. The current and recommended way is to use Webpack 4 for asset preparation. You may also need help migrating from the `rails/webpacker`'s Webpack configuration to a better setup ready for Server Side Rendering.
6
+ We specialize in helping companies to quickly and efficiently upgrade. The older versions use the Rails asset pipeline to package client assets. The current and recommended way is to use Webpack 4+ for asset preparation. You may also need help migrating from the `rails/webpacker`'s Webpack configuration to a better setup ready for Server Side Rendering.
7
7
 
8
8
  ## Upgrading to v12
9
9
  ### Recent versions
10
- Make sure that you are on a relatively more recent version of rails and webpacker.
10
+ Make sure that you are on a relatively more recent version of rails and webpacker. Yes, the [rails/webpacker](https://github.com/rails/webpacker) gem is required!
11
11
  v12 is tested on Rails 6. It should work on Rails v5. If you're on any older version,
12
12
  and v12 doesn't work, please file an issue.
13
13
 
@@ -100,7 +100,7 @@ wrapper such that you're returning a function rather than a React Element, then:
100
100
 
101
101
  ## Upgrading rails/webpacker from v3 to v4
102
102
  ### Custom Webpack build file
103
- The default value for `extract_css` is **false** in `config/webpack.yml`. Custom webpack builds should set this value to true or else no CSS link tags are generated. You have a custom webpack build if you are not using [rails/webpacker](https://github.com/rails/webpacker to setup your Webpack configuration.
103
+ The default value for `extract_css` is **false** in `config/webpack.yml`. Custom webpack builds should set this value to true or else no CSS link tags are generated. You have a custom webpack build if you are not using [rails/webpacker](https://github.com/rails/webpacker) to setup your Webpack configuration.
104
104
 
105
105
  ```yml
106
106
  default: &default
@@ -117,8 +117,8 @@ There's an implemented example of code splitting in the `spec/dummy` folder of t
117
117
 
118
118
  See:
119
119
 
120
- - [spec/dummy/client/app/startup/clientRegistration.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/clientRegistration.jsx)
121
- - [spec/dummy/client/app/startup/serverRegistration.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/serverRegistration.jsx)
120
+ - [spec/dummy/client/app/startup/client-bundle.js](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/client-bundle.js)
121
+ - [spec/dummy/client/app/packs/server-bundle.js](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/packs/server-bundle.js)
122
122
  - [spec/dummy/client/app/startup/DeferredRenderAppClient](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/DeferredRenderAppClient.jsx)<-- Code splitting implemented here
123
123
  - [spec/dummy/client/app/startup/DeferredRenderAppServer.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/DeferredRenderAppServer.jsx)
124
124
  - [spec/dummy/client/app/components/DeferredRender.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/components/DeferredRender.jsx)
@@ -2,7 +2,7 @@
2
2
 
3
3
  -----
4
4
 
5
- **August 2, 2020**: See the example repo of [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh) for a new way to setup the creation of your SSR bundle with `rails/webpacker`. This file will be update shortly. Most of it is still relevant.
5
+ **November 11, 2020**: See the example repo of [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh) for a new way to setup the creation of your SSR bundle with `rails/webpacker`. This file will be update shortly. Most of it is still relevant.
6
6
 
7
7
  -----
8
8
 
@@ -43,7 +43,14 @@ module ReactOnRails
43
43
  end
44
44
 
45
45
  def add_yarn_dependencies
46
- run "yarn add react-on-rails --exact"
46
+ major_minor_patch_only = /\A\d+\.\d+\.\d+\z/.freeze
47
+ if ReactOnRails::VERSION.match?(major_minor_patch_only)
48
+ run "yarn add react-on-rails@#{ReactOnRails::VERSION} --exact"
49
+ else
50
+ # otherwise add latest
51
+ puts "Adding the lastest react-on-rails NPM module. Double check this is correct in package.json"
52
+ run "yarn add react-on-rails --exact"
53
+ end
47
54
  end
48
55
 
49
56
  def append_to_spec_rails_helper
@@ -17,7 +17,7 @@ if ENV["COVERAGE"] == "true"
17
17
 
18
18
  # Don't report anything that has "spec" in the path
19
19
  add_filter do |src|
20
- src.filename =~ %r{\/spec\/}
20
+ src.filename =~ %r{/spec/}
21
21
  end
22
22
  end
23
23
  end
@@ -53,6 +53,7 @@ module ReactOnRails
53
53
  :server_render_method, :random_dom_id,
54
54
  :same_bundle_for_client_and_server
55
55
 
56
+ # rubocop:disable Metrics/AbcSize
56
57
  def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender: nil,
57
58
  replay_console: nil,
58
59
  trace: nil, development_mode: nil,
@@ -98,6 +99,7 @@ module ReactOnRails
98
99
 
99
100
  self.server_render_method = server_render_method
100
101
  end
102
+ # rubocop:enable Metrics/AbcSize
101
103
 
102
104
  # on ReactOnRails
103
105
  def setup_config_values
@@ -10,10 +10,10 @@ module ReactOnRails
10
10
  status = `git status --porcelain`
11
11
  return false if $CHILD_STATUS.success? && status.empty?
12
12
 
13
- error = if !$CHILD_STATUS.success?
14
- "You do not have Git installed. Please install Git, and commit your changes before continuing"
15
- else
13
+ error = if $CHILD_STATUS.success?
16
14
  "You have uncommitted code. Please commit or stash your changes before continuing"
15
+ else
16
+ "You do not have Git installed. Please install Git, and commit your changes before continuing"
17
17
  end
18
18
  message_handler.add_error(error)
19
19
  true
@@ -32,8 +32,8 @@ module ReactOnRails
32
32
  # Exposing the react_component_name is necessary to both a plain ReactComponent as well as
33
33
  # a generator:
34
34
  # See README.md for how to "register" your react components.
35
- # See spec/dummy/client/app/startup/serverRegistration.jsx and
36
- # spec/dummy/client/app/startup/ClientRegistration.jsx for examples of this
35
+ # See spec/dummy/client/app/packs/server-bundle.js and
36
+ # spec/dummy/client/app/packs/client-bundle.js for examples of this.
37
37
  #
38
38
  # options:
39
39
  # props: Ruby Hash or JSON string which contains the properties to pass to the react object. Do
@@ -57,14 +57,15 @@ module ReactOnRails
57
57
  server_rendered_html = internal_result[:result]["html"]
58
58
  console_script = internal_result[:result]["consoleReplayScript"]
59
59
 
60
- if server_rendered_html.is_a?(String)
60
+ case server_rendered_html
61
+ when String
61
62
  build_react_component_result_for_server_rendered_string(
62
63
  server_rendered_html: server_rendered_html,
63
64
  component_specification_tag: internal_result[:tag],
64
65
  console_script: console_script,
65
66
  render_options: internal_result[:render_options]
66
67
  )
67
- elsif server_rendered_html.is_a?(Hash)
68
+ when Hash
68
69
  msg = <<~MSG
69
70
  Use react_component_hash (not react_component) to return a Hash to your ruby view code. See
70
71
  https://github.com/shakacode/react_on_rails/blob/master/spec/dummy/client/app/startup/ReactHelmetServerApp.jsx
@@ -243,7 +244,7 @@ module ReactOnRails
243
244
  # second parameter passed to both component and store Render-Functions.
244
245
  # This method can be called from views and from the controller, as `helpers.rails_context`
245
246
  #
246
- # rubocop:disable Metrics/AbcSize
247
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
247
248
  def rails_context(server_side: true)
248
249
  # ALERT: Keep in sync with node_package/src/types/index.ts for the properties of RailsContext
249
250
  @rails_context ||= begin
@@ -291,7 +292,7 @@ module ReactOnRails
291
292
 
292
293
  @rails_context.merge(serverSide: server_side)
293
294
  end
294
- # rubocop:enable Metrics/AbcSize
295
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
295
296
 
296
297
  private
297
298
 
@@ -5,10 +5,6 @@ require "erb"
5
5
  module ReactOnRails
6
6
  module Locales
7
7
  class ToJs < Base
8
- def initialize
9
- super
10
- end
11
-
12
8
  private
13
9
 
14
10
  def file_format
@@ -5,10 +5,6 @@ require "erb"
5
5
  module ReactOnRails
6
6
  module Locales
7
7
  class ToJson < Base
8
- def initialize
9
- super
10
- end
11
-
12
8
  private
13
9
 
14
10
  def file_format
@@ -47,6 +47,7 @@ module ReactOnRails
47
47
  # Note, js_code does not have to be based on React.
48
48
  # js_code MUST RETURN json stringify Object
49
49
  # Calling code will probably call 'html_safe' on return value before rendering to the view.
50
+ # rubocop:disable Metrics/CyclomaticComplexity
50
51
  def exec_server_render_js(js_code, render_options, js_evaluator = nil)
51
52
  js_evaluator ||= self
52
53
  if render_options.trace
@@ -67,16 +68,15 @@ module ReactOnRails
67
68
  console_script = result["consoleReplayScript"]
68
69
  console_script_lines = console_script.split("\n")
69
70
  console_script_lines = console_script_lines[2..-2]
70
- re = /console\.(log|error)\.apply\(console, \["\[SERVER\] (?<msg>.*)"\]\);/
71
- if console_script_lines
72
- console_script_lines.each do |line|
73
- match = re.match(line)
74
- Rails.logger.info { "[react_on_rails] #{match[:msg]}" } if match
75
- end
71
+ re = /console\.(?:log|error)\.apply\(console, \["\[SERVER\] (?<msg>.*)"\]\);/
72
+ console_script_lines&.each do |line|
73
+ match = re.match(line)
74
+ Rails.logger.info { "[react_on_rails] #{match[:msg]}" } if match
76
75
  end
77
76
  end
78
77
  result
79
78
  end
79
+ # rubocop:enable Metrics/CyclomaticComplexity
80
80
 
81
81
  def trace_js_code_used(msg, js_code, file_name = "tmp/server-generated.js", force: false)
82
82
  return unless ReactOnRails.configuration.trace || force
@@ -52,6 +52,7 @@ module ReactOnRails
52
52
  # don't provide one.
53
53
  # webpack_generated_files List of files to check for up-to-date-status, defaulting to
54
54
  # webpack_generated_files in your configuration
55
+ # rubocop:disable Metrics/CyclomaticComplexity
55
56
  def self.ensure_assets_compiled(webpack_assets_status_checker: nil,
56
57
  webpack_assets_compiler: nil,
57
58
  source_path: nil,
@@ -96,4 +97,5 @@ module ReactOnRails
96
97
  ).call
97
98
  end
98
99
  end
100
+ # rubocop:enable Metrics/CyclomaticComplexity
99
101
  end
@@ -8,7 +8,7 @@ module ReactOnRails
8
8
  def compile_assets
9
9
  if ReactOnRails.configuration.build_test_command.blank?
10
10
  msg = <<~MSG
11
- You are using the React on Rails test helper.
11
+ You are using the React on Rails test helper.
12
12
  Either you used:
13
13
  ReactOnRails::TestHelper.configure_rspec_to_compile_assets or
14
14
  ReactOnRails::TestHelper.ensure_assets_compiled
@@ -34,7 +34,7 @@ module ReactOnRails
34
34
  end
35
35
 
36
36
  def self.object_to_boolean(value)
37
- [true, "true", "yes", 1, "1", "t"].include?(value.class == String ? value.downcase : value)
37
+ [true, "true", "yes", 1, "1", "t"].include?(value.instance_of?(String) ? value.downcase : value)
38
38
  end
39
39
 
40
40
  def self.server_rendering_is_enabled?
@@ -118,9 +118,11 @@ module ReactOnRails
118
118
  end
119
119
  end
120
120
 
121
+ # rubocop:disable Naming/VariableNumber
121
122
  def self.rails_version_less_than_4_1_1
122
123
  rails_version_less_than("4.1.1")
123
124
  end
125
+ # rubocop:enable Naming/VariableNumber
124
126
 
125
127
  module Required
126
128
  def required(arg_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "12.0.3"
4
+ VERSION = "12.0.4"
5
5
  end
@@ -20,8 +20,8 @@ unless ReactOnRails::WebpackerUtils.webpacker_webpack_production_config_exists?
20
20
  # VERSIONS is per the rails/webpacker clean method definition.
21
21
  # We set it very big so that it is not used, and then clean just
22
22
  # removes files older than 1 hour.
23
- VERSIONS = 100_000
24
- Rake::Task["webpacker:clean"].invoke(VERSIONS)
23
+ versions = 100_000
24
+ Rake::Task["webpacker:clean"].invoke(versions)
25
25
  }
26
26
 
27
27
  if Rake::Task.task_defined?("assets:precompile")
@@ -40,10 +40,10 @@ end
40
40
  namespace :react_on_rails do
41
41
  namespace :assets do
42
42
  desc <<-DESC.strip_heredoc
43
- Compile assets with webpack
44
- Uses command defined with ReactOnRails.configuration.build_production_command
45
- sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
46
- Note: This command is not automatically added to assets:precompile if the rails/webpacker
43
+ Compile assets with webpack
44
+ Uses command defined with ReactOnRails.configuration.build_production_command
45
+ sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
46
+ Note: This command is not automatically added to assets:precompile if the rails/webpacker
47
47
  configuration file config/webpack/production.js exists.
48
48
  DESC
49
49
  task webpack: :locale do
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "12.0.3",
3
+ "version": "12.0.4",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
@@ -6,11 +6,6 @@ namespace :docker do
6
6
  sh "docker-compose run lint rake lint:rubocop"
7
7
  end
8
8
 
9
- desc "Run ruby-lint linter from docker"
10
- task :ruby do
11
- sh "docker-compose run lint rake lint:ruby"
12
- end
13
-
14
9
  desc "Run scss-lint linter from docker"
15
10
  task :scss do
16
11
  sh "docker-compose run lint rake lint:scss"
@@ -7,13 +7,7 @@ namespace :lint do
7
7
 
8
8
  desc "Run Rubocop as shell"
9
9
  task :rubocop do
10
- sh_in_dir(gem_root, "bundle exec rubocop .")
11
- end
12
-
13
- desc "Run ruby-lint as shell"
14
- task :ruby do
15
- puts "See /ruby-lint.yml for what directories are included."
16
- sh_in_dir(gem_root, "bundle exec ruby-lint .")
10
+ sh_in_dir(gem_root, "bundle exec rubocop --version", "bundle exec rubocop .")
17
11
  end
18
12
 
19
13
  desc "Run scss-lint as shell"
@@ -23,10 +17,10 @@ namespace :lint do
23
17
 
24
18
  desc "Run eslint as shell"
25
19
  task :eslint do
26
- sh_in_dir(gem_root, "yarn run eslint")
20
+ sh_in_dir(gem_root, "yarn run eslint --version", "yarn run eslint .")
27
21
  end
28
22
 
29
- desc "Run all eslint & rubocop linters. Skip ruby-lint and scss"
23
+ desc "Run all eslint & rubocop linters. Skip scss"
30
24
  task lint: %i[eslint rubocop] do
31
25
  puts "Completed all linting"
32
26
  end
@@ -4,6 +4,13 @@ require_relative "task_helpers"
4
4
  require_relative File.join(gem_root, "lib", "react_on_rails", "version_syntax_converter")
5
5
  require_relative File.join(gem_root, "lib", "react_on_rails", "git_utils")
6
6
  require_relative File.join(gem_root, "lib", "react_on_rails", "utils")
7
+
8
+ class RaisingMessageHandler
9
+ def add_error(error)
10
+ raise error
11
+ end
12
+ end
13
+
7
14
  desc("Releases both the gem and node package using the given version.
8
15
 
9
16
  IMPORTANT: the gem version must be in valid rubygem format (no dashes).
@@ -19,19 +26,11 @@ which are installed via `bundle install` and `yarn`
19
26
  2nd argument: Perform a dry run by passing 'true' as a second argument.
20
27
 
21
28
  Example: `rake release[2.1.0,false]`")
22
-
23
- # rubocop:disable Metrics/BlockLength
24
29
  task :release, %i[gem_version dry_run tools_install] do |_t, args|
25
30
  include ReactOnRails::TaskHelpers
26
31
 
27
- class MessageHandler
28
- def add_error(error)
29
- raise error
30
- end
31
- end
32
-
33
32
  # Check if there are uncommited changes
34
- ReactOnRails::GitUtils.uncommitted_changes?(MessageHandler.new)
33
+ ReactOnRails::GitUtils.uncommitted_changes?(RaisingMessageHandler.new)
35
34
  args_hash = args.to_hash
36
35
 
37
36
  is_dry_run = ReactOnRails::Utils.object_to_boolean(args_hash[:dry_run])
@@ -69,4 +68,3 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|
69
68
  # Release the new gem version
70
69
  sh_in_dir(gem_root, "gem release") unless is_dry_run
71
70
  end
72
- # rubocop:enable Metrics/BlockLength
@@ -86,16 +86,15 @@ task run_rspec: ["run_rspec:run_rspec"]
86
86
  private
87
87
 
88
88
  def calc_path(dir)
89
- path = if dir.is_a?(String)
90
- if dir.start_with?(File::SEPARATOR)
91
- Pathname.new(dir)
92
- else
93
- Pathname.new(File.join(gem_root, dir))
94
- end
95
- else
96
- dir
97
- end
98
- path
89
+ if dir.is_a?(String)
90
+ if dir.start_with?(File::SEPARATOR)
91
+ Pathname.new(dir)
92
+ else
93
+ Pathname.new(File.join(gem_root, dir))
94
+ end
95
+ else
96
+ dir
97
+ end
99
98
  end
100
99
 
101
100
  # Runs rspec in the given directory.
@@ -17,9 +17,8 @@ module ReactOnRails
17
17
  end
18
18
 
19
19
  # Executes a string or an array of strings in a shell in the given directory
20
- def sh_in_dir(dir, shell_commands)
21
- shell_commands = [shell_commands] if shell_commands.is_a?(String)
22
- shell_commands.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
20
+ def sh_in_dir(dir, *shell_commands)
21
+ shell_commands.flatten.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
23
22
  end
24
23
 
25
24
  def bundle_install_in(dir)
@@ -32,27 +32,13 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency "rainbow", "~> 3.0"
33
33
  s.add_dependency "webpacker", ">= 4.0"
34
34
 
35
- s.add_development_dependency "awesome_print"
36
35
  s.add_development_dependency "bundler", "~> 2"
37
- s.add_development_dependency "coveralls"
38
36
  s.add_development_dependency "gem-release"
39
- s.add_development_dependency "generator_spec"
40
- s.add_development_dependency "listen"
41
- s.add_development_dependency "pry"
42
- s.add_development_dependency "pry-byebug"
43
- s.add_development_dependency "pry-doc"
44
- s.add_development_dependency "pry-rescue"
45
- s.add_development_dependency "pry-state"
46
- s.add_development_dependency "rails", "~> 5.2"
47
-
48
- s.add_development_dependency "rake", "~> 10.0"
49
- s.add_development_dependency "rspec"
50
- s.add_development_dependency "rubocop", "0.85.0"
51
-
52
37
  s.post_install_message = '
53
38
  --------------------------------------------------------------------------------
54
- Email contact@shakacode.com for access to our slack room and information about our "pro support plan"
55
- which supports better performance, via caching helpers and our node rendering server.
39
+ Checkout https://www.shakacode.com/react-on-rails-pro for information about
40
+ "React on Rails Pro" which includes one hour a month of support and a gem for
41
+ better performance, via caching helpers, and our node rendering server.
56
42
  --------------------------------------------------------------------------------
57
43
  '
58
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.3
4
+ version: 12.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-21 00:00:00.000000000 Z
11
+ date: 2020-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '4.0'
97
- - !ruby/object:Gem::Dependency
98
- name: awesome_print
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: bundler
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +108,6 @@ dependencies:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
110
  version: '2'
125
- - !ruby/object:Gem::Dependency
126
- name: coveralls
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: gem-release
141
113
  requirement: !ruby/object:Gem::Requirement
@@ -150,160 +122,6 @@ dependencies:
150
122
  - - ">="
151
123
  - !ruby/object:Gem::Version
152
124
  version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: generator_spec
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: listen
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: pry
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: pry-byebug
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
- - !ruby/object:Gem::Dependency
210
- name: pry-doc
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '0'
223
- - !ruby/object:Gem::Dependency
224
- name: pry-rescue
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
- - !ruby/object:Gem::Dependency
238
- name: pry-state
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - ">="
242
- - !ruby/object:Gem::Version
243
- version: '0'
244
- type: :development
245
- prerelease: false
246
- version_requirements: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - ">="
249
- - !ruby/object:Gem::Version
250
- version: '0'
251
- - !ruby/object:Gem::Dependency
252
- name: rails
253
- requirement: !ruby/object:Gem::Requirement
254
- requirements:
255
- - - "~>"
256
- - !ruby/object:Gem::Version
257
- version: '5.2'
258
- type: :development
259
- prerelease: false
260
- version_requirements: !ruby/object:Gem::Requirement
261
- requirements:
262
- - - "~>"
263
- - !ruby/object:Gem::Version
264
- version: '5.2'
265
- - !ruby/object:Gem::Dependency
266
- name: rake
267
- requirement: !ruby/object:Gem::Requirement
268
- requirements:
269
- - - "~>"
270
- - !ruby/object:Gem::Version
271
- version: '10.0'
272
- type: :development
273
- prerelease: false
274
- version_requirements: !ruby/object:Gem::Requirement
275
- requirements:
276
- - - "~>"
277
- - !ruby/object:Gem::Version
278
- version: '10.0'
279
- - !ruby/object:Gem::Dependency
280
- name: rspec
281
- requirement: !ruby/object:Gem::Requirement
282
- requirements:
283
- - - ">="
284
- - !ruby/object:Gem::Version
285
- version: '0'
286
- type: :development
287
- prerelease: false
288
- version_requirements: !ruby/object:Gem::Requirement
289
- requirements:
290
- - - ">="
291
- - !ruby/object:Gem::Version
292
- version: '0'
293
- - !ruby/object:Gem::Dependency
294
- name: rubocop
295
- requirement: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - '='
298
- - !ruby/object:Gem::Version
299
- version: 0.85.0
300
- type: :development
301
- prerelease: false
302
- version_requirements: !ruby/object:Gem::Requirement
303
- requirements:
304
- - - '='
305
- - !ruby/object:Gem::Version
306
- version: 0.85.0
307
125
  description: See README.md
308
126
  email:
309
127
  - justin@shakacode.com
@@ -335,6 +153,7 @@ files:
335
153
  - CONTRIBUTING.md
336
154
  - Dockerfile_tests
337
155
  - Gemfile
156
+ - Gemfile.development_dependencies
338
157
  - KUDOS.md
339
158
  - LICENSE.md
340
159
  - NEWS.md
@@ -368,7 +187,6 @@ files:
368
187
  - docs/additional-reading/turbolinks.md
369
188
  - docs/additional-reading/updating-dependencies.md
370
189
  - docs/additional-reading/upgrade-webpacker-v3-to-v4.md
371
- - docs/additional-reading/webpack-dev-server.md
372
190
  - docs/additional-reading/webpack-v1-notes.md
373
191
  - docs/additional-reading/webpack.md
374
192
  - docs/api/javascript-api.md
@@ -480,7 +298,6 @@ files:
480
298
  - rakelib/run_rspec.rake
481
299
  - rakelib/task_helpers.rb
482
300
  - react_on_rails.gemspec
483
- - ruby-lint.yml
484
301
  - script/bootstrap
485
302
  - script/release
486
303
  - script/setup
@@ -495,8 +312,9 @@ metadata: {}
495
312
  post_install_message: |2
496
313
 
497
314
  --------------------------------------------------------------------------------
498
- Email contact@shakacode.com for access to our slack room and information about our "pro support plan"
499
- which supports better performance, via caching helpers and our node rendering server.
315
+ Checkout https://www.shakacode.com/react-on-rails-pro for information about
316
+ "React on Rails Pro" which includes one hour a month of support and a gem for
317
+ better performance, via caching helpers, and our node rendering server.
500
318
  --------------------------------------------------------------------------------
501
319
  rdoc_options: []
502
320
  require_paths:
@@ -512,8 +330,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
512
330
  - !ruby/object:Gem::Version
513
331
  version: '0'
514
332
  requirements: []
515
- rubygems_version: 3.0.8
516
- signing_key:
333
+ rubygems_version: 3.1.4
334
+ signing_key:
517
335
  specification_version: 4
518
336
  summary: Rails with react server rendering with webpack.
519
337
  test_files: []
@@ -1,15 +0,0 @@
1
- ## Developing with the Webpack Dev Server
2
- One of the benefits of using webpack is access to [webpack's dev server](https://webpack.github.io/docs/webpack-dev-server.html) and its [hot module replacement](https://webpack.github.io/docs/hot-module-replacement-with-webpack.html) functionality.
3
-
4
- The webpack dev server with HMR will apply changes from the code (or styles!) to the browser as soon as you save whatever file you're working on. You won't need to reload the page, and your data will still be there. Start foreman as normal (it boots up the Rails server *and* the webpack HMR dev server at the same time).
5
-
6
- ```bash
7
- foreman start -f Procfile.dev
8
- ```
9
-
10
- Open your browser to [localhost:3000](http://localhost:3000). Whenever you make changes to your JavaScript code in the `client` folder, they will automatically show up in the browser. Hot module replacement is already enabled by default.
11
-
12
- Note that **React-related error messages are possibly more helpful when encountered in the dev server** than the Rails server as they do not include noise added by the React on Rails gem.
13
-
14
- ### Adding Additional Routes for the Dev Server
15
- As you add more routes to your front-end application, you will need to make the corresponding API for the dev server in `client/server.js`. See our example `server.js` from our [tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client%2Fserver-express.js).
@@ -1,25 +0,0 @@
1
- # Not currently using ruby-lint
2
- ---
3
- presenter: syntastic
4
-
5
- # Be sure to edit this per your project!
6
- directories:
7
- - app
8
- - lib
9
- - spec
10
-
11
- ignore_paths:
12
- - client
13
- - node_modules
14
- - coverage
15
- - examples
16
-
17
- analysis_classes:
18
- # - argument_amount
19
- - pedantics
20
- - shadowing_variables
21
- # Too many false positives for these
22
- # - undefined_methods
23
- # - undefined_variables
24
- # - unused_variables
25
- - useless_equality_checks