shakapacker 7.0.0.rc.0 → 7.0.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +4 -8
  3. data/.github/workflows/dummy.yml +21 -0
  4. data/.github/workflows/generator.yml +37 -0
  5. data/.github/workflows/jest.yml +2 -2
  6. data/.github/workflows/js-lint.yml +2 -2
  7. data/.github/workflows/rubocop.yml +1 -1
  8. data/.github/workflows/ruby-backward-compatibility.yml +2 -6
  9. data/.github/workflows/ruby.yml +2 -6
  10. data/.gitignore +3 -0
  11. data/CHANGELOG.md +17 -18
  12. data/CONTRIBUTING.md +76 -20
  13. data/README.md +5 -1
  14. data/Rakefile +44 -8
  15. data/docs/deployment.md +1 -2
  16. data/lib/install/binstubs.rb +3 -1
  17. data/lib/install/config/shakapacker.yml +9 -0
  18. data/lib/install/config/webpack/webpack.config.js +3 -2
  19. data/lib/install/template.rb +27 -15
  20. data/lib/shakapacker/deprecation_helper.rb +4 -5
  21. data/lib/shakapacker/version.rb +1 -1
  22. data/lib/tasks/shakapacker/check_binstubs.rake +14 -10
  23. data/lib/tasks/shakapacker/compile.rake +1 -6
  24. data/package/__tests__/index-bc.js +22 -0
  25. data/package/environments/__tests__/base-bc.js +2 -2
  26. data/package/environments/__tests__/base.js +2 -2
  27. data/package/environments/__tests__/development.js +53 -0
  28. data/package/environments/__tests__/production.js +53 -0
  29. data/package/environments/base.js +4 -3
  30. data/package/environments/production.js +9 -0
  31. data/package/index.js +24 -1
  32. data/package/utils/helpers.js +1 -1
  33. data/package.json +1 -1
  34. data/spec/dummy/.browserslistrc +1 -0
  35. data/spec/dummy/.gitignore +20 -0
  36. data/spec/dummy/.prettierrc.yaml +4 -0
  37. data/spec/dummy/Gemfile +63 -0
  38. data/spec/dummy/Procfile.dev +5 -0
  39. data/spec/dummy/Procfile.dev-static +9 -0
  40. data/spec/dummy/README.md +1 -0
  41. data/spec/dummy/Rakefile +6 -0
  42. data/spec/dummy/app/assets/config/manifest.js +2 -0
  43. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  44. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  45. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  46. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  47. data/spec/dummy/app/controllers/hello_world_controller.rb +9 -0
  48. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  49. data/spec/dummy/app/javascript/Globals.d.ts +3 -0
  50. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +25 -0
  51. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +47 -0
  52. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx +5 -0
  53. data/spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg +7 -0
  54. data/spec/dummy/app/javascript/packs/application.js +17 -0
  55. data/spec/dummy/app/javascript/packs/hello-world-bundle.ts +8 -0
  56. data/spec/dummy/app/javascript/packs/server-bundle.ts +8 -0
  57. data/spec/dummy/app/jobs/application_job.rb +7 -0
  58. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  59. data/spec/dummy/app/models/application_record.rb +3 -0
  60. data/spec/dummy/app/models/concerns/.keep +0 -0
  61. data/spec/dummy/app/views/hello_world/index.html.erb +2 -0
  62. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  63. data/spec/dummy/app/views/layouts/hello_world.html.erb +13 -0
  64. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  65. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  66. data/spec/dummy/babel.config.js +30 -0
  67. data/spec/dummy/bin/bundle +114 -0
  68. data/spec/dummy/bin/dev +30 -0
  69. data/spec/dummy/bin/dev-static +30 -0
  70. data/spec/dummy/bin/rails +9 -0
  71. data/spec/dummy/bin/rake +9 -0
  72. data/spec/dummy/bin/setup +33 -0
  73. data/spec/dummy/bin/shakapacker +13 -0
  74. data/spec/dummy/bin/shakapacker-dev-server +13 -0
  75. data/spec/dummy/bin/spring +17 -0
  76. data/spec/dummy/bin/yarn +18 -0
  77. data/spec/dummy/config/application.rb +32 -0
  78. data/spec/dummy/config/boot.rb +4 -0
  79. data/spec/dummy/config/cable.yml +10 -0
  80. data/spec/dummy/config/credentials.yml.enc +1 -0
  81. data/spec/dummy/config/database.yml +25 -0
  82. data/spec/dummy/config/environment.rb +5 -0
  83. data/spec/dummy/config/environments/development.rb +54 -0
  84. data/spec/dummy/config/environments/production.rb +106 -0
  85. data/spec/dummy/config/environments/test.rb +49 -0
  86. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  87. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  88. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  89. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  90. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  91. data/spec/dummy/config/initializers/inflections.rb +16 -0
  92. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  93. data/spec/dummy/config/initializers/react_on_rails.rb +58 -0
  94. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  95. data/spec/dummy/config/locales/en.yml +33 -0
  96. data/spec/dummy/config/puma.rb +38 -0
  97. data/spec/dummy/config/routes.rb +6 -0
  98. data/spec/dummy/config/shakapacker.yml +62 -0
  99. data/spec/dummy/config/spring.rb +6 -0
  100. data/spec/dummy/config/storage.yml +34 -0
  101. data/spec/dummy/config/webpack/ServerClientOrBoth.js +34 -0
  102. data/spec/dummy/config/webpack/clientWebpackConfig.js +15 -0
  103. data/spec/dummy/config/webpack/commonWebpackConfig.js +18 -0
  104. data/spec/dummy/config/webpack/development.js +32 -0
  105. data/spec/dummy/config/webpack/production.js +9 -0
  106. data/spec/dummy/config/webpack/serverWebpackConfig.js +116 -0
  107. data/spec/dummy/config/webpack/test.js +7 -0
  108. data/spec/dummy/config/webpack/webpack.config.js +24 -0
  109. data/spec/dummy/config.ru +5 -0
  110. data/spec/dummy/db/seeds.rb +7 -0
  111. data/spec/dummy/lib/assets/.keep +0 -0
  112. data/spec/dummy/lib/tasks/.keep +0 -0
  113. data/spec/dummy/package.json +44 -0
  114. data/spec/dummy/postcss.config.js +12 -0
  115. data/spec/dummy/public/404.html +67 -0
  116. data/spec/dummy/public/422.html +67 -0
  117. data/spec/dummy/public/500.html +66 -0
  118. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  119. data/spec/dummy/public/apple-touch-icon.png +0 -0
  120. data/spec/dummy/public/favicon.ico +0 -0
  121. data/spec/dummy/public/robots.txt +1 -0
  122. data/spec/dummy/spec/rails_helper.rb +118 -0
  123. data/spec/dummy/spec/spec_helper.rb +96 -0
  124. data/spec/dummy/spec/system/hello_world_spec.rb +19 -0
  125. data/spec/dummy/tsconfig.json +21 -0
  126. data/spec/dummy/vendor/.keep +0 -0
  127. data/spec/dummy/yarn.lock +4697 -0
  128. data/spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb +4 -0
  129. data/spec/generator_specs/e2e_template/files/app/javascript/components/App.js +12 -0
  130. data/spec/generator_specs/e2e_template/files/app/javascript/packs/application.js +10 -0
  131. data/spec/generator_specs/e2e_template/files/app/views/home/index.html.erb +2 -0
  132. data/spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb +17 -0
  133. data/spec/generator_specs/e2e_template/files/config/routes.rb +3 -0
  134. data/spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb +13 -0
  135. data/spec/generator_specs/e2e_template/template.rb +21 -0
  136. data/spec/generator_specs/generator_spec.rb +169 -0
  137. data/spec/{configuration_spec.rb → shakapacker/configuration_spec.rb} +10 -10
  138. data/spec/{dev_server_runner_spec.rb → shakapacker/dev_server_runner_spec.rb} +1 -1
  139. data/spec/{engine_rake_tasks_spec.rb → shakapacker/engine_rake_tasks_spec.rb} +2 -2
  140. data/spec/{manifest_spec.rb → shakapacker/manifest_spec.rb} +1 -1
  141. data/spec/shakapacker/rake_tasks_spec.rb +93 -0
  142. data/spec/{spec_helper_initializer.rb → shakapacker/spec_helper_initializer.rb} +1 -1
  143. data/spec/shakapacker/test_app/config/webpack/webpack.config.js +0 -0
  144. data/spec/shakapacker/test_app/some.config.js +0 -0
  145. data/spec/{version_checker_spec.rb → shakapacker/version_checker_spec.rb} +9 -9
  146. data/spec/{webpack_runner_spec.rb → shakapacker/webpack_runner_spec.rb} +1 -1
  147. metadata +173 -64
  148. data/gemfiles/Gemfile-rails.5.2.x +0 -9
  149. data/spec/rake_tasks_spec.rb +0 -34
  150. /data/docs/{developing_webpacker.md → developing_shakapacker.md} +0 -0
  151. /data/spec/backward_compatibility_specs/{command_spec_bc.rb → command_spec.rb} +0 -0
  152. /data/spec/backward_compatibility_specs/{compiler_spec_bc.rb → compiler_spec.rb} +0 -0
  153. /data/spec/backward_compatibility_specs/{compiler_strategy_spec_bc.rb → compiler_strategy_spec.rb} +0 -0
  154. /data/spec/backward_compatibility_specs/{configuration_spec_bc.rb → configuration_spec.rb} +0 -0
  155. /data/spec/backward_compatibility_specs/{dev_server_runner_spec_bc.rb → dev_server_runner_spec.rb} +0 -0
  156. /data/spec/backward_compatibility_specs/{dev_server_spec_bc.rb → dev_server_spec.rb} +0 -0
  157. /data/spec/backward_compatibility_specs/{digest_strategy_spec_bc.rb → digest_strategy_spec.rb} +0 -0
  158. /data/spec/backward_compatibility_specs/{engine_rake_tasks_spec_bc.rb → engine_rake_tasks_spec.rb} +0 -0
  159. /data/spec/backward_compatibility_specs/{env_spec_bc.rb → env_spec.rb} +0 -0
  160. /data/spec/backward_compatibility_specs/{helper_spec_bc.rb → helper_spec.rb} +0 -0
  161. /data/spec/backward_compatibility_specs/{instance_spec_bc.rb → instance_spec.rb} +0 -0
  162. /data/spec/backward_compatibility_specs/{manifest_spec_bc.rb → manifest_spec.rb} +0 -0
  163. /data/spec/backward_compatibility_specs/{mtime_strategy_spec_bc.rb → mtime_strategy_spec.rb} +0 -0
  164. /data/spec/backward_compatibility_specs/{rake_tasks_spec_bc.rb → rake_tasks_spec.rb} +0 -0
  165. /data/spec/backward_compatibility_specs/{webpack_runner_spec_bc.rb → webpack_runner_spec.rb} +0 -0
  166. /data/spec/backward_compatibility_specs/{webpacker_spec_bc.rb → webpacker_spec.rb} +0 -0
  167. /data/spec/{test_app/config/webpack/webpack.config.js → dummy/app/assets/images/.keep} +0 -0
  168. /data/spec/{test_app/some.config.js → dummy/app/controllers/concerns/.keep} +0 -0
  169. /data/spec/{command_spec.rb → shakapacker/command_spec.rb} +0 -0
  170. /data/spec/{compiler_spec.rb → shakapacker/compiler_spec.rb} +0 -0
  171. /data/spec/{compiler_strategy_spec.rb → shakapacker/compiler_strategy_spec.rb} +0 -0
  172. /data/spec/{dev_server_spec.rb → shakapacker/dev_server_spec.rb} +0 -0
  173. /data/spec/{digest_strategy_spec.rb → shakapacker/digest_strategy_spec.rb} +0 -0
  174. /data/spec/{env_spec.rb → shakapacker/env_spec.rb} +0 -0
  175. /data/spec/{helper_spec.rb → shakapacker/helper_spec.rb} +0 -0
  176. /data/spec/{instance_spec.rb → shakapacker/instance_spec.rb} +0 -0
  177. /data/spec/{mtime_strategy_spec.rb → shakapacker/mtime_strategy_spec.rb} +0 -0
  178. /data/spec/{webpacker_spec.rb → shakapacker/shakapacker_spec.rb} +0 -0
  179. /data/spec/{test_app → shakapacker/test_app}/.gitignore +0 -0
  180. /data/spec/{test_app → shakapacker/test_app}/Rakefile +0 -0
  181. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/application.js +0 -0
  182. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/generated/something.js +0 -0
  183. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/multi_entry.css +0 -0
  184. /data/spec/{test_app → shakapacker/test_app}/app/javascript/entrypoints/multi_entry.js +0 -0
  185. /data/spec/{test_app → shakapacker/test_app}/bin/shakapacker +0 -0
  186. /data/spec/{test_app → shakapacker/test_app}/bin/shakapacker-dev-server +0 -0
  187. /data/spec/{test_app → shakapacker/test_app}/config/application.rb +0 -0
  188. /data/spec/{test_app → shakapacker/test_app}/config/environment.rb +0 -0
  189. /data/spec/{test_app → shakapacker/test_app}/config/initializers/inspect_autoload_paths.rb +0 -0
  190. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker.yml +0 -0
  191. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_css_extract_ignore_order_warnings.yml +0 -0
  192. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_defaults_fallback.yml +0 -0
  193. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_manifest_path.yml +0 -0
  194. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_nested_entries.yml +0 -0
  195. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_no_precompile.yml +0 -0
  196. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_other_location.yml +0 -0
  197. /data/spec/{test_app → shakapacker/test_app}/config/shakapacker_public_root.yml +0 -0
  198. /data/spec/{test_app → shakapacker/test_app}/config.ru +0 -0
  199. /data/spec/{test_app → shakapacker/test_app}/package.json +0 -0
  200. /data/spec/{test_app → shakapacker/test_app}/public/packs/manifest.json +0 -0
  201. /data/spec/{test_app → shakapacker/test_app}/yarn.lock +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c2600d05c024a802ccccf3e373a2e90f9042a6fe6a7fc73034f66bca4ac01bd
