shakapacker 6.6.0 → 7.0.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-backward-compatibility.yml +43 -0
  3. data/CHANGELOG.md +50 -4
  4. data/CONTRIBUTING.md +4 -4
  5. data/Gemfile.development_dependencies +1 -1
  6. data/README.md +113 -88
  7. data/Rakefile +5 -0
  8. data/config/shakapacker.yml +1 -0
  9. data/docs/deployment.md +12 -10
  10. data/docs/developing_webpacker.md +5 -5
  11. data/docs/react.md +10 -6
  12. data/docs/style_loader_vs_mini_css.md +2 -2
  13. data/docs/troubleshooting.md +22 -18
  14. data/docs/using_esbuild_loader.md +5 -3
  15. data/docs/using_swc_loader.md +2 -2
  16. data/docs/v6_upgrade.md +2 -2
  17. data/docs/v7_upgrade.md +56 -0
  18. data/lib/install/bin/shakapacker +13 -0
  19. data/lib/install/bin/shakapacker-dev-server +13 -0
  20. data/lib/install/config/{webpacker.yml → shakapacker.yml} +13 -8
  21. data/lib/install/template.rb +7 -7
  22. data/lib/{webpacker → shakapacker}/base_strategy.rb +2 -2
  23. data/lib/{webpacker → shakapacker}/commands.rb +4 -4
  24. data/lib/{webpacker → shakapacker}/compiler.rb +43 -15
  25. data/lib/{webpacker → shakapacker}/compiler_strategy.rb +6 -6
  26. data/lib/{webpacker → shakapacker}/configuration.rb +52 -21
  27. data/lib/shakapacker/deprecation_helper.rb +88 -0
  28. data/lib/{webpacker → shakapacker}/dev_server.rb +27 -4
  29. data/lib/{webpacker → shakapacker}/dev_server_proxy.rb +4 -4
  30. data/lib/shakapacker/dev_server_runner.rb +104 -0
  31. data/lib/{webpacker → shakapacker}/digest_strategy.rb +6 -6
  32. data/lib/{webpacker → shakapacker}/env.rb +8 -8
  33. data/lib/{webpacker → shakapacker}/helper.rb +20 -20
  34. data/lib/{webpacker → shakapacker}/instance.rb +13 -10
  35. data/lib/{webpacker → shakapacker}/manifest.rb +14 -14
  36. data/lib/{webpacker → shakapacker}/mtime_strategy.rb +5 -5
  37. data/lib/shakapacker/railtie.rb +70 -0
  38. data/lib/shakapacker/runner.rb +28 -0
  39. data/lib/shakapacker/utils/version_syntax_converter.rb +2 -2
  40. data/lib/{webpacker → shakapacker}/version.rb +2 -2
  41. data/lib/{webpacker → shakapacker}/version_checker.rb +8 -8
  42. data/lib/shakapacker/webpack_runner.rb +67 -0
  43. data/lib/shakapacker.rb +51 -1
  44. data/lib/tasks/shakapacker/binstubs.rake +15 -0
  45. data/lib/tasks/shakapacker/check_binstubs.rake +25 -0
  46. data/lib/tasks/shakapacker/check_node.rake +31 -0
  47. data/lib/tasks/shakapacker/check_yarn.rake +33 -0
  48. data/lib/tasks/shakapacker/clean.rake +23 -0
  49. data/lib/tasks/shakapacker/clobber.rake +18 -0
  50. data/lib/tasks/shakapacker/compile.rake +31 -0
  51. data/lib/tasks/shakapacker/info.rake +21 -0
  52. data/lib/tasks/shakapacker/install.rake +17 -0
  53. data/lib/tasks/shakapacker/verify_config.rake +12 -0
  54. data/lib/tasks/shakapacker/verify_install.rake +4 -0
  55. data/lib/tasks/shakapacker/yarn_install.rake +24 -0
  56. data/lib/tasks/shakapacker.rake +18 -0
  57. data/lib/tasks/webpacker/binstubs.rake +5 -11
  58. data/lib/tasks/webpacker/check_binstubs.rake +6 -9
  59. data/lib/tasks/webpacker/check_node.rake +5 -27
  60. data/lib/tasks/webpacker/check_yarn.rake +5 -29
  61. data/lib/tasks/webpacker/clean.rake +5 -19
  62. data/lib/tasks/webpacker/clobber.rake +6 -13
  63. data/lib/tasks/webpacker/compile.rake +5 -33
  64. data/lib/tasks/webpacker/info.rake +5 -17
  65. data/lib/tasks/webpacker/install.rake +5 -13
  66. data/lib/tasks/webpacker/verify_config.rake +6 -11
  67. data/lib/tasks/webpacker/verify_install.rake +7 -2
  68. data/lib/tasks/webpacker/yarn_install.rake +5 -20
  69. data/lib/tasks/webpacker.rake +15 -13
  70. data/lib/webpacker/dev_server_runner.rb +9 -96
  71. data/lib/webpacker/webpack_runner.rb +9 -58
  72. data/lib/webpacker.rb +3 -47
  73. data/package/__tests__/config-bc.js +27 -0
  74. data/package/__tests__/config.js +6 -5
  75. data/package/__tests__/dev_server-bc.js +46 -0
  76. data/package/__tests__/dev_server.js +9 -8
  77. data/package/__tests__/development-bc.js +66 -0
  78. data/package/__tests__/development.js +36 -5
  79. data/package/__tests__/env-bc.js +59 -0
  80. data/package/__tests__/env.js +3 -2
  81. data/package/__tests__/index.js +13 -0
  82. data/package/__tests__/production-bc.js +51 -0
  83. data/package/__tests__/production.js +25 -3
  84. data/package/__tests__/staging-bc.js +53 -0
  85. data/package/__tests__/staging.js +27 -4
  86. data/package/__tests__/test-bc.js +43 -0
  87. data/package/__tests__/test.js +22 -4
  88. data/package/babel/preset.js +1 -4
  89. data/package/config.js +25 -7
  90. data/package/dev_server.js +7 -4
  91. data/package/env.js +22 -3
  92. data/package/environments/__tests__/base-bc.js +107 -0
  93. data/package/environments/__tests__/base.js +13 -13
  94. data/package/environments/base.js +1 -1
  95. data/package/environments/development.js +4 -46
  96. data/package/environments/production.js +1 -1
  97. data/package/index.js +11 -4
  98. data/package/rules/__tests__/__utils__/webpack.js +1 -1
  99. data/package/rules/__tests__/file.js +27 -0
  100. data/package/rules/__tests__/swc.js +1 -2
  101. data/package/rules/file.js +2 -2
  102. data/package/utils/configPath.js +19 -0
  103. data/package/utils/defaultConfigPath.js +2 -0
  104. data/package/utils/get_style_rule.js +5 -2
  105. data/package/utils/helpers.js +24 -1
  106. data/package/utils/inliningCss.js +7 -0
  107. data/package/utils/snakeToCamelCase +7 -0
  108. data/package/webpackDevServerConfig.js +68 -0
  109. data/package.json +2 -2
  110. data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
  111. data/spec/backward_compatibility_specs/command_spec_bc.rb +116 -0
  112. data/spec/backward_compatibility_specs/compiler_spec_bc.rb +59 -0
  113. data/spec/backward_compatibility_specs/compiler_strategy_spec_bc.rb +22 -0
  114. data/spec/backward_compatibility_specs/configuration_spec_bc.rb +286 -0
  115. data/spec/backward_compatibility_specs/dev_server_runner_spec_bc.rb +79 -0
  116. data/spec/backward_compatibility_specs/dev_server_spec_bc.rb +47 -0
  117. data/spec/backward_compatibility_specs/digest_strategy_spec_bc.rb +35 -0
  118. data/spec/backward_compatibility_specs/engine_rake_tasks_spec_bc.rb +44 -0
  119. data/spec/backward_compatibility_specs/env_spec_bc.rb +23 -0
  120. data/spec/backward_compatibility_specs/helper_spec_bc.rb +243 -0
  121. data/spec/backward_compatibility_specs/instance_spec_bc.rb +31 -0
  122. data/spec/backward_compatibility_specs/manifest_spec_bc.rb +100 -0
  123. data/spec/backward_compatibility_specs/mtime_strategy_spec_bc.rb +55 -0
  124. data/spec/backward_compatibility_specs/rake_tasks_spec_bc.rb +37 -0
  125. data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
  126. data/spec/backward_compatibility_specs/webpack_runner_spec_bc.rb +56 -0
  127. data/spec/backward_compatibility_specs/webpacker_spec_bc.rb +41 -0
  128. data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
  129. data/spec/backward_compatibility_specs/webpacker_test_app/Rakefile +3 -0
  130. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/application.js +1 -1
  131. data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker +0 -0
  132. data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +11 -0
  133. data/spec/backward_compatibility_specs/webpacker_test_app/config/environment.rb +4 -0
  134. data/spec/backward_compatibility_specs/webpacker_test_app/config/initializers/inspect_autoload_paths.rb +1 -0
  135. data/spec/backward_compatibility_specs/webpacker_test_app/config/webpack/webpack.config.js +0 -0
  136. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
  137. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
  138. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_defaults_fallback.yml +1 -1
  139. data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +7 -0
  140. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_other_location.yml +1 -1
  141. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_public_root.yml +1 -1
  142. data/spec/backward_compatibility_specs/webpacker_test_app/config.ru +5 -0
  143. data/spec/backward_compatibility_specs/webpacker_test_app/package.json +13 -0
  144. data/spec/backward_compatibility_specs/webpacker_test_app/public/packs/manifest.json +58 -0
  145. data/spec/backward_compatibility_specs/webpacker_test_app/some.config.js +0 -0
  146. data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +1 -0
  147. data/spec/backward_compatibility_specs/webpacker_test_app/yarn.lock +11 -0
  148. data/spec/command_spec.rb +18 -16
  149. data/spec/compiler_spec.rb +19 -17
  150. data/spec/compiler_strategy_spec.rb +9 -7
  151. data/spec/configuration_spec.rb +108 -66
  152. data/spec/dev_server_runner_spec.rb +9 -8
  153. data/spec/dev_server_spec.rb +97 -9
  154. data/spec/digest_strategy_spec.rb +4 -2
  155. data/spec/engine_rake_tasks_spec.rb +12 -16
  156. data/spec/env_spec.rb +7 -5
  157. data/spec/helper_spec.rb +4 -2
  158. data/spec/instance_spec.rb +31 -0
  159. data/spec/manifest_spec.rb +21 -19
  160. data/spec/mounted_app/test/dummy/config/application.rb +1 -1
  161. data/spec/mounted_app/test/dummy/config/webpacker.yml +3 -3
  162. data/spec/mtime_strategy_spec.rb +4 -2
  163. data/spec/rake_tasks_spec.rb +20 -18
  164. data/spec/spec_helper.rb +0 -25
  165. data/spec/spec_helper_initializer.rb +24 -0
  166. data/spec/test_app/.gitignore +2 -0
  167. data/spec/test_app/app/javascript/entrypoints/application.js +10 -0
  168. data/spec/test_app/app/javascript/entrypoints/generated/something.js +2 -0
  169. data/spec/test_app/app/javascript/entrypoints/multi_entry.css +4 -0
  170. data/spec/test_app/app/javascript/entrypoints/multi_entry.js +4 -0
  171. data/spec/test_app/bin/{webpacker-dev-server → shakapacker} +3 -3
  172. data/spec/test_app/bin/{webpacker → shakapacker-dev-server} +3 -3
  173. data/spec/test_app/config/application.rb +1 -1
  174. data/spec/test_app/config/shakapacker.yml +82 -0
  175. data/spec/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +84 -0
  176. data/spec/test_app/config/shakapacker_defaults_fallback.yml +11 -0
  177. data/spec/test_app/config/shakapacker_manifest_path.yml +80 -0
  178. data/spec/test_app/config/shakapacker_nested_entries.yml +83 -0
  179. data/spec/test_app/config/shakapacker_no_precompile.yml +7 -0
  180. data/spec/test_app/config/shakapacker_other_location.yml +85 -0
  181. data/spec/test_app/config/shakapacker_public_root.yml +18 -0
  182. data/spec/version_checker_spec.rb +16 -15
  183. data/spec/webpack_runner_spec.rb +4 -3
  184. data/spec/webpacker_spec.rb +9 -29
  185. metadata +119 -44
  186. data/config/webpacker.yml +0 -1
  187. data/lib/webpacker/railtie.rb +0 -70
  188. data/lib/webpacker/runner.rb +0 -23
  189. data/package/configPath.js +0 -3
  190. data/package/inliningCss.js +0 -7
  191. data/spec/test_app/config/webpacker_no_precompile.yml +0 -7
  192. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
  193. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
  194. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.js +0 -0
  195. /data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker-dev-server +0 -0
  196. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
  197. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_nested_entries.yml +0 -0
