react_on_rails 11.0.5 → 13.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +338 -0
  3. data/.eslintignore +2 -1
  4. data/.eslintrc +32 -3
  5. data/.github/FUNDING.yml +1 -0
  6. data/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
  7. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. data/.github/PULL_REQUEST_TEMPLATE.md +19 -0
  9. data/.github/workflows/lint-js-and-ruby.yml +54 -0
  10. data/.github/workflows/main.yml +183 -0
  11. data/.github/workflows/package-js-tests.yml +35 -0
  12. data/.github/workflows/rspec-package-specs.yml +46 -0
  13. data/.gitignore +3 -4
  14. data/.prettierignore +14 -0
  15. data/.prettierrc +20 -0
  16. data/.rubocop.yml +76 -34
  17. data/.travis.yml +15 -22
  18. data/CHANGELOG.md +443 -55
  19. data/CONTRIBUTING.md +62 -80
  20. data/Gemfile +1 -35
  21. data/Gemfile.development_dependencies +50 -0
  22. data/KUDOS.md +4 -1
  23. data/{docs/LICENSE.md → LICENSE.md} +1 -1
  24. data/NEWS.md +14 -4
  25. data/REACT-ON-RAILS-PRO-LICENSE +95 -0
  26. data/README.md +107 -802
  27. data/Rakefile +1 -8
  28. data/SUMMARY.md +51 -29
  29. data/book.json +5 -5
  30. data/docs/{basics/generator.md → additional-details/generator-details.md} +5 -13
  31. data/docs/{basics/installation-overview.md → additional-details/manual-installation-overview.md} +9 -14
  32. data/docs/{basics → additional-details}/migrating-from-react-rails.md +1 -1
  33. data/docs/additional-details/recommended-project-structure.md +69 -0
  34. data/docs/additional-details/tips-for-usage-with-sp6.md +15 -0
  35. data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +10 -0
  36. data/docs/api/javascript-api.md +35 -6
  37. data/docs/api/redux-store-api.md +102 -0
  38. data/docs/api/view-helpers-api.md +133 -0
  39. data/docs/contributor-info/errors-with-hooks.md +45 -0
  40. data/docs/contributor-info/linters.md +5 -6
  41. data/docs/contributor-info/pull-requests.md +42 -0
  42. data/docs/contributor-info/releasing.md +1 -1
  43. data/docs/deployment/heroku-deployment.md +39 -0
  44. data/docs/getting-started.md +196 -0
  45. data/docs/guides/client-vs-server-rendering.md +27 -0
  46. data/docs/guides/configuration.md +289 -0
  47. data/docs/guides/deployment.md +5 -0
  48. data/docs/guides/file-system-based-automated-bundle-generation.md +197 -0
  49. data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +104 -0
  50. data/docs/guides/how-react-on-rails-works.md +44 -0
  51. data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +40 -0
  52. data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +98 -0
  53. data/docs/guides/i18n.md +87 -0
  54. data/docs/guides/installation-into-an-existing-rails-app.md +66 -0
  55. data/docs/guides/minitest-configuration.md +31 -0
  56. data/docs/guides/rails-webpacker-react-integration-options.md +213 -0
  57. data/docs/guides/react-on-rails-overview.md +29 -0
  58. data/docs/guides/react-server-rendering.md +32 -0
  59. data/docs/guides/render-functions-and-railscontext.md +205 -0
  60. data/docs/guides/rspec-configuration.md +73 -0
  61. data/docs/guides/tutorial.md +371 -0
  62. data/docs/{basics → guides}/upgrading-react-on-rails.md +126 -3
  63. data/docs/guides/webpack-configuration.md +42 -0
  64. data/docs/home.md +23 -0
  65. data/docs/javascript/asset-pipeline.md +12 -0
  66. data/docs/{additional-reading → javascript}/code-splitting.md +21 -11
  67. data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +10 -0
  68. data/docs/javascript/credits.md +10 -0
  69. data/docs/{additional-reading → javascript}/images.md +5 -6
  70. data/docs/javascript/react-helmet.md +100 -0
  71. data/docs/javascript/react-router.md +90 -0
  72. data/docs/{additional-reading → javascript}/server-rendering-tips.md +15 -12
  73. data/docs/javascript/troubleshooting-when-using-shakapacker.md +77 -0
  74. data/docs/{additional-reading → javascript}/webpack.md +2 -2
  75. data/docs/misc/articles.md +20 -0
  76. data/docs/misc/doctrine.md +5 -6
  77. data/docs/outdated/deferred-rendering.md +39 -0
  78. data/docs/{additional-reading → outdated}/rails-assets-relative-paths.md +4 -4
  79. data/docs/{additional-reading → outdated}/rails-assets.md +12 -20
  80. data/docs/{misc → outdated}/rails3.md +2 -2
  81. data/docs/rails/convert-rails-5-api-only-app.md +19 -0
  82. data/docs/rails/rails-engine-integration.md +32 -0
  83. data/docs/{additional-reading → rails}/rails_view_rendering_from_inline_javascript.md +2 -1
  84. data/docs/{additional-reading → rails}/turbolinks.md +13 -1
  85. data/docs/react-on-rails-pro/react-on-rails-pro.md +43 -0
  86. data/docs/testimonials/hvmn.md +25 -0
  87. data/docs/testimonials/resortpass.md +13 -0
  88. data/docs/testimonials/testimonials.md +28 -0
  89. data/jest.config.js +4 -0
  90. data/lib/generators/USAGE +1 -1
  91. data/lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb +41 -0
  92. data/lib/generators/react_on_rails/base_generator.rb +55 -43
  93. data/lib/generators/react_on_rails/bin/dev +30 -0
  94. data/lib/generators/react_on_rails/bin/dev-static +30 -0
  95. data/lib/generators/react_on_rails/dev_tests_generator.rb +4 -3
  96. data/lib/generators/react_on_rails/generator_helper.rb +8 -6
  97. data/lib/generators/react_on_rails/generator_messages.rb +40 -0
  98. data/lib/generators/react_on_rails/install_generator.rb +37 -0
  99. data/lib/generators/react_on_rails/templates/.eslintrc +3 -1
  100. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +4 -6
  101. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static +9 -0
  102. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +21 -40
  103. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +4 -0
  104. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorldServer.js +5 -0
  105. data/lib/generators/react_on_rails/templates/base/base/app/javascript/packs/server-bundle.js +8 -0
  106. data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/hello_world.html.erb +2 -1
  107. data/lib/generators/react_on_rails/templates/base/base/babel.config.js.tt +32 -0
  108. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +20 -4
  109. data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +62 -0
  110. data/lib/generators/react_on_rails/templates/base/base/config/webpack/clientWebpackConfig.js.tt +17 -0
  111. data/lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt +17 -0
  112. data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +25 -0
  113. data/lib/generators/react_on_rails/templates/base/base/config/webpack/production.js.tt +9 -0
  114. data/lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt +117 -0
  115. data/lib/generators/react_on_rails/templates/base/base/config/webpack/test.js.tt +9 -0
  116. data/lib/generators/react_on_rails/templates/base/base/config/webpack/webpack.config.js.tt +15 -0
  117. data/lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt +36 -0
  118. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +8 -2
  119. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
  120. data/lib/generators/react_on_rails/templates/dev_tests/spec/{features → system}/hello_world_spec.rb +2 -2
  121. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +6 -9
  122. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/store/helloWorldStore.js +1 -3
  123. data/lib/react_on_rails/configuration.rb +198 -145
  124. data/lib/react_on_rails/error.rb +2 -0
  125. data/lib/react_on_rails/git_utils.rb +5 -3
  126. data/lib/react_on_rails/{react_on_rails_helper.rb → helper.rb} +201 -190
  127. data/lib/react_on_rails/json_output.rb +1 -1
  128. data/lib/react_on_rails/json_parse_error.rb +28 -0
  129. data/lib/react_on_rails/locales/base.rb +169 -0
  130. data/lib/react_on_rails/locales/to_js.rb +33 -0
  131. data/lib/react_on_rails/locales/to_json.rb +23 -0
  132. data/lib/react_on_rails/packs_generator.rb +234 -0
  133. data/lib/react_on_rails/prerender_error.rb +35 -27
  134. data/lib/react_on_rails/react_component/render_options.rb +64 -9
  135. data/lib/react_on_rails/server_rendering_js_code.rb +55 -0
  136. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +126 -76
  137. data/lib/react_on_rails/server_rendering_pool.rb +0 -1
  138. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +9 -8
  139. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +17 -0
  140. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +13 -12
  141. data/lib/react_on_rails/test_helper.rb +24 -3
  142. data/lib/react_on_rails/utils.rb +94 -25
  143. data/lib/react_on_rails/version.rb +1 -1
  144. data/lib/react_on_rails/version_checker.rb +5 -1
  145. data/lib/react_on_rails/version_syntax_converter.rb +14 -12
  146. data/lib/react_on_rails/webpacker_utils.rb +105 -5
  147. data/lib/react_on_rails.rb +8 -2
  148. data/lib/tasks/assets.rake +28 -60
  149. data/lib/tasks/generate_packs.rake +11 -0
  150. data/lib/tasks/locale.rake +5 -4
  151. data/package-scripts.yml +49 -0
  152. data/package.json +52 -47
  153. data/rakelib/docker.rake +0 -5
  154. data/rakelib/dummy_apps.rake +5 -8
  155. data/rakelib/example_type.rb +12 -3
  156. data/rakelib/examples.rake +5 -4
  157. data/rakelib/lint.rake +5 -16
  158. data/rakelib/node_package.rake +2 -2
  159. data/rakelib/release.rake +37 -23
  160. data/rakelib/run_rspec.rake +16 -44
  161. data/rakelib/task_helpers.rb +16 -4
  162. data/react_on_rails.gemspec +6 -22
  163. data/tsconfig.json +14 -0
  164. data/webpackConfigLoader.js +5 -4
  165. data/yarn.lock +5935 -3106
  166. metadata +122 -272
  167. data/Gemfile.rails32 +0 -74
  168. data/docs/additional-reading/asset-pipeline.md +0 -20
  169. data/docs/additional-reading/babel.md +0 -5
  170. data/docs/additional-reading/caching-and-performance.md +0 -4
  171. data/docs/additional-reading/heroku-deployment.md +0 -92
  172. data/docs/additional-reading/hot-reloading-rails-development.md +0 -57
  173. data/docs/additional-reading/node-server-rendering.md +0 -5
  174. data/docs/additional-reading/rails-engine-integration.md +0 -34
  175. data/docs/additional-reading/react-helmet.md +0 -80
  176. data/docs/additional-reading/react-router.md +0 -113
  177. data/docs/additional-reading/recommended-project-structure.md +0 -49
  178. data/docs/additional-reading/rspec-configuration.md +0 -56
  179. data/docs/additional-reading/webpack-dev-server.md +0 -15
  180. data/docs/api/ruby-api-hot-reload-view-helpers.md +0 -44
  181. data/docs/api/ruby-api.md +0 -8
  182. data/docs/basics/configuration.md +0 -163
  183. data/docs/basics/i18n.md +0 -77
  184. data/docs/tutorial.md +0 -220
  185. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +0 -12
  186. data/lib/react_on_rails/assets_precompile.rb +0 -150
  187. data/lib/react_on_rails/locales_to_js.rb +0 -134
  188. data/ruby-lint.yml +0 -25
  189. /data/docs/{additional-reading → additional-details}/updating-dependencies.md +0 -0
  190. /data/docs/{additional-reading → deployment}/elastic-beanstalk.md +0 -0
  191. /data/docs/{additional-reading → javascript}/angular-js-integration-migration.md +0 -0
  192. /data/docs/{additional-reading → javascript}/capistrano-deployment.md +0 -0
  193. /data/docs/{additional-reading → javascript}/foreman-issues.md +0 -0
  194. /data/docs/{additional-reading → javascript}/node-dependencies-and-npm.md +0 -0
  195. /data/docs/{additional-reading → javascript}/react-and-redux.md +0 -0
  196. /data/docs/{additional-reading → javascript}/troubleshooting-when-using-webpacker.md +0 -0
  197. /data/docs/{additional-reading → javascript}/webpack-v1-notes.md +0 -0
  198. /data/docs/{coding-style → misc}/style.md +0 -0
  199. /data/docs/{additional-reading → misc}/tips.md +0 -0
