react_on_rails 11.1.7 → 12.0.0.pre.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +320 -0
  3. data/.eslintignore +2 -1
  4. data/.eslintrc +30 -2
  5. data/.github/FUNDING.yml +1 -0
  6. data/.gitignore +3 -1
  7. data/.prettierignore +10 -0
  8. data/.prettierrc +23 -0
  9. data/.release-it.json +3 -0
  10. data/.rubocop.yml +37 -11
  11. data/.travis.yml +10 -20
  12. data/CHANGELOG.md +86 -3
  13. data/CONTRIBUTING.md +61 -80
  14. data/Gemfile +3 -5
  15. data/{COMM-LICENSE → REACT-ON-RAILS-PRO-LICENSE} +6 -9
  16. data/README.md +117 -68
  17. data/Rakefile +0 -7
  18. data/SUMMARY.md +12 -12
  19. data/book.json +5 -5
  20. data/docs/additional-reading/asset-pipeline.md +8 -16
  21. data/docs/additional-reading/images.md +1 -1
  22. data/docs/additional-reading/rails_view_rendering_from_inline_javascript.md +2 -1
  23. data/docs/additional-reading/react-helmet.md +30 -10
  24. data/docs/additional-reading/react-router.md +52 -75
  25. data/docs/additional-reading/server-rendering-tips.md +12 -7
  26. data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +10 -0
  27. data/docs/api/javascript-api.md +3 -3
  28. data/docs/api/redux-store-api.md +4 -2
  29. data/docs/api/view-helpers-api.md +17 -14
  30. data/docs/basics/configuration.md +64 -61
  31. data/docs/basics/deployment.md +1 -2
  32. data/docs/basics/generator-details.md +1 -1
  33. data/docs/basics/i18n.md +44 -22
  34. data/docs/basics/installation-into-an-existing-rails-app.md +2 -2
  35. data/docs/basics/minitest-configuration.md +31 -0
  36. data/docs/basics/react-server-rendering.md +3 -1
  37. data/docs/basics/recommended-project-structure.md +24 -1
  38. data/docs/basics/{generator-functions-and-railscontext.md → render-functions-and-railscontext.md} +59 -21
  39. data/docs/basics/rspec-configuration.md +2 -2
  40. data/docs/basics/upgrading-react-on-rails.md +61 -3
  41. data/docs/basics/webpack-configuration.md +26 -1
  42. data/docs/contributor-info/errors-with-hooks.md +45 -0
  43. data/docs/contributor-info/pull-requests.md +44 -0
  44. data/docs/misc/doctrine.md +1 -1
  45. data/docs/{misc-pending → outdated}/code-splitting.md +13 -9
  46. data/docs/{additional-reading → outdated}/heroku-deployment.md +0 -6
  47. data/docs/{basics → outdated}/how-react-on-rails-works.md +2 -2
  48. data/docs/{misc-pending → outdated}/manual-installation-overview.md +5 -5
  49. data/docs/{additional-reading → outdated}/rails-assets-relative-paths.md +3 -3
  50. data/docs/{misc-pending → outdated}/rails-assets.md +4 -7
  51. data/docs/{misc → outdated}/rails3.md +0 -0
  52. data/docs/testimonials/hvmn.md +25 -0
  53. data/docs/testimonials/resortpass.md +13 -0
  54. data/docs/testimonials/testimonials.md +28 -0
  55. data/docs/tutorial.md +157 -25
  56. data/jest.config.js +4 -0
  57. data/lib/generators/react_on_rails/dev_tests_generator.rb +2 -1
  58. data/lib/generators/react_on_rails/generator_helper.rb +4 -6
  59. data/lib/generators/react_on_rails/install_generator.rb +2 -0
  60. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +9 -8
  61. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +4 -8
  62. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/store/helloWorldStore.js +1 -3
  63. data/lib/react_on_rails.rb +4 -1
  64. data/lib/react_on_rails/configuration.rb +15 -23
  65. data/lib/react_on_rails/error.rb +2 -0
  66. data/lib/react_on_rails/git_utils.rb +2 -0
  67. data/lib/react_on_rails/helper.rb +110 -159
  68. data/lib/react_on_rails/json_output.rb +1 -1
  69. data/lib/react_on_rails/json_parse_error.rb +2 -0
  70. data/lib/react_on_rails/locales/base.rb +142 -0
  71. data/lib/react_on_rails/locales/to_js.rb +37 -0
  72. data/lib/react_on_rails/locales/to_json.rb +27 -0
  73. data/lib/react_on_rails/prerender_error.rb +11 -15
  74. data/lib/react_on_rails/react_component/render_options.rb +4 -0
  75. data/lib/react_on_rails/server_rendering_js_code.rb +42 -0
  76. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +85 -60
  77. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +7 -8
  78. data/lib/react_on_rails/utils.rb +19 -20
  79. data/lib/react_on_rails/version.rb +1 -1
  80. data/lib/react_on_rails/version_checker.rb +5 -1
  81. data/lib/react_on_rails/webpacker_utils.rb +21 -2
  82. data/lib/tasks/assets.rake +5 -45
  83. data/lib/tasks/locale.rake +8 -2
  84. data/package-scripts.yml +49 -0
  85. data/package.json +41 -31
  86. data/rakelib/dummy_apps.rake +1 -9
  87. data/rakelib/example_type.rb +3 -1
  88. data/rakelib/examples.rake +3 -0
  89. data/rakelib/lint.rake +2 -7
  90. data/rakelib/node_package.rake +2 -2
  91. data/rakelib/release.rake +3 -2
  92. data/rakelib/run_rspec.rake +5 -18
  93. data/react_on_rails.gemspec +3 -5
  94. data/tsconfig.json +14 -0
  95. data/webpackConfigLoader.js +5 -4
  96. data/yarn.lock +7042 -2327
  97. metadata +40 -57
  98. data/Gemfile.rails32 +0 -74
  99. data/docs/additional-reading/babel.md +0 -5
  100. data/docs/additional-reading/hot-reloading-rails-development.md +0 -57
  101. data/docs/api/ruby-api-hot-reload-view-helpers.md +0 -44
  102. data/docs/testimonials.md +0 -11
  103. data/lib/react_on_rails/assets_precompile.rb +0 -150
  104. data/lib/react_on_rails/locales_to_js.rb +0 -136