@@ -0,0 +1,56 @@
1
+ require_relative "spec_helper_initializer"
2
+ # Requiring from webpacker directory to ensure old ./bin/webpacker-dev-server works fine
3
+ require "webpacker/webpack_runner"
4
+
5
+ describe "WebpackRunner" do
6
+ before :all do
7
+ @original_node_env, ENV["NODE_ENV"] = ENV["NODE_ENV"], "development"
8
+ @original_rails_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "development"
9
+ end
10
+
11
+ after :all do
12
+ ENV["NODE_ENV"] = @original_node_env
13
+ ENV["RAILS_ENV"] = @original_rails_env
14
+ end
15
+
16
+ it "runs cmd via node_modules" do
17
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
18
+
19
+ verify_command(cmd, use_node_modules: true)
20
+ end
21
+
22
+ it "runs cmd via yarn" do
23
+ cmd = ["yarn", "webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
24
+
25
+ verify_command(cmd, use_node_modules: false)
26
+ end
27
+
28
+ it "runs cmd argv" do
29
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--watch"]
30
+
31
+ verify_command(cmd, argv: ["--watch"])
32
+ end
33
+
34
+ private
35
+ def test_app_path
36
+ File.expand_path("webpacker_test_app", __dir__)
37
+ end
38
+
39
+ def verify_command(cmd, use_node_modules: true, argv: [])
40
+ cwd = Dir.pwd
41
+ Dir.chdir(test_app_path)
42
+
43
+ klass = Webpacker::WebpackRunner
44
+ instance = klass.new(argv)
45
+
46
+ allow(klass).to receive(:new).and_return(instance)
47
+ allow(instance).to receive(:node_modules_bin_exist?).and_return(use_node_modules)
48
+ allow(Kernel).to receive(:exec)
49
+
50
+ klass.run(argv)
51
+
52
+ expect(Kernel).to have_received(:exec).with(Webpacker::Compiler.env, *cmd)
53
+ ensure
54
+ Dir.chdir(cwd)
55
+ end
56
+ end
@@ -0,0 +1,41 @@
1
+ require_relative "spec_helper_initializer"
2
+
3
+ describe "webpacker" do
4
+ describe "#inline_css?" do
5
+ let(:dev_server) { instance_double("Webpacker::DevServer") }
6
+
7
+ before :each do
8
+ allow(dev_server).to receive(:host).and_return("localhost")
9
+ allow(dev_server).to receive(:port).and_return("3035")
10
+ allow(dev_server).to receive(:pretty?).and_return(false)
11
+ allow(dev_server).to receive(:https?).and_return(true)
12
+ allow(dev_server).to receive(:running?).and_return(true)
13
+ end
14
+
15
+ it "returns nil with disabled dev_server" do
16
+ expect(Webpacker.inlining_css?).to be nil
17
+ end
18
+
19
+ it "returns true with enabled hmr" do
20
+ allow(dev_server).to receive(:hmr?).and_return(true)
21
+ allow(dev_server).to receive(:inline_css?).and_return(true)
22
+
23
+ allow(Webpacker.instance).to receive(:dev_server).and_return(dev_server)
24
+
25
+ expect(Webpacker.inlining_css?).to be true
26
+ end
27
+
28
+ it "returns false with enabled hmr and explicitly setting inline_css to false" do
29
+ allow(dev_server).to receive(:hmr?).and_return(true)
30
+ allow(dev_server).to receive(:inline_css?).and_return(false)
31
+
32
+ allow(Webpacker.instance).to receive(:dev_server).and_return(dev_server)
33
+
34
+ expect(Webpacker.inlining_css?).to be false
35
+ end
36
+ end
37
+
38
+ it "has app_autoload_paths cleanup" do
39
+ expect($test_app_autoload_paths_in_initializer).to eq []
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ require_relative "config/application"
2
+
3
+ Rails.application.load_tasks
@@ -7,4 +7,4 @@
7
7
  // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8
8
  // layout file, like app/views/layouts/application.html.erb
9
9
 
10
- console.log('Hello World from Webpacker')
10
+ console.log('Hello World from shakapacker')
@@ -0,0 +1,11 @@
1
+ require "action_controller/railtie"
2
+ require "action_view/railtie"
3
+ require "shakapacker"
4
+
5
+ module WebpackerTestApp
6
+ class Application < ::Rails::Application
7
+ config.secret_key_base = "abcdef"
8
+ config.eager_load = true
9
+ config.active_support.test_order = :sorted
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ require_relative "application"
2
+
3
+ Rails.backtrace_cleaner.remove_silencers!
4
+ Rails.application.initialize!
@@ -0,0 +1 @@
1
+ $test_app_autoload_paths_in_initializer = ActiveSupport::Dependencies.autoload_paths
@@ -1,4 +1,4 @@
1
- # Note: You must restart bin/webpacker-dev-server for changes to take effect
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
4
  source_path: app/packs
@@ -1,4 +1,4 @@
1
- # Note: You must restart bin/webpacker-dev-server for changes to take effect
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
4
  source_path: app/packs
@@ -1,4 +1,4 @@
1
- # Note: You must restart bin/webpacker-dev-server for changes to take effect
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
4
  # cache_manifest will be fetched from bundled defaults
@@ -0,0 +1,7 @@
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ webpacker_precompile: false
5
+
6
+ production:
7
+ <<: *default
@@ -1,4 +1,4 @@
1
- # Note: You must restart bin/webpacker-dev-server for changes to take effect
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
4
  source_path: app/packs
@@ -1,4 +1,4 @@
1
- # Note: You must restart bin/webpacker-dev-server for changes to take effect
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
4
  public_root_path: ../public
@@ -0,0 +1,5 @@
1
+ # This file allows the `Rails.root` to be correctly determined.
2
+
3
+ require_relative "config/environment"
4
+
5
+ run Rails.application
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "webpacker_test_app",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "license": "MIT",
6
+ "private": true,
7
+ "dependencies": {
8
+ "left-pad": "^1.2.0"
9
+ },
10
+ "devDependencies": {
11
+ "right-pad": "^1.0.1"
12
+ }
13
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "bootstrap.css": "/packs/bootstrap-c38deda30895059837cf.css",
3
+ "application.css": "/packs/application-dd6b1cd38bfa093df600.css",
4
+ "bootstrap.js": "/packs/bootstrap-300631c4f0e0f9c865bc.js",
5
+ "main.js": "/packs/main-e323a53c7f30f5d53cbb.js",
6
+ "application.js": "/packs/application-k344a6d59eef8632c9d1.js",
7
+ "application.png": "/packs/application-k344a6d59eef8632c9d1.png",
8
+ "fonts/fa-regular-400.woff2": "/packs/fonts/fa-regular-400-944fb546bd7018b07190a32244f67dc9.woff2",
9
+ "static/image.jpg": "/packs/static/image-c38deda30895059837cf.jpg",
10
+ "static/image-2x.jpg": "/packs/static/image-2x-7cca48e6cae66ec07b8e.jpg",
11
+ "static/nested/image.jpg": "/packs/static/nested/image-c38deda30895059837cf.jpg",
12
+ "static/mb-icon.png": "/packs/static/mb-icon-c38deda30895059837cf.png",
13
+ "static/nested/mb-icon.png": "/packs/static/nested/mb-icon-c38deda30895059837cf.png",
14
+ "entrypoints": {
15
+ "application": {
16
+ "assets": {
17
+ "js": [
18
+ "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
19
+ "/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js",
20
+ "/packs/application-k344a6d59eef8632c9d1.js"
21
+ ],
22
+ "css": [
23
+ "/packs/1-c20632e7baf2c81200d3.chunk.css",
24
+ "/packs/application-k344a6d59eef8632c9d1.chunk.css"
25
+ ]
26
+ }
27
+ },
28
+ "bootstrap": {
29
+ "assets": {
30
+ "js": [
31
+ "/packs/bootstrap-300631c4f0e0f9c865bc.js"
32
+ ]
33
+ }
34
+ },
35
+ "main": {
36
+ "assets": {
37
+ "js": [
38
+ "/packs/main-e323a53c7f30f5d53cbb.js"
39
+ ]
40
+ }
41
+ },
42
+ "hello_stimulus": {
43
+ "assets": {
44
+ "css": [
45
+ "/packs/1-c20632e7baf2c81200d3.chunk.css",
46
+ "/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css"
47
+ ]
48
+ }
49
+ },
50
+ "print/application": {
51
+ "assets": {
52
+ "css": [
53
+ "/packs/print/application-983b6c164a47f7ed49cd.css"
54
+ ]
55
+ }
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,11 @@
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ left-pad@^1.2.0:
6
+ version "1.2.0"
7
+ resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
8
+
9
+ right-pad@^1.0.1:
10
+ version "1.0.1"
11
+ resolved "https://registry.yarnpkg.com/right-pad/-/right-pad-1.0.1.tgz#8ca08c2cbb5b55e74dafa96bf7fd1a27d568c8d0"
data/spec/command_spec.rb CHANGED
@@ -1,27 +1,29 @@
1
+ require_relative "spec_helper_initializer"
2
+
1
3
  describe "Command" do
2
4
  before do
3
- allow(Webpacker.logger).to receive(:info)
5
+ allow(Shakapacker.logger).to receive(:info)
4
6
  end
5
7
 
6
8
  describe "#compile" do
7
9
  it "returns success status when stale" do
8
- expect(Webpacker.compiler).to receive(:stale?).and_return(true)
9
- expect(Webpacker.compiler).to receive(:run_webpack).and_return(true)
10
+ expect(Shakapacker.compiler).to receive(:stale?).and_return(true)
11
+ expect(Shakapacker.compiler).to receive(:run_webpack).and_return(true)
10
12
 
11
- expect(Webpacker.commands.compile).to be true
13
+ expect(Shakapacker.commands.compile).to be true
12
14
  end
13
15
 
14
16
  it "returns success status when fresh" do
15
- expect(Webpacker.compiler).to receive(:stale?).and_return(false)
17
+ expect(Shakapacker.compiler).to receive(:stale?).and_return(false)
16
18
 
17
- expect(Webpacker.commands.compile).to be true
19
+ expect(Shakapacker.commands.compile).to be true
18
20
  end
19
21
 
20
22
  it "returns failure status when stale" do
21
- expect(Webpacker.compiler).to receive(:stale?).and_return(true)
22
- expect(Webpacker.compiler).to receive(:run_webpack).and_return(false)
23
+ expect(Shakapacker.compiler).to receive(:stale?).and_return(true)
24
+ expect(Shakapacker.compiler).to receive(:run_webpack).and_return(false)
23
25
 
24
- expect(Webpacker.commands.compile).to be false
26
+ expect(Shakapacker.commands.compile).to be false
25
27
  end
26
28
  end
27
29
 
@@ -30,7 +32,7 @@ describe "Command" do
30
32
  let(:prev_files) do
31
33
  # Test assets to be kept and deleted, path and mtime
32
34
  {
33
- # recent versions to be kept with Webpacker.commands.clean(count = 2)
35
+ # recent versions to be kept with Shakapacker.commands.clean(count = 2)
34
36
  "js/application-deadbeef.js" => now - 4000,
35
37
  "js/common-deadbeee.js" => now - 4002,
36
38
  "css/common-deadbeed.css" => now - 4004,
@@ -39,12 +41,12 @@ describe "Command" do
39
41
  "js/common-1eadbeee.js" => now - 8002,
40
42
  "css/common-1eadbeed.css" => now - 8004,
41
43
  "media/images/logo-1eadbeeb.css" => now - 8006,
42
- # new files to be kept with Webpacker.commands.clean(age = 3600)
44
+ # new files to be kept with Shakapacker.commands.clean(age = 3600)
43
45
  "js/brandnew-0001.js" => now,
44
46
  "js/brandnew-0002.js" => now - 10,
45
47
  "js/brandnew-0003.js" => now - 20,
46
48
  "js/brandnew-0004.js" => now - 40,
47
- }.transform_keys { |path| "#{Webpacker.config.public_output_path}/#{path}" }
49
+ }.transform_keys { |path| "#{Shakapacker.config.public_output_path}/#{path}" }
48
50
  end
49
51
 
50
52
  let(:expired_files) do
@@ -54,7 +56,7 @@ describe "Command" do
54
56
  "js/common-0eadbeee.js" => now - 9002,
55
57
  "css/common-0eadbeed.css" => now - 9004,
56
58
  "js/brandnew-0005.js" => now - 3640,
57
- }.transform_keys { |path| "#{Webpacker.config.public_output_path}/#{path}" }
59
+ }.transform_keys { |path| "#{Shakapacker.config.public_output_path}/#{path}" }
58
60
  end