@@ -0,0 +1,183 @@
1
+ name: Main test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build-dummy-app-webpack-test-bundles:
7
+ strategy:
8
+ matrix:
9
+ ruby: [2.7]
10
+ node: [14]
11
+ runs-on: ubuntu-22.04
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Setup Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ bundler: 2.4.17
19
+ # libyaml-dev is needed for psych v5
20
+ # this gem depends on sdoc which depends on rdoc which depends on psych
21
+ - name: Fix dependency for libyaml-dev
22
+ run: sudo apt install libyaml-dev
23
+ - name: Setup Node
24
+ uses: actions/setup-node@v2-beta
25
+ with:
26
+ node-version: ${{ matrix.node }}
27
+ - name: Print system information
28
+ run: |
29
+ echo "Linux release: "; cat /etc/issue
30
+ echo "Current user: "; whoami
31
+ echo "Current directory: "; pwd
32
+ echo "Ruby version: "; ruby -v
33
+ echo "Node version: "; node -v
34
+ echo "Yarn version: "; yarn --version
35
+ echo "Bundler version: "; bundle --version
36
+ - name: Save root node_modules to cache
37
+ uses: actions/cache@v3
38
+ with:
39
+ path: node_modules
40
+ key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
41
+ - name: Install Node modules with Yarn for renderer package
42
+ run: |
43
+ yarn install --no-progress --no-emoji
44
+ yarn run eslint -v
45
+ sudo yarn global add yalc
46
+ - name: yalc publish for react-on-rails
47
+ run: yalc publish
48
+ - name: Save spec/dummy/node_modules to cache
49
+ uses: actions/cache@v3
50
+ with:
51
+ path: spec/dummy/node_modules
52
+ key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}
53
+ - name: yalc add react-on-rails
54
+ run: cd spec/dummy && yalc add react-on-rails
55
+ - name: Install Node modules with Yarn for dummy app
56
+ run: cd spec/dummy && yarn install --no-progress --no-emoji
57
+ - name: Save dummy app ruby gems to cache
58
+ uses: actions/cache@v3
59
+ with:
60
+ path: spec/dummy/vendor/bundle
61
+ key: v5-dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}
62
+ - name: Install Ruby Gems for dummy app
63
+ run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.4.17_ install --path=vendor/bundle --jobs=4 --retry=3
64
+ - name: generate file system-based packs
65
+ run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs
66
+ - name: Build test bundles for dummy app
67
+ run: cd spec/dummy && yarn run build:test
68
+ - id: get-sha
69
+ run: echo "::set-output name=sha::$(git rev-parse HEAD)"
70
+ - name: Save test webpack bundles to cache (for build number checksum used by rspec job)
71
+ uses: actions/cache/save@v3
72
+ with:
73
+ path: spec/dummy/public/webpack
74
+ key: v5-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}
75
+
76
+ main:
77
+ needs: build-dummy-app-webpack-test-bundles
78
+ strategy:
79
+ matrix:
80
+ ruby: [2.7]
81
+ node: [14]
82
+ rake_task: ['run_rspec:all_but_examples', 'run_rspec:examples']
83
+ runs-on: ubuntu-22.04
84
+ steps:
85
+ - uses: actions/checkout@v2
86
+ - name: Setup Ruby
87
+ uses: ruby/setup-ruby@v1
88
+ with:
89
+ ruby-version: ${{ matrix.ruby }}
90
+ bundler: 2.4.17
91
+ - name: Setup Node
92
+ uses: actions/setup-node@v2-beta
93
+ with:
94
+ node-version: ${{ matrix.node }}
95
+ - name: Print system information
96
+ run: |
97
+ echo "Linux release: "; cat /etc/issue
98
+ echo "Current user: "; whoami
99
+ echo "Current directory: "; pwd
100
+ echo "Ruby version: "; ruby -v
101
+ echo "Node version: "; node -v
102
+ echo "Yarn version: "; yarn --version
103
+ echo "Bundler version: "; bundle --version
104
+ - name: Save root node_modules to cache
105
+ uses: actions/cache@v3
106
+ with:
107
+ path: node_modules
108
+ key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
109
+ - name: Save root ruby gems to cache
110
+ uses: actions/cache@v3
111
+ with:
112
+ path: vendor/bundle
113
+ key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}
114
+ - name: Save dummy app ruby gems to cache
115
+ uses: actions/cache@v3
116
+ with:
117
+ path: spec/dummy/vendor/bundle
118
+ key: v5-dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}
119
+ - name: Save spec/dummy/node_modules to cache
120
+ uses: actions/cache@v3
121
+ with:
122
+ path: spec/dummy/node_modules
123
+ key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}
124
+ - id: get-sha
125
+ run: echo "::set-output name=sha::$(git rev-parse HEAD)"
126
+ - name: Save test webpack bundles to cache (for build number checksum used by rspec job)
127
+ uses: actions/cache@v3
128
+ with:
129
+ path: spec/dummy/public/webpack
130
+ key: v5-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}
131
+ - name: Install Node modules with Yarn for renderer package
132
+ run: |
133
+ yarn install --no-progress --no-emoji
134
+ yarn run eslint -v
135
+ sudo yarn global add yalc
136
+ - name: yalc publish for react-on-rails
137
+ run: yalc publish
138
+ - name: yalc add react-on-rails
139
+ run: cd spec/dummy && yalc add react-on-rails
140
+ - name: Install Ruby Gems for package
141
+ run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
142
+ - name: Install Ruby Gems for dummy app
143
+ run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.4.17_ install --path=vendor/bundle --jobs=4 --retry=3
144
+ - name: Ensure minimum required Chrome version
145
+ run: |
146
+ echo -e "Already installed $(google-chrome --version)\n"
147
+ MINIMUM_REQUIRED_CHROME_VERSION=75
148
+ INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)"
149
+ if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then
150
+ wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
151
+ sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
152
+ sudo apt-get update
153
+ sudo apt-get install google-chrome-stable
154
+ echo -e "\nInstalled $(google-chrome --version)"
155
+ fi
156
+ - name: Install yalc globally
157
+ run: sudo yarn global add yalc
158
+ - name: Increase the amount of inotify watchers
159
+ run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
160
+ - name: generate file system-based packs
161
+ run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs
162
+ - name: Main CI
163
+ run: bundle exec rake ${{ matrix.rake_task }}
164
+ - name: Store test results
165
+ uses: actions/upload-artifact@v2
166
+ with:
167
+ name: main-rspec
168
+ path: ~/rspec
169
+ - name: Store artifacts
170
+ uses: actions/upload-artifact@v2
171
+ with:
172
+ name: dummy-app-capybara
173
+ path: spec/dummy/tmp/capybara
174
+ - name: Store artifacts
175
+ uses: actions/upload-artifact@v2
176
+ with:
177
+ name: dummy-app-test-log
178
+ path: spec/dummy/log/test.log
179
+ - name: Store artifacts
180
+ uses: actions/upload-artifact@v2
181
+ with:
182
+ name: dummy-app-yarn-log
183
+ path: spec/dummy/yarn-error.log
@@ -0,0 +1,35 @@
1
+ name: JS unit tests for Renderer package
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ strategy:
8
+ matrix:
9
+ node: [12, 14]
10
+ runs-on: ubuntu-22.04
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Setup Node
14
+ uses: actions/setup-node@v2-beta
15
+ with:
16
+ node-version: ${{ matrix.node }}
17
+ - name: Print system information
18
+ run: |
19
+ echo "Linux release: "; cat /etc/issue
20
+ echo "Current user: "; whoami
21
+ echo "Current directory: "; pwd
22
+ echo "Node version: "; node -v
23
+ echo "Yarn version: "; yarn --version
24
+ - name: Save root node_modules to cache
25
+ uses: actions/cache@v2
26
+ with:
27
+ path: node_modules
28
+ key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }}
29
+ - name: Install Node modules with Yarn for renderer package
30
+ run: |
31
+ yarn install --no-progress --no-emoji
32
+ yarn run eslint -v
33
+ sudo yarn global add yalc
34
+ - name: Run JS unit tests for Renderer package
35
+ run: yarn test
@@ -0,0 +1,46 @@
1
+ name: Rspec test for gem
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ strategy:
8
+ matrix:
9
+ ruby: [2.7]
10
+ node: [14]
11
+ runs-on: ubuntu-22.04
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Setup Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ bundler: 2.4.17
19
+ - name: Print system information
20
+ run: |
21
+ echo "Linux release: "; cat /etc/issue
22
+ echo "Current user: "; whoami
23
+ echo "Current directory: "; pwd
24
+ echo "Ruby version: "; ruby -v
25
+ echo "Node version: "; node -v
26
+ echo "Yarn version: "; yarn --version
27
+ echo "Bundler version: "; bundle --version
28
+ - name: Save root ruby gems to cache
29
+ uses: actions/cache@v2
30
+ with:
31
+ path: vendor/bundle
32
+ key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}
33
+ - name: Install Ruby Gems for package
34
+ run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
35
+ - name: Run rspec tests
36
+ run: bundle exec rspec spec/react_on_rails
37
+ - name: Store test results
38
+ uses: actions/upload-artifact@v2
39
+ with:
40
+ name: main-rspec
41
+ path: ~/rspec
42
+ - name: Store artifacts
43
+ uses: actions/upload-artifact@v2
44
+ with:
45
+ name: main-test-log
46
+ path: log/test.log
data/.gitignore CHANGED
@@ -1,7 +1,6 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
3
  /Gemfile.lock