@@ -0,0 +1,3 @@
1
+ {
2
+ "requireCleanWorkingDir": false
3
+ }
@@ -3,7 +3,7 @@
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 2.2
6
+ TargetRubyVersion: 2.5
7
7
 
8
8
  Include:
9
9
  - '**/Rakefile'
@@ -27,12 +27,8 @@ AllCops:
27
27
  - 'spec/react_on_rails/dummy-for-generators/**/*'
28
28
  - 'spec/dummy/Procfile.*'
29
29
  - 'spec/dummy/bin/**/*'
30
- - 'spec/dummy/client/node_modules/**/*'
31
- - 'spec/dummy/client/node_modules/**/.*'
32
- - 'spec/dummy_no_webpacker/Procfile.*'
33
- - 'spec/dummy_no_webpacker/bin/**/*'
34
- - 'spec/dummy_no_webpacker/client/node_modules/**/*'
35
- - 'spec/dummy_no_webpacker/client/node_modules/**/.*'
30
+ - 'spec/dummy/node_modules/**/*'
31
+ - 'spec/dummy/node_modules/**/.*'
36
32
  - 'gen-examples/examples/**/.*'
37
33
  - 'gen-examples/examples/**/*'
38
34
 
@@ -40,13 +36,12 @@ Naming/FileName:
40
36
  Exclude:
41
37
  - 'Gemfile'
42
38
  - 'spec/dummy/Gemfile'
43
- - 'spec/dummy_no_webpacker/Gemfile'
44
39
 
45
40
  # Turn off until we require 2.3 ruby
46
41
  Style/SafeNavigation:
47
42
  Enabled: false
48
43
 
49
- Metrics/LineLength:
44
+ Layout/LineLength:
50
45
  Max: 120
51
46
 
52
47
  Style/StringLiterals:
@@ -55,11 +50,20 @@ Style/StringLiterals:
55
50
  Style/Documentation:
56
51
  Enabled: false
57
52
 