59
61
 
60
62
  let(:all_files) { prev_files.merge(expired_files) }
@@ -66,7 +68,7 @@ describe "Command" do
66
68
  before :context do
67
69
  @dir_glob_stub = Proc.new { |arg|
68
70
  case arg
69
- when "#{Webpacker.config.public_output_path}/**/*"
71
+ when "#{Shakapacker.config.public_output_path}/**/*"
70
72
  all_files.keys
71
73
  else
72
74
  []
@@ -76,7 +78,7 @@ describe "Command" do
76
78
 
77
79
  it "works with nested hashes and without any compiled files" do
78
80
  allow(File).to receive(:delete).and_return(true)
79
- expect(Webpacker.commands.clean).to be true
81
+ expect(Shakapacker.commands.clean).to be true
80
82
  end
81
83
 
82
84
  it "deletes only and only expired versioned files if no parameter passed" do
@@ -85,7 +87,7 @@ describe "Command" do
85
87
  end
86
88
 
87
89
  with_time_dir_and_files_stub do
88
- expect(Webpacker.commands.clean).to be true
90
+ expect(Shakapacker.commands.clean).to be true
89
91
 
90
92
  # Verify that only and only expired files are deleted
91
93
  all_files.keys.each do |longpath|
@@ -1,32 +1,34 @@
1
- describe "Webpacker::Compiler" do
1
+ require_relative "spec_helper_initializer"
2
+
3
+ describe "Shakapacker::Compiler" do
2
4
  it "accepts custom environment variables" do
3
- expect(Webpacker.compiler.send(:webpack_env)["FOO"]).to be nil
5
+ expect(Shakapacker.compiler.send(:webpack_env)["FOO"]).to be nil
4
6
 
5
- Webpacker.compiler.env["FOO"] = "BAR"
6
- expect(Webpacker.compiler.send(:webpack_env)["FOO"]).to eq "BAR"
7
+ Shakapacker.compiler.env["FOO"] = "BAR"
8
+ expect(Shakapacker.compiler.send(:webpack_env)["FOO"]).to eq "BAR"
7
9
  ensure
8
- Webpacker.compiler.env = {}
10
+ Shakapacker.compiler.env = {}
9
11
  end
10
12
 
11
13
  it "returns true when fresh" do
12
14
  mocked_strategy = double("Strategy")
13
15
  expect(mocked_strategy).to receive(:stale?).and_return(false)
14
16
 
15
- expect(Webpacker.compiler).to receive(:strategy).and_return(mocked_strategy)
17
+ expect(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy)
16
18
 
17
- expect(Webpacker.compiler.compile).to be true
19
+ expect(Shakapacker.compiler.compile).to be true
18
20
  end
19
21
 
20
22
  it "returns true and calls after_compile_hook on successful compile" do
21
23
  mocked_strategy = spy("Strategy")
22
24
  expect(mocked_strategy).to receive(:stale?).and_return(true)
23
25
 
24
- allow(Webpacker.compiler).to receive(:strategy).and_return(mocked_strategy)
26
+ allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy)
25
27
 