4
- /Gemfile.rails32.lock
5
4
  /_yardoc/
6
5
  /coverage/
7
6
  /doc/
@@ -12,9 +11,6 @@
12
11
  /vendor/
13
12
 
14
13
  /spec/examples.txt
15
- /spec/dummy/client/node_modules
16
- /spec/dummy/public/webpack/
17
- /spec/dummy/coverage/
18
14
  /spec/react_on_rails/dummy-for-generators/
19
15
 
20
16
  # RVM
@@ -32,3 +28,6 @@ npm-debug.*
32
28
  /gen-examples
33
29
 
34
30
  .DS_Store
31
+
32
+ .yalc
33
+ yalc.lock
data/.prettierignore ADDED
@@ -0,0 +1,14 @@
1
+ node_modules/
2
+ package.json
3
+ tmp/
4
+ coverage/
5
+ **/app/assets/webpack/
6
+ gen-examples/examples/*
7
+ node_package/lib/*
8
+ spec/react_on_rails/dummy-for-generators/app/javascript/bundles/HelloWorld/*
9
+ bundle/
10
+ spec/dummy/lib/bs/**
11
+ spec/dummy/public
12
+ **/.yalc/**
13
+ **/generated/**
14
+ *.bs.js
data/.prettierrc ADDED
@@ -0,0 +1,20 @@
1
+ printWidth: 110
2
+ tabWidth: 2
3
+ useTabs: false
4
+ semi: true
5
+ singleQuote: true
6
+ trailingComma: all
7
+ bracketSpacing: true
8
+ jsxBracketSameLine: false
9
+ parser: flow
10
+
11
+ overrides:
12
+ - files: "*.@(css|scss)"
13
+ options:
14
+ parser: css
15
+ singleQuote: false
16
+ printWidth: 120
17
+ - files: "*.@(json)"
18
+ options:
19
+ parser: json
20
+ printWidth: 100
data/.rubocop.yml CHANGED
@@ -1,50 +1,44 @@
1
1
  # This is the configuration used to check the rubocop source code.
2
2
  # Check out: https://github.com/bbatsov/rubocop
3
+ require:
4
+ - rubocop-performance
5
+ - rubocop-rspec
3
6
 
4
7
  AllCops:
8
+ NewCops: enable
5
9
  DisplayCopNames: true
6
- TargetRubyVersion: 2.1
10
+ TargetRubyVersion: 2.5
7
11
 
8
12
  Include:
9
13
  - '**/Rakefile'
