shakapacker 7.0.3 → 7.2.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/dummy.yml +3 -1
- data/.github/workflows/generator.yml +6 -1
- data/.github/workflows/jest.yml +4 -2
- data/.github/workflows/js-lint.yml +4 -2
- data/.github/workflows/rubocop.yml +3 -1
- data/.github/workflows/ruby-backward-compatibility.yml +9 -1
- data/.github/workflows/ruby.yml +11 -2
- data/CHANGELOG.md +16 -3
- data/README.md +58 -23
- data/docs/troubleshooting.md +4 -8
- data/docs/using_esbuild_loader.md +2 -4
- data/docs/v6_upgrade.md +1 -1
- data/lib/install/template.rb +58 -18
- data/lib/shakapacker/compiler.rb +5 -3
- data/lib/shakapacker/configuration.rb +8 -0
- data/lib/shakapacker/deprecation_helper.rb +1 -1
- data/lib/shakapacker/dev_server_runner.rb +13 -6
- data/lib/shakapacker/runner.rb +19 -1
- data/lib/shakapacker/utils/misc.rb +12 -0
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker/version_checker.rb +35 -2
- data/lib/shakapacker/webpack_runner.rb +16 -8
- data/lib/tasks/shakapacker/binstubs.rake +1 -1
- data/lib/tasks/shakapacker/check_manager.rake +27 -0
- data/lib/tasks/shakapacker/check_yarn.rake +2 -1
- data/lib/tasks/shakapacker/info.rake +20 -3
- data/lib/tasks/shakapacker/install.rake +1 -1
- data/lib/tasks/shakapacker/verify_install.rake +1 -1
- data/lib/tasks/shakapacker.rake +2 -2
- data/lib/tasks/webpacker/check_yarn.rake +1 -1
- data/package/__tests__/index.js +24 -0
- data/package/index.d.ts +1 -1
- data/package/index.js +8 -2
- data/package.json +2 -2
- data/shakapacker.gemspec +1 -0
- data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +5 -3
- data/spec/backward_compatibility_specs/configuration_spec.rb +12 -4
- data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +103 -42
- data/spec/backward_compatibility_specs/dev_server_spec.rb +1 -1
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +2 -0
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +30 -7
- data/spec/backward_compatibility_specs/helper_spec.rb +20 -20
- data/spec/backward_compatibility_specs/instance_spec.rb +3 -3
- data/spec/backward_compatibility_specs/manifest_spec.rb +12 -12
- data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +3 -3
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +9 -5
- data/spec/backward_compatibility_specs/webpack_runner_spec.rb +55 -25
- data/spec/dummy/config/webpack/commonWebpackConfig.js +1 -1
- data/spec/fixtures/beta_pnpm-lock.v7.yaml +116 -0
- data/spec/fixtures/beta_pnpm-lock.v8.yaml +2537 -0
- data/spec/fixtures/git_url_pnpm-lock.v7.yaml +126 -0
- data/spec/fixtures/git_url_pnpm-lock.v8.yaml +3728 -0
- data/spec/fixtures/github_url_pnpm-lock.v7.yaml +126 -0
- data/spec/fixtures/github_url_pnpm-lock.v8.yaml +3728 -0
- data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +18 -0
- data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +22 -0
- data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +117 -0
- data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +117 -0
- data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +116 -0
- data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/without_pnpm-lock.v7.yaml +23 -0
- data/spec/fixtures/without_pnpm-lock.v8.yaml +27 -0
- data/spec/generator_specs/e2e_template/template.rb +31 -10
- data/spec/generator_specs/fake-bin/bun +10 -0
- data/spec/generator_specs/fake-bin/npm +10 -0
- data/spec/generator_specs/fake-bin/pnpm +10 -0
- data/spec/generator_specs/fake-bin/yarn +10 -0
- data/spec/generator_specs/generator_spec.rb +172 -18
- data/spec/mounted_app/package.json +1 -0
- data/spec/shakapacker/compiler_spec.rb +9 -5
- data/spec/shakapacker/compiler_strategy_spec.rb +5 -3
- data/spec/shakapacker/configuration_spec.rb +60 -2
- data/spec/shakapacker/dev_server_runner_spec.rb +108 -43
- data/spec/shakapacker/dev_server_spec.rb +1 -1
- data/spec/shakapacker/digest_strategy_spec.rb +2 -0
- data/spec/shakapacker/engine_rake_tasks_spec.rb +28 -6
- data/spec/shakapacker/helper_spec.rb +20 -20
- data/spec/shakapacker/instance_spec.rb +2 -2
- data/spec/shakapacker/manifest_spec.rb +12 -12
- data/spec/shakapacker/mtime_strategy_spec.rb +3 -3
- data/spec/shakapacker/rake_tasks_spec.rb +10 -6
- data/spec/shakapacker/shakapacker_spec.rb +4 -4
- data/spec/shakapacker/spec_helper_initializer.rb +18 -0
- data/spec/shakapacker/version_checker_spec.rb +468 -121
- data/spec/shakapacker/webpack_runner_spec.rb +55 -25
- data/spec/spec_helper.rb +2 -0
- data/spec/support/package_json_helpers.rb +16 -0
- metadata +42 -5
@@ -12,44 +12,74 @@ describe "WebpackRunner" do
|
|
12
12
|
ENV["RAILS_ENV"] = @original_rails_env
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
15
|
+
let(:test_app_path) { File.expand_path("./test_app", __dir__) }
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
NODE_PACKAGE_MANAGERS.each do |fallback_manager|
|
18
|
+
context "when using package_json with #{fallback_manager} as the manager" do
|
19
|
+
with_use_package_json_gem(enabled: true, fallback_manager: fallback_manager)
|
20
|
+
|
21
|
+
let(:package_json) { PackageJson.read(test_app_path) }
|
22
|
+
|
23
|
+
require "package_json"
|
24
|
+
|
25
|
+
it "uses the expected package manager", unless: fallback_manager == "yarn_classic" do
|
26
|
+
cmd = package_json.manager.native_exec_command("webpack", ["--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
27
|
+
|
28
|
+
manager_name = fallback_manager.split("_")[0]
|
20
29
|
|
21
|
-
|
22
|
-
|
30
|
+
expect(cmd).to start_with(manager_name)
|
31
|
+
end
|
23
32
|
|
24
|
-
|
33
|
+
it "runs the command using the manager" do
|
34
|
+
cmd = package_json.manager.native_exec_command("webpack", ["--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
35
|
+
|
36
|
+
verify_command(cmd)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "passes on arguments" do
|
40
|
+
cmd = package_json.manager.native_exec_command("webpack", ["--config", "#{test_app_path}/config/webpack/webpack.config.js", "--watch"])
|
41
|
+
|
42
|
+
verify_command(cmd, argv: (["--watch"]))
|
43
|
+
end
|
44
|
+
end
|
25
45
|
end
|
26
46
|
|
27
|
-
|
28
|
-
|
47
|
+
context "when not using package_json" do
|
48
|
+
with_use_package_json_gem(enabled: false)
|
49
|
+
|
50
|
+
it "supports running via node_modules" do
|
51
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
29
52
|
|
30
|
-
|
53
|
+
verify_command(cmd, use_node_modules: true)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "supports running via yarn" do
|
57
|
+
cmd = ["yarn", "webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
58
|
+
|
59
|
+
verify_command(cmd, use_node_modules: false)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "passes on arguments" do
|
63
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--watch"]
|
64
|
+
|
65
|
+
verify_command(cmd, argv: ["--watch"])
|
66
|
+
end
|
31
67
|
end
|
32
68
|
|
33
69
|
private
|
34
|
-
def test_app_path
|
35
|
-
File.expand_path("./test_app", __dir__)
|
36
|
-
end
|
37
70
|
|
38
71
|
def verify_command(cmd, use_node_modules: true, argv: [])
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
klass = Shakapacker::WebpackRunner
|
43
|
-
instance = klass.new(argv)
|
72
|
+
Dir.chdir(test_app_path) do
|
73
|
+
klass = Shakapacker::WebpackRunner
|
74
|
+
instance = klass.new(argv)
|
44
75
|
|
45
|
-
|
46
|
-
|
47
|
-
|
76
|
+
allow(klass).to receive(:new).and_return(instance)
|
77
|
+
allow(instance).to receive(:node_modules_bin_exist?).and_return(use_node_modules)
|
78
|
+
allow(Kernel).to receive(:exec)
|
48
79
|
|
49
|
-
|
80
|
+
klass.run(argv)
|
50
81
|
|
51
|
-
|
52
|
-
|
53
|
-
Dir.chdir(cwd)
|
82
|
+
expect(Kernel).to have_received(:exec).with(Shakapacker::Compiler.env, *cmd)
|
83
|
+
end
|
54
84
|
end
|
55
85
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "./support/package_json_helpers"
|
2
|
+
|
1
3
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
4
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
5
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
@@ -0,0 +1,16 @@
|
|
1
|
+
NODE_PACKAGE_MANAGERS = ["npm", "yarn_classic", "yarn_berry", "pnpm", "bun"]
|
2
|
+
|
3
|
+
def with_use_package_json_gem(enabled:, fallback_manager: nil)
|
4
|
+
around do |example|
|
5
|
+
old_use_package_json_gem_value = ENV["SHAKAPACKER_USE_PACKAGE_JSON_GEM"]
|
6
|
+
old_package_json_fallback_manager_value = ENV["PACKAGE_JSON_FALLBACK_MANAGER"]
|
7
|
+
|
8
|
+
ENV["SHAKAPACKER_USE_PACKAGE_JSON_GEM"] = enabled.to_s
|
9
|
+
ENV["PACKAGE_JSON_FALLBACK_MANAGER"] = fallback_manager.to_s
|
10
|
+
|
11
|
+
example.run
|
12
|
+
|
13
|
+
ENV["SHAKAPACKER_USE_PACKAGE_JSON_GEM"] = old_use_package_json_gem_value
|
14
|
+
ENV["PACKAGE_JSON_FALLBACK_MANAGER"] = old_package_json_fallback_manager_value
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shakapacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.2.0.rc.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -26,6 +26,20 @@ dependencies:
|
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '5.2'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: package_json
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: railties
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,6 +209,7 @@ files:
|
|
195
209
|
- lib/tasks/shakapacker.rake
|
196
210
|
- lib/tasks/shakapacker/binstubs.rake
|
197
211
|
- lib/tasks/shakapacker/check_binstubs.rake
|
212
|
+
- lib/tasks/shakapacker/check_manager.rake
|
198
213
|
- lib/tasks/shakapacker/check_node.rake
|
199
214
|
- lib/tasks/shakapacker/check_yarn.rake
|
200
215
|
- lib/tasks/shakapacker/clean.rake
|
@@ -425,41 +440,57 @@ files:
|
|
425
440
|
- spec/fixtures/beta_package-lock.v1.json
|
426
441
|
- spec/fixtures/beta_package-lock.v2.json
|
427
442
|
- spec/fixtures/beta_package.json
|
443
|
+
- spec/fixtures/beta_pnpm-lock.v7.yaml
|
444
|
+
- spec/fixtures/beta_pnpm-lock.v8.yaml
|
428
445
|
- spec/fixtures/beta_yarn.v1.lock
|
429
446
|
- spec/fixtures/beta_yarn.v2.lock
|
430
447
|
- spec/fixtures/git_url_package-lock.v1.json
|
431
448
|
- spec/fixtures/git_url_package-lock.v2.json
|
432
449
|
- spec/fixtures/git_url_package.json
|
450
|
+
- spec/fixtures/git_url_pnpm-lock.v7.yaml
|
451
|
+
- spec/fixtures/git_url_pnpm-lock.v8.yaml
|
433
452
|
- spec/fixtures/git_url_yarn.v1.lock
|
434
453
|
- spec/fixtures/git_url_yarn.v2.lock
|
435
454
|
- spec/fixtures/github_url_package-lock.v1.json
|
436
455
|
- spec/fixtures/github_url_package-lock.v2.json
|
437
456
|
- spec/fixtures/github_url_package.json
|
457
|
+
- spec/fixtures/github_url_pnpm-lock.v7.yaml
|
458
|
+
- spec/fixtures/github_url_pnpm-lock.v8.yaml
|
438
459
|
- spec/fixtures/github_url_yarn.v1.lock
|
439
460
|
- spec/fixtures/github_url_yarn.v2.lock
|
440
461
|
- spec/fixtures/relative_path_package-lock.v1.json
|
441
462
|
- spec/fixtures/relative_path_package-lock.v2.json
|
442
463
|
- spec/fixtures/relative_path_package.json
|
464
|
+
- spec/fixtures/relative_path_pnpm-lock.v7.yaml
|
465
|
+
- spec/fixtures/relative_path_pnpm-lock.v8.yaml
|
443
466
|
- spec/fixtures/relative_path_yarn.v1.lock
|
444
467
|
- spec/fixtures/relative_path_yarn.v2.lock
|
445
468
|
- spec/fixtures/semver_caret_package-lock.v1.json
|
446
469
|
- spec/fixtures/semver_caret_package-lock.v2.json
|
447
470
|
- spec/fixtures/semver_caret_package.json
|
471
|
+
- spec/fixtures/semver_caret_pnpm-lock.v7.yaml
|
472
|
+
- spec/fixtures/semver_caret_pnpm-lock.v8.yaml
|
448
473
|
- spec/fixtures/semver_caret_yarn.v1.lock
|
449
474
|
- spec/fixtures/semver_caret_yarn.v2.lock
|
450
475
|
- spec/fixtures/semver_exact_package-lock.v1.json
|
451
476
|
- spec/fixtures/semver_exact_package-lock.v2.json
|
452
477
|
- spec/fixtures/semver_exact_package.json
|
478
|
+
- spec/fixtures/semver_exact_pnpm-lock.v7.yaml
|
479
|
+
- spec/fixtures/semver_exact_pnpm-lock.v8.yaml
|
453
480
|
- spec/fixtures/semver_exact_yarn.v1.lock
|
454
481
|
- spec/fixtures/semver_exact_yarn.v2.lock
|
455
482
|
- spec/fixtures/semver_tilde_package-lock.v1.json
|
456
483
|
- spec/fixtures/semver_tilde_package-lock.v2.json
|
457
484
|
- spec/fixtures/semver_tilde_package.json
|
485
|
+
- spec/fixtures/semver_tilde_pnpm-lock.v7.yaml
|
486
|
+
- spec/fixtures/semver_tilde_pnpm-lock.v8.yaml
|
458
487
|
- spec/fixtures/semver_tilde_yarn.v1.lock
|
459
488
|
- spec/fixtures/semver_tilde_yarn.v2.lock
|
460
489
|
- spec/fixtures/without_package-lock.v1.json
|
461
490
|
- spec/fixtures/without_package-lock.v2.json
|
462
491
|
- spec/fixtures/without_package.json
|
492
|
+
- spec/fixtures/without_pnpm-lock.v7.yaml
|
493
|
+
- spec/fixtures/without_pnpm-lock.v8.yaml
|
463
494
|
- spec/fixtures/without_yarn.v1.lock
|
464
495
|
- spec/fixtures/without_yarn.v2.lock
|
465
496
|
- spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb
|
@@ -470,8 +501,13 @@ files:
|
|
470
501
|
- spec/generator_specs/e2e_template/files/config/routes.rb
|
471
502
|
- spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb
|
472
503
|
- spec/generator_specs/e2e_template/template.rb
|
504
|
+
- spec/generator_specs/fake-bin/bun
|
505
|
+
- spec/generator_specs/fake-bin/npm
|
506
|
+
- spec/generator_specs/fake-bin/pnpm
|
507
|
+
- spec/generator_specs/fake-bin/yarn
|
473
508
|
- spec/generator_specs/generator_spec.rb
|
474
509
|
- spec/mounted_app/Rakefile
|
510
|
+
- spec/mounted_app/package.json
|
475
511
|
- spec/mounted_app/test/dummy/Rakefile
|
476
512
|
- spec/mounted_app/test/dummy/bin/rails
|
477
513
|
- spec/mounted_app/test/dummy/bin/rake
|
@@ -524,12 +560,13 @@ files:
|
|
524
560
|
- spec/shakapacker/version_checker_spec.rb
|
525
561
|
- spec/shakapacker/webpack_runner_spec.rb
|
526
562
|
- spec/spec_helper.rb
|
563
|
+
- spec/support/package_json_helpers.rb
|
527
564
|
- yarn.lock
|
528
565
|
homepage: https://github.com/shakacode/shakapacker
|
529
566
|
licenses:
|
530
567
|
- MIT
|
531
568
|
metadata:
|
532
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.0.
|
569
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.2.0-rc.0
|
533
570
|
post_install_message:
|
534
571
|
rdoc_options: []
|
535
572
|
require_paths:
|
@@ -541,9 +578,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
541
578
|
version: 2.6.0
|
542
579
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
543
580
|
requirements:
|
544
|
-
- - "
|
581
|
+
- - ">"
|
545
582
|
- !ruby/object:Gem::Version
|
546
|
-
version:
|
583
|
+
version: 1.3.1
|
547
584
|
requirements: []
|
548
585
|
rubygems_version: 3.4.12
|
549
586
|
signing_key:
|