react_on_rails 12.0.0 → 12.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +0 -1
  3. data/.github/workflows/lint-js-and-ruby.yml +53 -0
  4. data/.github/workflows/main.yml +178 -0
  5. data/.github/workflows/package-js-tests.yml +35 -0
  6. data/.github/workflows/rspec-package-specs.yml +45 -0
  7. data/.rubocop.yml +18 -40
  8. data/.travis.yml +8 -4
  9. data/CHANGELOG.md +41 -20
  10. data/CONTRIBUTING.md +1 -1
  11. data/Gemfile +1 -33
  12. data/Gemfile.development_dependencies +54 -0
  13. data/NEWS.md +5 -0
  14. data/README.md +73 -65
  15. data/SUMMARY.md +1 -1
  16. data/docs/additional-reading/converting-from-custom-webpack-config-to-rails-webpacker-config.md +10 -0
  17. data/docs/additional-reading/react-router.md +1 -1
  18. data/docs/additional-reading/recommended-project-structure.md +69 -0
  19. data/docs/additional-reading/server-rendering-tips.md +4 -1
  20. data/docs/api/javascript-api.md +3 -3
  21. data/docs/api/redux-store-api.md +2 -2
  22. data/docs/api/view-helpers-api.md +4 -4
  23. data/docs/basics/client-vs-server-rendering.md +2 -0
  24. data/docs/basics/configuration.md +1 -1
  25. data/docs/basics/hmr-and-hot-reloading-with-the-webpack-dev-server.md +64 -9
  26. data/docs/basics/react-server-rendering.md +8 -5
  27. data/docs/basics/render-functions-and-railscontext.md +1 -1
  28. data/docs/basics/upgrading-react-on-rails.md +51 -14
  29. data/docs/basics/webpack-configuration.md +12 -18
  30. data/docs/misc/doctrine.md +0 -1
  31. data/docs/outdated/code-splitting.md +5 -5
  32. data/docs/tutorial.md +6 -0
  33. data/lib/generators/react_on_rails/base_generator.rb +8 -1
  34. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +4 -1
  35. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
  36. data/lib/react_on_rails/configuration.rb +2 -0
  37. data/lib/react_on_rails/git_utils.rb +3 -3
  38. data/lib/react_on_rails/helper.rb +15 -14
  39. data/lib/react_on_rails/locales/to_js.rb +0 -4
  40. data/lib/react_on_rails/locales/to_json.rb +0 -4
  41. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +6 -6
  42. data/lib/react_on_rails/test_helper.rb +2 -0
  43. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
  44. data/lib/react_on_rails/utils.rb +8 -2
  45. data/lib/react_on_rails/version.rb +1 -1
  46. data/lib/react_on_rails/webpacker_utils.rb +4 -4
  47. data/lib/tasks/assets.rake +21 -9
  48. data/package.json +1 -1
  49. data/rakelib/docker.rake +0 -5
  50. data/rakelib/examples.rake +1 -1
  51. data/rakelib/lint.rake +4 -10
  52. data/rakelib/release.rake +9 -13
  53. data/rakelib/run_rspec.rake +9 -10
  54. data/rakelib/task_helpers.rb +2 -3
  55. data/react_on_rails.gemspec +3 -17
  56. metadata +15 -192
  57. data/docs/additional-reading/webpack-dev-server.md +0 -15
  58. data/docs/basics/recommended-project-structure.md +0 -77
  59. data/ruby-lint.yml +0 -25
@@ -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.0
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-07-08 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
@@ -318,6 +136,10 @@ files:
318
136
  - ".eslintignore"
319
137
  - ".eslintrc"
320
138
  - ".github/FUNDING.yml"
139
+ - ".github/workflows/lint-js-and-ruby.yml"
140
+ - ".github/workflows/main.yml"
141
+ - ".github/workflows/package-js-tests.yml"
142
+ - ".github/workflows/rspec-package-specs.yml"
321
143
  - ".gitignore"
322
144
  - ".npmignore"