10
14
  - '**/config.ru'
15
+ - 'Gemfile'
16
+ - '**/*.rb'
17
+ - '**/*.rake'
11
18
 
12
19
  Exclude:
13
- - 'vendor/**/*'
14
- - 'spec/fixtures/**/*'
15
- - 'node_modules/**/.*'
16
- - 'node_modules/**/*'
20
+ <% `git status --ignored --porcelain`.lines.grep(/^!! /).each do |path| %>
21
+ - <%= path.sub(/^!! /, '') %>
22
+ <% end %>
23
+ - '**/*.js'
24
+ - '**/node_modules/**/*'
25
+ - '**/public/**/*'
26
+ - '**/tmp/**/*'
17
27
  - 'coverage/**/*'
18
- - 'db/**/*'
19
- - 'db/schema.rb'
20
- - 'db/seeds.rb'
21
- - 'client/node_modules/**/*.*'
22
- - 'client/node_modules/**/.*'
23
- - 'bin/**/*'
24
- - !ruby/regexp /old_and_unused\.rb$/
25
- - 'spec/react_on_rails/dummy-for-generators/**/*'
26
- - 'spec/dummy/Procfile.*'
27
- - 'spec/dummy/bin/**/*'
28
- - 'spec/dummy/client/node_modules/**/*'
29
- - 'spec/dummy/client/node_modules/**/.*'
30
- - 'spec/dummy_no_webpacker/Procfile.*'
31
- - 'spec/dummy_no_webpacker/bin/**/*'
32
- - 'spec/dummy_no_webpacker/client/node_modules/**/*'
33
- - 'spec/dummy_no_webpacker/client/node_modules/**/.*'
34
- - 'gen-examples/examples/**/.*'
35
28
  - 'gen-examples/examples/**/*'