53
+ Style/HashEachMethods:
54
+ Enabled: true
55
+
56
+ Style/HashTransformKeys:
57
+ Enabled: true
58
+
59
+ Style/HashTransformValues:
60
+ Enabled: true
61
+
58
62
  Lint/AssignmentInCondition:
59
63
  Exclude:
60
64
  - 'spec/dummy/bin/spring'
61
65
 
62
- Lint/HandleExceptions:
66
+ Lint/SuppressedException:
63
67
  Exclude:
64
68
  - 'spec/dummy/bin/rails'
65
69
  - 'spec/dummy/bin/rake'
@@ -86,9 +90,31 @@ Metrics/MethodLength:
86
90
  Metrics/ModuleLength:
87
91
  Max: 180
88
92
 
93
+ Naming/RescuedExceptionsVariableName:
94
+ Enabled: false
95
+
89
96
  Style/GlobalVars:
90
97
  Exclude:
91
98
  - 'spec/dummy/config/environments/development.rb'
92
99
 
93
100
  Style/FrozenStringLiteralComment:
94
- EnforcedStyle: when_needed
101
+ EnforcedStyle: always
102
+
103
+ Layout/EmptyLinesAroundAttributeAccessor:
104
+ Enabled: true
105
+
106
+ Layout/SpaceAroundMethodCallOperator:
107
+ Enabled: true
108
+
109
+ Lint/RaiseException:
110
+ Enabled: true
111
+
112
+ Lint/StructNewOverride:
113
+ Enabled: true
114
+
115
+ Style/ExponentialNotation:
116
+ Enabled: true
117
+
118
+ Style/SlicingWithRange:
119
+ Enabled: true
120
+
@@ -3,11 +3,10 @@ sudo: required
3
3
  language: ruby
4
4
 
5
5
  rvm:
6
- # Rails 5 requires 2.2
7
- - 2.3.1
8
- - 2.4.1
9
- - 2.5.0
10
- - 2.2.6
6
+ - 2.5.3
7
+ - 2.6.5
8
+ - 2.7.0
9
+
11
10
  services:
12
11
  - docker
13
12
 
@@ -19,7 +18,6 @@ cache:
19
18
 
20
19
  gemfile:
21
20
  - spec/dummy/Gemfile
22
- - spec/dummy_no_webpacker/Gemfile.rails32
23
21
 
24
22
  env:
25
23
  global:
@@ -36,13 +34,16 @@ before_install:
36
34
  - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen scn 1600x1200x16"
37
35
 
38
36
  install:
39
- - travis_retry gem install bundler
40
- - travis_retry nvm install 8.11.3
37
+ - travis_retry gem install bundler -v '>2'
38
+ - travis_retry nvm install 13.9.0
41
39
  - node -v
42
40
  - travis_retry npm i -g yarn
43
41
  - travis_retry bundle install
42
+ - travis_retry yarn global add yalc
43
+ - travis_retry yalc publish
44
+ - travis_retry cd spec/dummy && yalc add react-on-rails
44
45
  - travis_retry yarn
45
- - travis_retry yarn run build
46
+ - travis_retry cd ../.. && yarn run build
46
47
  - bundle exec rake prepare_for_ci
47
48
 
48
49
  before_script:
@@ -51,17 +52,6 @@ before_script:
51
52
  script:
52
53
  - bundle exec rake
53
54
 
54
- matrix:
55
- exclude:
56
- - gemfile: spec/dummy_no_webpacker/Gemfile.rails32
57
- rvm: 2.3.1
58
- - gemfile: spec/dummy_no_webpacker/Gemfile.rails32
59
- rvm: 2.4.1
60
- - gemfile: spec/dummy_no_webpacker/Gemfile.rails32
61
- rvm: 2.5.0
62
- - gemfile: spec/dummy/Gemfile
63
- rvm: 2.2.6
64
-
65
55
  notifications:
66
56
  slack:
67
57
  secure: LfcUk4AJ4vAxWwRIyw4tFh8QNbYefMwfG/oLfsN3CdRMWMOtCOHR1GGsRhAOlfVVJ/FvHqVqWj5gK7z7CaO5Uvl7rD3/zJ8QzExKx/iH9yWj55iIPuKLzwFNnBwRpFW/cqyU2lFPPRxGD50BUn3c+qybkuSqtKZ6qtTowwqlxLa5iyM3N95aZp7MEIKCP7cPcnHfLbJyP8wBpotp/rtw62eXM2HIRJJwgjcp+n+My7VFR9DnBXNFf6R91aZHM4U4cHHDbu15HFtH8honVrzK1JQdyqMNHga+j04dFuaS7z9Q369/hsELMOBp/227+Pz7ZRfWZFK4UASguOvyeX7RmGTRpTuWLm1XJeUzfsPZVROecaSVQBve+U7F12yKqilt97QlvRXn2EGyBILqvxtFNNR4S9kgAf72/6EFgiM1TKq7i9zy6lVOnagU2+7amq7UeopX1uoFsUfNKMR7YbgV1WjF0IK95UP0b0/7ZOJlPYgi5zzkQi129qAFWSMmxGk+ZpsttHh/tjJtvAh0A3mHq/zb5w4ub/MbSyZqeDUNgGj72QArOWUFSAStQT1ybsVLeDoKPgOvVq7OV1D64rpcHjBXcqOCit8tDZ+TqkFhcYJo2cITSaqE4zJXn+4F5s7So5O8CyfKYQq+kFJCooYGmfgTUckJpGl7eIvKmL4TN9Q=
@@ -1,7 +1,7 @@
1
1
  # Change Log
2
2
  All notable changes to this project's source code will be documented in this file. Items under `Unreleased` is upcoming features that will be out in next version. NOTE: major versions of the npm module and the gem must be kept in sync.
3
3
 
