react_on_rails 14.0.2 → 14.0.4

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -14
  3. data/CONTRIBUTING.md +11 -1
  4. data/Gemfile.development_dependencies +3 -1
  5. data/Gemfile.lock +23 -18
  6. data/NEWS.md +2 -2
  7. data/SUMMARY.md +1 -1
  8. data/lib/generators/USAGE +1 -1
  9. data/lib/generators/react_on_rails/base_generator.rb +36 -21
  10. data/lib/generators/react_on_rails/generator_helper.rb +5 -0
  11. data/lib/generators/react_on_rails/generator_messages.rb +1 -8
  12. data/lib/generators/react_on_rails/install_generator.rb +3 -9
  13. data/lib/generators/react_on_rails/templates/base/base/{Procfile.dev-static → Procfile.dev-static.tt} +2 -2
  14. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +5 -0
  15. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +1 -1
  16. data/lib/generators/react_on_rails/templates/base/base/config/initializers/{react_on_rails.rb → react_on_rails.rb.tt} +2 -2
  17. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +1 -1
  18. data/lib/react_on_rails/configuration.rb +32 -42
  19. data/lib/react_on_rails/helper.rb +3 -3
  20. data/lib/react_on_rails/{webpacker_utils.rb → packer_utils.rb} +67 -42
  21. data/lib/react_on_rails/packs_generator.rb +4 -4
  22. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +2 -2
  23. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
  24. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +4 -4
  25. data/lib/react_on_rails/test_helper.rb +4 -4
  26. data/lib/react_on_rails/utils.rb +20 -14
  27. data/lib/react_on_rails/version.rb +1 -1
  28. data/lib/react_on_rails/version_checker.rb +1 -1
  29. data/lib/react_on_rails.rb +1 -1
  30. data/lib/tasks/assets.rake +1 -1
  31. metadata +7 -7
  32. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87289fa53128766e9295ad92d57015cafddfc9668324e62977d90ace31cbac83
4
- data.tar.gz: 7f1d8b3e048ff7e93d4b0506bc2421ae25d5b0961d24c1972c2ca78b26e87edf
3
+ metadata.gz: 990382215a33db46c9f5b8bdf0e5db38fba4e6233da6ff1a5f3840428ac9e092
4
+ data.tar.gz: 21e052cfea0a8121d8c6ebd4fd3f4688ced23ef7b0b40df653889f6388f95834
5
5
  SHA512:
6
- metadata.gz: c1832bb6fbfe649168ff1de8a8d1a1f86f93ba52cf59c90fb2a2d23d28776240327521efc2d674b8d566f10bf1fa52da4390cc2b008b7c42c00901eea2a6a9e0
7
- data.tar.gz: 8a7c5df6bcf809ee854e1b42b48219c46b4e0607e1f22f7a3f4a97cd30f5ef279a3a189d3055b118702d02bac4efc225693966b27a2d864932dd6065d0aadd3e
6
+ metadata.gz: 4c37af672c59bf60b452af1684a25fdc75caf8a48a115a84179816a16a9933120628b4e516dd593f60550d6ecd3df8a4ee8e5ba4a670c2bd5cc9d43dfeea870b
7
+ data.tar.gz: ddda7ad407c195b32d15fcbad434e34b9fa0e5003666ddded2953c369a0081f1f14a9fd3b03bf8ba5678b97ac09402a1fdfe123815a0c4a895caabeb518c548b
data/CHANGELOG.md CHANGED
@@ -18,10 +18,25 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
18
18
  ### [Unreleased]
19
19
  Changes since the last non-beta release.
20
20
 