29
+ - 'node_modules/**/*'
30
+ - 'spec/dummy/bin/*'
31
+ - 'spec/fixtures/**/*'
32
+ - 'spec/react_on_rails/dummy-for-generators/**/*'
33
+ - 'tmp/**/*'
34
+ - 'vendor/**/*'
36
35
 
37
36
  Naming/FileName:
38
37
  Exclude:
39
- - 'Gemfile'
40
- - 'spec/dummy/Gemfile'
41
- - 'spec/dummy_no_webpacker/Gemfile'
42
-
43
- # Turn off until we require 2.3 ruby
44
- Style/SafeNavigation:
45
- Enabled: false
38
+ - '**/Gemfile'
39
+ - '**/Rakefile'
46
40
 
47
- Metrics/LineLength:
41
+ Layout/LineLength:
48
42
  Max: 120
49
43
 
50
44
  Style/StringLiterals:
@@ -53,11 +47,20 @@ Style/StringLiterals:
53
47
  Style/Documentation:
54
48
  Enabled: false
55
49
 
50
+ Style/HashEachMethods:
51
+ Enabled: true
52
+
53
+ Style/HashTransformKeys:
54
+ Enabled: true
55
+
56
+ Style/HashTransformValues:
57
+ Enabled: true
58
+
56
59
  Lint/AssignmentInCondition:
57
60
  Exclude:
58
61
  - 'spec/dummy/bin/spring'
59
62
 
60
- Lint/HandleExceptions:
63
+ Lint/SuppressedException:
61
64
  Exclude:
62
65
  - 'spec/dummy/bin/rails'
63
66
  - 'spec/dummy/bin/rake'
@@ -84,9 +87,48 @@ Metrics/MethodLength:
84
87
  Metrics/ModuleLength:
85
88
  Max: 180
86
89
 
90
+ Naming/RescuedExceptionsVariableName:
91
+ Enabled: false
92
+
93
+ RSpec/AnyInstance:
94
+ Exclude:
95
+ - 'spec/react_on_rails/git_utils_spec.rb'
96
+ - 'spec/react_on_rails/locales_to_js_spec.rb'
97
+ - 'spec/react_on_rails/binstubs/dev_spec.rb'
98
+ - 'spec/react_on_rails/binstubs/dev_static_spec.rb'
99
+
100
+ RSpec/DescribeClass:
101
+ Enabled: false
102
+
103
+ RSpec/ExampleLength:
104
+ Enabled: false
105
+
106
+ RSpec/MessageSpies:
107
+ Enabled: false
108
+
109
+ RSpec/NestedGroups:
110
+ Max: 4
111
+
112
+ RSpec/BeforeAfterAll:
113
+ Exclude:
114
+ - 'spec/react_on_rails/generators/dev_tests_generator_spec.rb'
115
+ - 'spec/react_on_rails/generators/install_generator_spec.rb'
116
+ - 'spec/react_on_rails/binstubs/dev_spec.rb'
117
+ - 'spec/react_on_rails/binstubs/dev_static_spec.rb'
118
+
119
+ RSpec/MessageChain:
120
+ Enabled: false
121
+
122
+ RSpec/MultipleExpectations:
123
+ Enabled: false
124
+
125
+ RSpec/MultipleDescribes:
126
+ Exclude:
127
+ - 'spec/dummy/spec/system/integration_spec.rb'
128
+
129
+ RSpec/MultipleMemoizedHelpers:
130
+ Max: 12
131
+
87
132
  Style/GlobalVars:
88
133
  Exclude:
89
134
  - 'spec/dummy/config/environments/development.rb'
90
-
91
- Style/FrozenStringLiteralComment:
92
- EnforcedStyle: when_needed
data/.travis.yml CHANGED
@@ -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,14 +34,20 @@ 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 9.11.1
37
+ - travis_retry gem install bundler -v '>2'
38
+ - travis_retry nvm install 14
41
39
  - node -v
42
- - travis_retry npm i -g yarn@0.27.5
43
- - travis_retry yarn global add babel-cli
44
- - travis_retry bundle install
40
+ - travis_retry npm i -g yarn
41
+ - travis_retry yarn global add yalc
42
+ - travis_retry yalc add react-on-rails
45
43
  - travis_retry yarn
44
+ - travis_retry bundle install
46
45
  - travis_retry yarn run build
46
+ - travis_retry yalc publish
47
+ - cd spec/dummy
48
+ - travis_retry yalc add react-on-rails
49
+ - travis_retry yarn
50
+ - cd ../..
47
51
  - bundle exec rake prepare_for_ci
48
52
 
49
53
  before_script:
@@ -52,17 +56,6 @@ before_script:
52
56
  script:
53
57
  - bundle exec rake
54
58
 
55
- matrix:
56
- exclude:
57
- - gemfile: spec/dummy_no_webpacker/Gemfile.rails32
58
- rvm: 2.3.1
59
- - gemfile: spec/dummy_no_webpacker/Gemfile.rails32
60
- rvm: 2.4.1
61
- - gemfile: spec/dummy_no_webpacker/Gemfile.rails32
62
- rvm: 2.5.0
63
- - gemfile: spec/dummy/Gemfile
64
- rvm: 2.2.6
65
-
66
59
  notifications:
67
60
  slack:
68
61
  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=