26
28
  status = OpenStruct.new(success?: true)
27
29
  allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status])
28
30
 
29
- expect(Webpacker.compiler.compile).to be true
31
+ expect(Shakapacker.compiler.compile).to be true
30
32
  expect(mocked_strategy).to have_received(:after_compile_hook)
31
33
  end
32
34
 
@@ -35,23 +37,23 @@ describe "Webpacker::Compiler" do
35
37
  allow(mocked_strategy).to receive(:stale?).and_return(true)
36
38
  allow(mocked_strategy).to receive(:after_compile_hook)
37
39
 
38
- allow(Webpacker.compiler).to receive(:strategy).and_return(mocked_strategy)
40
+ allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy)
39
41
 
40
42
  status = OpenStruct.new(success?: false)
41
43
  allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status])
42
44
 
43
- expect(Webpacker.compiler.compile).to be false
45
+ expect(Shakapacker.compiler.compile).to be false
44
46
  expect(mocked_strategy).to have_received(:after_compile_hook)
45
47
  end
46
48
 
47
49
  it "accepts external env variables" do
48
- expect(Webpacker.compiler.send(:webpack_env)["WEBPACKER_ASSET_HOST"]).to be nil
49
- expect(Webpacker.compiler.send(:webpack_env)["WEBPACKER_RELATIVE_URL_ROOT"]).to be nil
50
+ expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to be nil
51
+ expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to be nil
50
52
 
