react_on_rails 12.0.4 → 12.0.5.beta.0
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 +4 -4
- data/.circleci/config.yml +1 -1
- data/.github/workflows/lint-js-and-ruby.yml +3 -3
- data/.github/workflows/main.yml +6 -6
- data/.github/workflows/package-js-tests.yml +2 -2
- data/.github/workflows/rspec-package-specs.yml +2 -2
- data/.rubocop.yml +1 -7
- data/Gemfile.development_dependencies +3 -7
- data/README.md +14 -14
- data/docs/basics/installation-into-an-existing-rails-app.md +11 -4
- data/docs/tutorial.md +13 -21
- data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
- data/lib/react_on_rails/helper.rb +3 -3
- data/lib/react_on_rails/locales/base.rb +3 -3
- data/lib/react_on_rails/prerender_error.rb +1 -1
- data/lib/react_on_rails/version.rb +1 -1
- data/package.json +1 -1
- data/rakelib/release.rake +1 -1
- data/rakelib/run_rspec.rake +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c3761565aa14795caa2b5c486de9016269ff3d39230c11c0d7bd582a507daa4
|
4
|
+
data.tar.gz: 21ef8af0d15a75a828852ca179e0b6a9e7ba930036db6ecde58de0e09b5637e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c2c6a6cd0c2e584cfda8bb0ed3be9ad42c5ae14b196d436c3e99813a61df2278ba10940bfaad1968ea868daeb14b844f04ff440bd6424e3ae9bd3cdaf8119ee
|
7
|
+
data.tar.gz: 0bcfac754d871893719d1604d6e42022c55048e608e6e345d0b9ce5948af3a16a5af8e18d36c4b7232dcd064f931905476981553582203f92d1df4bc189f3be2
|
data/.circleci/config.yml
CHANGED
@@ -6,8 +6,8 @@ jobs:
|
|
6
6
|
build:
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
|
-
ruby: [2.
|
10
|
-
node: [
|
9
|
+
ruby: [2.7]
|
10
|
+
node: [14]
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
steps:
|
13
13
|
- uses: actions/checkout@v2
|
@@ -16,7 +16,7 @@ jobs:
|
|
16
16
|
with:
|
17
17
|
ruby-version: ${{ matrix.ruby }}
|
18
18
|
- name: Setup Node
|
19
|
-
uses: actions/setup-node@
|
19
|
+
uses: actions/setup-node@v2-beta
|
20
20
|
with:
|
21
21
|
node-version: ${{ matrix.node }}
|
22
22
|
- name: Print system information
|
data/.github/workflows/main.yml
CHANGED
@@ -6,8 +6,8 @@ jobs:
|
|
6
6
|
build-dummy-app-webpack-test-bundles:
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
|
-
ruby: [2.
|
10
|
-
node: [
|
9
|
+
ruby: [2.7]
|
10
|
+
node: [14]
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
steps:
|
13
13
|
- uses: actions/checkout@v2
|
@@ -16,7 +16,7 @@ jobs:
|
|
16
16
|
with:
|
17
17
|
ruby-version: ${{ matrix.ruby }}
|
18
18
|
- name: Setup Node
|
19
|
-
uses: actions/setup-node@
|
19
|
+
uses: actions/setup-node@v2-beta
|
20
20
|
with:
|
21
21
|
node-version: ${{ matrix.node }}
|
22
22
|
- name: Print system information
|
@@ -70,8 +70,8 @@ jobs:
|
|
70
70
|
needs: build-dummy-app-webpack-test-bundles
|
71
71
|
strategy:
|
72
72
|
matrix:
|
73
|
-
ruby: [2.
|
74
|
-
node: [
|
73
|
+
ruby: [2.7]
|
74
|
+
node: [14]
|
75
75
|
rake_task: ['run_rspec:all_dummy', 'run_rspec:all_but_examples', 'run_rspec:examples']
|
76
76
|
runs-on: ubuntu-latest
|
77
77
|
steps:
|
@@ -81,7 +81,7 @@ jobs:
|
|
81
81
|
with:
|
82
82
|
ruby-version: ${{ matrix.ruby }}
|
83
83
|
- name: Setup Node
|
84
|
-
uses: actions/setup-node@
|
84
|
+
uses: actions/setup-node@v2-beta
|
85
85
|
with:
|
86
86
|
node-version: ${{ matrix.node }}
|
87
87
|
- name: Print system information
|
@@ -6,12 +6,12 @@ jobs:
|
|
6
6
|
build:
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
|
-
node: [12]
|
9
|
+
node: [12, 14]
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
steps:
|
12
12
|
- uses: actions/checkout@v2
|
13
13
|
- name: Setup Node
|
14
|
-
uses: actions/setup-node@
|
14
|
+
uses: actions/setup-node@v2-beta
|
15
15
|
with:
|
16
16
|
node-version: ${{ matrix.node }}
|
17
17
|
- name: Print system information
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# This is the configuration used to check the rubocop source code.
|
2
2
|
# Check out: https://github.com/bbatsov/rubocop
|
3
|
+
require: rubocop-performance
|
3
4
|
|
4
5
|
AllCops:
|
5
6
|
NewCops: enable
|
@@ -18,16 +19,10 @@ AllCops:
|
|
18
19
|
- <%= path.sub(/^!! /, '') %>
|
19
20
|
<% end %>
|
20
21
|
- '**/*.js'
|
21
|
-
- '**/log/**/*'
|
22
22
|
- '**/node_modules/**/*'
|
23
23
|
- '**/public/**/*'
|
24
24
|
- '**/tmp/**/*'
|
25
|
-
- '.git/**/*'
|
26
|
-
- 'bin/**/*'
|
27
25
|
- 'coverage/**/*'
|
28
|
-
- 'db/**/*'
|
29
|
-
- 'db/schema.rb'
|
30
|
-
- 'db/seeds.rb'
|
31
26
|
- 'gen-examples/examples/**/*'
|
32
27
|
- 'node_modules/**/*'
|
33
28
|
- 'spec/dummy/bin/*'
|
@@ -39,7 +34,6 @@ AllCops:
|
|
39
34
|
Naming/FileName:
|
40
35
|
Exclude:
|
41
36
|
- 'Gemfile'
|
42
|
-
- 'spec/dummy/Gemfile'
|
43
37
|
|
44
38
|
Layout/LineLength:
|
45
39
|
Max: 120
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# We'll revert this before the final merge.
|
5
|
-
# gem "webpacker", git: 'https://github.com/rails/webpacker.git'
|
6
3
|
gem "webpacker"
|
7
4
|
gem "bootsnap", ">= 1.1.0", require: false
|
8
5
|
gem "rails"
|
@@ -22,9 +19,7 @@ gem "sdoc", group: :doc
|
|
22
19
|
|
23
20
|
gem "sprockets"
|
24
21
|
|
25
|
-
|
26
|
-
# gem 'capistrano-rails', group: :development
|
27
|
-
gem "awesome_print"
|
22
|
+
gem "amazing_print"
|
28
23
|
gem "mini_racer"
|
29
24
|
|
30
25
|
group :development, :test do
|
@@ -34,7 +29,8 @@ group :development, :test do
|
|
34
29
|
gem "pry-doc"
|
35
30
|
gem "pry-rails"
|
36
31
|
gem "pry-rescue"
|
37
|
-
gem "rubocop",
|
32
|
+
gem "rubocop", require: false
|
33
|
+
gem "rubocop-performance", require: false
|
38
34
|
gem "scss_lint", require: false
|
39
35
|
gem "spring"
|
40
36
|
end
|
data/README.md
CHANGED
@@ -94,35 +94,35 @@ Ruby on Rails >=5 and rails/webpacker 4.2+.
|
|
94
94
|
Note, the best way to understand how to use ReactOnRails is to study a few simple examples. You can do a quick demo setup, either on your existing app or on a new Rails app.
|
95
95
|
|
96
96
|
1. Do the quick [tutorial](docs/tutorial.md).
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
1. Add React on Rails to an existing Rails app per [the instructions](docs/basics/installation-into-an-existing-rails-app.md).
|
98
|
+
1. Look at [spec/dummy](spec/dummy), a simple, no DB example. This has an example of using `rails/webpacker` to configure server-side rendering.
|
99
|
+
1. 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`.
|
100
|
+
1. Look at [github.com/shakacode/react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial); it's a full-featured example live at [www.reactrails.com](http://www.reactrails.com).
|
100
101
|
|
101
102
|
## Basic Installation
|
102
103
|
|
103
104
|
*See also [the instructions for installing into an existing Rails app](docs/basics/installation-into-an-existing-rails-app.md).*
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
4. Commit this to git (or else you cannot run the generator unless you pass the option `--ignore-warnings`).
|
106
|
+
1. Add the `rails/webpacker` gem if you don't yet have it.
|
107
|
+
|
108
|
+
1. Add the `react_on_rails` gem to Gemfile. _Use the latest version for react_on_rails._
|
109
|
+
```bash
|
110
|
+
bundle add react_on_rails --version=12.0.4 --strict
|
111
|
+
```
|
112
112
|
|
113
|
-
|
113
|
+
1. Commit this to git (or else you cannot run the generator unless you pass the option `--ignore-warnings`).
|
114
114
|
|
115
|
+
1. Run the generator:
|
115
116
|
```bash
|
116
117
|
rails generate react_on_rails:install
|
117
118
|
```
|
118
119
|
|
119
|
-
|
120
|
-
|
120
|
+
1. Start the app:
|
121
121
|
```bash
|
122
122
|
rails s
|
123
123
|
```
|
124
124
|
|
125
|
-
|
125
|
+
1. Visit http://localhost:3000/hello_world.
|
126
126
|
|
127
127
|
|
128
128
|
### Turning on server rendering
|
@@ -4,19 +4,26 @@
|
|
4
4
|
|
5
5
|
**If you have rails-5 API only project**, first [convert the rails-5 API only app to rails app](#convert-rails-5-api-only-app-to-rails-app) before [getting started](#getting-started-with-an-existing-rails-app).
|
6
6
|
|
7
|
-
1. Add the following to your Gemfile and `bundle install`. We recommend fixing the version of React on Rails, as you will need to keep the exact version in sync with the version in your `
|
7
|
+
1. Add the following to your Gemfile and `bundle install`. We recommend fixing the version of React on Rails, as you will need to keep the exact version in sync with the version in your `package.json` file.
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
gem "react_on_rails", "12.0.0" # Update to the current version
|
11
11
|
gem "webpacker", "~> 5"
|
12
12
|
```
|
13
13
|
|
14
|
-
|
14
|
+
1. Add the webpacker and react_on_rails gems
|
15
|
+
_Use the latest version for react_on_rails._
|
15
16
|
|
17
|
+
```
|
18
|
+
bundle add webpacker
|
19
|
+
bundle add react_on_rails --version=12.0.4 --strict
|
20
|
+
```
|
21
|
+
|
22
|
+
2. Run the following 2 commands to install Webpacker with React. Note, if you are using an older version of Rails than 5.1, you'll need to install webpacker with React per the instructions [here](https://github.com/rails/webpacker).
|
16
23
|
|
17
24
|
```bash
|
18
|
-
|
19
|
-
|
25
|
+
bundle exec rails webpacker:install
|
26
|
+
bundle exec rails webpacker:install:react
|
20
27
|
```
|
21
28
|
|
22
29
|
3. Commit this to git (or else you cannot run the generator unless you pass the option `--ignore-warnings`).
|
data/docs/tutorial.md
CHANGED
@@ -59,11 +59,21 @@ cd test-react-on-rails
|
|
59
59
|
bundle
|
60
60
|
```
|
61
61
|
|
62
|
-
## Add the webpacker
|
62
|
+
## Add the webpacker and react_on_rails gems
|
63
|
+
To avoid issues regarding inconsistent gem and npm versions, you should specify the exact versions
|
64
|
+
of both the gem and npm package. In other words, don't use the `^` or `~` in the version specifications.
|
65
|
+
_Use the latest version for react_on_rails._
|
63
66
|
|
64
67
|
```
|
68
|
+
gem 'react_on_rails', '12.0.4' # prefer exact gem version to match npm version
|
69
|
+
```
|
70
|
+
|
71
|
+
Note: The latest released React On Rails version is considered stable. Please use the latest
|
72
|
+
version to ensure you get all the security patches and the best support.
|
73
|
+
|
74
|
+
```bash
|
65
75
|
bundle add webpacker
|
66
|
-
bundle add react_on_rails
|
76
|
+
bundle add react_on_rails --version=12.0.4 --strict
|
67
77
|
```
|
68
78
|
|
69
79
|
## Run the webpacker generator
|
@@ -82,25 +92,7 @@ git add -A
|
|
82
92
|
git commit -m "Initial commit"
|
83
93
|
```
|
84
94
|
|
85
|
-
##
|
86
|
-
|
87
|
-
To avoid issues regarding inconsistent gem and npm versions, you should specify the exact versions
|
88
|
-
of both the gem and npm package. In other words, don't use the `^` or `~` in the version specifications.
|
89
|
-
|
90
|
-
```
|
91
|
-
gem 'react_on_rails', '12.0.0' # prefer exact gem version to match npm version
|
92
|
-
```
|
93
|
-
|
94
|
-
Note: The latest released React On Rails version is considered stable. Please use the latest
|
95
|
-
version to ensure you get all the security patches and the best support.
|
96
|
-
|
97
|
-
Run `bundle` and commit the changes.
|
98
|
-
|
99
|
-
```
|
100
|
-
bundle
|
101
|
-
|
102
|
-
git commit -am "Added React on Rails Gem"
|
103
|
-
```
|
95
|
+
## Run the React on Rails Generator
|
104
96
|
|
105
97
|
Install React on Rails: `rails generate react_on_rails:install`. You need to first git commit your files before running the generator, or else it will generate an error.
|
106
98
|
|
@@ -170,7 +170,7 @@ module ReactOnRails
|
|
170
170
|
def redux_store_hydration_data
|
171
171
|
return if @registered_stores_defer_render.blank?
|
172
172
|
|
173
|
-
@registered_stores_defer_render.reduce(""
|
173
|
+
@registered_stores_defer_render.reduce(+"") do |accum, redux_store_data|
|
174
174
|
accum << render_redux_store_data(redux_store_data)
|
175
175
|
end.html_safe
|
176
176
|
end
|
@@ -487,13 +487,13 @@ module ReactOnRails
|
|
487
487
|
end
|
488
488
|
|
489
489
|
def initialize_redux_stores
|
490
|
-
result =
|
490
|
+
result = +<<-JS
|
491
491
|
ReactOnRails.clearHydratedStores();
|
492
492
|
JS
|
493
493
|
|
494
494
|
return result unless @registered_stores.present? || @registered_stores_defer_render.present?
|
495
495
|
|
496
|
-
declarations = "var reduxProps, store, storeGenerator;\n"
|
496
|
+
declarations = +"var reduxProps, store, storeGenerator;\n"
|
497
497
|
all_stores = (@registered_stores || []) + (@registered_stores_defer_render || [])
|
498
498
|
|
499
499
|
result << all_stores.each_with_object(declarations) do |redux_store_data, memo|
|
@@ -32,12 +32,12 @@ module ReactOnRails
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def exist_files
|
35
|
-
@exist_files ||= files.select
|
35
|
+
@exist_files ||= files.select { |file| File.exist?(file) }
|
36
36
|
end
|
37
37
|
|
38
38
|
def files_are_outdated
|
39
|
-
latest_yml = locale_files.map
|
40
|
-
earliest = exist_files.map
|
39
|
+
latest_yml = locale_files.map { |file| File.mtime(file) }.max
|
40
|
+
earliest = exist_files.map { |file| File.mtime(file) }.min
|
41
41
|
latest_yml > earliest
|
42
42
|
end
|
43
43
|
|
@@ -46,7 +46,7 @@ module ReactOnRails
|
|
46
46
|
private
|
47
47
|
|
48
48
|
def calc_message(component_name, console_messages, err, js_code, props)
|
49
|
-
message = "ERROR in SERVER PRERENDERING\n"
|
49
|
+
message = +"ERROR in SERVER PRERENDERING\n"
|
50
50
|
if err
|
51
51
|
message << <<~MSG
|
52
52
|
Encountered error: \"#{err}\"
|
data/package.json
CHANGED
data/rakelib/release.rake
CHANGED
@@ -59,7 +59,7 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|
|
|
59
59
|
sh_in_dir(gem_root, "git add .")
|
60
60
|
|
61
61
|
# Will bump the yarn version, commit, tag the commit, push to repo, and release on yarn
|
62
|
-
release_it_command = "$(yarn bin)/release-it"
|
62
|
+
release_it_command = +"$(yarn bin)/release-it"
|
63
63
|
release_it_command << " #{npm_version}" unless npm_version.strip.empty?
|
64
64
|
release_it_command << " --non-interactive --npm.publish"
|
65
65
|
release_it_command << " --dry-run --verbose" if is_dry_run
|
data/rakelib/run_rspec.rake
CHANGED
@@ -106,7 +106,7 @@ def run_tests_in(dir, options = {})
|
|
106
106
|
|
107
107
|
command_name = options.fetch(:command_name, path.basename)
|
108
108
|
rspec_args = options.fetch(:rspec_args, "")
|
109
|
-
env_vars = "#{options.fetch(:env_vars, '')} TEST_ENV_COMMAND_NAME=\"#{command_name}\""
|
109
|
+
env_vars = +"#{options.fetch(:env_vars, '')} TEST_ENV_COMMAND_NAME=\"#{command_name}\""
|
110
110
|
env_vars << "COVERAGE=true" if ENV["USE_COVERALLS"]
|
111
111
|
sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
|
112
112
|
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.
|
4
|
+
version: 12.0.5.beta.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Gordon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -326,9 +326,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
326
326
|
version: 2.5.0
|
327
327
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
328
328
|
requirements:
|
329
|
-
- - "
|
329
|
+
- - ">"
|
330
330
|
- !ruby/object:Gem::Version
|
331
|
-
version:
|
331
|
+
version: 1.3.1
|
332
332
|
requirements: []
|
333
333
|
rubygems_version: 3.1.4
|
334
334
|
signing_key:
|