323
145
  - ".prettierignore"
@@ -331,6 +153,7 @@ files:
331
153
  - CONTRIBUTING.md
332
154
  - Dockerfile_tests
333
155
  - Gemfile
156
+ - Gemfile.development_dependencies
334
157
  - KUDOS.md
335
158
  - LICENSE.md
336
159
  - NEWS.md
@@ -346,6 +169,7 @@ files:
346
169
  - docs/additional-reading/asset-pipeline.md
347
170
  - docs/additional-reading/capistrano-deployment.md
348
171
  - docs/additional-reading/convert-rails-5-api-only-app.md
172
+ - docs/additional-reading/converting-from-custom-webpack-config-to-rails-webpacker-config.md
349
173
  - docs/additional-reading/credits.md
350
174
  - docs/additional-reading/elastic-beanstalk.md
351
175
  - docs/additional-reading/foreman-issues.md
@@ -356,13 +180,13 @@ files:
356
180
  - docs/additional-reading/react-and-redux.md
357
181
  - docs/additional-reading/react-helmet.md
358
182
  - docs/additional-reading/react-router.md
183
+ - docs/additional-reading/recommended-project-structure.md
359
184
  - docs/additional-reading/server-rendering-tips.md
360
185
  - docs/additional-reading/tips.md
361
186
  - docs/additional-reading/troubleshooting-when-using-webpacker.md
362
187
  - docs/additional-reading/turbolinks.md
363
188
  - docs/additional-reading/updating-dependencies.md
364
189
  - docs/additional-reading/upgrade-webpacker-v3-to-v4.md
365
- - docs/additional-reading/webpack-dev-server.md
366
190
  - docs/additional-reading/webpack-v1-notes.md
367
191
  - docs/additional-reading/webpack.md
368
192
  - docs/api/javascript-api.md
@@ -380,7 +204,6 @@ files:
380
204
  - docs/basics/migrating-from-react-rails.md
381
205
  - docs/basics/minitest-configuration.md
382
206
  - docs/basics/react-server-rendering.md
383
- - docs/basics/recommended-project-structure.md
384
207
  - docs/basics/render-functions-and-railscontext.md
385
208
  - docs/basics/rspec-configuration.md
386
209
  - docs/basics/upgrading-react-on-rails.md
@@ -475,7 +298,6 @@ files:
475
298
  - rakelib/run_rspec.rake
476
299
  - rakelib/task_helpers.rb
477
300
  - react_on_rails.gemspec
478
- - ruby-lint.yml
479
301
  - script/bootstrap
480
302
  - script/release
481
303
  - script/setup
@@ -490,8 +312,9 @@ metadata: {}
490
312
  post_install_message: |2
491
313
 
492
314
  --------------------------------------------------------------------------------
493
- Email contact@shakacode.com for access to our slack room and information about our "pro support plan"
494
- 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.
495
318
  --------------------------------------------------------------------------------
496
319
  rdoc_options: []
497
320
  require_paths:
@@ -507,8 +330,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
507
330
  - !ruby/object:Gem::Version
508
331
  version: '0'
509
332
  requirements: []
510
- rubygems_version: 3.0.8
511
- signing_key:
333
+ rubygems_version: 3.1.4
334
+ signing_key:
512
335
  specification_version: 4
513
336
  summary: Rails with react server rendering with webpack.