4
- data.tar.gz: 683d520cb198b10c0bd10b3ee22d3c0bcf238bab85abb668d716ffa27481d283
3
+ metadata.gz: 58893ea0632011344e72e3fc4c887459f8e24872c5c5ab28792d1339d6d425e8
4
+ data.tar.gz: 2afede128c27cf45a4fcef08462fb9a64f5b89931075fdf89bd787af710939bd
5
5
  SHA512:
6
- metadata.gz: 923fc595797f7e0b15d49d8cfc040b1fd155c4b7da4f3587b43f2a3a5f7989468e3b4f404e94f84ada36f13faeb1bf42dcac7f140b11927534ea9799bc89e325
7
- data.tar.gz: e9b47474977e567da8256e677b5883bc86ebc498aaca5db6b3a1a6b172582cd152b61d48c2537b32cdec182db714b4989355c12033969d550135f4603820ee1c
6
+ metadata.gz: 7f49df282d8a4e42b28b2172a5f48b88d757c609323b57ffad3ab50091b3cea96110fcd5e6c9f865ab9552a7d49d51c864769ed0667c691f44f56d065b7d70ed
7
+ data.tar.gz: 1930a5cedaa8831fae4bbcab4e8baa05571414508ade9403e7b8a0ebd86f366d727ef6d3996e02a0a40e8b2faf21fdc5b4153a1fd7debd16e8467a8035071ee5
@@ -1,18 +1,14 @@
1
1
  ### Summary