4
- Migration instructions for the major updates can be found [here](docs/basics/upgrading-react-on-rails.md#upgrading-to-version-9.md). Some smaller migration information can be found here.
4
+ Migration instructions for the major updates can be found [here](docs/basics/upgrading-react-on-rails.md#upgrading-to-version-9.md). Some smaller migration information can be found here.
5
5
 
6
6
  ## Need Help Migrating?
7
7
  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).
@@ -16,6 +16,85 @@ Changes since last non-beta release.
16
16
 
17
17
  *Please add entries here for your pull requests that are not yet released.*
18
18
 
19
+ ## UPCOMING 12.0 RELEASE
20
+ ### [12.0.0]
21
+ #### BREAKING CHANGE
22
+ In order to solve the issues regarding React Hooks compatibility, the number of parameters
23
+ for functions is used to determine if you have a generator function that will get invoked to
24
+ return a React component, or you are registering a functional React component. Alternately, you can
25
+ set JavaScript property `renderFunction` on the function for which you want to return to be
26
+ invoked to return the React component. In that case, you won't need to pass any unused params.
27
+ [PR 1268](https://github.com/shakacode/react_on_rails/pull/1268) by [justin808](https://github.com/justin808)
28
+
29
+ See [docs/basics/upgrading-react-on-rails](./docs/basics/upgrading-react-on-rails#upgrading-to-v12)
30
+ for details.
31
+
32
+ * Requires the use of rails/webpacker helpers
33
+ * Removed **env_javascript_include_tag** and **env_stylesheet_link_tag** as these are replaced by view helpers
34
+ from rails/webpacker
35
+ * Removal of support for old Rubies and Rails.
36
+ * Removal of config.symlink_non_digested_assets_regex as it's no longer needed with rails/webpacker.
37
+ If any business needs this, we can move the code to a separate gem.
38
+ * Added configuration option `same_bundle_for_client_and_server` with default `false` because
39
+
40
+ 1. Production applications would typically have a server bundle that differs from the client bundle
41
+ 2. This change only affects trying to use HMR with react_on_rails with rails/webpacker.
42
+
43
+ The previous behavior was to always go to the webpack-dev-server for the server bundle if the
44
+ webpack-dev-server was running _and_ the server bundle was found in the `manifest.json`.
45
+
46
+ If you are using the **same bundle for client and server rendering**, then set this configuration option
47
+ to `true`. By [justin808](https://github.com/shakacode/react_on_rails/pull/1240).
48
+
49
+ * Added support to export locales in JSON format. New option added `i18n_output_format` which allows to
50
+ specify locales format either `JSON` or `JS`. **`JSON` format is now the default.**
51
+
52
+ Use this config setting to get the old behavior: config.i18n_output_format = 'js'
53
+
54
+ [PR 1271](https://github.com/shakacode/react_on_rails/pull/1271) by [ashgaliyev](https://github.com/ashgaliyev).
55
+
56
+ #### Improved
57
+ - Added Typescript definitions to the Node package. By [justin808](https://github.com/justin808) and [judahmeek](https://github.com/judahmeek) in [PR 1287](https://github.com/shakacode/react_on_rails/pull/1287).
58
+ - Removed unnecessary restriction to keep the server bundle in the same directory with the client bundles. Rails/webpacker 4 has an advanced cleanup that will remove any files in the directory of other webpack files. Removing this restriction allows the server bundle to be created in a sibling directory. By [justin808](https://github.com/shakacode/react_on_rails/pull/1240).
59
+
60
+ ### [11.3.0] - 2019-05-24
61
+ #### Added
62
+ - Added method for retrieving any option from `render_options` [PR 1213](https://github.com/shakacode/react_on_rails/pull/1213)
63
+ by [ashgaliyev](https://github.com/ashgaliyev).
64
+
65
+ - html_options has an option for 'tag' to set the html tag name like this: `html_options: { tag: "span" }`.
66
+ [PR 1208](https://github.com/shakacode/react_on_rails/pull/1208) by [tahsin352](https://github.com/tahsin352).
67
+
68
+ ### [11.2.2] - 2018-12-24
69
+ #### Improved
70
+ - rails_context can more easily be called from controller methods. The mandatory param of server_side has been made optional.
71
+
72
+ ### [11.2.1] - 2018-12-06
73
+ ## MIGRATION for v11.2
74
+ - If using **React on Rails Pro**, upgrade react_on_rails_pro to a version >= 1.3.
75
+
76
+ #### Improved
77
+ - To support React v16, updated API for manually calling `ReactOnRails.render(name, props, domNodeId, hydrate)`. Added 3rd @param hydrate Pass truthy to update server rendered html. Default is falsey Any truthy values calls hydrate rather than render. [PR 1159](https://github.com/shakacode/react_on_rails/pull/1159) by [justin808](https://github.com/justin808) and [coopersamuel](https://github.com/coopersamuel).
78
+
79
+ - Enabled the use of webpack-dev-server with Server-side rendering. [PR 1173](https://github.com/shakacode/react_on_rails/pull/1173) by [justin808](https://github.com/justin808) and [judahmeek](https://github.com/judahmeek).
80
+
81
+ #### Changed
82
+ - Changed the default for:
83
+ ```rb
84
+ config.raise_on_prerender_error = Rails.env.development?
85
+ ```
86
+
87
+ Thus, developers will need to fix server rendering errors before continuing.
88
+ [PR 1145](https://github.com/shakacode/react_on_rails/pull/1145) by [justin808](https://github.com/justin808).
89
+
90
+ ### 11.2.0 - 2018-12-06
91
+ Do not use. Unpublished. Caused by an issue with the release script.
92
+
93
+ ### [11.1.8] - 2018-10-14
94
+
95
+ #### Improved
96
+ - Improved tutorial and support for HMR when using `rails/webpacker` for Webpack configuration. [PR 1156](https://github.com/shakacode/react_on_rails/pull/1156) by [justin808](https://github.com/justin808).
97
+
19
98
  ### [11.1.7] - 2018-10-10
20
99
  #### Fixed
21
100
  - Fixed bug where intl parsing would fail when trying to parse integers or blank entries. by [sepehr500](https://github.com/sepehr500)
@@ -45,7 +124,7 @@ Changes since last non-beta release.
45
124
 
46
125
  #### Fixed
47
126
  - Tests now properly exit if the config.build_test_command fails!
48
- - Source path for project using Webpacker would default to "app/javascript" even if when the node_modules
127
+ - Source path for project using Webpacker would default to "app/javascript" even if when the node_modules
49
128
  directory was set to "client". Fix now makes the configuration of this crystal clear.
50
129
  - renamed method RenderOptions.has_random_dom_id? to RenderOptions.random_dom_id? for rubocop rule.
51
130
  [PR 1133](https://github.com/shakacode/react_on_rails/pull/1133) by [justin808](https://github.com/justin808)
@@ -834,7 +913,11 @@ Best done with Object destructing:
834
913
  ##### Fixed
835
914
  - Fix several generator related issues.
836
915
 
837
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/11.1.7...master
916
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/11.3.0...master
917
+ [11.3.0]: https://github.com/shakacode/react_on_rails/compare/11.2.2...11.3.0
918
+ [11.2.2]: https://github.com/shakacode/react_on_rails/compare/11.2.1...11.2.2
919
+ [11.2.1]: https://github.com/shakacode/react_on_rails/compare/11.1.8...11.2.1
920
+ [11.1.8]: https://github.com/shakacode/react_on_rails/compare/11.1.7...11.1.8
838
921
  [11.1.7]: https://github.com/shakacode/react_on_rails/compare/11.1.6...11.1.7
839
922
  [11.1.6]: https://github.com/shakacode/react_on_rails/compare/11.1.5...11.1.6
840
923
  [11.1.5]: https://github.com/shakacode/react_on_rails/compare/11.1.4...11.1.5
@@ -1,46 +1,9 @@
1
1
  # Tips for Contributors
2
2
 
3
- * See [docs/contributor-info/Releasing](./docs/contributor-info/releasing.md) for instructions on releasing.
3
+ * [docs/contributor-info/Releasing](./docs/contributor-info/releasing.md) for instructions on releasing.
4
+ * [docs/contributor-info/pull-requests](./docs/contributor-info/pull-requests.md)
4
5
  * See other docs in [docs/contributor-info](./docs/contributor-info)
5
6
 
6
- ## Summary
7
-
8
- For non-doc fixes:
9
-
10
- * Provide changelog entry in the [unreleased section of the CHANGELOG.md](https://github.com/shakacode/react_on_rails/blob/master/CHANGELOG.md#unreleased).
11
- * Ensure CI passes and that you added a test that passes with the fix and fails without the fix.
12
- * Squash all commits down to one with a nice commit message *ONLY* once final review is given. Make sure this single commit is rebased on top of master.
13
- * Please address all code review comments.
14
- * Ensure that docs are updated accordingly if a feature is added.
15
-
16
- ## Commit Messages
17
-
18
- From [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/)
19
-
20
- #### The seven rules of a great git commit message
21
- > Keep in mind: This has all been said before.
22
-
23
- 1. Separate subject from body with a blank line
24
- 1. Limit the subject line to 50 characters
25
- 1. Capitalize the subject line
26
- 1. Do not end the subject line with a period
27
- 1. Use the imperative mood in the subject line
28
- 1. Wrap the body at 72 characters
29
- 1. Use the body to explain what and why vs. how
30
-
31
-
32
- ## Doc Changes
33
-
34
- When making doc changes, we want the change to work on both the gitbook and the regular github site. The issue is that non-doc files will not go to the gitbook site, so doc references to non doc files must use the github URL.
35
-
36
- ### Links to other docs:
37
- * When making references to doc files, use a relative URL path like:
38
- `[Installation Overview](docs/basics/installation-overview.md)`
39
-
40
- * When making references to source code files, use a full url path like:
41
- `[spec/dummy/config/initializers/react_on_rails.rb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/initializers/react_on_rails.rb)`
42
-
43
-
44
7
  ## To run tests:
45
8
  * After updating code via git, to prepare all examples and run all tests:
46
9
 
@@ -91,60 +54,63 @@ gem "react_on_rails", path: "../path-to-react-on-rails"
91
54
 
92
55
  Note that you will need to bundle install after making this change, but also that **you will need to restart your Rails application if you make any changes to the gem**.
93
56
 
94
- ## Testing the Node package for react-on-rails
57
+ ## Testing the Node package for react-on-rails via Yalc
95
58
  In addition to testing the Ruby parts out, you can also test the node package parts of the gem with an external application. First, be **sure** to build the NPM package:
96
59
 
97
60
  ```sh
98
61
  cd react_on_rails/
99
62
  yarn
100
- yarn run build
101
- yarn install-react-on-rails
63
+
64
+ # Update the lib directory with babel compiled files
65
+ yarn run build:watch
102
66
  ```
67
+
68
+ You need to do this once:
103
69
 
104
- Install the local package by using yarn link, like this:
105
- ```sh
70
+ ```
71
+ # Will send the updates to other folders
72
+ yalc publish
73
+ cd spec/dummy
74
+ yalc add react-on-rails
75
+ ```
76
+
77
+ The workflow is:
78
+ 1. Make changes to the node package.
79
+ 2. We need yalc to push and then run yarn:
80
+ ```
81
+ cd <top dir>
82
+ # Will send the updates to other folders
83
+ yalc push
106
84
  cd spec/dummy
85
+
86
+ # Will update from yalc
107
87
  yarn
108
88
  ```
109
89
 
110
- Note, yarn will run the `postinstall` script of `spec/dummy/client` which runs `yarn link` to setup a sym link to the parent package.
90
+ When you run `yalc push`, you'll get an informative message
111
91
 
112
- #### Example: Testing NPM changes with the dummy app
113
- 1. Add `console.log('Hello!')` [here](https://github.com/shakacode/react_on_rails/blob/master/node_package/src/clientStartup.js#L181) in `react_on_rails/node_package/src/clientStartup.js` to confirm we're getting an update to the node package.
114
- 2. Refresh the browser if the server is already running or start the server using `foreman start` from `react_on_rails/spec/dummy` and navigate to `http://localhost:5000/`. You will now see the `Hello!` message printed in the browser's console.
92
+ ```
93
+ yalc push
94
+ react-on-rails@12.0.0-12070fd1 published in store.
95
+ Pushing react-on-rails@12.0.0 in /Users/justin/shakacode/react-on-rails/react_on_rails/spec/dummy
96
+ Package react-on-rails@12.0.0-12070fd1 added ==> /Users/justin/shakacode/react-on-rails/react_on_rails/spec/dummy/node_modules/react-on-rails.
97
+ Don't forget you may need to run yarn after adding packages with yalc to install/update dependencies/bin scripts.
98
+ ```
115
99
 
116
- _Note: running `npm i` automatically builds the npm package before installing. However, when using yarn you will need to run `yarn run build` in the root directory before the install script. This will be updated when [yarn issue #2649](https://github.com/yarnpkg/yarn/issues/2649) (above) is resolved._
100
+ #### Example: Testing NPM changes with the dummy app
101
+ 1. Add `console.log('Hello!')` to [clientStartup.ts, function render](https://github.com/shakacode/react_on_rails/blob/master/node_package/src/clientStartup.ts in `/node_package/src/clientStartup.js` to confirm we're getting an update to the node package client side. Do the same for function `serverRenderReactComponent` in `/node_package/src/serverRenderReactComponent.ts`.
102
+ 2. Refresh the browser if the server is already running or start the server using `foreman start` from `react_on_rails/spec/dummy` and navigate to `http://localhost:5000/`. You will now see the `Hello!` message printed in the browser's console. If you did not see that message, then review the steps above for the workflow of making changes and pushing them via yalc.
117
103
 
118
104
  # Development Setup for Gem and Node Package Contributors
119
105
 
120
- ## Checklist before Committing
121
- 1. `rake`: runs all linters and specs (you need Docker setup, see below)
122
- 2. Did you need any more tests for your change?
123
- 3. Did you document your change? Update the README.md?
124
-
125
106
  ## Dev Initial Setup
126
107
 
127
108
  ### Prereqs
128
109
  After checking out the repo, making sure you have rvm and nvm setup (setup ruby and node), cd to `spec/dummy` and run `bin/setup` to install ruby dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
129
110
 
130
- Additionally, our RSpec tests use the poltergeist web driver. You will need to install the phantomjs node module:
131
-
132
- ```sh
133
- yarn global add phantomjs-prebuilt
134
- ```
135
-
136
- Note this *must* be installed globally for the dummy test project rspec runner to see it properly.
137
-
138
111
  ### Local Node Package
139
- Because the example and dummy apps rely on the react-on-rails node package, they should link directly to your local version to pick up any changes you may have made to that package. To achieve this, switch to the dummy app's root directory and run this command below which runs something like [this script](spec/dummy/package.json#L14)
140
112
 
141
- ```sh
142
- cd react_on_rails/spec/dummy
143
- yarn run install-react-on-rails
144
- ```
145
- _Note: this runs npm under the hood as explained in **Test NPM for react-on-rails** section above_
146
-
147
- From now on, the example and dummy apps will use your local node_package folder as the react-on-rails node package. This will also be done automatically for you via the `rake examples:gen_all` rake task.
113
+ Note, the example and dummy apps will use your local node_package folder as the react-on-rails node package. This will also be done automatically for you via the `rake examples:gen_all` rake task.
148
114
 
149
115
  *Side note: It's critical to use the alias section of the webpack config to avoid a double inclusion error. This has already been done for you in the example and dummy apps, but for reference:*
150
116
 
@@ -171,7 +137,7 @@ spec/dummy.
171
137
 
172
138
  ```sh
173
139
  # Optionally change default selenium_firefox driver
174
- export DRIVER=poltergeist
140
+ export DRIVER=selenium_firefox
175
141
  cd react_on_rails/
176
142
  yarn run dummy:spec
177
143
  ```
@@ -190,13 +156,6 @@ cd react_on_rails/spec/dummy
190
156
  rspec
191
157
  ```
192
158
 
193
- Eventually, we may have JS tests:
194
-
195
- ```sh
196
- cd react_on_rails/spec/dummy/client
197
- yarn run test
198
- ```
199
-
200
159
  ### Run most tests and linting
201
160
 
202
161
  ```sh
@@ -205,7 +164,7 @@ yarn run check
205
164
  ```
206
165
 
207
166
  ### Starting the Dummy App
208
- To run the dummy app, it's **CRITICAL** to not just run `rails s`. You have to run `foreman start`. If you don't do this, then `webpack` will not generate a new bundle, and you will be seriously confused when you change JavaScript and the app does not change. If you change the webpack configs, then you need to restart foreman. If you change the JS code for react-on-rails, you need to run `yarn run build`. Since the react-on-rails package should be sym linked, you don't have to `yarn react-on-rails` after every change.
167
+ To run the dummy app, it's **CRITICAL** to not just run `rails s`. You have to run `foreman start` with one of the Procfiles. If you don't do this, then `webpack` will not generate a new bundle, and you will be seriously confused when you change JavaScript and the app does not change. If you change the webpack configs, then you need to restart foreman. If you change the JS code for react-on-rails, you need to run `yarn run build`. Since the react-on-rails package should be sym linked, you don't have to `yarn react-on-rails` after every change.
209
168
 
210
169
  ### RSpec Testing
211
170
  Run `rake` for testing the gem and `spec/dummy`. Otherwise, the `rspec` command only works for testing within the sample apps, like `spec/dummy`.
@@ -227,10 +186,26 @@ In your Rails app add this gem with a path to your fork.
227
186
 
228
187
  ```ruby
229
188
  gem 'react_on_rails', path: '../relative/path/to/react_on_rails'
230
- ```
189
+ ```
190
+
191
+ Then run `bundle`.
231
192
 
232
193
  The main installer can be run with ```rails generate react_on_rails:install```
233
194
 
195
+ Then use yalc to add the npm module.
196
+
197
+ Be sure that your ran this first at the top level of React on Rails
198
+
199
+ ```
200
+ yalc publish
201
+ ```
202
+
203
+ Then add the node package to your test app:
204
+
205
+ ```
206
+ yalc add react-on-rails
207
+ ```
208
+
234
209
  ### Testing the Generator
235
210
  The generators are covered by generator tests using Rails's generator testing helpers, but it never hurts to do a sanity check and explore the API. See [generator_testing_script.md](generator_testing_script.md) for a script on how to run the generator on a fresh project.
236
211
 
@@ -255,6 +230,12 @@ You can run specific linting for directories or files by using `docker-compose r
255
230
 
256
231
  `docker-compose run lint bash` sets you up to run from the container command line.
257
232
 
233
+ ### Updating Rubocop
234
+ 2 files require updating to update the Rubocop version:
235
+
236
+ 1. `react_on_rails.gemspec`
237
+ 2. `spec/dummy/Gemfile`
238
+
258
239
  ### Docker CI - Test and Linting
259
240
  Docker CI and Tests containers have a xvfd server automatically started for headless browser testing with selenium and Firefox.
260
241