514
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,77 +0,0 @@
1
- # Recommended Project structure
2
-
3
- The React on Rails generator uses the standard `rails/webpacker` convention of this structure:
4
-
5
- ```yml
6
- app/javascript:
7
- ├── bundles:
8
- │ # Logical groups of files that can be used for code splitting
9
- │ └── hello-world-bundle.js
10
- ├── packs:
11
- │ # only webpack entry files here
12
- │ └── hello-world-bundle.js
13
- ```
14
-
15
- However, you may wish to move all your client side files to a single directory called something like `/client`.
16
-
17
- ## Steps to convert from the generator defaults to use a `/client` directory structure.
18
-
19
- 1. Move the directory:
20
-
21
- ```
22
- mv app/javascript client
23
- ```
24
-
25
- 2. Edit your `/config/webpacker.yml` file. Change the `default/source_path`:
26
-
27
- ```yml
28
- source_path: client
29
- ```
30
-
31
- ## Moving node_modules from `/` to `/client` with a custom webpack setup.
32
-
33
- `rails/webpacker` probably doesn't support having your main node_modules directory under `/client`, so only follow these steps if you want to use your own webpack configuration.
34
-
35
- 1. Move the `/package.json` to `/client/package.json`
36
- 2. Create a `/package.json` that delegates to `/client/package.json`. See the example in [spec/dummy/package.json](../../spec/dummy/package.json).
37
- 3. See the webpack configuration in [spec/dummy/client](../../spec/dummy/client) for a webpack configuration example.
38
-
39
-
40
- ## JavaScript Assets
41
- 1. `/client`: All client side JavaScript goes under the `/client` directory. Place all the major domains of the client side app under client.
42
- 1. `/client/app`: All application JavaScript. Note the adherence to the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript#naming-conventions) where we name the files to correspond to exported Objects (PascalCase) or exported functions (camelCase). We don't use dashes or snake_case for JavaScript files, except for possibly some config files.
43
- 1. `/client/app/bundles`: Top level of different app domains. Use a name within this directory for you app domains. For example, if you had a domain called `widget-editing`, then you would have: `/client/app/bundles/widget-editing`
44
- 1. `/client/app/lib`: Common code for bundles
45
- 1. Within each bundle directory (or the lib directory), such as a domain named "comments"
46
- `/client/app/bundles/comments`, use following directory structure, if you're using redux. However, with React hooks, this will probably be a bit different:
47
-
48
- * `/actions`: Redux actions.
49
- * `/components`: "dumb" components (no connections to Redux or Ajax). These get props and can render themselves and children.
50
- * `/constants`: Constants used by Redux actions and reducers.
51
- * `/containers`: "smart" components. These components are bound to Redux.
52
- * `/reducers`: Reducers for redux.
53
- * `/routes`: Routes for React Router.
54
- * `/store`: Store, which might be [configured differently for dev vs. production](https://github.com/reactjs/redux/tree/master/examples/real-world/store).
55
- * `/startup`: Component bindings to stores, with registration of components and stores.
56
- * `/schemas`: Schemas for AJAX JSON requests and responses, as used by the [Normalizr](https://github.com/gaearon/normalizr) package.
57
-
58
- ## CSS, Sass, Fonts, and Images
59
- Should you move your styling assets to Webpack? Or stick with the plain Rails asset pipeline. It depends! You have 2 basic choices:
60
-
61
- ### Simple Rails Way
62
- This isn't really any technique, as you keep handling all your styling assets using Rails standard tools, such as using the [sass-rails gem](https://rubygems.org/gems/sass-rails/versions/5.0.4). Basically, Webpack doesn't get involved with styling. Your Rails layouts just doing the styling the standard Rails way.
63
-
64
- #### Advantages
65
- 1. Much simpler! There's no changes really from your current processes.
66
-
67
- ### Using Webpack to Manage Styling Assets
68
- This technique involves customization of the webpack config files to generate CSS, image, and font assets.
69
-
70
- #### Directory structure
71
- 1. `/client/app/assets`: Assets for CSS for client app.
72
- 1. `/client/app/assets/fonts` and `/client/app/assets/styles`: Globally shared assets for styling. Note, most Sass and image assets will be stored next to the JavaScript files.
73
-
74
- #### Advantages
75
- 1. You can use [CSS modules](https://github.com/css-modules/css-modules), which is super compelling once you seen the benefits.
76
- 1. You can do hot reloading of your assets. Thus, you do not have to refresh your web page to see asset change, including changing styles.
77
- 1. You can run your client code on a mocked out express server for super fast prototyping. In other words, your client application can somewhat more easily be move to a different application server.
@@ -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