2
2
 
3
- _Remove this paragraph and provide a general description of the code changes in your pull
4
- request... were there any bugs you had fixed? If so, mention them. If
5
- these bugs have open GitHub issues, be sure to tag them here as well,
6
- to keep the conversation linked together._
3
+ _Remove this paragraph and describe the code changes in your pull request... were there any bugs you had fixed? If so, mention them. If these bugs have open GitHub issues, tag them here as well to keep the conversation linked._
7
4
 
8
5
  ### Pull Request checklist
9
- _Remove this line after checking all the items here. If the item is not applicable to the PR, both check it out and wrap it by `~`._
6
+ _Remove this line after checking all the items here. If the item does not apply to the PR, both check it out and wrap it by `~`._
10
7
 
11
8
  - [ ] Add/update test to cover these changes
12
9
  - [ ] Update documentation
13
- - [ ] Update CHANGELOG file
14
- _Add the CHANGELOG entry at the top of the file._
10
+ - [ ] Update CHANGELOG file
15
11
 
16
12
  ### Other Information
17
13
 
18
- _Remove this parapraph and mention any other important and relevant information such as benchmarks._
14
+ _Remove this paragraph and mention other important and relevant information, such as benchmarks._
@@ -0,0 +1,21 @@
1
+ name: Dummy specs
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - uses: actions/checkout@v2
11
+ - uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: '3.1.2'
14
+ - name: Install dependencies
15
+ run: |
16
+ bundle install
17
+ yarn install
18
+ sudo yarn global add yalc
19
+
20
+ - name: Run tests
21
+ run: bundle exec rake run_spec:dummy
@@ -0,0 +1,37 @@
1
+ name: Generator specs
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ name: Generator specs
8
+ runs-on: ${{ matrix.os }}
9
+ strategy:
10
+ matrix:
11
+ os: [ubuntu-latest]
12
+ ruby: ['2.6', '2.7', '3.0']
13
+ gemfile:
14
+ - gemfiles/Gemfile-rails.6.0.x
15
+ - gemfiles/Gemfile-rails.6.1.x
16
+ - gemfiles/Gemfile-rails.7.0.x
17
+ # Uncomment the following line only to ensure compatibility with the
18
+ # upcomming Rails versions, maybe before a release.
19
+ #- gemfiles/Gemfile-rails-edge
20
+ exclude:
21
+ - ruby: 2.6
22
+ os: ubuntu-latest
23
+ gemfile: gemfiles/Gemfile-rails.7.0.x
24
+ - ruby: 2.6
25
+ os: ubuntu-latest
26
+ gemfile: gemfiles/Gemfile-rails-edge
27
+ env:
28
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
29
+
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: ${{ matrix.ruby }}
35
+ - name: Install dependencies
36
+ run: bundle install
37
+ - run: bundle exec rake run_spec:generator
@@ -1,6 +1,6 @@
1
1
  name: Jest specs
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  jest:
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  os: [ubuntu-latest]
11
- node: [12.x, 14.x, 16.x]
11
+ node: [14.x, 16.x, 18.x]
12
12
 