21
+
22
+ #### Improved
23
+ - Improved dependency management by integrating package_json. [PR 1639](https://github.com/shakacode/react_on_rails/pull/1639) by [vaukalak](https://github.com/vaukalak).
24
+
25
+ #### Changed
26
+ - Update outdated GitHub Actions to use Node.js 20.0 versions instead [PR 1623](https://github.com/shakacode/react_on_rails/pull/1623) by [adriangohjw](https://github.com/adriangohjw).
27
+
28
+
29
+ ### [14.0.3] - 2024-06-28
30
+
31
+ #### Fixed
32
+ - Fixed css-loader installation with [PR 1634](https://github.com/shakacode/react_on_rails/pull/1634) by [vaukalak](https://github.com/vaukalak).
33
+ - Address a number of typos and grammar mistakes [PR 1631](https://github.com/shakacode/react_on_rails/pull/1631) by [G-Rath](https://github.com/G-Rath).
34
+ - Adds an adapter module & improves test suite to support all versions of Shakapacker. [PR 1622](https://github.com/shakacode/react_on_rails/pull/1622) by [adriangohjw](https://github.com/adriangohjw) and [judahmeek](https://github.com/judahmeek).
35
+
21
36
  ### [14.0.2] - 2024-06-11
22
37
 
23
38
  #### Fixed
24
- - Project initialization with Shakapacker v8+ fixed [PR 1629](https://github.com/shakacode/react_on_rails/pull/1629) by [vaukalak](https://github.com/vaukalak)
39
+ - Generator errors with Shakapacker v8+ fixed [PR 1629](https://github.com/shakacode/react_on_rails/pull/1629) by [vaukalak](https://github.com/vaukalak)
25
40
 
26
41
  ### [14.0.1] - 2024-05-16
27
42
 
@@ -174,7 +189,7 @@ which was only used in the workaround. [PR 1580](https://github.com/shakacode/re
174
189
 
175
190
  #### Changed
176
191
  - Changed logic of determining the usage of the default rails/webpacker webpack config or a custom command to only check if the config.build_production_command is defined. [PR 1402](https://github.com/shakacode/react_on_rails/pull/1402) by [justin808](https://github.com/justin808) and [gscarv13](https://github.com/gscarv13).
177
- - Minimimum required Ruby is 2.7 to match lastest rails/webpacker.
192
+ - Minimum required Ruby is 2.7 to match latest rails/webpacker.
178
193
 
179
194
  ### [12.4.0] - 2021-09-22
180
195
  #### Added
@@ -201,7 +216,7 @@ which was only used in the workaround. [PR 1580](https://github.com/shakacode/re
201
216
  - Added the ability to assign a module with a `call` method to `config.build_production_command`. See [the configuration docs](https://www.shakacode.com/react-on-rails/docs/guides/configuration). [PR 1362: Accept custom module for config.build_production_command](https://github.com/shakacode/react_on_rails/pull/1362).
202
217
 
203
218
  #### Fixed
204
- - Stop setting NODE_ENV value during precompile, as it interferred with rails/webpacker's setting of NODE_ENV to production by default. Fixes [#1334](https://github.com/shakacode/react_on_rails/issues/1334). [PR 1356: Don't set NODE_ENV in assets.rake](https://github.com/shakacode/react_on_rails/pull/1356) by [alexrozanski](https://github.com/alexrozanski).
219
+ - Stop setting NODE_ENV value during precompile, as it interfered with rails/webpacker's setting of NODE_ENV to production by default. Fixes [#1334](https://github.com/shakacode/react_on_rails/issues/1334). [PR 1356: Don't set NODE_ENV in assets.rake](https://github.com/shakacode/react_on_rails/pull/1356) by [alexrozanski](https://github.com/alexrozanski).
205
220
 
206
221
  ### [12.0.4] - 2020-11-14
207
222
  #### Fixed
@@ -221,7 +236,7 @@ which was only used in the workaround. [PR 1580](https://github.com/shakacode/re
221
236
 
222
237
  ### [12.0.1] - 2020-07-09
223
238
  #### Fixed
224
- - Changed invocation of webpacker:clean to use a very large number of versions so it does not acidentally delete the server-bundle.js. [PR 1306](https://github.com/shakacode/react_on_rails/pull/1306) by By [justin808](https://github.com/justin808).
239
+ - Changed invocation of webpacker:clean to use a very large number of versions so it does not accidentally delete the server-bundle.js. [PR 1306](https://github.com/shakacode/react_on_rails/pull/1306) by By [justin808](https://github.com/justin808).
225
240
 
226
241
  ### [12.0.0] - 2020-07-08
227
242
  For upgrade instructions, see [docs/guides/upgrading-react-on-rails.md](https://www.shakacode.com/react-on-rails/docs/guides/upgrading-react-on-rails).
@@ -380,7 +395,7 @@ Do not use. Unpublished. Caused by an issue with the release script.
380
395
 
381
396
  ### [11.0.7] - 2018-05-16
382
397
  #### Fixed
383
- - Fix npm publshing. [PR 1090](https://github.com/shakacode/react_on_rails/pull/1090) by [justin808](https://github.com/justin808).
398
+ - Fix npm publishing. [PR 1090](https://github.com/shakacode/react_on_rails/pull/1090) by [justin808](https://github.com/justin808).
384
399
 
385
400
  ### [11.0.6] - 2018-05-15
386
401
  #### Changed
@@ -756,7 +771,7 @@ No changes.
756
771
  - Don't assume ActionMailer is available. [#608](https://github.com/shakacode/react_on_rails/pull/608) by [tuzz](https://github.com/tuzz).
757
772
 
758
773
  ## [6.2.1] - 2016-11-19
759
- - Removed unnecesary passing of context in the HelloWorld Container example and basic generator. [#612](https://github.com/shakacode/react_on_rails/pull/612) by [justin808](https://github.com/justin808)
774
+ - Removed unnecessary passing of context in the HelloWorld Container example and basic generator. [#612](https://github.com/shakacode/react_on_rails/pull/612) by [justin808](https://github.com/justin808)
760
775
 
761
776
  - Turbolinks 5 bugfix to use `before-cache`, not `before-render`. [#611](https://github.com/shakacode/react_on_rails/pull/611) by [volkanunsal](https://github.com/volkanunsal).
762
777
 
@@ -782,12 +797,12 @@ No changes.
782
797
 
783
798
  ##### Fixed
784
799
  - React on Rails now correctly parses single-digit version strings from package.json [#491](https://github.com/shakacode/react_on_rails/pull/491) by [samphilipd ](https://github.com/samphilipd).
785
- - Fixed assets symlinking to correctly use filenames with spaces. Begining in [#510](https://github.com/shakacode/react_on_rails/pull/510), ending in [#513](https://github.com/shakacode/react_on_rails/pull/513) by [dzirtusss](https://github.com/dzirtusss).
800
+ - Fixed assets symlinking to correctly use filenames with spaces. Beginning in [#510](https://github.com/shakacode/react_on_rails/pull/510), ending in [#513](https://github.com/shakacode/react_on_rails/pull/513) by [dzirtusss](https://github.com/dzirtusss).
786
801
  - Check encoding of request's original URL and force it to UTF-8 [#527](https://github.com/shakacode/react_on_rails/pull/527) by [lucke84](https://github.com/lucke84)
787
802
 
788
803
  ## [6.0.5] - 2016-07-11
789
804
  ##### Added
790
- - Added better error messages to avoid issues with shared redux stores [#470](https://github.com/shakacode/react_on_rails/pull/470) by by [justin808](https://github.com/justin808).
805
+ - Added better error messages to avoid issues with shared redux stores [#470](https://github.com/shakacode/react_on_rails/pull/470) by [justin808](https://github.com/justin808).
791
806
 
792
807
  ## [6.0.4] - 2016-06-13
793
808
  ##### Fixed
@@ -799,7 +814,7 @@ No changes.
799
814
 
800
815
  ## [6.0.2] - 2016-06-06
801
816
  ##### Fixed
802
- - Fix colisions in ids of DOM nodes generated by `react_component` by indexing in using an UUID rather than an auto-increment value. This means that it should be overriden using the `id` parameter of `react_component` if one wants to generate a predictable id (_e.g._ for testing purpose). See [Issue #437](https://github.com/shakacode/react_on_rails/issues/437). Fixed in [#438](https://github.com/shakacode/react_on_rails/pull/438) by [Michael Baudino](https://github.com/michaelbaudino).
817
+ - Fix collisions in ids of DOM nodes generated by `react_component` by indexing in using a UUID rather than an auto-increment value. This means that it should be overridden using the `id` parameter of `react_component` if one wants to generate a predictable id (_e.g._ for testing purpose). See [Issue #437](https://github.com/shakacode/react_on_rails/issues/437). Fixed in [#438](https://github.com/shakacode/react_on_rails/pull/438) by [Michael Baudino](https://github.com/michaelbaudino).
803
818
 
804
819
  ## [6.0.1] - 2016-05-27
805
820
  ##### Fixed
@@ -807,16 +822,16 @@ No changes.
807
822
 
808
823
  ## [6.0.0] - 2016-05-25
809
824
  ##### Breaking Changes
810
- - Added automatic compilation of assets at precompile is now done by ReactOnRails. Thus, you don't need to provide your own assets.rake file that does the precompilation.
825
+ - Added automatic compilation of assets at precompile is now done by ReactOnRails. Thus, you don't need to provide your own `assets.rake` file that does the precompilation.
811
826
  [#398](https://github.com/shakacode/react_on_rails/pull/398) by [robwise](https://github.com/robwise), [jbhatab](https://github.com/jbhatab), and [justin808](https://github.com/justin808).
812
827
  - **Migration to v6**
813
828
  - Do not run the generator again if you've already run it.
814
829
 
815
830
  - See [shakacode/react-webpack-rails-tutorial/pull/287](https://github.com/shakacode/react-webpack-rails-tutorial/pull/287) for an example of upgrading from v5.
816
831
 
817
- - To configure the asset compliation you can either
832
+ - To configure the asset compilation you can either
818
833
  1. Specify a `config/react_on_rails` setting for `build_production_command` to be nil to turn this feature off.
819
- 2. Specify the script command you want to run to build your production assets, and remove your assets.rake file.
834
+ 2. Specify the script command you want to run to build your production assets, and remove your `assets.rake` file.
820
835
 
821
836
  - If you are using the ReactOnRails test helper, then you will need to add the 'config.npm_build_test_command' to your config to tell react_on_rails what command to run when you run rspec.
822
837
 
@@ -903,7 +918,7 @@ All 5.1.0 changes can be found in [#362](https://github.com/shakacode/react_on_r
903
918
  ## [4.0.3] - 2016-03-17
904
919
 
905
920
  ##### Fixed
906
- - `ReactOnRailsHelper#react_component`: Invalid deprecation message when called with only one paramter, the component name.
921
+ - `ReactOnRailsHelper#react_component`: Invalid deprecation message when called with only one parameter, the component name.
907
922
 
908
923
  ## [4.0.2] - 2016-03-17
909
924
 
@@ -1133,7 +1148,8 @@ Best done with Object destructing:
1133
1148
  ##### Fixed
1134
1149
  - Fix several generator-related issues.
1135
1150
 
1136
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.2...master
1151
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.3...master
1152
+ [14.0.3]: https://github.com/shakacode/react_on_rails/compare/14.0.2...14.0.3
1137
1153
  [14.0.2]: https://github.com/shakacode/react_on_rails/compare/14.0.1...14.0.2
1138
1154
  [14.0.1]: https://github.com/shakacode/react_on_rails/compare/14.0.0...14.0.1
1139
1155
  [14.0.0]: https://github.com/shakacode/react_on_rails/compare/13.4.0...14.0.0
data/CONTRIBUTING.md CHANGED
@@ -137,12 +137,22 @@ spec/dummy.
137
137
 
138
138
 
139
139
  ```sh
140
- # Optionally change default selenium_firefox driver
140
+ # Optionally change default capybara driver
141
141
  export DRIVER=selenium_firefox
142
142
  cd react_on_rails/
143
143
  yarn run dummy:spec
144
144
  ```
145
145
 
146
+ To convert the development environment over to Shakapacker v6 instead of the default Shakapacker v8:
147
+
148
+ ```sh
149
+ # Optionally change default capybara driver
150
+ export DRIVER=selenium_firefox
151
+ cd react_on_rails/
152
+ script/convert
153
+ yarn run dummy:spec
154
+ ```
155
+
146
156
  ### Run NPM JS tests
147
157
 
148
158
  ```sh
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- gem "shakapacker", "7.2.1"
3
+ gem "shakapacker", "8.0.0"
4
4
  gem "bootsnap", require: false
5
5
  gem "rails", "~> 7.1"
6
6
 
@@ -23,7 +23,9 @@ gem "sprockets", "~> 4.0"
23
23
  gem "amazing_print"
24
24
 
25
25
  group :development, :test do
26
+ gem "package_json"
26
27
  gem "listen"
28
+ gem "debug"
27
29
  gem "pry"
28
30
  gem "pry-byebug"
29
31
  gem "pry-doc"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (14.0.0)
4
+ react_on_rails (14.0.3)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
@@ -93,7 +93,7 @@ GEM
93
93
  bigdecimal (3.1.8)
94
94
  bootsnap (1.18.3)
95
95
  msgpack (~> 1.2)
96
- builder (3.2.4)
96
+ builder (3.3.0)
97
97
  byebug (11.1.3)
98
98
  capybara (3.40.0)
99
99
  addressable
@@ -109,7 +109,7 @@ GEM
109
109
  launchy
110
110
  childprocess (5.0.0)
111
111
  coderay (1.1.3)
112
- concurrent-ruby (1.2.3)
112
+ concurrent-ruby (1.3.3)
113
113
  connection_pool (2.4.1)
114
114
  coveralls (0.8.23)
115
115
  json (>= 1.8, < 3)
@@ -119,12 +119,15 @@ GEM
119
119
  tins (~> 1.6)
120
120
  crass (1.0.6)
121
121
  date (3.3.4)
122
+ debug (1.9.2)
123
+ irb (~> 1.10)
124
+ reline (>= 0.3.8)
122
125
  diff-lcs (1.5.1)
123
126
  docile (1.4.0)
124
127
  drb (2.2.1)
125
128
  equivalent-xml (0.6.0)
126
129
  nokogiri (>= 1.4.3)
127
- erubi (1.12.0)
130
+ erubi (1.13.0)
128
131
  execjs (2.9.1)
129
132
  ffi (1.16.3)
130
133
  gem-release (2.2.2)
@@ -137,7 +140,7 @@ GEM
137
140
  concurrent-ruby (~> 1.0)
138
141
  interception (0.5)
139
142
  io-console (0.7.2)
140
- irb (1.13.1)
143
+ irb (1.13.2)
141
144
  rdoc (>= 4.0.0)
142
145
  reline (>= 0.4.2)
143
146
  jbuilder (2.12.0)
@@ -167,8 +170,8 @@ GEM
167
170
  matrix (0.4.2)
168
171
  method_source (1.1.0)
169
172
  mini_mime (1.1.5)
170
- mini_portile2 (2.8.6)
171
- minitest (5.23.0)
173
+ mini_portile2 (2.8.7)
174
+ minitest (5.24.1)
172
175
  msgpack (1.7.2)
173
176
  mutex_m (0.2.0)
174
177
  net-imap (0.4.11)
@@ -181,7 +184,7 @@ GEM
181
184
  net-smtp (0.5.0)
182
185
  net-protocol
183
186
  nio4r (2.7.3)
184
- nokogiri (1.16.5)
187
+ nokogiri (1.16.6)
185
188
  mini_portile2 (~> 2.8.2)
186
189
  racc (~> 1.4)
187
190
  package_json (0.1.0)
@@ -208,8 +211,8 @@ GEM
208
211
  public_suffix (5.0.5)
209
212
  puma (6.4.2)
210
213
  nio4r (~> 2.0)
211
- racc (1.7.3)
212
- rack (3.0.11)
214
+ racc (1.8.0)
215
+ rack (3.1.4)
213
216
  rack-proxy (0.7.7)
214
217
  rack
215
218
  rack-session (2.0.0)
@@ -253,22 +256,22 @@ GEM
253
256
  rb-fsevent (0.11.2)
254
257
  rb-inotify (0.10.1)
255
258
  ffi (~> 1.0)
256
- rdoc (6.6.3.1)
259
+ rdoc (6.7.0)
257
260
  psych (>= 4.0.0)
258
261
  regexp_parser (2.9.2)
259
- reline (0.5.7)
262
+ reline (0.5.9)
260
263
  io-console (~> 0.5)
261
264
  rexml (3.2.7)
262
265
  strscan (>= 3.0.9)
263
266
  rspec-core (3.13.0)
264
267
  rspec-support (~> 3.13.0)
265
- rspec-expectations (3.13.0)
268
+ rspec-expectations (3.13.1)
266
269
  diff-lcs (>= 1.2.0, < 2.0)
267
270
  rspec-support (~> 3.13.0)
268
271
  rspec-mocks (3.13.1)
269
272
  diff-lcs (>= 1.2.0, < 2.0)
270
273
  rspec-support (~> 3.13.0)
271
- rspec-rails (6.1.2)
274
+ rspec-rails (6.1.3)
272
275
  actionpack (>= 6.1)
273
276
  activesupport (>= 6.1)
274
277
  railties (>= 6.1)
@@ -334,7 +337,7 @@ GEM
334
337
  rubyzip (>= 1.2.2, < 3.0)
335
338
  websocket (~> 1.0)
336
339
  semantic_range (3.0.0)
337
- shakapacker (7.2.1)
340
+ shakapacker (8.0.0)
338
341
  activesupport (>= 5.2)
339
342
  package_json
340
343
  rack-proxy (>= 0.6.1)
@@ -355,7 +358,7 @@ GEM
355
358
  sprockets (>= 3.0.0)
356
359
  sqlite3 (1.7.3)
357
360
  mini_portile2 (~> 2.8.0)
358
- stringio (3.1.0)
361
+ stringio (3.1.1)
359
362
  strscan (3.1.0)
360
363
  sync (0.5.0)
361
364
  term-ansicolor (1.8.0)
@@ -386,7 +389,7 @@ GEM
386
389
  xpath (3.2.0)
387
390
  nokogiri (~> 1.8)
388
391
  yard (0.9.36)
389
- zeitwerk (2.6.14)
392
+ zeitwerk (2.6.16)
390
393
 
391
394
  PLATFORMS
392
395
  ruby
@@ -397,6 +400,7 @@ DEPENDENCIES
397
400
  capybara
398
401
  capybara-screenshot
399
402
  coveralls
403
+ debug
400
404
  equivalent-xml
401
405
  gem-release
402
406
  generator_spec
@@ -404,6 +408,7 @@ DEPENDENCIES
404
408
  jquery-rails
405
409
  launchy
406
410
  listen
411
+ package_json
407
412
  pry
408
413
  pry-byebug
409
414
  pry-doc
@@ -422,7 +427,7 @@ DEPENDENCIES
422
427
  scss_lint
423
428
  sdoc
424
429
  selenium-webdriver (= 4.9.0)
425
- shakapacker (= 7.2.1)
430
+ shakapacker (= 8.0.0)
426
431
  spring (~> 4.0)
427
432
  sprockets (~> 4.0)
428
433
  sqlite3 (~> 1.6)
data/NEWS.md CHANGED
@@ -28,11 +28,11 @@ that supports SSR.
28
28
  * 2016-12-20: New Video on Egghead.io: [Creating a component with React on Rails](https://egghead.io/lessons/react-creating-a-component-with-react-on-rails)
29
29
  * 2016-11-03: Spoke at [LA Ruby, 7pm, Thursday, November 10 in Venice, CA: "React on Rails: Why, What, and How?"](http://www.meetup.com/laruby/events/234825187/). [Video and pictures in this article](https://blog.shakacode.com/my-react-on-rails-talk-at-the-la-ruby-rails-meetup-november-10-2016-eaaa83aff800#.ej6h4eglp).
30
30
  * 2016-08-27: We now have a [Documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/) for improved readability & reference.
31
- * 2016-08-21: v6.1 ships with serveral new features and bug fixes. See the [Changelog](CHANGELOG.md).
31
+ * 2016-08-21: v6.1 ships with several new features and bug fixes. See the [Changelog](CHANGELOG.md).
32
32
  * 2016-07-28: If you're doing server rendering, be sure to use mini\_racer! See [issues/428](https://github.com/shakacode/react_on_rails/issues/428). It's supposedly much faster than `therubyracer`.
33
33
 
34
34
  * 2016-08-27: We now have a [Documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/) for improved readability & reference.
35
- * 2016-08-21: v6.1 ships with serveral new features and bug fixes. See the [Changelog](CHANGELOG.md).
35
+ * 2016-08-21: v6.1 ships with several new features and bug fixes. See the [Changelog](CHANGELOG.md).
36
36
  * 2016-06-13: 6.0.4 shipped with a critical fix regarding a missing polyfill for `clearTimeout`, used by babel-polyfill.
37
37
  * 2016-06-06: 6.0.2 shipped with a critical fix if you are fragment caching the server generated React.
38
38
  * 2016-05-24: 6.0.0 Released! Simplified generator and install process! See the [CHANGELOG.md](./CHANGELOG.md) for details.
data/SUMMARY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Table of Contents
2
2
 
3
- Doccumentation for React on Rails has moved!
3
+ Documentation for React on Rails has moved!
4
4
 
5
5
  Here is the new link:
6
6
 
data/lib/generators/USAGE CHANGED
@@ -21,4 +21,4 @@ Then you may run
21
21
 
22
22
  More Details:
23
23
 
24
- `https://github.com/shakacode/react_on_rails/blob/master/docs/basics/generator-details.md`
24
+ `https://github.com/shakacode/react_on_rails/blob/master/docs/additional-details/generator-details.md`
@@ -3,7 +3,6 @@
3
3
  require "rails/generators"
4
4
  require_relative "generator_messages"
5
5
  require_relative "generator_helper"
6
-
7
6
  module ReactOnRails
8
7
  module Generators
9
8
  class BaseGenerator < Rails::Generators::Base
@@ -30,17 +29,21 @@ module ReactOnRails
30
29
  def copy_base_files
31
30
  base_path = "base/base/"
32
31
  base_files = %w[app/controllers/hello_world_controller.rb
33
- app/views/layouts/hello_world.html.erb
34
- config/initializers/react_on_rails.rb
35
- Procfile.dev
36
- Procfile.dev-static]
32
+ app/views/layouts/hello_world.html.erb]
33
+ base_templates = %w[config/initializers/react_on_rails.rb
34
+ Procfile.dev
35
+ Procfile.dev-static]
37
36
  base_files.each { |file| copy_file("#{base_path}#{file}", file) }
37
+ base_templates.each do |file|
38
+ template("#{base_path}/#{file}.tt", file, { packer_type: ReactOnRails::PackerUtils.packer_type })
39
+ end
38
40
  end
39
41
 
40
42
  def copy_js_bundle_files
41
43
  base_path = "base/base/"
42
44
  base_files = %w[app/javascript/packs/server-bundle.js
43
- app/javascript/bundles/HelloWorld/components/HelloWorldServer.js]
45
+ app/javascript/bundles/HelloWorld/components/HelloWorldServer.js
46
+ app/javascript/bundles/HelloWorld/components/HelloWorld.module.css]
44
47
  base_files.each { |file| copy_file("#{base_path}#{file}", file) }
45
48
  end
46
49
 
@@ -59,42 +62,54 @@ module ReactOnRails
59
62
  config = {
60
63
  message: "// The source code including full typescript support is available at:"
61
64
  }
62
- base_files.each do |file|
63
- template("#{base_path}/#{file}.tt", file, config)
64
- end
65
+ base_files.each { |file| template("#{base_path}/#{file}.tt", file, config) }
65
66
  end
66
67
 
67
- def copy_shakapacker_config
68
- puts "Adding Shakapacker v7 config file"
68
+ def copy_packer_config
69
+ puts "Adding Shakapacker #{ReactOnRails::PackerUtils.shakapacker_version} config"
69
70
  base_path = "base/base/"
70
- base_files = %w[config/shakapacker.yml]
71
- base_files.each { |file| copy_file("#{base_path}#{file}", file) }
71
+ config = "config/shakapacker.yml"
72
+ copy_file("#{base_path}#{config}", config)
72
73
  end
73
74
 
74
75
  def add_base_gems_to_gemfile
75
76
  run "bundle"
76
77
  end
77
78
 
78
- def add_yarn_dependencies
79
+ def add_js_dependencies
79
80
  major_minor_patch_only = /\A\d+\.\d+\.\d+\z/
80
81
  if ReactOnRails::VERSION.match?(major_minor_patch_only)
81
- run "yarn add react-on-rails@#{ReactOnRails::VERSION} --exact"
82
+ package_json.manager.add(["react-on-rails@#{ReactOnRails::VERSION}"])
82
83
  else
83
84
  # otherwise add latest
84
- puts "Adding the lastest react-on-rails NPM module. Double check this is correct in package.json"
85
- run "yarn add react-on-rails --exact"
85
+ puts "Adding the latest react-on-rails NPM module. Double check this is correct in package.json"
86
+ package_json.manager.add(["react-on-rails"])
86
87
  end
87
88
 
88
89
  puts "Adding React dependencies"
89
- run "yarn add react react-dom @babel/preset-react prop-types babel-plugin-transform-react-remove-prop-types \
90
- babel-plugin-macros"
90
+ package_json.manager.add([
91
+ "react",
92
+ "react-dom",
93
+ "@babel/preset-react",
94
+ "prop-types",
95
+ "babel-plugin-transform-react-remove-prop-types",
96
+ "babel-plugin-macros"
97
+ ])
91
98
 
92
99
  puts "Adding CSS handlers"
93
100
 
94
- run "yarn add css-loader css-minimizer-webpack-plugin mini-css-extract-plugin style-loader@"
101
+ package_json.manager.add(%w[
102
+ css-loader
103
+ css-minimizer-webpack-plugin
104
+ mini-css-extract-plugin
105
+ style-loader
106
+ ])
95
107
 
96
108
  puts "Adding dev dependencies"
97
- run "yarn add -D @pmmmwh/react-refresh-webpack-plugin react-refresh"
109
+ package_json.manager.add([
110
+ "@pmmmwh/react-refresh-webpack-plugin",
111
+ "react-refresh"
112
+ ], type: :dev)
98
113
  end
99
114
 
100
115
  def append_to_spec_rails_helper
@@ -1,8 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "package_json"
3
4
  require "rainbow"
4
5
 
5
6
  module GeneratorHelper
7
+ def package_json
8
+ @package_json ||= PackageJson.read
9
+ end
10
+
6
11
  # Takes a relative path from the destination root, such as `.gitignore` or `app/assets/javascripts/application.js`
7
12
  def dest_file_exists?(file)
8
13
  dest_file = File.join(destination_root, file)
@@ -65,16 +65,9 @@ module GeneratorMessages
65
65
 
66
66
  Alternative steps to run the app:
67
67
 
68
- - Run `rails s` to start the Rails server.
69
-
70
- - Run bin/shakapacker-dev-server to start the Webpack dev server for compilation of Webpack
71
- assets as soon as you save. This default setup with the dev server does not work
72
- for server rendering
68
+ - We recommend using Procfile.dev with foreman, overmind, or a similar program. Alternately, you can run each of the processes listed in Procfile.dev in a separate tab in your terminal.
73
69
 
74
70
  - Visit http://localhost:3000/hello_world and see your React On Rails app running!
75
-
76
- - To turn on HMR, edit config/shakapacker.yml and set HMR to true. Restart the rails server
77
- and bin/shakapacker-dev-server. Or use Procfile.dev.
78
71
  MSG
79
72
  end
80
73
  end
@@ -88,19 +88,13 @@ module ReactOnRails
88
88
  Dir.chdir("#{__dir__}/bin") do
89
89
  files_to_copy.concat(Dir.glob("*"))
90
90
  end
91
- files_to_become_excutable = files_to_copy.map { |filename| "bin/#{filename}" }
91
+ files_to_become_executable = files_to_copy.map { |filename| "bin/#{filename}" }
92
92
 
93
- File.chmod(0o755, *files_to_become_excutable)
93
+ File.chmod(0o755, *files_to_become_executable)
94
94
  end
95
95
 
96
96
  def add_post_install_message
97
- message = GeneratorMessages.helpful_message_after_installation
98
- unless using_shakapacker_7_or_above?
99
- message = message.gsub("config/shakapacker", "config/webpacker")
100
- message = message.gsub("bin/shakapacker", "bin/webpacker")
101
- end
102
-
103
- GeneratorMessages.add_info(message)
97
+ GeneratorMessages.add_info(GeneratorMessages.helpful_message_after_installation)
104
98
  end
105
99
 
106
100
  def using_shakapacker_7_or_above?
@@ -5,5 +5,5 @@ web: rails s -p 3000
5
5
  # When making frequent changes to client side assets, you will prefer building webpack assets
6
6
  # upon saving rather than when you refresh your browser page.
7
7
  # Note, if using React on Rails localization you will need to run
8
- # `bundle exec rake react_on_rails:locale` before you run bin/shakapacker
9
- webpack: sh -c 'rm -rf public/packs/* || true && bin/shakapacker -w'
8
+ # `bundle exec rake react_on_rails:locale` before you run bin/<%= config[:packer_type] %>
9
+ webpack: sh -c 'rm -rf public/packs/* || true && bin/<%= config[:packer_type] %> -w'
@@ -0,0 +1,5 @@
1
+ # Procfile for development using HMR
2
+ # You can run these commands in separate shells
3
+ rails: bundle exec rails s -p 3000
4
+ wp-client: bin/<%= config[:packer_type] %>-dev-server
5
+ wp-server: SERVER_BUNDLE_ONLY=yes bin/<%= config[:packer_type] %> --watch
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useState } from 'react';
3
- import style from './HelloWorld.module.css';
3
+ import * as style from './HelloWorld.module.css';
4
4
 
5
5
  const HelloWorld = (props) => {
6
6
  const [name, setName] = useState(props.name);
@@ -24,8 +24,8 @@ ReactOnRails.configure do |config|
24
24
  # to automatically refresh your webpack assets on every test run.
25
25
  #
26
26
  # Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`
27
- # and set the config/shakapacker.yml option for test to true.
28
- config.build_test_command = "RAILS_ENV=test bin/shakapacker"
27
+ # and set the config/<%= config[:packer_type] %>.yml option for test to true.
28
+ config.build_test_command = "RAILS_ENV=test bin/<%= config[:packer_type] %>"
29
29
 
30
30
  ################################################################################
31
31
  ################################################################################
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
- import style from './HelloWorld.module.css';
3
+ import * as style from './HelloWorld.module.css';
4
4
 
5
5
  const HelloWorld = ({ name, updateName }) => (
6
6
  <div>