51
- ENV["WEBPACKER_ASSET_HOST"] = "foo.bar"
52
- ENV["WEBPACKER_RELATIVE_URL_ROOT"] = "/baz"
53
+ ENV["SHAKAPACKER_ASSET_HOST"] = "foo.bar"
54
+ ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = "/baz"
53
55
 
54
- expect(Webpacker.compiler.send(:webpack_env)["WEBPACKER_ASSET_HOST"]).to eq "foo.bar"
55
- expect(Webpacker.compiler.send(:webpack_env)["WEBPACKER_RELATIVE_URL_ROOT"]).to eq "/baz"
56
+ expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "foo.bar"
57
+ expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "/baz"
56
58
  end
57
59
  end
@@ -1,20 +1,22 @@
1
- describe "Webpacker::CompilerStrategy" do
1
+ require_relative "spec_helper_initializer"
2
+
3
+ describe "Shakapacker::CompilerStrategy" do
2
4
  describe "#from_config" do
3
5
  it "returns and instance of MtimeStrategy when compiler_strategy is set to mtime" do
4
- allow(Webpacker.config).to receive(:compiler_strategy).and_return("mtime")
5
- expect(Webpacker::CompilerStrategy.from_config).to be_an_instance_of(Webpacker::MtimeStrategy)
6
+ allow(Shakapacker.config).to receive(:compiler_strategy).and_return("mtime")
7
+ expect(Shakapacker::CompilerStrategy.from_config).to be_an_instance_of(Shakapacker::MtimeStrategy)
6
8
  end
7
9
 
8
10
  it "returns and instance of DigestStrategy when compiler_strategy is set to digest" do
9
- allow(Webpacker.config).to receive(:compiler_strategy).and_return("digest")
10
- expect(Webpacker::CompilerStrategy.from_config).to be_an_instance_of(Webpacker::DigestStrategy)
11
+ allow(Shakapacker.config).to receive(:compiler_strategy).and_return("digest")
12
+ expect(Shakapacker::CompilerStrategy.from_config).to be_an_instance_of(Shakapacker::DigestStrategy)
11
13
  end
12
14
 
13
15
  it "raise exception for unknown compiler_strategy in the config file" do
14
16
  expected_error_message = "Unknown strategy 'other'. Available options are 'mtime' and 'digest'."
15
- allow(Webpacker.config).to receive(:compiler_strategy).and_return("other")
17
+ allow(Shakapacker.config).to receive(:compiler_strategy).and_return("other")
16
18
 
17
- expect { Webpacker::CompilerStrategy.from_config }.to raise_error(expected_error_message)
19
+ expect { Shakapacker::CompilerStrategy.from_config }.to raise_error(expected_error_message)
18
20
  end
19
21
  end
20
22
  end