13
13
  runs-on: ${{ matrix.os }}
14
14
 
@@ -1,6 +1,6 @@
1
1
  name: JS lint
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  lint:
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  os: [ubuntu-latest]
11
- node: [12.x, 14.x, 16.x]
11
+ node: [14.x, 16.x, 18.x]
12
12
 
13
13
  runs-on: ${{ matrix.os }}
14
14
 
@@ -1,6 +1,6 @@
1
1
  name: Rubocop
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  rubocop:
@@ -1,6 +1,6 @@
1
1
  name: Ruby specs - Backward compatibility
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  test:
@@ -11,7 +11,6 @@ jobs:
11
11
  os: [ubuntu-latest]
12
12
  ruby: ['2.6', '2.7', '3.0']
13
13
  gemfile:
14
- - gemfiles/Gemfile-rails.5.2.x
15
14
  - gemfiles/Gemfile-rails.6.0.x
16
15
  - gemfiles/Gemfile-rails.6.1.x
17
16
  - gemfiles/Gemfile-rails.7.0.x
@@ -25,9 +24,6 @@ jobs:
25
24
  - ruby: 2.6
26
25
  os: ubuntu-latest
27
26
  gemfile: gemfiles/Gemfile-rails-edge
28
- - ruby: 3.0
29
- os: ubuntu-latest
30
- gemfile: gemfiles/Gemfile-rails.5.2.x
31
27
 
32
28
  env:
33
29
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
@@ -40,4 +36,4 @@ jobs:
40
36
  bundler-cache: true
41
37
 
42
38
  - name: Ruby specs - Backward compatibility
43
- run: bundle exec rake test_bc
39
+ run: bundle exec rake run_spec:gem_bc
@@ -1,6 +1,6 @@
1
1
  name: Ruby specs
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  test:
@@ -11,7 +11,6 @@ jobs:
11
11
  os: [ubuntu-latest]
12
12
  ruby: ['2.6', '2.7', '3.0']
13
13
  gemfile:
14
- - gemfiles/Gemfile-rails.5.2.x
15
14
  - gemfiles/Gemfile-rails.6.0.x
16
15
  - gemfiles/Gemfile-rails.6.1.x
17
16
  - gemfiles/Gemfile-rails.7.0.x
@@ -25,9 +24,6 @@ jobs:
25
24
  - ruby: 2.6
26
25
  os: ubuntu-latest
27
26
  gemfile: gemfiles/Gemfile-rails-edge
28
- - ruby: 3.0
29
- os: ubuntu-latest
30
- gemfile: gemfiles/Gemfile-rails.5.2.x
31
27
 
32
28
  env:
33
29
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
@@ -40,4 +36,4 @@ jobs:
40
36
  bundler-cache: true
41
37
 
42
38
  - name: Ruby specs
43
- run: bundle exec rake test
39
+ run: bundle exec rake run_spec:gem_bc
data/.gitignore CHANGED
@@ -12,3 +12,6 @@ yarn-error.log*
12
12
  /log
13
13
  gemfiles/*.lock
14
14
  .DS_Store
15
+
16
+ .yalc
17
+ yalc.lock
data/CHANGELOG.md CHANGED
@@ -8,8 +8,6 @@
8
8
  Changes since last non-beta release.
9
9
 
10
10
  _Please add entries here for your pull requests that are not yet released._
11
- ### Improved
12
- - Set CSS modules mode depending on file type. [PR 261](https://github.com/shakacode/shakapacker/pull/261) by [talyuk](https://github.com/talyuk).
13
11
 
14
12
  ### Breaking changes
15
13
  - Removes defaults passed to `@babel/preset-typescript`. [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
@@ -18,42 +16,43 @@ _Please add entries here for your pull requests that are not yet released._
18
16
 
19
17
  - Export immutable webpackConfig function. [PR 293](https://github.com/shakacode/shakapacker/pull/293) by [tomdracz](https://github.com/tomdracz).
20
18
 
21
- The `webpackConfig` property in the `shakapacker` module has been updated to be a function instead of a global mutable webpack configuration. This function now returns an immutable webpack configuration object, which ensures that any modifications made to it will not affect any other usage of the webpack configuration. If a project still requires the old mutable object, it can be accessed by replacing `webpackConfig` with `globalMutableWebpackConfig`.
19
+ The `webpackConfig` property in the `shakapacker` module has been updated to be a function instead of a global mutable webpack configuration. This function now returns an immutable webpack configuration object, which ensures that any modifications made to it will not affect any other usage of the webpack configuration. If a project still requires the old mutable object, it can be accessed by replacing `webpackConfig` with `globalMutableWebpackConfig`. Check [v7-upgrade](https://github.com/shakacode/shakapacker/blob/master/docs/v7_upgrade.md) documentation for more detail.
22
20
 
23
- ### Improved
24
- - Move compilation lock file into the working directory. [PR 272](https://github.com/shakacode/shakapacker/pull/272) by [tomdracz](https://github.com/tomdracz).
21
+ ### Added
22
+ - Set CSS modules mode depending on file type. [PR 261](https://github.com/shakacode/shakapacker/pull/261) by [talyuk](https://github.com/talyuk).
23
+ - All standard webpack entries with the camelCase format are now supported in `shakapacker.yml` in snake_case format. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha).
24
+ - The `shakapacker:install` rake task now has an option to force overriding files using `FORCE=true` environment variable [PR311](https://github.com/shakacode/shakapacker/pull/311) by [ahangarha](https://github.com/ahangarha).
25
+ - Allow configuration of use of contentHash for specific environment [PR 234](https://github.com/shakacode/shakapacker/pull/234) by [justin808](https://github/justin808).
25
26
 
26
27
  ### Changed
27
28
  - Rename Webpacker to Shakapacker in the entire project including config files, binstubs, environment variables, etc. with a high degree of backward compatibility.
28
29
 
29
30
  This change might be breaking for certain setups and edge cases. More information: [v7 Upgrade Guide](./docs/v7_upgrade.md) [PR157](https://github.com/shakacode/shakapacker/pull/157) by [ahangarha](https://github.com/ahangarha)
30
- - Set `source_entry_path` to `packs` and `nested_entries` to `true` in`shakapacker.yml` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
31
-
32
- ### Fixed
33
- - Process `source_entry_path` with values starting with `/` as a relative path to `source_path` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
34
31
 
32
+ - Set `source_entry_path` to `packs` and `nested_entries` to `true` in`shakapacker.yml` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
35
33
  - Dev server configuration is modified to follow [webpack recommended configurations](https://webpack.js.org/configuration/dev-server/) for dev server. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha):
36
- - Deprecated `https` entry is removed from the default configuration file, allowing to set `server` or `https` as per the project requirements. For more detail, check Webpack documentation. The `https` entry can be effective only if there is no `server` entry in the config file.
34
+ - Deprecated `https` entry is removed from the default configuration file, allowing to set `server` or `https` as per the project requirements. For more detail, check webpack documentation. The `https` entry can be effective only if there is no `server` entry in the config file.
37
35
  - `allowed_hosts` is now set to `auto` instead of `all` by default.
38
36
 
39
- - Removes defaults passed to `@babel/preset-typescript`. [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
40
-
41
- `@babel/preset-typescript` has been initialised in default configuration with `{ allExtensions: true, isTSX: true }` - meaning every file in the codebase was treated as TSX leading to potential issues. This has been removed and returns to sensible default of the preset which is to figure out the file type from the extensions. This change might affect generated output however so it is marked as breaking.
42
-
43
37
  - Remove the arbitrary stripping of the top-level directory when generating static file paths. [PR 283](https://github.com/shakacode/shakapacker/pull/283) by [tomdracz](https://github.com/tomdracz).
44
38
 
45
39
  Prior to this change, top level directory of static assets like images and fonts was stripped. This meant that file in `app/javascript/images/image.png` would be output to `static/image.png` directory and could be referenced through helpers as `image_pack_tag("image.jpg")` or `image_pack_tag("static/image.jpg")`.
46
40
 
47
41
  Going forward, the top level directory of static files will be retained so this will necessitate the update of file name references in asset helpers. In the example above, the file sourced from `app/javascript/images/image.png` will be now output to `static/images/image.png` and needs to be referenced as `image_pack_tag("images/image.jpg")` or `image_pack_tag("static/images/image.jpg")`.
48
42
 
43
+ ### Fixed
44
+ - Move compilation lock file into the working directory. [PR 272](https://github.com/shakacode/shakapacker/pull/272) by [tomdracz](https://github.com/tomdracz).
45
+ - Process `source_entry_path` with values starting with `/` as a relative path to `source_path` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
46
+ - Removes defaults passed to `@babel/preset-typescript` to make it possible to have projects with mix of JS and TS code [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
47
+
48
+ `@babel/preset-typescript` has been initialised in default configuration with `{ allExtensions: true, isTSX: true }` - meaning every file in the codebase was treated as TSX leading to potential issues. This has been removed and returns to sensible default of the preset which is to figure out the file type from the extensions. This change might affect generated output however so it is marked as breaking.
49
+
50
+ - Fixed RC version detection during installation. [PR312](https://github.com/shakacode/shakapacker/pull/312) by [ahangarha](https://github.com/ahangarha)
51
+ - Fix addition of webpack-dev-server to devDependencies during installation. [PR310](https://github.com/shakacode/shakapacker/pull/310) by [ahangarha](https://github.com/ahangarha)
49
52
  ### Removed
50
53
  - Remove redundant enhancement for precompile task to run `yarn install` [PR 270](https://github.com/shakacode/shakapacker/pull/270) by [ahangarha](https://github.com/ahangarha).
51
54
  - Remove deprecated `check_yarn_integrity` from `Shakapacker::Configuration` [PR SP288](https://github.com/shakacode/shakapacker/pull/288) by [ahangarha](https://github.com/ahangarha).
52
55
 
53
- ### Added
54
- - All standard Webpack entries with the camelCase format are now supported in `shakapacker.yml` in snake_case format. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha).
55
-
56
-
57
56
  ## [v6.6.0] - March 7, 2023
58
57
  ### Improved
59
58
  - Allow configuration of webpacker.yml through env variable. [PR 254](https://github.com/shakacode/shakapacker/pull/254) by [alecslupu](https://github.com/alecslupu).
data/CONTRIBUTING.md CHANGED
@@ -1,26 +1,60 @@
1
+ # Contributing Guidelines
2
+
3
+ Thank you for your interest in contributing to Shakapacker! We welcome all contributions that align with our project goals and values. To ensure a smooth and productive collaboration, please follow these guidelines.
4
+
1
5
  ## Contents
6
+ - [Reporting Issues](#reporting-issues)
7
+ - [Submitting Pull Requests](#submitting-pull-requests)
2
8
  - [Setting Up a Development Environment](#setting-up-a-development-environment)
3
9
  - [Making sure your changes pass all tests](#making-sure-your-changes-pass-all-tests)
4
10
  - [Testing the generator](#testing-the-generator)
5
- - [Find existing issues](#find-existing-issues)
6
11
 
7
- ---
8
- ## Setting Up a Development Environment
12
+ ## Reporting Issues
13
+ If you encounter any issues with the project, please first check the exisiting issues (including closed ones). If the issues is not reported before, please opening an issue on our GitHub repository. Please provide a clear and detailed description of the issue, including steps to reproduce it. Creating a demo repository to demonstrate the issue would be ideal (and in some cases necessary).
9
14
 
10
- 1. Install [Yarn](https://yarnpkg.com/)
15
+ If looking to contribute to the project by fixing existing issues, we recommend looking at issues, particularly with the "[help wanted](https://github.com/shakacode/shakapacker/issues?q=is%3Aissue+label%3A%22help+wanted%22)" label.
11
16
 
12
- 2. Run the following commands to set up the development environment.
17
+ ## Submitting Pull Requests
18
+ We welcome pull requests that fix bugs, add new features, or improve existing ones. Before submitting a pull request, please make sure to:
13
19
 
14
- ```
15
- bundle install
16
- yarn
17
- ```
20
+ - Open an issue about what you want to propose before start working on.
21
+ - Fork the repository and create a new branch for your changes.
22
+ - Write clear and concise commit messages.
23
+ - Follow our code style guidelines.
24
+ - Write tests for your changes and [make sure all tests pass](#making-sure-your-changes-pass-all-tests).
25
+ - Update the documentation as needed.
26
+ - Update CHANGELOG.md if the changes affect public behavior of the project.
27
+
28
+ ---
29
+ ## Setting Up a Development Environment
30
+
31
+ 1. Install [Yarn](https://classic.yarnpkg.com/)
32
+ 2. To test your changes on a Rails test project do the following steps:
33
+ - For Ruby gem, update `Gemfile` and point the `shakapacker` to the locally developing Shakapacker project:
34
+ ```ruby
35
+ gem 'shakapacker', path: "relative_or_absolute_path_to_local_shakapacker"
36
+ ```
37
+ - For npm package, use `yalc` with following steps:
38
+ ```bash
39
+ # In Shakapacker root directory
40
+ yalc publish
41
+ # In Rails app for testing
42
+ yalc link shakapacker
43
+
44
+ # After every chagnes in shakapacker, run the folloing in Shakapacker directory
45
+ yalc push # or yalc publish --push
46
+ ```
47
+ 3. Run the following commands to set up the development environment.
48
+ ```
49
+ bundle install
50
+ yarn install
51
+ ```
18
52
 
19
53
  ## Making sure your changes pass all tests
20
54
 
21
- There are a number of automated checks which run on GitHub Actions when a pull request is created.
55
+ There are several specs, covering different aspects of Shakapacker gem. You may run them locally or rely on GitHub CI actions configured to test the gem functionality if different Ruby, Rails, and Node environment.
22
56
 
23
- You can run those checks on your own locally to make sure that your changes would not break the CI build.
57
+ We request running tests locally to ensure the new changes would not break the CI build.
24
58
 
25
59
  ### 1. Check the code for JavaScript style violations
26
60
 
@@ -40,12 +74,14 @@ bundle exec rubocop
40
74
  yarn test
41
75
  ```
42
76
 
43
- ### 4. Run the Ruby test suite
77
+ ### 4. Run all the Ruby test suite
44
78
 
45
79
  ```
46
80
  bundle exec rake test
47
81
  ```
48
82
 
83
+ Note: For this, you need `yalc` to be installed on your local machine
84
+
49
85
  #### 4.1 Run a single ruby test file
50
86
 
51
87
  ```
@@ -58,15 +94,35 @@ bundle exec rspec spec/configuration_spec.rb
58
94
  bundle exec rspec -e "#source_entry_path returns correct path"
59
95
  ```
60
96
 
61
- ## Testing the generator
62
- If you change the generator, check that install instructions work.
97
+ #### 4.3 Run only Shakapacker gem specs
63
98
 
64
- 1. Update the gemfile so that gem "shakapacker" has a line like this, pointing to your install of shakapacker
99
+ ```
100
+ bundle exec rake run_spec:gem
101
+ ```
102
+
103
+ #### 4.4 Run only Shakapacker gem specs for backward compatibility
104
+ These specs are to check Shakapcker v7 backward compatibility with v6.x
105
+
106
+ ```
107
+ bundle exec rake run_spec:gem_bc
108
+ ```
109
+
110
+ #### 4.5 Run dummy app test
111
+ For this, you need `yalc` to be installed on your local machine
112
+
113
+ ```
114
+ bundle exec rake run_spec:dummy
115
+ ```
116
+
117
+ #### 4.6 Testing the installer
118
+ To ensure that your installer works as expected, either you can run `bundle exec rake run_spec:install`, or take the following manual testing steps:
119
+
120
+ 1. Update the `Gemfile` so that gem `shakapacker` has a line like this, pointing to your developing Shakapacker:
65
121
  ```ruby
66
- gem 'shakapacker', path: "~/shakacode/forks/shakapacker"
122
+ gem 'shakapacker', path: "relative_or_absolute_path_to_the_gem"
67
123
  ```
68
- 2. `bundle`
69
- 3. Run the generator confirm that you got the right changes.
124
+ 2. Run `bundle install` to install the updated gem.
125
+ 3. Run `bundle exec rails shakapacker:install` to confirm that you got the right changes.
126
+
127
+ **Note:** Ensure that you use bundle exec otherwise the installed shakapacker gem will run and not the one you are working on.
70
128
 
71
- ## Find existing issues
72
- You may look at the issues list to find existing known issues to be addressed. In this, we recommend to look at closed issues, particularly with "[help wanted](https://github.com/shakacode/shakapacker/issues?q=is%3Aissue+label%3A%22help+wanted%22+is%3Aclosed+)" label.
data/README.md CHANGED
@@ -144,6 +144,8 @@ Then run the following to install Shakapacker:
144
144
  ./bin/rails shakapacker:install
145
145
  ```
146
146
 
147
+ Before initiating the installation process, ensure you have committed all the changes. While installing Shakapacker, there might be some conflict between the existing file content and what Shakapacker tries to copy. You can either approve all the prompts for overriding these files or use the `FORCE=true` environment variable before the installation command to force the override without any prompt.
148
+
147
149
  When `package.json` and/or `yarn.lock` changes, such as when pulling down changes to your local environment in team settings, be sure to keep your NPM packages up-to-date:
148
150
 
149
151
  ```bash
@@ -214,6 +216,8 @@ Webpack intelligently includes only necessary files. In this example, the file `
214
216
 
215
217
  `nested_entries` allows you to have webpack entry points nested in subdirectories. This defaults to false so you don't accidentally create entry points for an entire tree of files. In other words, with `nested_entries: false`, you can have your entire `source_path` used for your source (using the `source_entry_path: /`) and you place files at the top level that you want as entry points. `nested_entries: true` allows you to have entries that are in subdirectories. This is useful if you have entries that are generated, so you can have a `generated` subdirectory and easily separate generated files from the rest of your codebase.
216
218
 
219
+ To enable/disable the usage of contentHash in any node environment (specified using the `NODE_ENV` environment variable), add/modify `useContentHash` with a boolean value in `config/shakapacker.yml`. This feature is disabled for all environments except production by default. You may not disable the content hash for a `NODE_ENV` of production as that would break the browser caching of assets. Notice that despite the possibility of enabling this option for the development environment, [it is not recommended](https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling).
220
+
217
221
  #### Setting custom config path
218
222
 
219
223
  You can use the environment variable `SHAKAPACKER_CONFIG` to enforce a particular path to the config file rather than the default `config/shakapacker.yml`.
@@ -854,7 +858,7 @@ This behavior is optional & can be disabled by either setting a `SHAKAPACKER_PRE
854
858
 
855
859
  When compiling assets for production on a remote server, such as a continuous integration environment, it's recommended to use `yarn install --frozen-lockfile` to install NPM packages on the remote host to ensure that the installed packages match the `yarn.lock` file.
856
860
 
857
- If you are using a CDN setup, Shakapacker will use the configured [asset host](https://guides.rubyonrails.org/configuring.html#rails-general-configuration) value to prefix URLs for images or font icons which are included inside JS code or CSS. It is possible to override this value during asset compilation by setting the `SHAKAPACKER_ASSET_HOST` environment variable.
861
+ If you are using a CDN setup, Shakapacker does NOT use the `ASSET_HOST` environment variable to prefix URLs for assets during bundle compilation. You must use the `SHAKAPACKER_ASSET_HOST` environment variable instead (`WEBPACKER_ASSET_HOST` if you're using any version of Webpacker or Shakapacker before Shakapacker v7).
858
862
 
859
863
  ## Example Apps
860
864
  * [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh)
data/Rakefile CHANGED
@@ -1,15 +1,51 @@
1
1
  # frozen_string_literal: true
2
2
  require "bundler/gem_tasks"
3
+ require "pathname"
3
4
 
4
- begin
5
- require "rspec/core/rake_task"
6
- RSpec::Core::RakeTask.new(:test)
7
- rescue LoadError
8
- end
5
+ desc "Run all specs"
6
+ task test: ["run_spec:all_specs"]
9
7
 
10
8
  task default: :test
11
9
 
12
- desc "Run backward compatibility specs"
13
- task :test_bc do
14
- system("bundle exec rspec spec/backward_compatibility_specs/*_spec_bc.rb")
10
+ namespace :run_spec do
11
+ desc "Run shakapacker specs"
12
+ task :gem do
13
+ puts "Running Shakapacker gem specs"
14
+ sh("bundle exec rspec spec/shakapacker/*_spec.rb")
15
+ end
16
+
17
+ desc "Run backward compatibility specs"
18
+ task :gem_bc do
19
+ puts "Running Shakapacker gem specs for backward compatibility"
20
+ sh("bundle exec rspec spec/backward_compatibility_specs/*_spec.rb")
21
+ end
22
+
23
+ desc "Run specs in the dummy app"
24
+ task :dummy do
25
+ puts "Running dummy app specs"
26
+ spec_dummy_dir = Pathname.new(File.join("spec", "dummy")).realpath
27
+ Bundler.with_unbundled_env do
28
+ sh_in_dir(".", "yalc publish")
29
+ sh_in_dir(spec_dummy_dir, [
30
+ "bundle install",
31
+ "yalc link shakapacker",
32
+ "yarn install",
33
+ "bundle exec rspec"
34
+ ])
35
+ end
36
+ end
37
+
38
+ desc "Run generator specs"
39
+ task :generator do
40
+ sh("bundle exec rspec spec/generator_specs/*_spec.rb")
41
+ end
42
+
43
+ desc "Run all specs"
44
+ task all_specs: %i[gem gem_bc dummy generator] do
45
+ puts "Completed all RSpec tests"
46
+ end
47
+ end
48
+
49
+ def sh_in_dir(dir, *shell_commands)
50
+ Shakapacker::Utils::Misc.sh_in_dir(dir, *shell_commands)
15
51
  end
data/docs/deployment.md CHANGED
@@ -88,8 +88,7 @@ Now, you can set `brotli_static on;` in your nginx site config, as per the confi
88
88
 
89
89
  ## CDN
90
90
 
91
- Shakapacker out-of-the-box provides CDN support using your Rails app `config.action_controller.asset_host` setting. If you already have [CDN](http://guides.rubyonrails.org/asset_pipeline.html#cdns) added in your Rails app
92
- you don't need to do anything extra for Shakapacker, it just works.
91
+ If you are using a CDN setup, Shakapacker does NOT use the `ASSET_HOST` environment variable to prefix URLs for assets during bundle compilation. You must use the `SHAKAPACKER_ASSET_HOST` environment variable instead (`WEBPACKER_ASSET_HOST` if you're using any version of Webpacker or Shakapacker before Shakapacker v7).
93
92
 
94
93
  ## Capistrano
95
94
 
@@ -1,4 +1,6 @@
1
+ force_option = ENV["FORCE"] ? { force: true } : {}
2
+
1
3
  say "Copying binstubs"
2
- directory "#{__dir__}/bin", "bin"
4
+ directory "#{__dir__}/bin", "bin", force_option
3
5
 
4
6
  chmod "bin", 0755 & ~File.umask, verbose: false
@@ -1,4 +1,5 @@
1
1
  # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
+ # This file contains the defaults used by shakapacker.
2
3
 
3
4
  default: &default
4
5
  source_path: app/javascript
@@ -44,6 +45,11 @@ default: &default
44
45
  # Select whether the compiler will use SHA digest ('digest' option) or most most recent modified timestamp ('mtime') to determine freshness
45
46
  compiler_strategy: digest
46
47
 
48
+ # Select whether the compiler will always use a content hash and not just in production
49
+ # Don't use contentHash except for production for performance
50
+ # https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
51
+ useContentHash: false
52
+
47
53
  development:
48
54
  <<: *default
49
55
  compile: true
@@ -105,5 +111,8 @@ production:
105
111
  # Production depends on precompilation of packs prior to booting for performance.
106
112
  compile: false
107
113
 
114
+ # Use content hash for naming assets. Cannot be overridden by for production.
115
+ useContentHash: true
116
+
108
117
  # Cache manifest.json for performance
109
118
  cache_manifest: true
@@ -1,5 +1,6 @@
1
- const { webpackConfig } = require('shakapacker')
2
-
3
1
  // See the shakacode/shakapacker README and docs directory for advice on customizing your webpackConfig.
2
+ const { generateWebpackConfig } = require('shakapacker')
3
+
4
+ const webpackConfig = generateWebpackConfig()
4
5
 
5
6
  module.exports = webpackConfig
@@ -1,9 +1,14 @@
1
+ require "shakapacker/utils/version_syntax_converter"
2
+
1
3
  # Install Shakapacker
2
- copy_file "#{__dir__}/config/shakapacker.yml", "config/shakapacker.yml"
3
- copy_file "#{__dir__}/package.json", "package.json"
4
+
5
+ force_option = ENV["FORCE"] ? { force: true } : {}
6
+
7
+ copy_file "#{__dir__}/config/shakapacker.yml", "config/shakapacker.yml", force_option
8
+ copy_file "#{__dir__}/package.json", "package.json", force_option
4
9
 
5
10
  say "Copying webpack core config"
6
- directory "#{__dir__}/config/webpack", "config/webpack"
11
+ directory "#{__dir__}/config/webpack", "config/webpack", force_option
7
12
 
8
13
  if Dir.exist?(Shakapacker.config.source_path)
9
14
  say "The packs app source directory already exists"
@@ -68,26 +73,33 @@ end
68
73
  results = []
69
74
 
70
75
  Dir.chdir(Rails.root) do
71
- if Shakapacker::VERSION.match?(/^[0-9]+\.[0-9]+\.[0-9]+$/)
72
- say "Installing shakapacker@#{Shakapacker::VERSION}"
73
- results << run("yarn add shakapacker@#{Shakapacker::VERSION} --exact")
74
- else
75
- say "Installing shakapacker@next"
76
- results << run("yarn add shakapacker@next --exact")
77
- end
76
+ npm_version = Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(Shakapacker::VERSION)
77
+ say "Installing shakapacker@#{npm_version}"
78
+ results << run("yarn add shakapacker@#{npm_version} --exact")
78
79
 
79
80
  package_json = File.read("#{__dir__}/../../package.json")
80
81
  peers = JSON.parse(package_json)["peerDependencies"]
81
- peers_to_add = peers.reduce([]) do |result, (package, version)|
82
+ dev_dependency_packages = ["webpack-dev-server"]
83
+
84
+ dependencies_to_add = []
85
+ dev_dependencies_to_add = []
86
+
87
+ peers.each do |(package, version)|
82
88
  major_version = version.match(/(\d+)/)[1]
83
- result << "#{package}@#{major_version}"
84
- end.join(" ")
89
+ entry = "#{package}@#{major_version}"
90
+
91
+ if dev_dependency_packages.include? package
92
+ dev_dependencies_to_add << entry
93
+ else
94
+ dependencies_to_add << entry
95
+ end
96
+ end
85
97
 
86
98
  say "Adding shakapacker peerDependencies"
87
- results << run("yarn add #{peers_to_add}")
99
+ results << run("yarn add #{dependencies_to_add.join(' ')}")
88
100
 
89
101
  say "Installing webpack-dev-server for live reloading as a development dependency"
90
- results << run("yarn add --dev webpack-dev-server")
102
+ results << run("yarn add --dev #{dev_dependencies_to_add.join(' ')}")
91
103
  end
92
104
 
93
105
  unless results.all?