From 156df7f3bbeaa7a6d8e33a5cf7ade10d797b4c3f Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Mon, 20 May 2024 23:48:33 +0800 Subject: [PATCH 01/81] fix: replace Webpacker with Shakapacker --- lib/react_on_rails/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index bd2d20bad..bd24c763f 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -258,7 +258,7 @@ def raise_missing_components_subdirectory def shakapacker_precompile? return Webpacker.config.webpacker_precompile? if ReactOnRails::WebpackerUtils.using_shakapacker_6? - Webpacker.config.shakapacker_precompile? + Shakapacker.config.shakapacker_precompile? end def shakapacker_clean_task From 6df4e8d81fc220f8992125b8d96b4114603c475e Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Mon, 20 May 2024 23:40:36 -0500 Subject: [PATCH 02/81] add changelog entry --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5d5396a..51a0def9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,10 +21,14 @@ Changes since the last non-beta release. #### Fixed - Address a number of typos and grammar mistakes [PR 1631](https://github.com/shakacode/react_on_rails/pull/1631) by [G-Rath](https://github.com/G-Rath) +#### Added + +- Adds an adapter module & improves test suite to support all versions of Shakapacker. [PR 1622](https://github.com/shakacode/react_on_rails/pull/1622) by [adriangohjw](https://github.com/adriangohjw) + ### [14.0.2] - 2024-06-11 #### Fixed -- Project initialization with Shakapacker v8+ fixed [PR 1629](https://github.com/shakacode/react_on_rails/pull/1629) by [vaukalak](https://github.com/vaukalak) +- Generator errors with Shakapacker v8+ fixed [PR 1629](https://github.com/shakacode/react_on_rails/pull/1629) by [vaukalak](https://github.com/vaukalak) ### [14.0.1] - 2024-05-16 From 5051a5506f45fde4334ab817cc0def90f5e8b596 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Tue, 21 May 2024 16:16:06 +0800 Subject: [PATCH 03/81] update gemfile to use shakapacker 8.0.0 --- Gemfile.development_dependencies | 2 +- Gemfile.lock | 6 +++--- spec/dummy/Gemfile.lock | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.development_dependencies b/Gemfile.development_dependencies index 5ed1b239f..f972b719f 100644 --- a/Gemfile.development_dependencies +++ b/Gemfile.development_dependencies @@ -1,6 +1,6 @@ # frozen_string_literal: true -gem "shakapacker", "7.2.1" +gem "shakapacker", "8.0.0" gem "bootsnap", require: false gem "rails", "~> 7.1" diff --git a/Gemfile.lock b/Gemfile.lock index 728c05d38..2cfcfd92f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - react_on_rails (14.0.0) + react_on_rails (14.0.1) addressable connection_pool execjs (~> 2.5) @@ -334,7 +334,7 @@ GEM rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) semantic_range (3.0.0) - shakapacker (7.2.1) + shakapacker (8.0.0) activesupport (>= 5.2) package_json rack-proxy (>= 0.6.1) @@ -422,7 +422,7 @@ DEPENDENCIES scss_lint sdoc selenium-webdriver (= 4.9.0) - shakapacker (= 7.2.1) + shakapacker (= 8.0.0) spring (~> 4.0) sprockets (~> 4.0) sqlite3 (~> 1.6) diff --git a/spec/dummy/Gemfile.lock b/spec/dummy/Gemfile.lock index e08a41895..967a46f71 100644 --- a/spec/dummy/Gemfile.lock +++ b/spec/dummy/Gemfile.lock @@ -332,7 +332,7 @@ GEM rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) semantic_range (3.0.0) - shakapacker (7.2.1) + shakapacker (8.0.0) activesupport (>= 5.2) package_json rack-proxy (>= 0.6.1) @@ -418,7 +418,7 @@ DEPENDENCIES scss_lint sdoc selenium-webdriver (= 4.9.0) - shakapacker (= 7.2.1) + shakapacker (= 8.0.0) spring (~> 4.0) sprockets (~> 4.0) sqlite3 (~> 1.6) From 6212747fef522b1592b185c5ea197423d7f78561 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Tue, 21 May 2024 23:30:45 +0800 Subject: [PATCH 04/81] Replace Webpacker with Shakapacker --- lib/react_on_rails/configuration.rb | 12 ++-- lib/react_on_rails/utils.rb | 2 +- lib/react_on_rails/webpacker_utils.rb | 35 +++++------- spec/react_on_rails/configuration_spec.rb | 51 +++++++---------- .../webpack_assets_status_checker_spec.rb | 2 +- spec/react_on_rails/utils_spec.rb | 56 +++++++++---------- 6 files changed, 68 insertions(+), 90 deletions(-) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index bd24c763f..d910a5cae 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -256,27 +256,23 @@ def raise_missing_components_subdirectory end def shakapacker_precompile? - return Webpacker.config.webpacker_precompile? if ReactOnRails::WebpackerUtils.using_shakapacker_6? - Shakapacker.config.shakapacker_precompile? end def shakapacker_clean_task - ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker:clean" : "shakapacker:clean" + "shakapacker:clean" end def compile_command_conflict_message - packer = ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker" : "shakapacker" - <<~MSG React on Rails and Shakapacker error in configuration! In order to use config/react_on_rails.rb config.build_production_command, - you must edit config/#{packer}.yml to include this value in the default configuration: - '#{packer}_precompile: false' + you must edit config/shakapacker.yml to include this value in the default configuration: + 'shakapacker_precompile: false' Alternatively, remove the config/react_on_rails.rb config.build_production_command and the - default bin/#{packer} script will be used for assets:precompile. + default bin/shakapacker script will be used for assets:precompile. MSG end diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index 7f3529b98..21947626e 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -82,7 +82,7 @@ def self.server_bundle_js_file_path @server_bundle_path = if ReactOnRails::WebpackerUtils.using_webpacker? begin bundle_js_file_path(bundle_name) - rescue Webpacker::Manifest::MissingEntryError + rescue Shakapacker::Manifest::MissingEntryError File.expand_path( File.join(ReactOnRails::WebpackerUtils.webpacker_public_output_path, bundle_name) diff --git a/lib/react_on_rails/webpacker_utils.rb b/lib/react_on_rails/webpacker_utils.rb index 659390c6e..b4e794b00 100644 --- a/lib/react_on_rails/webpacker_utils.rb +++ b/lib/react_on_rails/webpacker_utils.rb @@ -5,14 +5,13 @@ module WebpackerUtils def self.using_webpacker? return @using_webpacker if defined?(@using_webpacker) - @using_webpacker = ReactOnRails::Utils.gem_available?("webpacker") || - ReactOnRails::Utils.gem_available?("shakapacker") + @using_webpacker = ReactOnRails::Utils.gem_available?("shakapacker") end def self.dev_server_running? return false unless using_webpacker? - Webpacker.dev_server.running? + Shakapacker.dev_server.running? end def self.shakapacker_version @@ -41,7 +40,7 @@ def self.bundle_js_uri_from_webpacker(bundle_name) # [2] (pry) ReactOnRails::WebpackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js") # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js" # Next line will throw if the file or manifest does not exist - hashed_bundle_name = Webpacker.manifest.lookup!(bundle_name) + hashed_bundle_name = Shakapacker.manifest.lookup!(bundle_name) # Support for hashing the server-bundle and having that built # the webpack-dev-server is provided by the config value @@ -49,43 +48,43 @@ def self.bundle_js_uri_from_webpacker(bundle_name) # would mean that the bundle is created by the webpack-dev-server is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file - if Webpacker.dev_server.running? && (!is_server_bundle || + if Shakapacker.dev_server.running? && (!is_server_bundle || ReactOnRails.configuration.same_bundle_for_client_and_server) - "#{Webpacker.dev_server.protocol}://#{Webpacker.dev_server.host_with_port}#{hashed_bundle_name}" + "#{Shakapacker.dev_server.protocol}://#{Shakapacker.dev_server.host_with_port}#{hashed_bundle_name}" else File.expand_path(File.join("public", hashed_bundle_name)).to_s end end def self.webpacker_source_path - Webpacker.config.source_path + Shakapacker.config.source_path end def self.webpacker_source_entry_path - Webpacker.config.source_entry_path + Shakapacker.config.source_entry_path end def self.nested_entries? - Webpacker.config.nested_entries? + Shakapacker.config.nested_entries? end def self.webpacker_public_output_path - # Webpacker has the full absolute path of webpacker output files in a Pathname - Webpacker.config.public_output_path.to_s + # Shakapacker has the full absolute path of webpacker output files in a Pathname + Shakapacker.config.public_output_path.to_s end def self.manifest_exists? - Webpacker.config.public_manifest_path.exist? + Shakapacker.config.public_manifest_path.exist? end def self.webpacker_source_path_explicit? - # WARNING: Calling private method `data` on Webpacker::Configuration, lib/webpacker/configuration.rb - config_webpacker_yml = Webpacker.config.send(:data) + # WARNING: Calling private method `data` on Shakapacker::Configuration, lib/webpacker/configuration.rb + config_webpacker_yml = Shakapacker.config.send(:data) config_webpacker_yml[:source_path].present? end def self.check_manifest_not_cached - return unless using_webpacker? && Webpacker.config.cache_manifest? + return unless using_webpacker? && Shakapacker.config.cache_manifest? msg = <<-MSG.strip_heredoc ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the @@ -141,11 +140,5 @@ def self.raise_shakapacker_not_installed def self.semver_to_string(ary) "#{ary[0]}.#{ary[1]}.#{ary[2]}" end - - def self.using_shakapacker_6? - shakapacker_major_version = shakapacker_version_as_array[0] - - shakapacker_major_version == 6 - end end end diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index 1f2193fc5..627dd37b1 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -27,7 +27,7 @@ module ReactOnRails before do allow(Rails).to receive(:root).and_return(File.expand_path(".")) - allow(Webpacker).to receive_message_chain("config.public_output_path") + allow(Shakapacker).to receive_message_chain("config.public_output_path") .and_return(webpacker_public_output_path) end @@ -75,43 +75,43 @@ module ReactOnRails end describe ".build_production_command" do - context "when using Shakapacker 6" do + context "when using Shakapacker 7" do before do allow(ReactOnRails::WebpackerUtils) .to receive("shakapacker_version") - .and_return("6.0.0") + .and_return("7.0.0") end - it "fails when \"webpacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") + it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure do |config| - config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/webpacker" + config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker" end - end.to raise_error(ReactOnRails::Error, /webpacker_precompile: false/) + end.to raise_error(ReactOnRails::Error, /shakapacker_precompile: false/) end - it "doesn't fail when \"webpacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") + it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure do |config| - config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/webpacker" + config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker" end end.not_to raise_error end - it "doesn't fail when \"webpacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") + it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock end.not_to raise_error end - it "doesn't fail when \"webpacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") + it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -119,26 +119,15 @@ module ReactOnRails end end - context "when using Shakapacker 7" do + context "when using Shakapacker 8" do before do allow(ReactOnRails::WebpackerUtils) .to receive("shakapacker_version") - .and_return("7.0.0") - end - - it "doesn't show deprecation message for webpacker_precompile?" do - allow(Webpacker).to receive_message_chain("config.shakapacker_precompile?") - .and_return(false) - - expect do - ReactOnRails.configure do |config| - config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker" - end - end.not_to output(/Consider using `shakapacker_precompile?`/).to_stdout + .and_return("8.0.0") end it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(Webpacker).to receive_message_chain("config.shakapacker_precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure do |config| @@ -148,7 +137,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(Webpacker).to receive_message_chain("config.shakapacker_precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure do |config| @@ -158,7 +147,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(Webpacker).to receive_message_chain("config.shakapacker_precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -166,7 +155,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(Webpacker).to receive_message_chain("config.shakapacker_precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index d8d26a081..88dfe70ac 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -74,7 +74,7 @@ .and_return(File.join(generated_assets_full_path, "manifest.json")) allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) .with("server-bundle.js") - .and_raise(Webpacker::Manifest::MissingEntryError) + .and_raise(Shakapacker::Manifest::MissingEntryError) touch_files_in_dir(generated_assets_full_path) end diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index a8a19e246..8186d46d1 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -20,34 +20,34 @@ module ReactOnRails described_class.bundle_js_file_path("webpack-bundle.js") end - context "with Webpacker enabled", :webpacker do - let(:webpacker_public_output_path) do + context "with Shakapacker enabled", :shakapacker do + let(:shakapacker_public_output_path) do File.expand_path(File.join(Rails.root, "public/webpack/dev")) end before do allow(ReactOnRails).to receive_message_chain(:configuration, :generated_assets_dir) .and_return("") - allow(Webpacker).to receive_message_chain("dev_server.running?") + allow(Shakapacker).to receive_message_chain("dev_server.running?") .and_return(false) - allow(Webpacker).to receive_message_chain("config.public_output_path") - .and_return(webpacker_public_output_path) + allow(Shakapacker).to receive_message_chain("config.public_output_path") + .and_return(shakapacker_public_output_path) allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(true) end context "when file in manifest", :webpacker do before do - # Note Webpacker manifest lookup is inside of the public_output_path - # [2] (pry) ReactOnRails::WebpackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js") + # Note Shakapacker manifest lookup is inside of the public_output_path + # [2] (pry) ReactOnRails::WebpackerUtils: 0> Shakapacker.manifest.lookup("app-bundle.js") # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js" - allow(Webpacker).to receive_message_chain("manifest.lookup!") + allow(Shakapacker).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") .and_return("/webpack/dev/webpack-bundle-0123456789abcdef.js") allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return("server-bundle.js") end - it { is_expected.to eq("#{webpacker_public_output_path}/webpack-bundle-0123456789abcdef.js") } + it { is_expected.to eq("#{shakapacker_public_output_path}/webpack-bundle-0123456789abcdef.js") } end context "with manifest.json" do @@ -55,11 +55,11 @@ module ReactOnRails described_class.bundle_js_file_path("manifest.json") end - it { is_expected.to eq("#{webpacker_public_output_path}/manifest.json") } + it { is_expected.to eq("#{shakapacker_public_output_path}/manifest.json") } end end - context "without Webpacker enabled" do + context "without Shakapacker enabled" do before do allow(ReactOnRails).to receive_message_chain(:configuration, :generated_assets_dir) .and_return("public/webpack/dev") @@ -74,8 +74,8 @@ module ReactOnRails it "returns false if node_modules is blank" do allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("") - allow(Webpacker).to receive_message_chain("config.send").with(:data) - .and_return({}) + allow(Shakapacker).to receive_message_chain("config.send").with(:data) + .and_return({}) expect(described_class.using_webpacker_source_path_is_not_defined_and_custom_node_modules?).to be(false) end @@ -83,8 +83,8 @@ module ReactOnRails it "returns false if source_path is defined in the config/webpacker.yml and node_modules defined" do allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("client") - allow(Webpacker).to receive_message_chain("config.send").with(:data) - .and_return(source_path: "client/app") + allow(Shakapacker).to receive_message_chain("config.send").with(:data) + .and_return(source_path: "client/app") expect(described_class.using_webpacker_source_path_is_not_defined_and_custom_node_modules?).to be(false) end @@ -92,18 +92,18 @@ module ReactOnRails it "returns true if node_modules is not blank and the source_path is not defined in config/webpacker.yml" do allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("node_modules") - allow(Webpacker).to receive_message_chain("config.send").with(:data) - .and_return({}) + allow(Shakapacker).to receive_message_chain("config.send").with(:data) + .and_return({}) expect(described_class.using_webpacker_source_path_is_not_defined_and_custom_node_modules?).to be(true) end end - describe ".server_bundle_js_file_path with Webpacker enabled" do + describe ".server_bundle_js_file_path with Shakapacker enabled" do before do allow(Rails).to receive(:root).and_return(Pathname.new(".")) allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(true) - allow(Webpacker).to receive_message_chain("config.public_output_path") + allow(Shakapacker).to receive_message_chain("config.public_output_path") .and_return(Pathname.new("public/webpack/development")) end @@ -112,9 +112,9 @@ module ReactOnRails server_bundle_name = "server-bundle.js" allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return(server_bundle_name) - allow(Webpacker).to receive_message_chain("manifest.lookup!") + allow(Shakapacker).to receive_message_chain("manifest.lookup!") .with(server_bundle_name) - .and_raise(Webpacker::Manifest::MissingEntryError) + .and_raise(Shakapacker::Manifest::MissingEntryError) path = described_class.server_bundle_js_file_path @@ -128,7 +128,7 @@ module ReactOnRails .and_return("webpack-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") .and_return(true) - allow(Webpacker).to receive_message_chain("manifest.lookup!") + allow(Shakapacker).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") .and_return("webpack/development/webpack-bundle-123456.js") @@ -143,13 +143,13 @@ module ReactOnRails .and_return("webpack-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") .and_return(true) - allow(Webpacker).to receive_message_chain("dev_server.running?") + allow(Shakapacker).to receive_message_chain("dev_server.running?") .and_return(true) - allow(Webpacker).to receive_message_chain("dev_server.protocol") + allow(Shakapacker).to receive_message_chain("dev_server.protocol") .and_return("http") - allow(Webpacker).to receive_message_chain("dev_server.host_with_port") + allow(Shakapacker).to receive_message_chain("dev_server.host_with_port") .and_return("localhost:3035") - allow(Webpacker).to receive_message_chain("manifest.lookup!") + allow(Shakapacker).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") .and_return("/webpack/development/webpack-bundle-123456.js") @@ -167,10 +167,10 @@ module ReactOnRails .and_return("server-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") .and_return(false) - allow(Webpacker).to receive_message_chain("manifest.lookup!") + allow(Shakapacker).to receive_message_chain("manifest.lookup!") .with("server-bundle.js") .and_return("webpack/development/server-bundle-123456.js") - allow(Webpacker).to receive_message_chain("dev_server.running?") + allow(Shakapacker).to receive_message_chain("dev_server.running?") .and_return(true) path = described_class.server_bundle_js_file_path From 39b32e2ea0383375518199b1fb789793e5ae935e Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Wed, 22 May 2024 01:09:20 +0800 Subject: [PATCH 05/81] Update WebpackerUtils to ShakapackerUtils --- lib/react_on_rails.rb | 2 +- lib/react_on_rails/configuration.rb | 30 ++++++------- lib/react_on_rails/helper.rb | 4 +- lib/react_on_rails/packs_generator.rb | 8 ++-- ...ebpacker_utils.rb => shakapacker_utils.rb} | 40 +++++++++--------- lib/react_on_rails/test_helper.rb | 4 +- .../webpack_assets_status_checker.rb | 4 +- lib/react_on_rails/utils.rb | 20 ++++----- spec/dummy/spec/packs_generator_spec.rb | 42 +++++++++---------- spec/react_on_rails/configuration_spec.rb | 30 ++++++------- spec/react_on_rails/locales_to_js_spec.rb | 2 +- ...tils_spec.rb => shakapacker_utils_spec.rb} | 6 +-- .../ensure_assets_compiled_spec.rb | 2 +- .../webpack_assets_status_checker_spec.rb | 14 +++---- spec/react_on_rails/utils_spec.rb | 8 ++-- 15 files changed, 108 insertions(+), 108 deletions(-) rename lib/react_on_rails/{webpacker_utils.rb => shakapacker_utils.rb} (75%) rename spec/react_on_rails/{webpacker_utils_spec.rb => shakapacker_utils_spec.rb} (94%) diff --git a/lib/react_on_rails.rb b/lib/react_on_rails.rb index 347534a4d..6a3a1b8b1 100644 --- a/lib/react_on_rails.rb +++ b/lib/react_on_rails.rb @@ -18,7 +18,7 @@ require "react_on_rails/test_helper" require "react_on_rails/git_utils" require "react_on_rails/utils" -require "react_on_rails/webpacker_utils" +require "react_on_rails/shakapacker_utils" require "react_on_rails/packs_generator" require "react_on_rails/test_helper/webpack_assets_compiler" require "react_on_rails/test_helper/webpack_assets_status_checker" diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index d910a5cae..956d3eef4 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -128,12 +128,12 @@ def check_autobundling_requirements_if_configured raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present? return unless components_subdirectory.present? - ReactOnRails::WebpackerUtils.raise_shakapacker_not_installed unless ReactOnRails::WebpackerUtils.using_webpacker? - ReactOnRails::WebpackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless - ReactOnRails::WebpackerUtils.shackapacker_version_requirement_met?( + ReactOnRails::ShakapackerUtils.raise_shakapacker_not_installed unless ReactOnRails::ShakapackerUtils.using_shakapacker? + ReactOnRails::ShakapackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless + ReactOnRails::ShakapackerUtils.shackapacker_version_requirement_met?( ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION ) - ReactOnRails::WebpackerUtils.raise_nested_entries_disabled unless ReactOnRails::WebpackerUtils.nested_entries? + ReactOnRails::ShakapackerUtils.raise_nested_entries_disabled unless ReactOnRails::ShakapackerUtils.nested_entries? end def adjust_precompile_task @@ -168,21 +168,21 @@ def adjust_precompile_task end def error_if_using_webpacker_and_generated_assets_dir_not_match_public_output_path - return unless ReactOnRails::WebpackerUtils.using_webpacker? + return unless ReactOnRails::ShakapackerUtils.using_shakapacker? return if generated_assets_dir.blank? - webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path + shakapacker_public_output_path = ReactOnRails::ShakapackerUtils.shakapacker_public_output_path - if File.expand_path(generated_assets_dir) == webpacker_public_output_path.to_s + if File.expand_path(generated_assets_dir) == shakapacker_public_output_path.to_s Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \ "with Webpacker. Remove this line from your configuration file.") else msg = <<~MSG - Error configuring /config/initializers/react_on_rails.rb: You are using webpacker + Error configuring /config/initializers/react_on_rails.rb: You are using shakapacker and your specified value for generated_assets_dir = #{generated_assets_dir} that does not match the value for public_output_path specified in - webpacker.yml = #{webpacker_public_output_path}. You should remove the configuration + shakapacker.yml = #{shakapacker_public_output_path}. You should remove the configuration value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file. MSG raise ReactOnRails::Error, msg @@ -202,7 +202,7 @@ def check_server_render_method_is_only_execjs end def ensure_generated_assets_dir_present - return if generated_assets_dir.present? || ReactOnRails::WebpackerUtils.using_webpacker? + return if generated_assets_dir.present? || ReactOnRails::ShakapackerUtils.using_shakapacker? self.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}" @@ -211,11 +211,11 @@ def ensure_generated_assets_dir_present def configure_generated_assets_dirs_deprecation return if generated_assets_dirs.blank? - if ReactOnRails::WebpackerUtils.using_webpacker? - webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path + if ReactOnRails::ShakapackerUtils.using_shakapacker? + shakapacker_public_output_path = ReactOnRails::ShakapackerUtils.shakapacker_public_output_path Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the " \ - "generated_assets_dirs no the generated_assets_dir when using Webpacker. This is defined " \ - "by public_output_path specified in webpacker.yml = #{webpacker_public_output_path}." + "generated_assets_dirs no the generated_assets_dir when using Shakapacker. This is defined " \ + "by public_output_path specified in webpacker.yml = #{shakapacker_public_output_path}." return end @@ -225,7 +225,7 @@ def configure_generated_assets_dirs_deprecation self.generated_assets_dir = generated_assets_dirs else Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and " \ - "generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Webpacker " \ + "generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Shakapacker " \ "and define neither if using Webpacker" end end diff --git a/lib/react_on_rails/helper.rb b/lib/react_on_rails/helper.rb index af2afb543..88af17bfc 100644 --- a/lib/react_on_rails/helper.rb +++ b/lib/react_on_rails/helper.rb @@ -316,7 +316,7 @@ def rails_context(server_side: true) def load_pack_for_generated_component(react_component_name, render_options) return unless render_options.auto_load_bundle - ReactOnRails::WebpackerUtils.raise_nested_entries_disabled unless ReactOnRails::WebpackerUtils.nested_entries? + ReactOnRails::ShakapackerUtils.raise_nested_entries_disabled unless ReactOnRails::ShakapackerUtils.nested_entries? if Rails.env.development? is_component_pack_present = File.exist?(generated_components_pack_path(react_component_name)) raise_missing_autoloaded_bundle(react_component_name) unless is_component_pack_present @@ -331,7 +331,7 @@ def load_pack_for_generated_component(react_component_name, render_options) private def generated_components_pack_path(react_component_name) - "#{ReactOnRails::WebpackerUtils.webpacker_source_entry_path}/generated/#{react_component_name}.js" + "#{ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path}/generated/#{react_component_name}.js" end def build_react_component_result_for_server_rendered_string( diff --git a/lib/react_on_rails/packs_generator.rb b/lib/react_on_rails/packs_generator.rb index d461e4ddf..56dba8e6a 100644 --- a/lib/react_on_rails/packs_generator.rb +++ b/lib/react_on_rails/packs_generator.rb @@ -102,7 +102,7 @@ def generated_server_bundle_file_path generated_interim_server_bundle_path = server_bundle_entrypoint.sub(".js", "-generated.js") generated_server_bundle_file_name = component_name(generated_interim_server_bundle_path) - source_entrypoint_parent = Pathname(ReactOnRails::WebpackerUtils.webpacker_source_entry_path).parent + source_entrypoint_parent = Pathname(ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path).parent generated_nonentrypoints_path = "#{source_entrypoint_parent}/generated" FileUtils.mkdir_p(generated_nonentrypoints_path) @@ -115,12 +115,12 @@ def clean_generated_packs_directory end def server_bundle_entrypoint - Rails.root.join(ReactOnRails::WebpackerUtils.webpacker_source_entry_path, + Rails.root.join(ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path, ReactOnRails.configuration.server_bundle_js_file) end def generated_packs_directory_path - source_entry_path = ReactOnRails::WebpackerUtils.webpacker_source_entry_path + source_entry_path = ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path "#{source_entry_path}/generated" end @@ -185,7 +185,7 @@ def server_component_to_path end def components_search_path - source_path = ReactOnRails::WebpackerUtils.webpacker_source_path + source_path = ReactOnRails::ShakapackerUtils.shakapacker_source_path "#{source_path}/**/#{ReactOnRails.configuration.components_subdirectory}" end diff --git a/lib/react_on_rails/webpacker_utils.rb b/lib/react_on_rails/shakapacker_utils.rb similarity index 75% rename from lib/react_on_rails/webpacker_utils.rb rename to lib/react_on_rails/shakapacker_utils.rb index b4e794b00..8c929f464 100644 --- a/lib/react_on_rails/webpacker_utils.rb +++ b/lib/react_on_rails/shakapacker_utils.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true module ReactOnRails - module WebpackerUtils - def self.using_webpacker? - return @using_webpacker if defined?(@using_webpacker) + module ShakapackerUtils + def self.using_shakapacker? + return @using_shakapacker if defined?(@using_shakapacker) - @using_webpacker = ReactOnRails::Utils.gem_available?("shakapacker") + @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") end def self.dev_server_running? - return false unless using_webpacker? + return false unless using_shakapacker? Shakapacker.dev_server.running? end @@ -35,9 +35,9 @@ def self.shackapacker_version_requirement_met?(required_version) # This returns either a URL for the webpack-dev-server, non-server bundle or # the hashed server bundle if using the same bundle for the client. # Otherwise returns a file path. - def self.bundle_js_uri_from_webpacker(bundle_name) + def self.bundle_js_uri_from_shakapacker(bundle_name) # Note Webpacker 3.4.3 manifest lookup is inside of the public_output_path - # [2] (pry) ReactOnRails::WebpackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js") + # [2] (pry) ReactOnRails::ShakapackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js") # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js" # Next line will throw if the file or manifest does not exist hashed_bundle_name = Shakapacker.manifest.lookup!(bundle_name) @@ -56,11 +56,11 @@ def self.bundle_js_uri_from_webpacker(bundle_name) end end - def self.webpacker_source_path + def self.shakapacker_source_path Shakapacker.config.source_path end - def self.webpacker_source_entry_path + def self.shakapacker_source_entry_path Shakapacker.config.source_entry_path end @@ -68,8 +68,8 @@ def self.nested_entries? Shakapacker.config.nested_entries? end - def self.webpacker_public_output_path - # Shakapacker has the full absolute path of webpacker output files in a Pathname + def self.shakapacker_public_output_path + # Shakapacker has the full absolute path of shakapacker output files in a Pathname Shakapacker.config.public_output_path.to_s end @@ -77,19 +77,19 @@ def self.manifest_exists? Shakapacker.config.public_manifest_path.exist? end - def self.webpacker_source_path_explicit? - # WARNING: Calling private method `data` on Shakapacker::Configuration, lib/webpacker/configuration.rb - config_webpacker_yml = Shakapacker.config.send(:data) - config_webpacker_yml[:source_path].present? + def self.shakapacker_source_path_explicit? + # WARNING: Calling private method `data` on Shakapacker::Configuration, lib/shakapacker/configuration.rb + config_shakapacker_yml = Shakapacker.config.send(:data) + config_shakapacker_yml[:source_path].present? end def self.check_manifest_not_cached - return unless using_webpacker? && Shakapacker.config.cache_manifest? + return unless using_shakapacker? && Shakapacker.config.cache_manifest? msg = <<-MSG.strip_heredoc ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper - To fix this: edit your config/webpacker.yml file and set cache_manifest to false for test. + To fix this: edit your config/shakapacker.yml file and set cache_manifest to false for test. MSG puts wrap_message(msg) exit! @@ -119,9 +119,9 @@ def self.raise_nested_entries_disabled def self.raise_shakapacker_version_incompatible_for_autobundling msg = <<~MSG - **ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ReactOnRails::WebpackerUtils.semver_to_string(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)} or \ + **ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ReactOnRails::ShakapackerUtils.semver_to_string(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)} or \ above to use the automated bundle generation feature. The currently installed version is \ - #{ReactOnRails::WebpackerUtils.semver_to_string(ReactOnRails::WebpackerUtils.shakapacker_version_as_array)}. + #{ReactOnRails::ShakapackerUtils.semver_to_string(ReactOnRails::ShakapackerUtils.shakapacker_version_as_array)}. MSG raise ReactOnRails::Error, msg @@ -130,7 +130,7 @@ def self.raise_shakapacker_version_incompatible_for_autobundling def self.raise_shakapacker_not_installed msg = <<~MSG **ERROR** ReactOnRails: Missing Shakapacker gem. Please upgrade to use Shakapacker \ - #{ReactOnRails::WebpackerUtils.semver_to_string(minimum_required_shakapacker_version)} or above to use the \ + #{ReactOnRails::ShakapackerUtils.semver_to_string(minimum_required_shakapacker_version)} or above to use the \ automated bundle generation feature. MSG diff --git a/lib/react_on_rails/test_helper.rb b/lib/react_on_rails/test_helper.rb index 9ddb280ed..62c5fe5fa 100644 --- a/lib/react_on_rails/test_helper.rb +++ b/lib/react_on_rails/test_helper.rb @@ -67,7 +67,7 @@ def self.ensure_assets_compiled(webpack_assets_status_checker: nil, source_path: nil, generated_assets_full_path: nil, webpack_generated_files: nil) - ReactOnRails::WebpackerUtils.check_manifest_not_cached + ReactOnRails::ShakapackerUtils.check_manifest_not_cached if webpack_assets_status_checker.nil? source_path ||= ReactOnRails::Utils.source_path generated_assets_full_path ||= ReactOnRails::Utils.generated_assets_full_path @@ -86,7 +86,7 @@ def self.ensure_assets_compiled(webpack_assets_status_checker: nil, puts @printed_once = true - if ReactOnRails::WebpackerUtils.using_webpacker? && + if ReactOnRails::ShakapackerUtils.using_shakapacker? && ReactOnRails::Utils.using_webpacker_source_path_is_not_defined_and_custom_node_modules? msg = <<-MSG.strip_heredoc WARNING: Define config.webpacker.yml to include sourcePath to configure diff --git a/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb b/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb index a8c813fe2..6e0e00927 100644 --- a/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +++ b/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb @@ -30,8 +30,8 @@ def stale_generated_webpack_files end def stale_generated_files(files) - manifest_needed = ReactOnRails::WebpackerUtils.using_webpacker? && - !ReactOnRails::WebpackerUtils.manifest_exists? + manifest_needed = ReactOnRails::ShakapackerUtils.using_shakapacker? && + !ReactOnRails::ShakapackerUtils.manifest_exists? return ["manifest.json"] if manifest_needed diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index 21947626e..ccb3b169c 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -79,12 +79,12 @@ def self.server_bundle_js_file_path return @server_bundle_path if @server_bundle_path && !Rails.env.development? bundle_name = ReactOnRails.configuration.server_bundle_js_file - @server_bundle_path = if ReactOnRails::WebpackerUtils.using_webpacker? + @server_bundle_path = if ReactOnRails::ShakapackerUtils.using_shakapacker? begin bundle_js_file_path(bundle_name) rescue Shakapacker::Manifest::MissingEntryError File.expand_path( - File.join(ReactOnRails::WebpackerUtils.webpacker_public_output_path, + File.join(ReactOnRails::ShakapackerUtils.shakapacker_public_output_path, bundle_name) ) end @@ -94,8 +94,8 @@ def self.server_bundle_js_file_path end def self.bundle_js_file_path(bundle_name) - if ReactOnRails::WebpackerUtils.using_webpacker? && bundle_name != "manifest.json" - ReactOnRails::WebpackerUtils.bundle_js_uri_from_webpacker(bundle_name) + if ReactOnRails::ShakapackerUtils.using_shakapacker? && bundle_name != "manifest.json" + ReactOnRails::ShakapackerUtils.bundle_js_uri_from_shakapacker(bundle_name) else # Default to the non-hashed name in the specified output directory, which, for legacy # React on Rails, this is the output directory picked up by the asset pipeline. @@ -129,23 +129,23 @@ def self.prepend_cd_node_modules_directory(cmd) end def self.source_path - if ReactOnRails::WebpackerUtils.using_webpacker? - ReactOnRails::WebpackerUtils.webpacker_source_path + if ReactOnRails::ShakapackerUtils.using_shakapacker? + ReactOnRails::ShakapackerUtils.shakapacker_source_path else ReactOnRails.configuration.node_modules_location end end def self.using_webpacker_source_path_is_not_defined_and_custom_node_modules? - return false unless ReactOnRails::WebpackerUtils.using_webpacker? + return false unless ReactOnRails::ShakapackerUtils.using_shakapacker? - !ReactOnRails::WebpackerUtils.webpacker_source_path_explicit? && + !ReactOnRails::ShakapackerUtils.shakapacker_source_path_explicit? && ReactOnRails.configuration.node_modules_location.present? end def self.generated_assets_full_path - if ReactOnRails::WebpackerUtils.using_webpacker? - ReactOnRails::WebpackerUtils.webpacker_public_output_path + if ReactOnRails::ShakapackerUtils.using_shakapacker? + ReactOnRails::ShakapackerUtils.shakapacker_public_output_path else File.expand_path(ReactOnRails.configuration.generated_assets_dir) end diff --git a/spec/dummy/spec/packs_generator_spec.rb b/spec/dummy/spec/packs_generator_spec.rb index c2bfb64bf..a83384496 100644 --- a/spec/dummy/spec/packs_generator_spec.rb +++ b/spec/dummy/spec/packs_generator_spec.rb @@ -8,8 +8,8 @@ module ReactOnRails # rubocop:disable Metrics/BlockLength describe PacksGenerator do - let(:webpacker_source_path) { File.expand_path("./fixtures/automated_packs_generation", __dir__) } - let(:webpacker_source_entry_path) { File.expand_path("./fixtures/automated_packs_generation/packs", __dir__) } + let(:shakapacker_source_path) { File.expand_path("./fixtures/automated_packs_generation", __dir__) } + let(:shakapacker_source_entry_path) { File.expand_path("./fixtures/automated_packs_generation/packs", __dir__) } let(:generated_directory) { File.expand_path("./fixtures/automated_packs_generation/packs/generated", __dir__) } let(:server_bundle_js_file) { "server-bundle.js" } let(:server_bundle_js_file_path) do @@ -26,13 +26,13 @@ module ReactOnRails ReactOnRails.configuration.components_subdirectory = "ror_components" ReactOnRails.configuration.webpack_generated_files = webpack_generated_files - allow(ReactOnRails::WebpackerUtils).to receive_messages( + allow(ReactOnRails::ShakapackerUtils).to receive_messages( manifest_exists?: true, - using_webpacker?: true, + using_shakapacker?: true, nested_entries?: true, - webpacker_source_entry_path: webpacker_source_entry_path, shakapacker_version: "7.0.0" + shakapacker_source_entry_path: shakapacker_source_entry_path, shakapacker_version: "7.0.0" ) - allow(ReactOnRails::Utils).to receive_messages(generated_assets_full_path: webpacker_source_entry_path, + allow(ReactOnRails::Utils).to receive_messages(generated_assets_full_path: shakapacker_source_entry_path, server_bundle_js_file_path: server_bundle_js_file_path) end @@ -40,7 +40,7 @@ module ReactOnRails ReactOnRails.configuration.server_bundle_js_file = old_server_bundle ReactOnRails.configuration.components_subdirectory = old_subdirectory - FileUtils.rm_rf "#{webpacker_source_entry_path}/generated" + FileUtils.rm_rf "#{shakapacker_source_entry_path}/generated" FileUtils.rm_rf generated_server_bundle_file_path File.truncate(server_bundle_js_file_path, 0) end @@ -52,7 +52,7 @@ module ReactOnRails ReactOnRails.configuration.make_generated_server_bundle_the_entrypoint = true described_class.instance.generate_packs_if_stale expect(File.exist?(server_bundle_js_file_path)).to equal(true) - expect(File.exist?("#{Pathname(webpacker_source_entry_path).parent}/server-bundle-generated.js")) + expect(File.exist?("#{Pathname(shakapacker_source_entry_path).parent}/server-bundle-generated.js")) .to equal(false) FileUtils.mv("./temp", server_bundle_js_file_path) ReactOnRails.configuration.make_generated_server_bundle_the_entrypoint = false @@ -65,7 +65,7 @@ module ReactOnRails before do stub_webpacker_source_path(component_name: component_name, - webpacker_source_path: webpacker_source_path) + shakapacker_source_path: shakapacker_source_path) described_class.instance.generate_packs_if_stale end @@ -104,7 +104,7 @@ module ReactOnRails before do stub_webpacker_source_path(component_name: component_name, - webpacker_source_path: webpacker_source_path) + shakapacker_source_path: shakapacker_source_path) end it "raises an error for definition override" do @@ -123,8 +123,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - allow(ReactOnRails::WebpackerUtils).to receive(:webpacker_source_path) - .and_return("#{webpacker_source_path}/components/#{component_name}") + allow(ReactOnRails::ShakapackerUtils).to receive(:shakapacker_source_path) + .and_return("#{shakapacker_source_path}/components/#{component_name}") end it "raises an error for definition override" do @@ -144,7 +144,7 @@ module ReactOnRails before do stub_webpacker_source_path(component_name: component_name, - webpacker_source_path: webpacker_source_path) + shakapacker_source_path: shakapacker_source_path) end it "raises an error for definition override" do @@ -159,7 +159,7 @@ module ReactOnRails before do stub_webpacker_source_path(component_name: component_name, - webpacker_source_path: webpacker_source_path) + shakapacker_source_path: shakapacker_source_path) end it "raises missing client file error" do @@ -178,7 +178,7 @@ module ReactOnRails before do stub_webpacker_source_path(component_name: component_name, - webpacker_source_path: webpacker_source_path) + shakapacker_source_path: shakapacker_source_path) described_class.instance.generate_packs_if_stale end @@ -217,7 +217,7 @@ module ReactOnRails before do stub_webpacker_source_path(component_name: component_name, - webpacker_source_path: webpacker_source_path) + shakapacker_source_path: shakapacker_source_path) FileUtils.mkdir_p(generated_directory) File.write(component_pack, "wat") File.write(generated_server_bundle_file_path, "wat") @@ -251,7 +251,7 @@ module ReactOnRails expect do described_class.instance.generate_packs_if_stale end.to output(GENERATED_PACKS_CONSOLE_OUTPUT_REGEX).to_stdout - FileUtils.rm "#{webpacker_source_path}/components/ComponentWithCommonOnly/ror_components/NewComponent.jsx" + FileUtils.rm "#{shakapacker_source_path}/components/ComponentWithCommonOnly/ror_components/NewComponent.jsx" end it "generate packs if an old component is updated" do @@ -265,7 +265,7 @@ module ReactOnRails def create_new_component(name) components_subdirectory = ReactOnRails.configuration.components_subdirectory - path = "#{webpacker_source_path}/components/#{component_name}/#{components_subdirectory}/#{name}.jsx" + path = "#{shakapacker_source_path}/components/#{component_name}/#{components_subdirectory}/#{name}.jsx" File.write(path, "// Empty Test Component\n") end @@ -289,9 +289,9 @@ def generated_server_bundle_file_path described_class.instance.send(:generated_server_bundle_file_path) end - def stub_webpacker_source_path(webpacker_source_path:, component_name:) - allow(ReactOnRails::WebpackerUtils).to receive(:webpacker_source_path) - .and_return("#{webpacker_source_path}/components/#{component_name}") + def stub_webpacker_source_path(shakapacker_source_path:, component_name:) + allow(ReactOnRails::ShakapackerUtils).to receive(:shakapacker_source_path) + .and_return("#{shakapacker_source_path}/components/#{component_name}") end end # rubocop:enable Metrics/BlockLength diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index 627dd37b1..311b8e71b 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -8,10 +8,10 @@ module ReactOnRails RSpec.describe Configuration do let(:existing_path) { Pathname.new(Dir.mktmpdir) } let(:not_existing_path) { "/path/to/#{SecureRandom.hex(4)}" } - let(:using_webpacker) { false } + let(:using_shakapacker) { false } before do - allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(using_webpacker) + allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(using_shakapacker) ReactOnRails.instance_variable_set(:@configuration, nil) end @@ -20,15 +20,15 @@ module ReactOnRails end describe "generated_assets_dir" do - let(:using_webpacker) { true } - let(:webpacker_public_output_path) do + let(:using_shakapacker) { true } + let(:shakapacker_public_output_path) do File.expand_path(File.join(Rails.root, "public/webpack/dev")) end before do allow(Rails).to receive(:root).and_return(File.expand_path(".")) allow(Shakapacker).to receive_message_chain("config.public_output_path") - .and_return(webpacker_public_output_path) + .and_return(shakapacker_public_output_path) end it "does not throw if the generated assets dir is blank with webpacker" do @@ -39,7 +39,7 @@ module ReactOnRails end.not_to raise_error end - it "does not throw if the webpacker_public_output_path does match the generated assets dir" do + it "does not throw if the shakapacker_public_output_path does match the generated assets dir" do expect do ReactOnRails.configure do |config| config.generated_assets_dir = "public/webpack/dev" @@ -47,7 +47,7 @@ module ReactOnRails end.not_to raise_error end - it "does throw if the webpacker_public_output_path does not match the generated assets dir" do + it "does throw if the shakapacker_public_output_path does not match the generated assets dir" do expect do ReactOnRails.configure do |config| config.generated_assets_dir = "public/webpack/other" @@ -77,7 +77,7 @@ module ReactOnRails describe ".build_production_command" do context "when using Shakapacker 7" do before do - allow(ReactOnRails::WebpackerUtils) + allow(ReactOnRails::ShakapackerUtils) .to receive("shakapacker_version") .and_return("7.0.0") end @@ -121,7 +121,7 @@ module ReactOnRails context "when using Shakapacker 8" do before do - allow(ReactOnRails::WebpackerUtils) + allow(ReactOnRails::ShakapackerUtils) .to receive("shakapacker_version") .and_return("8.0.0") end @@ -266,18 +266,18 @@ module ReactOnRails end it "checks that autobundling requirements are met if configuration options for autobundling are set" do - allow(ReactOnRails::WebpackerUtils).to receive_messages(using_webpacker?: true, - shackapacker_version_requirement_met?: true, - nested_entries?: true) + allow(ReactOnRails::ShakapackerUtils).to receive_messages(using_shakapacker?: true, + shackapacker_version_requirement_met?: true, + nested_entries?: true) ReactOnRails.configure do |config| config.auto_load_bundle = true config.components_subdirectory = "something" end - expect(ReactOnRails::WebpackerUtils).to have_received(:using_webpacker?).thrice - expect(ReactOnRails::WebpackerUtils).to have_received(:shackapacker_version_requirement_met?) - expect(ReactOnRails::WebpackerUtils).to have_received(:nested_entries?) + expect(ReactOnRails::ShakapackerUtils).to have_received(:using_shakapacker?).thrice + expect(ReactOnRails::ShakapackerUtils).to have_received(:shackapacker_version_requirement_met?) + expect(ReactOnRails::ShakapackerUtils).to have_received(:nested_entries?) end it "has a default configuration of the gem" do diff --git a/spec/react_on_rails/locales_to_js_spec.rb b/spec/react_on_rails/locales_to_js_spec.rb index 2fe05b704..eefa37827 100644 --- a/spec/react_on_rails/locales_to_js_spec.rb +++ b/spec/react_on_rails/locales_to_js_spec.rb @@ -10,7 +10,7 @@ module ReactOnRails let(:default_path) { "#{i18n_dir}/default.js" } before do - allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(false) + allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(false) end shared_examples "locale to js" do diff --git a/spec/react_on_rails/webpacker_utils_spec.rb b/spec/react_on_rails/shakapacker_utils_spec.rb similarity index 94% rename from spec/react_on_rails/webpacker_utils_spec.rb rename to spec/react_on_rails/shakapacker_utils_spec.rb index c30af8b90..fc94c4660 100644 --- a/spec/react_on_rails/webpacker_utils_spec.rb +++ b/spec/react_on_rails/shakapacker_utils_spec.rb @@ -3,10 +3,10 @@ require_relative "spec_helper" module ReactOnRails - describe WebpackerUtils do - describe ".using_webpacker?" do + describe ShakapackerUtils do + describe ".using_shakapacker?" do subject do - described_class.using_webpacker? + described_class.using_shakapacker? end it { is_expected.to be(true) } diff --git a/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb b/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb index 427b73824..16735373b 100644 --- a/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb +++ b/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb @@ -9,7 +9,7 @@ after { described_class.has_been_run = false } before do - allow(ReactOnRails::WebpackerUtils).to receive(:check_manifest_not_cached).and_return(nil) + allow(ReactOnRails::ShakapackerUtils).to receive(:check_manifest_not_cached).and_return(nil) double_packs = instance_double(ReactOnRails::PacksGenerator) allow(ReactOnRails::PacksGenerator).to receive(:instance).and_return(double_packs) allow(double_packs).to receive(:generate_packs_if_stale) diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index 88dfe70ac..5dd18d9df 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -20,13 +20,13 @@ end before do - allow(ReactOnRails::WebpackerUtils).to receive(:check_manifest_not_cached).and_return(nil) + allow(ReactOnRails::ShakapackerUtils).to receive(:check_manifest_not_cached).and_return(nil) allow(ReactOnRails::Utils).to receive(:generated_assets_full_path).and_return(generated_assets_full_path) end context "with Webpacker" do before do - allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(true) + allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(true) end context "when compiled assets with manifest exist and are up-to-date" do @@ -34,7 +34,7 @@ before do require "shakapacker" - allow(ReactOnRails::WebpackerUtils).to receive(:manifest_exists?).and_return(true) + allow(ReactOnRails::ShakapackerUtils).to receive(:manifest_exists?).and_return(true) allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) .with("manifest.json") .and_return(File.join(generated_assets_full_path, "manifest.json")) @@ -52,7 +52,7 @@ before do require "shakapacker" - allow(ReactOnRails::WebpackerUtils).to receive(:manifest_exists?).and_return(false) + allow(ReactOnRails::ShakapackerUtils).to receive(:manifest_exists?).and_return(false) end specify { expect(checker.stale_generated_webpack_files).to eq(["manifest.json"]) } @@ -64,9 +64,9 @@ before do require "shakapacker" - allow(ReactOnRails::WebpackerUtils).to receive_messages( + allow(ReactOnRails::ShakapackerUtils).to receive_messages( manifest_exists?: true, - webpacker_public_output_path: generated_assets_full_path + shakapacker_public_output_path: generated_assets_full_path ) allow(ReactOnRails.configuration).to receive(:server_bundle_js_file).and_return("server-bundle.js") allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) @@ -89,7 +89,7 @@ let(:webpack_generated_files) { %w[client-bundle.js server-bundle.js] } before do - allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(false) + allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(false) end context "when compiled assets exist and are up-to-date" do diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index 8186d46d1..85bc431b4 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -32,13 +32,13 @@ module ReactOnRails .and_return(false) allow(Shakapacker).to receive_message_chain("config.public_output_path") .and_return(shakapacker_public_output_path) - allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(true) + allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(true) end context "when file in manifest", :webpacker do before do # Note Shakapacker manifest lookup is inside of the public_output_path - # [2] (pry) ReactOnRails::WebpackerUtils: 0> Shakapacker.manifest.lookup("app-bundle.js") + # [2] (pry) ReactOnRails::ShakapackerUtils: 0> Shakapacker.manifest.lookup("app-bundle.js") # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js" allow(Shakapacker).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") @@ -63,7 +63,7 @@ module ReactOnRails before do allow(ReactOnRails).to receive_message_chain(:configuration, :generated_assets_dir) .and_return("public/webpack/dev") - allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(false) + allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(false) end it { is_expected.to eq(File.expand_path(File.join(Rails.root, "public/webpack/dev/webpack-bundle.js"))) } @@ -102,7 +102,7 @@ module ReactOnRails describe ".server_bundle_js_file_path with Shakapacker enabled" do before do allow(Rails).to receive(:root).and_return(Pathname.new(".")) - allow(ReactOnRails::WebpackerUtils).to receive(:using_webpacker?).and_return(true) + allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(true) allow(Shakapacker).to receive_message_chain("config.public_output_path") .and_return(Pathname.new("public/webpack/development")) end From 8c0d019eaccdca8f0f8910577be798170d2ee0d9 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Wed, 22 May 2024 01:21:50 +0800 Subject: [PATCH 06/81] (spec) package.json - update shakapacker to v8 + add "packageManager" --- spec/dummy/package.json | 5 +++-- spec/dummy/yarn.lock | 13 ++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/dummy/package.json b/spec/dummy/package.json index 94135da49..9ee3eba05 100644 --- a/spec/dummy/package.json +++ b/spec/dummy/package.json @@ -50,7 +50,7 @@ "sass": "^1.43.4", "sass-loader": "^12.3.0", "sass-resources-loader": "^2.1.0", - "shakapacker": "7.2.1", + "shakapacker": "8.0.0", "style-loader": "^3.3.1", "terser-webpack-plugin": "5.3.1", "url-loader": "^4.0.0", @@ -83,5 +83,6 @@ "build:rescript": "rescript clean && rescript build -with-deps", "build:rescript:dev": "rescript build -w" }, - "version": "0.0.0" + "version": "0.0.0", + "packageManager": "yarn@1.22.19" } diff --git a/spec/dummy/yarn.lock b/spec/dummy/yarn.lock index 3b3dfcd73..2c66fbf79 100644 --- a/spec/dummy/yarn.lock +++ b/spec/dummy/yarn.lock @@ -4480,7 +4480,7 @@ glob@^7.0.0, glob@^7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.1.3, glob@^7.2.0: +glob@^7.1.3: version "7.2.0" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== @@ -6434,7 +6434,7 @@ react-is@^18.0.0: integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== "react-on-rails@file:.yalc/react-on-rails": - version "14.0.2" + version "14.0.0" dependencies: "@babel/runtime-corejs3" "^7.12.5" @@ -7029,12 +7029,11 @@ sha.js@^2.4.0, sha.js@^2.4.8: inherits "^2.0.1" safe-buffer "^5.0.1" -shakapacker@7.2.1: - version "7.2.1" - resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-7.2.1.tgz#de9895bbbb6b6ee1016478dbbb8d4c37b25e5a50" - integrity sha512-IRPkEdIY2JiPfj7fnQ9sP8SBaUcaArMVBHAn3ctB91FndgyaM/bfXXlSEiveWPT3A3wkoadx44U6pKXo1DdC3w== +shakapacker@8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-8.0.0.tgz#f29537c19078af7318758c92e7a1bca4cee96bdd" + integrity sha512-HCdpITzIKXzGEyUWQhKzPbpwwOsgTamaPH+0kXdhM59VQxZ3NWnT5cL3DlJdAT3sGsWCJskEl3eMkQlnh9DjhA== dependencies: - glob "^7.2.0" js-yaml "^4.1.0" path-complete-extname "^1.0.0" From 7723165b95d7bb2fade3efd98e0f2f9369ce5371 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Wed, 22 May 2024 01:29:09 +0800 Subject: [PATCH 07/81] fix specs - Update Webpacker to Shakapacker --- spec/dummy/spec/helpers/react_on_rails_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb b/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb index f53699c88..3281e8043 100644 --- a/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb +++ b/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb @@ -9,7 +9,7 @@ class PlainReactOnRailsHelper # rubocop:disable Metrics/BlockLength describe ReactOnRailsHelper do - include Webpacker::Helper + include Shakapacker::Helper before do allow(self).to receive(:request) { Struct.new("Request", :original_url, :env) From 797ea16bfeb8e888a4ab5fc912baf27d83a47441 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Wed, 22 May 2024 01:42:27 +0800 Subject: [PATCH 08/81] Fix rubocop linting error --- lib/react_on_rails/configuration.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index 956d3eef4..1a1b75c55 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -128,7 +128,8 @@ def check_autobundling_requirements_if_configured raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present? return unless components_subdirectory.present? - ReactOnRails::ShakapackerUtils.raise_shakapacker_not_installed unless ReactOnRails::ShakapackerUtils.using_shakapacker? + ReactOnRails::ShakapackerUtils.raise_shakapacker_not_installed unless + ReactOnRails::ShakapackerUtils.using_shakapacker? ReactOnRails::ShakapackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless ReactOnRails::ShakapackerUtils.shackapacker_version_requirement_met?( ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION From f1c6fd74de4b0df01d9b00a794ce29fbbb34912b Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Wed, 22 May 2024 01:48:00 +0800 Subject: [PATCH 09/81] remove post-install action for shakapacker < v7 --- .../react_on_rails/install_generator.rb | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/generators/react_on_rails/install_generator.rb b/lib/generators/react_on_rails/install_generator.rb index cde32c21a..91ecfd59c 100644 --- a/lib/generators/react_on_rails/install_generator.rb +++ b/lib/generators/react_on_rails/install_generator.rb @@ -53,8 +53,6 @@ def invoke_generators else invoke "react_on_rails:react_no_redux" end - - invoke "react_on_rails:adapt_for_older_shakapacker" unless using_shakapacker_7_or_above? end # NOTE: other requirements for existing files such as .gitignore or application. @@ -95,21 +93,8 @@ def add_bin_scripts def add_post_install_message message = GeneratorMessages.helpful_message_after_installation - unless using_shakapacker_7_or_above? - message = message.gsub("config/shakapacker", "config/webpacker") - message = message.gsub("bin/shakapacker", "bin/webpacker") - end - GeneratorMessages.add_info(message) end - - def using_shakapacker_7_or_above? - shakapacker_gem = Gem::Specification.find_by_name("shakapacker") - shakapacker_gem.version.segments.first >= 7 - rescue Gem::MissingSpecError - # In case using Webpacker - false - end end end end From 8559b2c9dc6a11aec28c41a1b44e836f1dc60556 Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Wed, 22 May 2024 02:22:06 +0800 Subject: [PATCH 10/81] fix: updated test description and context tag --- spec/react_on_rails/utils_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index 85bc431b4..003ffeb88 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -35,7 +35,7 @@ module ReactOnRails allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(true) end - context "when file in manifest", :webpacker do + context "when file in manifest", :shakapacker do before do # Note Shakapacker manifest lookup is inside of the public_output_path # [2] (pry) ReactOnRails::ShakapackerUtils: 0> Shakapacker.manifest.lookup("app-bundle.js") @@ -107,7 +107,7 @@ module ReactOnRails .and_return(Pathname.new("public/webpack/development")) end - context "with server file not in manifest", :webpacker do + context "with server file not in manifest", :shakapacker do it "returns the unhashed server path" do server_bundle_name = "server-bundle.js" allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") @@ -122,7 +122,7 @@ module ReactOnRails end end - context "with server file in the manifest, used for client", :webpacker do + context "with server file in the manifest, used for client", :shakapacker do it "returns the correct path hashed server path" do allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return("webpack-bundle.js") @@ -161,7 +161,7 @@ module ReactOnRails end context "with dev-server running, and server file in the manifest, and separate client/server files", - :webpacker do + :shakapacker do it "returns the correct path hashed server path" do allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return("server-bundle.js") From d832db43bdb8f8a9c170f6dfcf26a78332ac778c Mon Sep 17 00:00:00 2001 From: adriangohjw Date: Wed, 22 May 2024 02:31:38 +0800 Subject: [PATCH 11/81] update min. shakapacker version to 7.2.1 --- lib/react_on_rails/packs_generator.rb | 2 +- spec/react_on_rails/shakapacker_utils_spec.rb | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/react_on_rails/packs_generator.rb b/lib/react_on_rails/packs_generator.rb index 56dba8e6a..2ed028020 100644 --- a/lib/react_on_rails/packs_generator.rb +++ b/lib/react_on_rails/packs_generator.rb @@ -6,7 +6,7 @@ module ReactOnRails # rubocop:disable Metrics/ClassLength class PacksGenerator CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/ - MINIMUM_SHAKAPACKER_VERSION = [6, 5, 1].freeze + MINIMUM_SHAKAPACKER_VERSION = [7, 2, 1].freeze def self.instance @instance ||= PacksGenerator.new diff --git a/spec/react_on_rails/shakapacker_utils_spec.rb b/spec/react_on_rails/shakapacker_utils_spec.rb index fc94c4660..aecbf5ba9 100644 --- a/spec/react_on_rails/shakapacker_utils_spec.rb +++ b/spec/react_on_rails/shakapacker_utils_spec.rb @@ -13,33 +13,32 @@ module ReactOnRails end describe ".shackapacker_version_requirement_met?" do - minimum_version = [6, 5, 3] + minimum_version = [7, 2, 1] it "returns false when version is lower than minimum_version" do - allow(described_class).to receive(:shakapacker_version).and_return("6.5.0") - + allow(described_class).to receive(:shakapacker_version).and_return("7.2.0") expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(false) - allow(described_class).to receive(:shakapacker_version).and_return("6.4.7") + allow(described_class).to receive(:shakapacker_version).and_return("7.1.0") expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(false) - allow(described_class).to receive(:shakapacker_version).and_return("5.7.7") + allow(described_class).to receive(:shakapacker_version).and_return("6.6.0") expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(false) end it "returns true when version is equal to minimum_version" do - allow(described_class).to receive(:shakapacker_version).and_return("6.5.3") + allow(described_class).to receive(:shakapacker_version).and_return("7.2.1") expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) end it "returns true when version is greater than minimum_version" do - allow(described_class).to receive(:shakapacker_version).and_return("6.6.0") + allow(described_class).to receive(:shakapacker_version).and_return("7.2.3") expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) - allow(described_class).to receive(:shakapacker_version).and_return("6.5.4") + allow(described_class).to receive(:shakapacker_version).and_return("7.3.0") expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) - allow(described_class).to receive(:shakapacker_version).and_return("7.7.7") + allow(described_class).to receive(:shakapacker_version).and_return("8.0.0") expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) end end From 4609d03f54facc2d91d1130b69a835cc200ad7f6 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 14 Jun 2023 16:28:29 -0500 Subject: [PATCH 12/81] use adapter method for Shakapacker --- lib/generators/USAGE | 2 +- .../react_on_rails/base_generator.rb | 26 ++--- .../templates/base/base/Procfile.dev | 5 - ...file.dev-static => Procfile.dev-static.tt} | 4 +- .../templates/base/base/Procfile.dev.tt | 5 + ...react_on_rails.rb => react_on_rails.rb.tt} | 4 +- lib/react_on_rails.rb | 2 +- lib/react_on_rails/configuration.rb | 61 +++++------ lib/react_on_rails/helper.rb | 6 +- .../{shakapacker_utils.rb => packer_utils.rb} | 100 ++++++++++++------ lib/react_on_rails/packs_generator.rb | 8 +- lib/react_on_rails/test_helper.rb | 8 +- .../test_helper/webpack_assets_compiler.rb | 2 +- .../webpack_assets_status_checker.rb | 8 +- lib/react_on_rails/utils.rb | 32 +++--- lib/tasks/assets.rake | 2 +- spec/dummy/spec/packs_generator_spec.rb | 53 +++++----- spec/react_on_rails/configuration_spec.rb | 22 ++-- spec/react_on_rails/locales_to_js_spec.rb | 2 +- spec/react_on_rails/packer_utils_spec.rb | 39 +++++++ spec/react_on_rails/shakapacker_utils_spec.rb | 46 -------- spec/react_on_rails/spec_helper.rb | 2 +- .../ensure_assets_compiled_spec.rb | 2 +- .../webpack_assets_status_checker_spec.rb | 12 +-- spec/react_on_rails/utils_spec.rb | 31 +++--- 25 files changed, 262 insertions(+), 222 deletions(-) delete mode 100644 lib/generators/react_on_rails/templates/base/base/Procfile.dev rename lib/generators/react_on_rails/templates/base/base/{Procfile.dev-static => Procfile.dev-static.tt} (67%) create mode 100644 lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt rename lib/generators/react_on_rails/templates/base/base/config/initializers/{react_on_rails.rb => react_on_rails.rb.tt} (95%) rename lib/react_on_rails/{shakapacker_utils.rb => packer_utils.rb} (56%) create mode 100644 spec/react_on_rails/packer_utils_spec.rb delete mode 100644 spec/react_on_rails/shakapacker_utils_spec.rb diff --git a/lib/generators/USAGE b/lib/generators/USAGE index d7a7dd668..7091d6e09 100644 --- a/lib/generators/USAGE +++ b/lib/generators/USAGE @@ -21,4 +21,4 @@ Then you may run More Details: - `https://github.com/shakacode/react_on_rails/blob/master/docs/basics/generator-details.md` + `https://github.com/shakacode/react_on_rails/blob/master/docs/additional-details/generator-details.md` diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index cecd0868a..04df541be 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -3,7 +3,7 @@ require "rails/generators" require_relative "generator_messages" require_relative "generator_helper" - +# rubocop:disable Metrics/ClassLength module ReactOnRails module Generators class BaseGenerator < Rails::Generators::Base @@ -30,11 +30,14 @@ def create_react_directories def copy_base_files base_path = "base/base/" base_files = %w[app/controllers/hello_world_controller.rb - app/views/layouts/hello_world.html.erb - config/initializers/react_on_rails.rb - Procfile.dev - Procfile.dev-static] + app/views/layouts/hello_world.html.erb] + base_templates = %w[config/initializers/react_on_rails.rb + Procfile.dev + Procfile.dev-static] base_files.each { |file| copy_file("#{base_path}#{file}", file) } + base_templates.each do |file| + template("#{base_path}/#{file}.tt", file, { packer_type: ReactOnRails::PackerUtils.packer_type }) + end end def copy_js_bundle_files @@ -59,16 +62,14 @@ def copy_webpack_config config = { message: "// The source code including full typescript support is available at:" } - base_files.each do |file| - template("#{base_path}/#{file}.tt", file, config) - end + base_files.each { |file| template("#{base_path}/#{file}.tt", file, config) } end - def copy_shakapacker_config - puts "Adding Shakapacker v7 config file" + def copy_packer_config + puts "Adding Shakapacker #{ReactOnRails::PackerUtils.shakapacker_version} config" base_path = "base/base/" - base_files = %w[config/shakapacker.yml] - base_files.each { |file| copy_file("#{base_path}#{file}", file) } + config = "config/#{ReactOnRails::PackerUtils.packer_type}.yml" + copy_file("#{base_path}#{config}", config) end def add_base_gems_to_gemfile @@ -166,3 +167,4 @@ def add_configure_rspec_to_compile_assets(helper_file) end end end +# rubocop:enable Metrics/ClassLength diff --git a/lib/generators/react_on_rails/templates/base/base/Procfile.dev b/lib/generators/react_on_rails/templates/base/base/Procfile.dev deleted file mode 100644 index 4aa1033ae..000000000 --- a/lib/generators/react_on_rails/templates/base/base/Procfile.dev +++ /dev/null @@ -1,5 +0,0 @@ -# Procfile for development using HMR -# You can run these commands in separate shells -rails: bundle exec rails s -p 3000 -wp-client: bin/shakapacker-dev-server -wp-server: SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch diff --git a/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static b/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static.tt similarity index 67% rename from lib/generators/react_on_rails/templates/base/base/Procfile.dev-static rename to lib/generators/react_on_rails/templates/base/base/Procfile.dev-static.tt index 811197375..39ccec23b 100644 --- a/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static +++ b/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static.tt @@ -5,5 +5,5 @@ web: rails s -p 3000 # When making frequent changes to client side assets, you will prefer building webpack assets # upon saving rather than when you refresh your browser page. # Note, if using React on Rails localization you will need to run -# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker -webpack: sh -c 'rm -rf public/packs/* || true && bin/shakapacker -w' +# `bundle exec rake react_on_rails:locale` before you run bin/<%= config[:packer_type] %> +webpack: sh -c 'rm -rf public/packs/* || true && bin/<%= config[:packer_type] %> -w' diff --git a/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt b/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt new file mode 100644 index 000000000..b87fce83a --- /dev/null +++ b/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt @@ -0,0 +1,5 @@ +# Procfile for development using HMR +# You can run these commands in separate shells +rails: bundle exec rails s -p 3000 +wp-client: bin/<%= config[:packer_type] %>-dev-server +wp-server: SERVER_BUNDLE_ONLY=yes bin/<%= config[:packer_type] %> --watch diff --git a/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb b/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt similarity index 95% rename from lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb rename to lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt index 727008ba0..6a72dc205 100644 --- a/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +++ b/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt @@ -24,8 +24,8 @@ # to automatically refresh your webpack assets on every test run. # # Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets` - # and set the config/shakapacker.yml option for test to true. - config.build_test_command = "RAILS_ENV=test bin/shakapacker" + # and set the config/<%= config[:packer_type] %>.yml option for test to true. + config.build_test_command = "RAILS_ENV=test bin/<%= config[:packer_type] %>" ################################################################################ ################################################################################ diff --git a/lib/react_on_rails.rb b/lib/react_on_rails.rb index 6a3a1b8b1..2cdf7a472 100644 --- a/lib/react_on_rails.rb +++ b/lib/react_on_rails.rb @@ -18,7 +18,7 @@ require "react_on_rails/test_helper" require "react_on_rails/git_utils" require "react_on_rails/utils" -require "react_on_rails/shakapacker_utils" +require "react_on_rails/packer_utils" require "react_on_rails/packs_generator" require "react_on_rails/test_helper/webpack_assets_compiler" require "react_on_rails/test_helper/webpack_assets_status_checker" diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index 1a1b75c55..99e8b25b4 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -117,7 +117,7 @@ def setup_config_values configure_skip_display_none_deprecation ensure_generated_assets_dir_present check_server_render_method_is_only_execjs - error_if_using_webpacker_and_generated_assets_dir_not_match_public_output_path + error_if_using_packer_and_generated_assets_dir_not_match_public_output_path # check_deprecated_settings adjust_precompile_task end @@ -128,13 +128,12 @@ def check_autobundling_requirements_if_configured raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present? return unless components_subdirectory.present? - ReactOnRails::ShakapackerUtils.raise_shakapacker_not_installed unless - ReactOnRails::ShakapackerUtils.using_shakapacker? - ReactOnRails::ShakapackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless - ReactOnRails::ShakapackerUtils.shackapacker_version_requirement_met?( + ReactOnRails::PackerUtils.raise_shakapacker_not_installed unless ReactOnRails::PackerUtils.using_packer? + ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless + ReactOnRails::PackerUtils.shakapacker_version_requirement_met?( ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION ) - ReactOnRails::ShakapackerUtils.raise_nested_entries_disabled unless ReactOnRails::ShakapackerUtils.nested_entries? + ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries? end def adjust_precompile_task @@ -142,7 +141,7 @@ def adjust_precompile_task return if skip_react_on_rails_precompile || build_production_command.blank? - raise(ReactOnRails::Error, compile_command_conflict_message) if shakapacker_precompile? + raise(ReactOnRails::Error, compile_command_conflict_message) if ReactOnRails::PackerUtils.precompile? precompile_tasks = lambda { Rake::Task["react_on_rails:generate_packs"].invoke @@ -152,9 +151,8 @@ def adjust_precompile_task # We set it very big so that it is not used, and then clean just # removes files older than 1 hour. versions = 100_000 - - puts "Invoking task #{shakapacker_clean_task} from React on Rails" - Rake::Task[shakapacker_clean_task].invoke(versions) + puts "Invoking task #{ReactOnRails::PackerUtils.packer_type}:clean from React on Rails" + Rake::Task["#{ReactOnRails::PackerUtils.packer_type}:clean"].invoke(versions) } if Rake::Task.task_defined?("assets:precompile") @@ -168,22 +166,23 @@ def adjust_precompile_task end end - def error_if_using_webpacker_and_generated_assets_dir_not_match_public_output_path - return unless ReactOnRails::ShakapackerUtils.using_shakapacker? + def error_if_using_packer_and_generated_assets_dir_not_match_public_output_path + return unless ReactOnRails::PackerUtils.using_packer? return if generated_assets_dir.blank? - shakapacker_public_output_path = ReactOnRails::ShakapackerUtils.shakapacker_public_output_path + packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path - if File.expand_path(generated_assets_dir) == shakapacker_public_output_path.to_s - Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \ - "with Webpacker. Remove this line from your configuration file.") + if File.expand_path(generated_assets_dir) == packer_public_output_path.to_s + Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` "\ + "with #{ReactOnRails::PackerUtils.packer_type}. "\ + "Remove this line from your configuration file.") else msg = <<~MSG - Error configuring /config/initializers/react_on_rails.rb: You are using shakapacker + Error configuring /config/initializers/react_on_rails.rb: You are using #{ReactOnRails::PackerUtils.packer_type} and your specified value for generated_assets_dir = #{generated_assets_dir} that does not match the value for public_output_path specified in - shakapacker.yml = #{shakapacker_public_output_path}. You should remove the configuration + #{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}. You should remove the configuration value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file. MSG raise ReactOnRails::Error, msg @@ -203,7 +202,7 @@ def check_server_render_method_is_only_execjs end def ensure_generated_assets_dir_present - return if generated_assets_dir.present? || ReactOnRails::ShakapackerUtils.using_shakapacker? + return if generated_assets_dir.present? || ReactOnRails::PackerUtils.using_packer? self.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}" @@ -212,11 +211,13 @@ def ensure_generated_assets_dir_present def configure_generated_assets_dirs_deprecation return if generated_assets_dirs.blank? - if ReactOnRails::ShakapackerUtils.using_shakapacker? - shakapacker_public_output_path = ReactOnRails::ShakapackerUtils.shakapacker_public_output_path - Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the " \ - "generated_assets_dirs no the generated_assets_dir when using Shakapacker. This is defined " \ - "by public_output_path specified in webpacker.yml = #{shakapacker_public_output_path}." + if ReactOnRails::PackerUtils.using_packer? + packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path + # rubocop:disable Layout/LineLength + Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor "\ + "the generated_assets_dir when using Shakapacker. This is defined by "\ + "public_output_path specified in #{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}." + # rubocop:enable Layout/LineLength return end @@ -267,13 +268,13 @@ def shakapacker_clean_task def compile_command_conflict_message <<~MSG - React on Rails and Shakapacker error in configuration! - In order to use config/react_on_rails.rb config.build_production_command, - you must edit config/shakapacker.yml to include this value in the default configuration: - 'shakapacker_precompile: false' + React on Rails and Shakapacker error in configuration! + In order to use config/react_on_rails.rb config.build_production_command, + you must edit config/#{ReactOnRails::PackerUtils.packer_type}.yml to include this value in the default configuration: + '#{ReactOnRails::PackerUtils.packer_type}_precompile: false' - Alternatively, remove the config/react_on_rails.rb config.build_production_command and the - default bin/shakapacker script will be used for assets:precompile. + Alternatively, remove the config/react_on_rails.rb config.build_production_command and the + default bin/#{ReactOnRails::PackerUtils.packer_type} script will be used for assets:precompile. MSG end diff --git a/lib/react_on_rails/helper.rb b/lib/react_on_rails/helper.rb index 88af17bfc..f354f2615 100644 --- a/lib/react_on_rails/helper.rb +++ b/lib/react_on_rails/helper.rb @@ -316,7 +316,7 @@ def rails_context(server_side: true) def load_pack_for_generated_component(react_component_name, render_options) return unless render_options.auto_load_bundle - ReactOnRails::ShakapackerUtils.raise_nested_entries_disabled unless ReactOnRails::ShakapackerUtils.nested_entries? + ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries? if Rails.env.development? is_component_pack_present = File.exist?(generated_components_pack_path(react_component_name)) raise_missing_autoloaded_bundle(react_component_name) unless is_component_pack_present @@ -330,8 +330,8 @@ def load_pack_for_generated_component(react_component_name, render_options) private - def generated_components_pack_path(react_component_name) - "#{ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path}/generated/#{react_component_name}.js" + def generated_components_pack_path(component_name) + "#{ReactOnRails::PackerUtils.packer_source_entry_path}/generated/#{component_name}.js" end def build_react_component_result_for_server_rendered_string( diff --git a/lib/react_on_rails/shakapacker_utils.rb b/lib/react_on_rails/packer_utils.rb similarity index 56% rename from lib/react_on_rails/shakapacker_utils.rb rename to lib/react_on_rails/packer_utils.rb index 8c929f464..5569b4a71 100644 --- a/lib/react_on_rails/shakapacker_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -1,23 +1,55 @@ # frozen_string_literal: true module ReactOnRails - module ShakapackerUtils + module PackerUtils + def self.using_packer? + using_shakapacker? || using_webpacker? + end + def self.using_shakapacker? return @using_shakapacker if defined?(@using_shakapacker) - @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") + @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") && + shakapacker_version_requirement_met?([7, 0, 0]) + end + + def self.using_webpacker? + return @using_webpacker if defined?(@using_webpacker) + + @using_webpacker = (ReactOnRails::Utils.gem_available?("shakapacker") && + shakapacker_version_as_array[0] <= 6) || + ReactOnRails::Utils.gem_available?("webpacker") + end + + def self.packer_type + return "shakapacker" if using_shakapacker? + return "webpacker" if using_webpacker? + + nil + end + + def self.adapter + return nil unless using_packer? + + if using_shakapacker? + require "shakapacker" + return ::Shakapacker + end + require "webpacker" + ::Webpacker end def self.dev_server_running? - return false unless using_shakapacker? + return false unless using_packer? - Shakapacker.dev_server.running? + adapter.dev_server.running? end def self.shakapacker_version - return nil unless ReactOnRails::Utils.gem_available?("shakapacker") + return @shakapacker_version if defined?(@shakapacker_version) - @shakapacker_version ||= Gem.loaded_specs["shakapacker"].version.to_s + @shakapacker_version = nil unless ReactOnRails::Utils.gem_available?("shakapacker") + @shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s end def self.shakapacker_version_as_array @@ -26,7 +58,7 @@ def self.shakapacker_version_as_array @shakapacker_version_as_array = [match[1].to_i, match[2].to_i, match[3].to_i] end - def self.shackapacker_version_requirement_met?(required_version) + def self.shakapacker_version_requirement_met?(required_version) req_ver = semver_to_string(required_version) Gem::Version.new(shakapacker_version) >= Gem::Version.new(req_ver) @@ -35,12 +67,8 @@ def self.shackapacker_version_requirement_met?(required_version) # This returns either a URL for the webpack-dev-server, non-server bundle or # the hashed server bundle if using the same bundle for the client. # Otherwise returns a file path. - def self.bundle_js_uri_from_shakapacker(bundle_name) - # Note Webpacker 3.4.3 manifest lookup is inside of the public_output_path - # [2] (pry) ReactOnRails::ShakapackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js") - # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js" - # Next line will throw if the file or manifest does not exist - hashed_bundle_name = Shakapacker.manifest.lookup!(bundle_name) + def self.bundle_js_uri_from_packer(bundle_name) + hashed_bundle_name = adapter.manifest.lookup!(bundle_name) # Support for hashing the server-bundle and having that built # the webpack-dev-server is provided by the config value @@ -48,48 +76,52 @@ def self.bundle_js_uri_from_shakapacker(bundle_name) # would mean that the bundle is created by the webpack-dev-server is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file - if Shakapacker.dev_server.running? && (!is_server_bundle || + if adapter.dev_server.running? && (!is_server_bundle || ReactOnRails.configuration.same_bundle_for_client_and_server) - "#{Shakapacker.dev_server.protocol}://#{Shakapacker.dev_server.host_with_port}#{hashed_bundle_name}" + "#{adapter.dev_server.protocol}://#{adapter.dev_server.host_with_port}#{hashed_bundle_name}" else File.expand_path(File.join("public", hashed_bundle_name)).to_s end end - def self.shakapacker_source_path - Shakapacker.config.source_path + def self.precompile? + return ::Webpacker.config.webpacker_precompile? if using_webpacker? + return ::Shakapacker.config.shakapacker_precompile? if using_shakapacker? + + false + end + + def self.packer_source_path + adapter.config.source_path end - def self.shakapacker_source_entry_path - Shakapacker.config.source_entry_path + def self.packer_source_entry_path + adapter.config.source_entry_path end def self.nested_entries? - Shakapacker.config.nested_entries? + adapter.config.nested_entries? end - def self.shakapacker_public_output_path - # Shakapacker has the full absolute path of shakapacker output files in a Pathname - Shakapacker.config.public_output_path.to_s + def self.packer_public_output_path + adapter.config.public_output_path.to_s end def self.manifest_exists? - Shakapacker.config.public_manifest_path.exist? + adapter.config.public_manifest_path.exist? end - def self.shakapacker_source_path_explicit? - # WARNING: Calling private method `data` on Shakapacker::Configuration, lib/shakapacker/configuration.rb - config_shakapacker_yml = Shakapacker.config.send(:data) - config_shakapacker_yml[:source_path].present? + def self.packer_source_path_explicit? + adapter.config.send(:data)[:source_path].present? end def self.check_manifest_not_cached - return unless using_shakapacker? && Shakapacker.config.cache_manifest? + return unless using_packer? && adapter.config.cache_manifest? msg = <<-MSG.strip_heredoc ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper - To fix this: edit your config/shakapacker.yml file and set cache_manifest to false for test. + To fix this: edit your config/#{packer_type}.yml file and set cache_manifest to false for test. MSG puts wrap_message(msg) exit! @@ -110,7 +142,7 @@ def self.webpack_assets_status_checker def self.raise_nested_entries_disabled msg = <<~MSG **ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shakapacker. Please update \ - webpacker.yml to enable nested entries. for more information read + config/#{packer_type}.yml to enable nested entries. for more information read https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md#enable-nested_entries-for-shakapacker MSG @@ -119,9 +151,9 @@ def self.raise_nested_entries_disabled def self.raise_shakapacker_version_incompatible_for_autobundling msg = <<~MSG - **ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ReactOnRails::ShakapackerUtils.semver_to_string(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)} or \ + **ERROR** ReactOnRails: Please upgrade Shakapacker to version #{semver_to_string(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)} or \ above to use the automated bundle generation feature. The currently installed version is \ - #{ReactOnRails::ShakapackerUtils.semver_to_string(ReactOnRails::ShakapackerUtils.shakapacker_version_as_array)}. + #{semver_to_string(ReactOnRails::PackerUtils.shakapacker_version_as_array)}. MSG raise ReactOnRails::Error, msg @@ -130,7 +162,7 @@ def self.raise_shakapacker_version_incompatible_for_autobundling def self.raise_shakapacker_not_installed msg = <<~MSG **ERROR** ReactOnRails: Missing Shakapacker gem. Please upgrade to use Shakapacker \ - #{ReactOnRails::ShakapackerUtils.semver_to_string(minimum_required_shakapacker_version)} or above to use the \ + #{semver_to_string(minimum_required_shakapacker_version)} or above to use the \ automated bundle generation feature. MSG diff --git a/lib/react_on_rails/packs_generator.rb b/lib/react_on_rails/packs_generator.rb index 2ed028020..1efc04529 100644 --- a/lib/react_on_rails/packs_generator.rb +++ b/lib/react_on_rails/packs_generator.rb @@ -102,7 +102,7 @@ def generated_server_bundle_file_path generated_interim_server_bundle_path = server_bundle_entrypoint.sub(".js", "-generated.js") generated_server_bundle_file_name = component_name(generated_interim_server_bundle_path) - source_entrypoint_parent = Pathname(ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path).parent + source_entrypoint_parent = Pathname(ReactOnRails::PackerUtils.packer_source_entry_path).parent generated_nonentrypoints_path = "#{source_entrypoint_parent}/generated" FileUtils.mkdir_p(generated_nonentrypoints_path) @@ -115,12 +115,12 @@ def clean_generated_packs_directory end def server_bundle_entrypoint - Rails.root.join(ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path, + Rails.root.join(ReactOnRails::PackerUtils.packer_source_entry_path, ReactOnRails.configuration.server_bundle_js_file) end def generated_packs_directory_path - source_entry_path = ReactOnRails::ShakapackerUtils.shakapacker_source_entry_path + source_entry_path = ReactOnRails::PackerUtils.packer_source_entry_path "#{source_entry_path}/generated" end @@ -185,7 +185,7 @@ def server_component_to_path end def components_search_path - source_path = ReactOnRails::ShakapackerUtils.shakapacker_source_path + source_path = ReactOnRails::PackerUtils.packer_source_path "#{source_path}/**/#{ReactOnRails.configuration.components_subdirectory}" end diff --git a/lib/react_on_rails/test_helper.rb b/lib/react_on_rails/test_helper.rb index 62c5fe5fa..a8cb1f589 100644 --- a/lib/react_on_rails/test_helper.rb +++ b/lib/react_on_rails/test_helper.rb @@ -67,7 +67,7 @@ def self.ensure_assets_compiled(webpack_assets_status_checker: nil, source_path: nil, generated_assets_full_path: nil, webpack_generated_files: nil) - ReactOnRails::ShakapackerUtils.check_manifest_not_cached + ReactOnRails::PackerUtils.check_manifest_not_cached if webpack_assets_status_checker.nil? source_path ||= ReactOnRails::Utils.source_path generated_assets_full_path ||= ReactOnRails::Utils.generated_assets_full_path @@ -86,10 +86,10 @@ def self.ensure_assets_compiled(webpack_assets_status_checker: nil, puts @printed_once = true - if ReactOnRails::ShakapackerUtils.using_shakapacker? && - ReactOnRails::Utils.using_webpacker_source_path_is_not_defined_and_custom_node_modules? + if ReactOnRails::PackerUtils.using_packer? && + ReactOnRails::Utils.using_packer_source_path_is_not_defined_and_custom_node_modules? msg = <<-MSG.strip_heredoc - WARNING: Define config.webpacker.yml to include sourcePath to configure + WARNING: Define config/#{ReactOnRails::PackerUtils.packer_type}.yml to include sourcePath to configure the location of your JavaScript source for React on Rails. Default location of #{source_path} is used. MSG diff --git a/lib/react_on_rails/test_helper/webpack_assets_compiler.rb b/lib/react_on_rails/test_helper/webpack_assets_compiler.rb index 3da9e0fc3..bf87b8e9d 100644 --- a/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +++ b/lib/react_on_rails/test_helper/webpack_assets_compiler.rb @@ -16,7 +16,7 @@ def compile_assets React on Rails is aborting your test run - If you wish to use the config/webpacker.yml compile option for tests + If you wish to use the config/#{ReactOnRails::PackerUtils.packer_type}.yml compile option for tests them remove your call to the ReactOnRails test helper. MSG puts Rainbow(msg).red diff --git a/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb b/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb index 6e0e00927..e951df322 100644 --- a/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +++ b/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb @@ -10,7 +10,7 @@ module ReactOnRails module TestHelper class WebpackAssetsStatusChecker include Utils::Required - # source_path is typically configured in the webpacker.yml file + # source_path is typically configured in the (shaka/web)packer.yml file # for `source_path` # or for legacy React on Rails, it's /client, where all client files go attr_reader :source_path, :generated_assets_full_path @@ -30,8 +30,8 @@ def stale_generated_webpack_files end def stale_generated_files(files) - manifest_needed = ReactOnRails::ShakapackerUtils.using_shakapacker? && - !ReactOnRails::ShakapackerUtils.manifest_exists? + manifest_needed = ReactOnRails::PackerUtils.using_packer? && + !ReactOnRails::PackerUtils.manifest_exists? return ["manifest.json"] if manifest_needed @@ -63,7 +63,7 @@ def all_compiled_assets file_list = make_file_list(make_globs(generated_assets_full_path)).to_ary puts "V" * 80 puts "Please define config.webpack_generated_files (array) so the test helper knows " \ - "which files are required. If you are using webpacker, you typically need to only " \ + "which files are required. If you are using Shakapacker, you typically need to only " \ "include 'manifest.json'." puts "Detected the possible following files to check for webpack compilation in " \ "#{generated_assets_full_path}" diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index ccb3b169c..737d955aa 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -79,12 +79,12 @@ def self.server_bundle_js_file_path return @server_bundle_path if @server_bundle_path && !Rails.env.development? bundle_name = ReactOnRails.configuration.server_bundle_js_file - @server_bundle_path = if ReactOnRails::ShakapackerUtils.using_shakapacker? + @server_bundle_path = if ReactOnRails::PackerUtils.using_packer? begin bundle_js_file_path(bundle_name) - rescue Shakapacker::Manifest::MissingEntryError + rescue Webpacker::Manifest::MissingEntryError, Shakapacker::Manifest::MissingEntryError File.expand_path( - File.join(ReactOnRails::ShakapackerUtils.shakapacker_public_output_path, + File.join(ReactOnRails::PackerUtils.packer_public_output_path, bundle_name) ) end @@ -94,12 +94,12 @@ def self.server_bundle_js_file_path end def self.bundle_js_file_path(bundle_name) - if ReactOnRails::ShakapackerUtils.using_shakapacker? && bundle_name != "manifest.json" - ReactOnRails::ShakapackerUtils.bundle_js_uri_from_shakapacker(bundle_name) + if ReactOnRails::PackerUtils.using_packer? && bundle_name != "manifest.json" + ReactOnRails::PackerUtils.bundle_js_uri_from_packer(bundle_name) else # Default to the non-hashed name in the specified output directory, which, for legacy # React on Rails, this is the output directory picked up by the asset pipeline. - # For Webpacker, this is the public output path defined in the webpacker.yml file. + # For Shakapacker, this is the public output path defined in the (shaka/web)packer.yml file. File.join(generated_assets_full_path, bundle_name) end end @@ -129,23 +129,23 @@ def self.prepend_cd_node_modules_directory(cmd) end def self.source_path - if ReactOnRails::ShakapackerUtils.using_shakapacker? - ReactOnRails::ShakapackerUtils.shakapacker_source_path + if ReactOnRails::PackerUtils.using_packer? + ReactOnRails::PackerUtils.packer_source_path else ReactOnRails.configuration.node_modules_location end end - def self.using_webpacker_source_path_is_not_defined_and_custom_node_modules? - return false unless ReactOnRails::ShakapackerUtils.using_shakapacker? + def self.using_packer_source_path_is_not_defined_and_custom_node_modules? + return false unless ReactOnRails::PackerUtils.using_packer? - !ReactOnRails::ShakapackerUtils.shakapacker_source_path_explicit? && + !ReactOnRails::PackerUtils.packer_source_path_explicit? && ReactOnRails.configuration.node_modules_location.present? end def self.generated_assets_full_path - if ReactOnRails::ShakapackerUtils.using_shakapacker? - ReactOnRails::ShakapackerUtils.shakapacker_public_output_path + if ReactOnRails::PackerUtils.using_packer? + ReactOnRails::PackerUtils.packer_public_output_path else File.expand_path(ReactOnRails.configuration.generated_assets_dir) end @@ -156,7 +156,11 @@ def self.gem_available?(name) rescue Gem::LoadError false rescue StandardError - Gem.available?(name).present? + begin + Gem.available?(name).present? + rescue NoMethodError + false + end end # Todo -- remove this for v13, as we don't need both boolean and number diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 104ef30d9..685b8fbaf 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -5,7 +5,7 @@ namespace :react_on_rails do namespace :assets do desc <<~DESC If config.build_production_command is defined, this command is automatically - added to task assets:precompile and the regular webpacker compile will not run. + added to task assets:precompile and the regular #{ReactOnRails::PackerUtils.packer_type.upcase_first} compile will not run. The defined command is either a script or a module with a method `call`. DESC task webpack: :locale do diff --git a/spec/dummy/spec/packs_generator_spec.rb b/spec/dummy/spec/packs_generator_spec.rb index a83384496..d2c615cf5 100644 --- a/spec/dummy/spec/packs_generator_spec.rb +++ b/spec/dummy/spec/packs_generator_spec.rb @@ -8,8 +8,8 @@ module ReactOnRails # rubocop:disable Metrics/BlockLength describe PacksGenerator do - let(:shakapacker_source_path) { File.expand_path("./fixtures/automated_packs_generation", __dir__) } - let(:shakapacker_source_entry_path) { File.expand_path("./fixtures/automated_packs_generation/packs", __dir__) } + let(:packer_source_path) { File.expand_path("./fixtures/automated_packs_generation", __dir__) } + let(:packer_source_entry_path) { File.expand_path("./fixtures/automated_packs_generation/packs", __dir__) } let(:generated_directory) { File.expand_path("./fixtures/automated_packs_generation/packs/generated", __dir__) } let(:server_bundle_js_file) { "server-bundle.js" } let(:server_bundle_js_file_path) do @@ -26,13 +26,14 @@ module ReactOnRails ReactOnRails.configuration.components_subdirectory = "ror_components" ReactOnRails.configuration.webpack_generated_files = webpack_generated_files - allow(ReactOnRails::ShakapackerUtils).to receive_messages( + allow(ReactOnRails::PackerUtils).to receive_messages( manifest_exists?: true, using_shakapacker?: true, nested_entries?: true, - shakapacker_source_entry_path: shakapacker_source_entry_path, shakapacker_version: "7.0.0" + packer_source_entry_path: packer_source_entry_path, + shakapacker_version: "7.0.0" ) - allow(ReactOnRails::Utils).to receive_messages(generated_assets_full_path: shakapacker_source_entry_path, + allow(ReactOnRails::Utils).to receive_messages(generated_assets_full_path: packer_source_entry_path, server_bundle_js_file_path: server_bundle_js_file_path) end @@ -40,7 +41,7 @@ module ReactOnRails ReactOnRails.configuration.server_bundle_js_file = old_server_bundle ReactOnRails.configuration.components_subdirectory = old_subdirectory - FileUtils.rm_rf "#{shakapacker_source_entry_path}/generated" + FileUtils.rm_rf "#{packer_source_entry_path}/generated" FileUtils.rm_rf generated_server_bundle_file_path File.truncate(server_bundle_js_file_path, 0) end @@ -52,7 +53,7 @@ module ReactOnRails ReactOnRails.configuration.make_generated_server_bundle_the_entrypoint = true described_class.instance.generate_packs_if_stale expect(File.exist?(server_bundle_js_file_path)).to equal(true) - expect(File.exist?("#{Pathname(shakapacker_source_entry_path).parent}/server-bundle-generated.js")) + expect(File.exist?("#{Pathname(packer_source_entry_path).parent}/server-bundle-generated.js")) .to equal(false) FileUtils.mv("./temp", server_bundle_js_file_path) ReactOnRails.configuration.make_generated_server_bundle_the_entrypoint = false @@ -64,8 +65,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - stub_webpacker_source_path(component_name: component_name, - shakapacker_source_path: shakapacker_source_path) + stub_packer_source_path(component_name: component_name, + packer_source_path: packer_source_path) described_class.instance.generate_packs_if_stale end @@ -103,8 +104,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - stub_webpacker_source_path(component_name: component_name, - shakapacker_source_path: shakapacker_source_path) + stub_packer_source_path(component_name: component_name, + packer_source_path: packer_source_path) end it "raises an error for definition override" do @@ -123,8 +124,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - allow(ReactOnRails::ShakapackerUtils).to receive(:shakapacker_source_path) - .and_return("#{shakapacker_source_path}/components/#{component_name}") + allow(ReactOnRails::PackerUtils).to receive(:packer_source_path) + .and_return("#{packer_source_path}/components/#{component_name}") end it "raises an error for definition override" do @@ -143,8 +144,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - stub_webpacker_source_path(component_name: component_name, - shakapacker_source_path: shakapacker_source_path) + stub_packer_source_path(component_name: component_name, + packer_source_path: packer_source_path) end it "raises an error for definition override" do @@ -158,8 +159,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - stub_webpacker_source_path(component_name: component_name, - shakapacker_source_path: shakapacker_source_path) + stub_packer_source_path(component_name: component_name, + packer_source_path: packer_source_path) end it "raises missing client file error" do @@ -177,8 +178,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - stub_webpacker_source_path(component_name: component_name, - shakapacker_source_path: shakapacker_source_path) + stub_packer_source_path(component_name: component_name, + packer_source_path: packer_source_path) described_class.instance.generate_packs_if_stale end @@ -216,8 +217,8 @@ module ReactOnRails let(:component_pack) { "#{generated_directory}/#{component_name}.js" } before do - stub_webpacker_source_path(component_name: component_name, - shakapacker_source_path: shakapacker_source_path) + stub_packer_source_path(component_name: component_name, + packer_source_path: packer_source_path) FileUtils.mkdir_p(generated_directory) File.write(component_pack, "wat") File.write(generated_server_bundle_file_path, "wat") @@ -251,7 +252,7 @@ module ReactOnRails expect do described_class.instance.generate_packs_if_stale end.to output(GENERATED_PACKS_CONSOLE_OUTPUT_REGEX).to_stdout - FileUtils.rm "#{shakapacker_source_path}/components/ComponentWithCommonOnly/ror_components/NewComponent.jsx" + FileUtils.rm "#{packer_source_path}/components/ComponentWithCommonOnly/ror_components/NewComponent.jsx" end it "generate packs if an old component is updated" do @@ -265,7 +266,7 @@ module ReactOnRails def create_new_component(name) components_subdirectory = ReactOnRails.configuration.components_subdirectory - path = "#{shakapacker_source_path}/components/#{component_name}/#{components_subdirectory}/#{name}.jsx" + path = "#{packer_source_path}/components/#{component_name}/#{components_subdirectory}/#{name}.jsx" File.write(path, "// Empty Test Component\n") end @@ -289,9 +290,9 @@ def generated_server_bundle_file_path described_class.instance.send(:generated_server_bundle_file_path) end - def stub_webpacker_source_path(shakapacker_source_path:, component_name:) - allow(ReactOnRails::ShakapackerUtils).to receive(:shakapacker_source_path) - .and_return("#{shakapacker_source_path}/components/#{component_name}") + def stub_packer_source_path(packer_source_path:, component_name:) + allow(ReactOnRails::PackerUtils).to receive(:packer_source_path) + .and_return("#{packer_source_path}/components/#{component_name}") end end # rubocop:enable Metrics/BlockLength diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index 311b8e71b..1a6b2bf38 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -8,10 +8,10 @@ module ReactOnRails RSpec.describe Configuration do let(:existing_path) { Pathname.new(Dir.mktmpdir) } let(:not_existing_path) { "/path/to/#{SecureRandom.hex(4)}" } - let(:using_shakapacker) { false } + let(:using_packer) { false } before do - allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(using_shakapacker) + allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(using_packer) ReactOnRails.instance_variable_set(:@configuration, nil) end @@ -20,15 +20,15 @@ module ReactOnRails end describe "generated_assets_dir" do - let(:using_shakapacker) { true } - let(:shakapacker_public_output_path) do + let(:using_packer) { true } + let(:packer_public_output_path) do File.expand_path(File.join(Rails.root, "public/webpack/dev")) end before do allow(Rails).to receive(:root).and_return(File.expand_path(".")) allow(Shakapacker).to receive_message_chain("config.public_output_path") - .and_return(shakapacker_public_output_path) + .and_return(packer_public_output_path) end it "does not throw if the generated assets dir is blank with webpacker" do @@ -39,7 +39,7 @@ module ReactOnRails end.not_to raise_error end - it "does not throw if the shakapacker_public_output_path does match the generated assets dir" do + it "does not throw if the packer_public_output_path does match the generated assets dir" do expect do ReactOnRails.configure do |config| config.generated_assets_dir = "public/webpack/dev" @@ -47,7 +47,7 @@ module ReactOnRails end.not_to raise_error end - it "does throw if the shakapacker_public_output_path does not match the generated assets dir" do + it "does throw if the packer_public_output_path does not match the generated assets dir" do expect do ReactOnRails.configure do |config| config.generated_assets_dir = "public/webpack/other" @@ -266,7 +266,7 @@ module ReactOnRails end it "checks that autobundling requirements are met if configuration options for autobundling are set" do - allow(ReactOnRails::ShakapackerUtils).to receive_messages(using_shakapacker?: true, + allow(ReactOnRails::PackerUtils).to receive_messages(using_packer?: true, shackapacker_version_requirement_met?: true, nested_entries?: true) @@ -275,9 +275,9 @@ module ReactOnRails config.components_subdirectory = "something" end - expect(ReactOnRails::ShakapackerUtils).to have_received(:using_shakapacker?).thrice - expect(ReactOnRails::ShakapackerUtils).to have_received(:shackapacker_version_requirement_met?) - expect(ReactOnRails::ShakapackerUtils).to have_received(:nested_entries?) + expect(ReactOnRails::PackerUtils).to have_received(:using_packer?).thrice + expect(ReactOnRails::PackerUtils).to have_received(:shakapacker_version_requirement_met?) + expect(ReactOnRails::PackerUtils).to have_received(:nested_entries?) end it "has a default configuration of the gem" do diff --git a/spec/react_on_rails/locales_to_js_spec.rb b/spec/react_on_rails/locales_to_js_spec.rb index eefa37827..e33e3d2b5 100644 --- a/spec/react_on_rails/locales_to_js_spec.rb +++ b/spec/react_on_rails/locales_to_js_spec.rb @@ -10,7 +10,7 @@ module ReactOnRails let(:default_path) { "#{i18n_dir}/default.js" } before do - allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(false) + allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(false) end shared_examples "locale to js" do diff --git a/spec/react_on_rails/packer_utils_spec.rb b/spec/react_on_rails/packer_utils_spec.rb new file mode 100644 index 000000000..b7bd4f2e5 --- /dev/null +++ b/spec/react_on_rails/packer_utils_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require_relative "spec_helper" + +module ReactOnRails + describe PackerUtils do + describe ".shakapacker_version_requirement_met?" do + minimum_version = [6, 5, 3] + + it "returns false when version is lower than minimum_version" do + allow(described_class).to receive(:shakapacker_version).and_return("6.5.0") + + expect(described_class.shakapacker_version_requirement_met?(minimum_version)).to be(false) + + allow(described_class).to receive(:shakapacker_version).and_return("6.4.7") + expect(described_class.shakapacker_version_requirement_met?(minimum_version)).to be(false) + + allow(described_class).to receive(:shakapacker_version).and_return("5.7.7") + expect(described_class.shakapacker_version_requirement_met?(minimum_version)).to be(false) + end + + it "returns true when version is equal to minimum_version" do + allow(described_class).to receive(:shakapacker_version).and_return("6.5.3") + expect(described_class.shakapacker_version_requirement_met?(minimum_version)).to be(true) + end + + it "returns true when version is greater than minimum_version" do + allow(described_class).to receive(:shakapacker_version).and_return("6.6.0") + expect(described_class.shakapacker_version_requirement_met?(minimum_version)).to be(true) + + allow(described_class).to receive(:shakapacker_version).and_return("6.5.4") + expect(described_class.shakapacker_version_requirement_met?(minimum_version)).to be(true) + + allow(described_class).to receive(:shakapacker_version).and_return("7.7.7") + expect(described_class.shakapacker_version_requirement_met?(minimum_version)).to be(true) + end + end + end +end diff --git a/spec/react_on_rails/shakapacker_utils_spec.rb b/spec/react_on_rails/shakapacker_utils_spec.rb deleted file mode 100644 index aecbf5ba9..000000000 --- a/spec/react_on_rails/shakapacker_utils_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -require_relative "spec_helper" - -module ReactOnRails - describe ShakapackerUtils do - describe ".using_shakapacker?" do - subject do - described_class.using_shakapacker? - end - - it { is_expected.to be(true) } - end - - describe ".shackapacker_version_requirement_met?" do - minimum_version = [7, 2, 1] - - it "returns false when version is lower than minimum_version" do - allow(described_class).to receive(:shakapacker_version).and_return("7.2.0") - expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(false) - - allow(described_class).to receive(:shakapacker_version).and_return("7.1.0") - expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(false) - - allow(described_class).to receive(:shakapacker_version).and_return("6.6.0") - expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(false) - end - - it "returns true when version is equal to minimum_version" do - allow(described_class).to receive(:shakapacker_version).and_return("7.2.1") - expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) - end - - it "returns true when version is greater than minimum_version" do - allow(described_class).to receive(:shakapacker_version).and_return("7.2.3") - expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) - - allow(described_class).to receive(:shakapacker_version).and_return("7.3.0") - expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) - - allow(described_class).to receive(:shakapacker_version).and_return("8.0.0") - expect(described_class.shackapacker_version_requirement_met?(minimum_version)).to be(true) - end - end - end -end diff --git a/spec/react_on_rails/spec_helper.rb b/spec/react_on_rails/spec_helper.rb index 92a2bd31a..c88d12355 100644 --- a/spec/react_on_rails/spec_helper.rb +++ b/spec/react_on_rails/spec_helper.rb @@ -69,7 +69,7 @@ # ENV value RSPEC_RETRY_RETRY_COUNT should be set to 1 if you don't want to retry (defined in # rspec/retry) - config.default_retry_count = 3 + config.default_retry_count = 1 # Only retry when Selenium raises Net::ReadTimeout # config.exceptions_to_retry = [Net::ReadTimeout] diff --git a/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb b/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb index 16735373b..347b3f126 100644 --- a/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb +++ b/spec/react_on_rails/test_helper/ensure_assets_compiled_spec.rb @@ -9,7 +9,7 @@ after { described_class.has_been_run = false } before do - allow(ReactOnRails::ShakapackerUtils).to receive(:check_manifest_not_cached).and_return(nil) + allow(ReactOnRails::PackerUtils).to receive(:check_manifest_not_cached).and_return(nil) double_packs = instance_double(ReactOnRails::PacksGenerator) allow(ReactOnRails::PacksGenerator).to receive(:instance).and_return(double_packs) allow(double_packs).to receive(:generate_packs_if_stale) diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index 5dd18d9df..9f7b5e118 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -20,13 +20,13 @@ end before do - allow(ReactOnRails::ShakapackerUtils).to receive(:check_manifest_not_cached).and_return(nil) + allow(ReactOnRails::PackerUtils).to receive(:check_manifest_not_cached).and_return(nil) allow(ReactOnRails::Utils).to receive(:generated_assets_full_path).and_return(generated_assets_full_path) end context "with Webpacker" do before do - allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(true) + allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(true) end context "when compiled assets with manifest exist and are up-to-date" do @@ -34,7 +34,7 @@ before do require "shakapacker" - allow(ReactOnRails::ShakapackerUtils).to receive(:manifest_exists?).and_return(true) + allow(ReactOnRails::PackerUtils).to receive(:manifest_exists?).and_return(true) allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) .with("manifest.json") .and_return(File.join(generated_assets_full_path, "manifest.json")) @@ -52,7 +52,7 @@ before do require "shakapacker" - allow(ReactOnRails::ShakapackerUtils).to receive(:manifest_exists?).and_return(false) + allow(ReactOnRails::PackerUtils).to receive(:manifest_exists?).and_return(false) end specify { expect(checker.stale_generated_webpack_files).to eq(["manifest.json"]) } @@ -64,7 +64,7 @@ before do require "shakapacker" - allow(ReactOnRails::ShakapackerUtils).to receive_messages( + allow(ReactOnRails::PackerUtils).to receive_messages( manifest_exists?: true, shakapacker_public_output_path: generated_assets_full_path ) @@ -89,7 +89,7 @@ let(:webpack_generated_files) { %w[client-bundle.js server-bundle.js] } before do - allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(false) + allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(false) end context "when compiled assets exist and are up-to-date" do diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index 003ffeb88..db53b82d5 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -21,7 +21,7 @@ module ReactOnRails end context "with Shakapacker enabled", :shakapacker do - let(:shakapacker_public_output_path) do + let(:packer_public_output_path) do File.expand_path(File.join(Rails.root, "public/webpack/dev")) end @@ -31,14 +31,14 @@ module ReactOnRails allow(Shakapacker).to receive_message_chain("dev_server.running?") .and_return(false) allow(Shakapacker).to receive_message_chain("config.public_output_path") - .and_return(shakapacker_public_output_path) - allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(true) + .and_return(packer_public_output_path) + allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(true) end context "when file in manifest", :shakapacker do before do # Note Shakapacker manifest lookup is inside of the public_output_path - # [2] (pry) ReactOnRails::ShakapackerUtils: 0> Shakapacker.manifest.lookup("app-bundle.js") + # [2] (pry) ReactOnRails::PackerUtils: 0> Shakapacker.manifest.lookup("app-bundle.js") # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js" allow(Shakapacker).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") @@ -47,7 +47,7 @@ module ReactOnRails .and_return("server-bundle.js") end - it { is_expected.to eq("#{shakapacker_public_output_path}/webpack-bundle-0123456789abcdef.js") } + it { is_expected.to eq("#{packer_public_output_path}/webpack-bundle-0123456789abcdef.js") } end context "with manifest.json" do @@ -55,15 +55,15 @@ module ReactOnRails described_class.bundle_js_file_path("manifest.json") end - it { is_expected.to eq("#{shakapacker_public_output_path}/manifest.json") } + it { is_expected.to eq("#{packer_public_output_path}/manifest.json") } end end - context "without Shakapacker enabled" do + context "without a packer enabled" do before do allow(ReactOnRails).to receive_message_chain(:configuration, :generated_assets_dir) .and_return("public/webpack/dev") - allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(false) + allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(false) end it { is_expected.to eq(File.expand_path(File.join(Rails.root, "public/webpack/dev/webpack-bundle.js"))) } @@ -77,7 +77,7 @@ module ReactOnRails allow(Shakapacker).to receive_message_chain("config.send").with(:data) .and_return({}) - expect(described_class.using_webpacker_source_path_is_not_defined_and_custom_node_modules?).to be(false) + expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to eq(false) end it "returns false if source_path is defined in the config/webpacker.yml and node_modules defined" do @@ -86,7 +86,7 @@ module ReactOnRails allow(Shakapacker).to receive_message_chain("config.send").with(:data) .and_return(source_path: "client/app") - expect(described_class.using_webpacker_source_path_is_not_defined_and_custom_node_modules?).to be(false) + expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to eq(false) end it "returns true if node_modules is not blank and the source_path is not defined in config/webpacker.yml" do @@ -95,14 +95,14 @@ module ReactOnRails allow(Shakapacker).to receive_message_chain("config.send").with(:data) .and_return({}) - expect(described_class.using_webpacker_source_path_is_not_defined_and_custom_node_modules?).to be(true) + expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to eq(true) end end describe ".server_bundle_js_file_path with Shakapacker enabled" do before do allow(Rails).to receive(:root).and_return(Pathname.new(".")) - allow(ReactOnRails::ShakapackerUtils).to receive(:using_shakapacker?).and_return(true) + allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(true) allow(Shakapacker).to receive_message_chain("config.public_output_path") .and_return(Pathname.new("public/webpack/development")) end @@ -342,6 +342,13 @@ module ReactOnRails it { is_expected.to eq("") } end + + describe ".gem_available?" do + it "calls Gem.loaded_specs" do + expect(Gem).to receive(:loaded_specs) + described_class.gem_available?("nonexistent_gem") + end + end end end end From 812c94c76e4873b00e3973fce97a2aafc8da0aa2 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 11 Jun 2024 20:11:08 -0500 Subject: [PATCH 13/81] Ci fixes & linting --- Gemfile.lock | 2 +- .../react_on_rails/base_generator.rb | 2 -- lib/react_on_rails/configuration.rb | 20 +++++++++---------- lib/react_on_rails/utils.rb | 2 +- spec/react_on_rails/configuration_spec.rb | 8 ++++---- .../webpack_assets_status_checker_spec.rb | 2 +- spec/react_on_rails/utils_spec.rb | 6 +++--- 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2cfcfd92f..5864f7941 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - react_on_rails (14.0.1) + react_on_rails (14.0.2) addressable connection_pool execjs (~> 2.5) diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index 04df541be..c3941f4d6 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -3,7 +3,6 @@ require "rails/generators" require_relative "generator_messages" require_relative "generator_helper" -# rubocop:disable Metrics/ClassLength module ReactOnRails module Generators class BaseGenerator < Rails::Generators::Base @@ -167,4 +166,3 @@ def add_configure_rspec_to_compile_assets(helper_file) end end end -# rubocop:enable Metrics/ClassLength diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index 99e8b25b4..a2a0b35ff 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -174,8 +174,8 @@ def error_if_using_packer_and_generated_assets_dir_not_match_public_output_path packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path if File.expand_path(generated_assets_dir) == packer_public_output_path.to_s - Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` "\ - "with #{ReactOnRails::PackerUtils.packer_type}. "\ + Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \ + "with #{ReactOnRails::PackerUtils.packer_type}. " \ "Remove this line from your configuration file.") else msg = <<~MSG @@ -214,8 +214,8 @@ def configure_generated_assets_dirs_deprecation if ReactOnRails::PackerUtils.using_packer? packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path # rubocop:disable Layout/LineLength - Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor "\ - "the generated_assets_dir when using Shakapacker. This is defined by "\ + Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor " \ + "the generated_assets_dir when using Shakapacker. This is defined by " \ "public_output_path specified in #{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}." # rubocop:enable Layout/LineLength return @@ -268,13 +268,13 @@ def shakapacker_clean_task def compile_command_conflict_message <<~MSG - React on Rails and Shakapacker error in configuration! - In order to use config/react_on_rails.rb config.build_production_command, - you must edit config/#{ReactOnRails::PackerUtils.packer_type}.yml to include this value in the default configuration: - '#{ReactOnRails::PackerUtils.packer_type}_precompile: false' + React on Rails and Shakapacker error in configuration! + In order to use config/react_on_rails.rb config.build_production_command, + you must edit config/#{ReactOnRails::PackerUtils.packer_type}.yml to include this value in the default configuration: + '#{ReactOnRails::PackerUtils.packer_type}_precompile: false' - Alternatively, remove the config/react_on_rails.rb config.build_production_command and the - default bin/#{ReactOnRails::PackerUtils.packer_type} script will be used for assets:precompile. + Alternatively, remove the config/react_on_rails.rb config.build_production_command and the + default bin/#{ReactOnRails::PackerUtils.packer_type} script will be used for assets:precompile. MSG end diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index 737d955aa..c92067b88 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -82,7 +82,7 @@ def self.server_bundle_js_file_path @server_bundle_path = if ReactOnRails::PackerUtils.using_packer? begin bundle_js_file_path(bundle_name) - rescue Webpacker::Manifest::MissingEntryError, Shakapacker::Manifest::MissingEntryError + rescue ReactOnRails::PackerUtils.adapter::Manifest::MissingEntryError File.expand_path( File.join(ReactOnRails::PackerUtils.packer_public_output_path, bundle_name) diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index 1a6b2bf38..49dcfe17e 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -77,7 +77,7 @@ module ReactOnRails describe ".build_production_command" do context "when using Shakapacker 7" do before do - allow(ReactOnRails::ShakapackerUtils) + allow(ReactOnRails::PackerUtils) .to receive("shakapacker_version") .and_return("7.0.0") end @@ -121,7 +121,7 @@ module ReactOnRails context "when using Shakapacker 8" do before do - allow(ReactOnRails::ShakapackerUtils) + allow(ReactOnRails::PackerUtils) .to receive("shakapacker_version") .and_return("8.0.0") end @@ -267,8 +267,8 @@ module ReactOnRails it "checks that autobundling requirements are met if configuration options for autobundling are set" do allow(ReactOnRails::PackerUtils).to receive_messages(using_packer?: true, - shackapacker_version_requirement_met?: true, - nested_entries?: true) + shakapacker_version_requirement_met?: true, + nested_entries?: true) ReactOnRails.configure do |config| config.auto_load_bundle = true diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index 9f7b5e118..d1782bd31 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -66,7 +66,7 @@ require "shakapacker" allow(ReactOnRails::PackerUtils).to receive_messages( manifest_exists?: true, - shakapacker_public_output_path: generated_assets_full_path + packer_public_output_path: generated_assets_full_path ) allow(ReactOnRails.configuration).to receive(:server_bundle_js_file).and_return("server-bundle.js") allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index db53b82d5..0b1786ed0 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -77,7 +77,7 @@ module ReactOnRails allow(Shakapacker).to receive_message_chain("config.send").with(:data) .and_return({}) - expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to eq(false) + expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(false) end it "returns false if source_path is defined in the config/webpacker.yml and node_modules defined" do @@ -86,7 +86,7 @@ module ReactOnRails allow(Shakapacker).to receive_message_chain("config.send").with(:data) .and_return(source_path: "client/app") - expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to eq(false) + expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(false) end it "returns true if node_modules is not blank and the source_path is not defined in config/webpacker.yml" do @@ -95,7 +95,7 @@ module ReactOnRails allow(Shakapacker).to receive_message_chain("config.send").with(:data) .and_return({}) - expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to eq(true) + expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(true) end end From 328aacb0c3e202d9c77559b71d192f49fd77040d Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 12 Jun 2024 01:54:57 -0500 Subject: [PATCH 14/81] per review --- lib/react_on_rails/configuration.rb | 12 ++---------- lib/react_on_rails/packer_utils.rb | 24 ++++++++++++------------ lib/react_on_rails/utils.rb | 2 +- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index a2a0b35ff..c1ceb316a 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -215,7 +215,7 @@ def configure_generated_assets_dirs_deprecation packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path # rubocop:disable Layout/LineLength Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor " \ - "the generated_assets_dir when using Shakapacker. This is defined by " \ + "the generated_assets_dir when using #{ReactOnRails::PackerUtils.packer_type.upcase_first}. This is defined by " \ "public_output_path specified in #{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}." # rubocop:enable Layout/LineLength return @@ -257,18 +257,10 @@ def raise_missing_components_subdirectory raise ReactOnRails::Error, msg end - def shakapacker_precompile? - Shakapacker.config.shakapacker_precompile? - end - - def shakapacker_clean_task - "shakapacker:clean" - end - def compile_command_conflict_message <<~MSG - React on Rails and Shakapacker error in configuration! + React on Rails and #{ReactOnRails::PackerUtils.packer_type.upcase_first} error in configuration! In order to use config/react_on_rails.rb config.build_production_command, you must edit config/#{ReactOnRails::PackerUtils.packer_type}.yml to include this value in the default configuration: '#{ReactOnRails::PackerUtils.packer_type}_precompile: false' diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index 5569b4a71..6566305d3 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -28,7 +28,7 @@ def self.packer_type nil end - def self.adapter + def self.packer return nil unless using_packer? if using_shakapacker? @@ -42,7 +42,7 @@ def self.adapter def self.dev_server_running? return false unless using_packer? - adapter.dev_server.running? + packer.dev_server.running? end def self.shakapacker_version @@ -68,7 +68,7 @@ def self.shakapacker_version_requirement_met?(required_version) # the hashed server bundle if using the same bundle for the client. # Otherwise returns a file path. def self.bundle_js_uri_from_packer(bundle_name) - hashed_bundle_name = adapter.manifest.lookup!(bundle_name) + hashed_bundle_name = packer.manifest.lookup!(bundle_name) # Support for hashing the server-bundle and having that built # the webpack-dev-server is provided by the config value @@ -76,9 +76,9 @@ def self.bundle_js_uri_from_packer(bundle_name) # would mean that the bundle is created by the webpack-dev-server is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file - if adapter.dev_server.running? && (!is_server_bundle || + if packer.dev_server.running? && (!is_server_bundle || ReactOnRails.configuration.same_bundle_for_client_and_server) - "#{adapter.dev_server.protocol}://#{adapter.dev_server.host_with_port}#{hashed_bundle_name}" + "#{packer.dev_server.protocol}://#{packer.dev_server.host_with_port}#{hashed_bundle_name}" else File.expand_path(File.join("public", hashed_bundle_name)).to_s end @@ -92,31 +92,31 @@ def self.precompile? end def self.packer_source_path - adapter.config.source_path + packer.config.source_path end def self.packer_source_entry_path - adapter.config.source_entry_path + packer.config.source_entry_path end def self.nested_entries? - adapter.config.nested_entries? + packer.config.nested_entries? end def self.packer_public_output_path - adapter.config.public_output_path.to_s + packer.config.public_output_path.to_s end def self.manifest_exists? - adapter.config.public_manifest_path.exist? + packer.config.public_manifest_path.exist? end def self.packer_source_path_explicit? - adapter.config.send(:data)[:source_path].present? + packer.config.send(:data)[:source_path].present? end def self.check_manifest_not_cached - return unless using_packer? && adapter.config.cache_manifest? + return unless using_packer? && packer.config.cache_manifest? msg = <<-MSG.strip_heredoc ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index c92067b88..8c5bb0d63 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -82,7 +82,7 @@ def self.server_bundle_js_file_path @server_bundle_path = if ReactOnRails::PackerUtils.using_packer? begin bundle_js_file_path(bundle_name) - rescue ReactOnRails::PackerUtils.adapter::Manifest::MissingEntryError + rescue ReactOnRails::PackerUtils.packer::Manifest::MissingEntryError File.expand_path( File.join(ReactOnRails::PackerUtils.packer_public_output_path, bundle_name) From 52c0ea807cada32bf10006a12a167ec1ab2a0dfe Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 12 Jun 2024 23:12:43 -0500 Subject: [PATCH 15/81] Ci fix for changed-files --- .github/workflows/examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index a84b221aa..24c82d121 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -14,7 +14,7 @@ jobs: with: persist-credentials: false - name: Get changed files - id: changed-files-specific + id: changed-files uses: tj-actions/changed-files@v44 with: files: | From 3711e9c94d482bb7d1b3010fb3593315fa3f39cc Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 13 Jun 2024 00:07:34 -0500 Subject: [PATCH 16/81] revert changes to install generator --- .../react_on_rails/install_generator.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/generators/react_on_rails/install_generator.rb b/lib/generators/react_on_rails/install_generator.rb index 91ecfd59c..cde32c21a 100644 --- a/lib/generators/react_on_rails/install_generator.rb +++ b/lib/generators/react_on_rails/install_generator.rb @@ -53,6 +53,8 @@ def invoke_generators else invoke "react_on_rails:react_no_redux" end + + invoke "react_on_rails:adapt_for_older_shakapacker" unless using_shakapacker_7_or_above? end # NOTE: other requirements for existing files such as .gitignore or application. @@ -93,8 +95,21 @@ def add_bin_scripts def add_post_install_message message = GeneratorMessages.helpful_message_after_installation + unless using_shakapacker_7_or_above? + message = message.gsub("config/shakapacker", "config/webpacker") + message = message.gsub("bin/shakapacker", "bin/webpacker") + end + GeneratorMessages.add_info(message) end + + def using_shakapacker_7_or_above? + shakapacker_gem = Gem::Specification.find_by_name("shakapacker") + shakapacker_gem.version.segments.first >= 7 + rescue Gem::MissingSpecError + # In case using Webpacker + false + end end end end From 7810da090ed5b887fce776bfd09ac2ba2a5338ec Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 13 Jun 2024 19:02:13 -0500 Subject: [PATCH 17/81] WIP --- .github/workflows/main.yml | 24 +- Gemfile | 18 + Gemfile.development_dependencies | 2 +- Gemfile.lock | 21 +- appraisals | 7 + gemfiles/shakapacker_6.gemfile | 10 + gemfiles/shakapacker_6.gemfile.lock | 476 +++++++++++++++++ gemfiles/shakapacker_8.gemfile | 10 + gemfiles/shakapacker_8.gemfile.lock | 478 ++++++++++++++++++ lib/react_on_rails/packs_generator.rb | 2 +- rakelib/examples.rake | 2 +- spec/dummy/Gemfile | 1 + spec/dummy/Gemfile.lock | 7 +- spec/dummy/bin/shakapacker-dev-server | 2 +- spec/dummy/bin/webpacker | 25 + spec/dummy/bin/webpacker-dev-server | 22 + .../config/webpack/commonWebpackConfig.js | 4 +- spec/dummy/config/webpack/webpack.config.js | 4 +- spec/dummy/config/webpacker.yml | 73 +++ 19 files changed, 1156 insertions(+), 32 deletions(-) create mode 100644 appraisals create mode 100644 gemfiles/shakapacker_6.gemfile create mode 100644 gemfiles/shakapacker_6.gemfile.lock create mode 100644 gemfiles/shakapacker_8.gemfile create mode 100644 gemfiles/shakapacker_8.gemfile.lock create mode 100755 spec/dummy/bin/webpacker create mode 100755 spec/dummy/bin/webpacker-dev-server create mode 100644 spec/dummy/config/webpacker.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b26a3e9d..f0cfa1a42 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,9 +10,11 @@ jobs: build-dummy-app-webpack-test-bundles: strategy: matrix: - ruby: [3.0, 3.3] - node: [16, 20] + versions: ['oldest_versions', 'newest_versions'] runs-on: ubuntu-22.04 + env: + # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/shakapacker_${{ matrix.versions == 'oldest_versions' && '6' || '8' }}.gemfile steps: - uses: actions/checkout@v4 with: @@ -20,7 +22,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: ${{ matrix.versions == 'oldest_versions' && '3.0' || '3.3' }} bundler: 2.5.9 # libyaml-dev is needed for psych v5 # this gem depends on sdoc which depends on rdoc which depends on psych @@ -29,7 +31,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node }} + node-version: ${{ matrix.versions == 'oldest_versions' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -77,15 +79,17 @@ jobs: uses: actions/cache/save@v3 with: path: spec/dummy/public/webpack - key: v5-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }} + key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} main: needs: build-dummy-app-webpack-test-bundles strategy: matrix: - ruby: [3.0, 3.3] - node: [16, 20] + versions: ['oldest_versions', 'newest_versions'] runs-on: ubuntu-22.04 + env: + # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/shakapacker_${{ matrix.versions == 'oldest_versions' && '6' || '8' }}.gemfile steps: - uses: actions/checkout@v4 with: @@ -93,12 +97,12 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: ${{ matrix.versions == 'oldest_versions' && '3.0' || '3.3' }} bundler: 2.5.9 - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node }} + node-version: ${{ matrix.versions == 'oldest_versions' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -134,7 +138,7 @@ jobs: uses: actions/cache@v3 with: path: spec/dummy/public/webpack - key: v5-dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }} + key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji diff --git a/Gemfile b/Gemfile index 18a965c64..f02a91151 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,25 @@ # frozen_string_literal: true +require 'appraisal/bundler_dsl' +::Appraisal::BundlerDSL.class_eval do + def eval_gemfile(path, contents = nil) + (@eval_gemfile ||= []) << [path, contents] + end + + private + + def eval_gemfile_entry + @eval_gemfile.map { |(p, c)| "eval_gemfile(#{p.inspect}#{", #{c.inspect}" if c})" } * "\n\n" + end + + alias_method :eval_gemfile_entry_for_dup, :eval_gemfile_entry + + self::PARTS << 'eval_gemfile' +end unless ::Appraisal::BundlerDSL::PARTS[-1] == 'eval_gemfile' + source "https://rubygems.org" +gem "appraisal" # Specify your gem"s dependencies in react_on_rails.gemspec gemspec diff --git a/Gemfile.development_dependencies b/Gemfile.development_dependencies index f972b719f..147555d9d 100644 --- a/Gemfile.development_dependencies +++ b/Gemfile.development_dependencies @@ -1,8 +1,8 @@ # frozen_string_literal: true -gem "shakapacker", "8.0.0" gem "bootsnap", require: false gem "rails", "~> 7.1" +gem "rake", "~> 13.2.1" gem "sqlite3", "~> 1.6" gem "sass-rails", "~> 6.0" diff --git a/Gemfile.lock b/Gemfile.lock index 5864f7941..3aaafb193 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,6 +88,10 @@ GEM addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) amazing_print (1.6.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) ast (2.4.2) base64 (0.2.0) bigdecimal (3.1.8) @@ -119,6 +123,9 @@ GEM tins (~> 1.6) crass (1.0.6) date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) diff-lcs (1.5.1) docile (1.4.0) drb (2.2.1) @@ -184,7 +191,6 @@ GEM nokogiri (1.16.5) mini_portile2 (~> 2.8.2) racc (~> 1.4) - package_json (0.1.0) parallel (1.24.0) parser (3.3.1.0) ast (~> 2.4.1) @@ -210,8 +216,6 @@ GEM nio4r (~> 2.0) racc (1.7.3) rack (3.0.11) - rack-proxy (0.7.7) - rack rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -333,13 +337,6 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - semantic_range (3.0.0) - shakapacker (8.0.0) - activesupport (>= 5.2) - package_json - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -393,10 +390,12 @@ PLATFORMS DEPENDENCIES amazing_print + appraisal bootsnap capybara capybara-screenshot coveralls + debug equivalent-xml gem-release generator_spec @@ -411,6 +410,7 @@ DEPENDENCIES pry-rescue puma (~> 6.0) rails (~> 7.1) + rake (~> 13.2.1) react_on_rails! rspec-rails rspec-retry @@ -422,7 +422,6 @@ DEPENDENCIES scss_lint sdoc selenium-webdriver (= 4.9.0) - shakapacker (= 8.0.0) spring (~> 4.0) sprockets (~> 4.0) sqlite3 (~> 1.6) diff --git a/appraisals b/appraisals new file mode 100644 index 000000000..5d30481be --- /dev/null +++ b/appraisals @@ -0,0 +1,7 @@ +appraise 'shakapacker_6' do + gem 'shakapacker', '~> 6.6.0' +end + +appraise 'shakapacker_8' do + gem 'shakapacker', '~> 8.0.0' +end diff --git a/gemfiles/shakapacker_6.gemfile b/gemfiles/shakapacker_6.gemfile new file mode 100644 index 000000000..ad4aa2af9 --- /dev/null +++ b/gemfiles/shakapacker_6.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "shakapacker", "~> 6.6.0" + +gemspec path: "../" + +eval_gemfile("/Users/judahmeek/apps/react_on_rails/Gemfile.development_dependencies") diff --git a/gemfiles/shakapacker_6.gemfile.lock b/gemfiles/shakapacker_6.gemfile.lock new file mode 100644 index 000000000..b7c920b13 --- /dev/null +++ b/gemfiles/shakapacker_6.gemfile.lock @@ -0,0 +1,476 @@ +PATH + remote: .. + specs: + react_on_rails (14.0.2) + addressable + connection_pool + execjs (~> 2.5) + rails (>= 5.2) + rainbow (~> 3.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.3.6) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) + marcel (~> 1.0) + activesupport (7.1.3.4) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + amazing_print (1.6.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + bootsnap (1.18.3) + msgpack (~> 1.2) + builder (3.3.0) + byebug (11.1.3) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + capybara-screenshot (1.0.26) + capybara (>= 1.0, < 4) + launchy + childprocess (5.0.0) + coderay (1.1.3) + concurrent-ruby (1.3.3) + connection_pool (2.4.1) + coveralls (0.8.23) + json (>= 1.8, < 3) + simplecov (~> 0.16.1) + term-ansicolor (~> 1.3) + thor (>= 0.19.4, < 2.0) + tins (~> 1.6) + crass (1.0.6) + date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.0) + drb (2.2.1) + equivalent-xml (0.6.0) + nokogiri (>= 1.4.3) + erubi (1.13.0) + execjs (2.9.1) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + gem-release (2.2.2) + generator_spec (0.10.0) + activesupport (>= 3.0.0) + railties (>= 3.0.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) + concurrent-ruby (~> 1.0) + interception (0.5) + io-console (0.7.2) + irb (1.13.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + jquery-rails (4.6.0) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + json (2.7.2) + language_server-protocol (3.17.0.3) + launchy (3.0.1) + addressable (~> 2.8) + childprocess (~> 5.0) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) + method_source (1.1.0) + mini_mime (1.1.5) + minitest (5.23.1) + msgpack (1.7.2) + mutex_m (0.2.0) + net-imap (0.4.12) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.6-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86-linux) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-linux) + racc (~> 1.4) + parallel (1.25.1) + parser (3.3.3.0) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.10.1) + byebug (~> 11.0) + pry (>= 0.13, < 0.15) + pry-doc (1.5.0) + pry (~> 0.11) + yard (~> 0.9.11) + pry-rails (0.3.9) + pry (>= 0.10.4) + pry-rescue (1.6.0) + interception (>= 0.5) + pry (>= 0.12.0) + psych (5.1.2) + stringio + public_suffix (5.0.5) + puma (6.4.2) + nio4r (~> 2.0) + racc (1.8.0) + rack (3.1.3) + rack-proxy (0.7.7) + rack + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + bundler (>= 1.15.0) + railties (= 7.1.3.4) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rdoc (6.7.0) + psych (>= 4.0.0) + regexp_parser (2.9.2) + reline (0.5.9) + io-console (~> 0.5) + rexml (3.3.0) + strscan + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-retry (0.6.2) + rspec-core (> 3.3) + rspec-support (3.13.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.61.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.30.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) + rubocop-performance (1.20.2) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) + rubocop-rspec (2.31.0) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.29.1) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) + rubyzip (2.3.2) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + scss_lint (0.60.0) + sass (~> 3.5, >= 3.5.5) + sdoc (2.6.1) + rdoc (>= 5.0) + selenium-webdriver (4.9.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + semantic_range (3.0.0) + shakapacker (6.6.0) + activesupport (>= 5.2) + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + spring (4.2.1) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) + sprockets (>= 3.0.0) + sqlite3 (1.7.3-aarch64-linux) + sqlite3 (1.7.3-arm-linux) + sqlite3 (1.7.3-arm64-darwin) + sqlite3 (1.7.3-x86-linux) + sqlite3 (1.7.3-x86_64-darwin) + sqlite3 (1.7.3-x86_64-linux) + stringio (3.1.1) + strscan (3.1.0) + sync (0.5.0) + term-ansicolor (1.8.0) + tins (~> 1.0) + thor (1.3.1) + tilt (2.3.0) + timeout (0.4.1) + tins (1.33.0) + bigdecimal + sync + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + unicode-display_width (2.5.0) + webdrivers (5.3.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0, < 4.11) + webrick (1.8.1) + websocket (1.2.10) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.36) + zeitwerk (2.6.15) + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + amazing_print + appraisal + bootsnap + capybara + capybara-screenshot + coveralls + debug + equivalent-xml + gem-release + generator_spec + jbuilder + jquery-rails + launchy + listen + pry + pry-byebug + pry-doc + pry-rails + pry-rescue + puma (~> 6.0) + rails (~> 7.1) + rake (~> 13.2.1) + react_on_rails! + rspec-rails + rspec-retry + rspec_junit_formatter + rubocop (= 1.61.0) + rubocop-performance (~> 1.20.0) + rubocop-rspec (~> 2.26) + sass-rails (~> 6.0) + scss_lint + sdoc + selenium-webdriver (= 4.9.0) + shakapacker (~> 6.6.0) + spring (~> 4.0) + sprockets (~> 4.0) + sqlite3 (~> 1.6) + turbolinks + uglifier + webdrivers (= 5.3.0) + +BUNDLED WITH + 2.5.9 diff --git a/gemfiles/shakapacker_8.gemfile b/gemfiles/shakapacker_8.gemfile new file mode 100644 index 000000000..fd0bd954c --- /dev/null +++ b/gemfiles/shakapacker_8.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "appraisal" +gem "shakapacker", "~> 8.0.0" + +gemspec path: "../" + +eval_gemfile("/Users/judahmeek/apps/react_on_rails/Gemfile.development_dependencies") diff --git a/gemfiles/shakapacker_8.gemfile.lock b/gemfiles/shakapacker_8.gemfile.lock new file mode 100644 index 000000000..19c962860 --- /dev/null +++ b/gemfiles/shakapacker_8.gemfile.lock @@ -0,0 +1,478 @@ +PATH + remote: .. + specs: + react_on_rails (14.0.2) + addressable + connection_pool + execjs (~> 2.5) + rails (>= 5.2) + rainbow (~> 3.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) + globalid (>= 0.3.6) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) + marcel (~> 1.0) + activesupport (7.1.3.4) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + amazing_print (1.6.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + bootsnap (1.18.3) + msgpack (~> 1.2) + builder (3.3.0) + byebug (11.1.3) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + capybara-screenshot (1.0.26) + capybara (>= 1.0, < 4) + launchy + childprocess (5.0.0) + coderay (1.1.3) + concurrent-ruby (1.3.3) + connection_pool (2.4.1) + coveralls (0.8.23) + json (>= 1.8, < 3) + simplecov (~> 0.16.1) + term-ansicolor (~> 1.3) + thor (>= 0.19.4, < 2.0) + tins (~> 1.6) + crass (1.0.6) + date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.0) + drb (2.2.1) + equivalent-xml (0.6.0) + nokogiri (>= 1.4.3) + erubi (1.13.0) + execjs (2.9.1) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + gem-release (2.2.2) + generator_spec (0.10.0) + activesupport (>= 3.0.0) + railties (>= 3.0.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) + concurrent-ruby (~> 1.0) + interception (0.5) + io-console (0.7.2) + irb (1.13.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + jquery-rails (4.6.0) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + json (2.7.2) + language_server-protocol (3.17.0.3) + launchy (3.0.1) + addressable (~> 2.8) + childprocess (~> 5.0) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) + method_source (1.1.0) + mini_mime (1.1.5) + minitest (5.23.1) + msgpack (1.7.2) + mutex_m (0.2.0) + net-imap (0.4.12) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.6-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86-linux) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-linux) + racc (~> 1.4) + package_json (0.1.0) + parallel (1.25.1) + parser (3.3.3.0) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.10.1) + byebug (~> 11.0) + pry (>= 0.13, < 0.15) + pry-doc (1.5.0) + pry (~> 0.11) + yard (~> 0.9.11) + pry-rails (0.3.9) + pry (>= 0.10.4) + pry-rescue (1.6.0) + interception (>= 0.5) + pry (>= 0.12.0) + psych (5.1.2) + stringio + public_suffix (5.0.5) + puma (6.4.2) + nio4r (~> 2.0) + racc (1.8.0) + rack (3.1.3) + rack-proxy (0.7.7) + rack + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) + bundler (>= 1.15.0) + railties (= 7.1.3.4) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rdoc (6.7.0) + psych (>= 4.0.0) + regexp_parser (2.9.2) + reline (0.5.9) + io-console (~> 0.5) + rexml (3.3.0) + strscan + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-retry (0.6.2) + rspec-core (> 3.3) + rspec-support (3.13.1) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + rubocop (1.61.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.30.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) + rubocop-performance (1.20.2) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) + rubocop-rspec (2.31.0) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.29.1) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) + rubyzip (2.3.2) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + scss_lint (0.60.0) + sass (~> 3.5, >= 3.5.5) + sdoc (2.6.1) + rdoc (>= 5.0) + selenium-webdriver (4.9.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + semantic_range (3.0.0) + shakapacker (8.0.0) + activesupport (>= 5.2) + package_json + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + spring (4.2.1) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.1) + actionpack (>= 6.1) + activesupport (>= 6.1) + sprockets (>= 3.0.0) + sqlite3 (1.7.3-aarch64-linux) + sqlite3 (1.7.3-arm-linux) + sqlite3 (1.7.3-arm64-darwin) + sqlite3 (1.7.3-x86-linux) + sqlite3 (1.7.3-x86_64-darwin) + sqlite3 (1.7.3-x86_64-linux) + stringio (3.1.1) + strscan (3.1.0) + sync (0.5.0) + term-ansicolor (1.8.0) + tins (~> 1.0) + thor (1.3.1) + tilt (2.3.0) + timeout (0.4.1) + tins (1.33.0) + bigdecimal + sync + turbolinks (5.2.1) + turbolinks-source (~> 5.2) + turbolinks-source (5.2.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) + unicode-display_width (2.5.0) + webdrivers (5.3.0) + nokogiri (~> 1.6) + rubyzip (>= 1.3.0) + selenium-webdriver (~> 4.0, < 4.11) + webrick (1.8.1) + websocket (1.2.10) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.36) + zeitwerk (2.6.15) + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + amazing_print + appraisal + bootsnap + capybara + capybara-screenshot + coveralls + debug + equivalent-xml + gem-release + generator_spec + jbuilder + jquery-rails + launchy + listen + pry + pry-byebug + pry-doc + pry-rails + pry-rescue + puma (~> 6.0) + rails (~> 7.1) + rake (~> 13.2.1) + react_on_rails! + rspec-rails + rspec-retry + rspec_junit_formatter + rubocop (= 1.61.0) + rubocop-performance (~> 1.20.0) + rubocop-rspec (~> 2.26) + sass-rails (~> 6.0) + scss_lint + sdoc + selenium-webdriver (= 4.9.0) + shakapacker (~> 8.0.0) + spring (~> 4.0) + sprockets (~> 4.0) + sqlite3 (~> 1.6) + turbolinks + uglifier + webdrivers (= 5.3.0) + +BUNDLED WITH + 2.5.9 diff --git a/lib/react_on_rails/packs_generator.rb b/lib/react_on_rails/packs_generator.rb index 1efc04529..2db3d6b0c 100644 --- a/lib/react_on_rails/packs_generator.rb +++ b/lib/react_on_rails/packs_generator.rb @@ -6,7 +6,7 @@ module ReactOnRails # rubocop:disable Metrics/ClassLength class PacksGenerator CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/ - MINIMUM_SHAKAPACKER_VERSION = [7, 2, 1].freeze + MINIMUM_SHAKAPACKER_VERSION = [6, 5, 1].freeze def self.instance @instance ||= PacksGenerator.new diff --git a/rakelib/examples.rake b/rakelib/examples.rake index 559f50b5a..9c315ef3a 100644 --- a/rakelib/examples.rake +++ b/rakelib/examples.rake @@ -35,7 +35,7 @@ namespace :examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "touch .gitignore") append_to_gemfile(example_type.gemfile, example_type.required_gems) bundle_install_in(example_type.dir) - sh_in_dir(example_type.dir, "rake webpacker:install") + sh_in_dir(example_type.dir, "rake #{ReactOnRails::PackerUtils.packer_type}:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) sh_in_dir(example_type.dir, "yarn") end diff --git a/spec/dummy/Gemfile b/spec/dummy/Gemfile index a2bcc402b..12cd863af 100644 --- a/spec/dummy/Gemfile +++ b/spec/dummy/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" +gem "shakapacker" eval_gemfile File.expand_path("../../Gemfile.development_dependencies", __dir__) gem "react_on_rails", path: "../.." diff --git a/spec/dummy/Gemfile.lock b/spec/dummy/Gemfile.lock index 967a46f71..f0499bc1c 100644 --- a/spec/dummy/Gemfile.lock +++ b/spec/dummy/Gemfile.lock @@ -250,7 +250,7 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.0.6) + rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) @@ -357,7 +357,7 @@ GEM sync (0.5.0) term-ansicolor (1.7.1) tins (~> 1.0) - thor (1.2.2) + thor (1.3.1) tilt (2.2.0) timeout (0.4.1) tins (1.32.1) @@ -407,6 +407,7 @@ DEPENDENCIES pry-rescue puma (~> 6.0) rails (~> 7.1) + rake (~> 13.2.1) react_on_rails! rspec-rails rspec-retry @@ -418,7 +419,7 @@ DEPENDENCIES scss_lint sdoc selenium-webdriver (= 4.9.0) - shakapacker (= 8.0.0) + shakapacker spring (~> 4.0) sprockets (~> 4.0) sqlite3 (~> 1.6) diff --git a/spec/dummy/bin/shakapacker-dev-server b/spec/dummy/bin/shakapacker-dev-server index 0db2861b5..d110072a6 100755 --- a/spec/dummy/bin/shakapacker-dev-server +++ b/spec/dummy/bin/shakapacker-dev-server @@ -8,7 +8,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath) require "bundler/setup" - +require "rake" require "shakapacker" require "shakapacker/dev_server_runner" diff --git a/spec/dummy/bin/webpacker b/spec/dummy/bin/webpacker new file mode 100755 index 000000000..f05487491 --- /dev/null +++ b/spec/dummy/bin/webpacker @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby + +require "pathname" +require "bundler/setup" +require "webpacker" +require "webpacker/webpack_runner" + +ENV["RAILS_ENV"] ||= "development" +ENV["NODE_ENV"] ||= ENV["RAILS_ENV"] +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath) + +require "rake" + +# Recommendation is to generate packs before compilation. +# SERVER_BUNDLE_ONLY is true when also running the bin/webpacker-dev-server, +# so no need to run twice. +unless ENV["SERVER_BUNDLE_ONLY"] == "true" + Rake.application.load_rakefile + Rake::Task["react_on_rails:generate_packs"].invoke +end + +APP_ROOT = File.expand_path("..", __dir__) +Dir.chdir(APP_ROOT) do + Webpacker::WebpackRunner.run(ARGV) +end diff --git a/spec/dummy/bin/webpacker-dev-server b/spec/dummy/bin/webpacker-dev-server new file mode 100755 index 000000000..79e6e21c3 --- /dev/null +++ b/spec/dummy/bin/webpacker-dev-server @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +ENV["RAILS_ENV"] ||= "development" +ENV["NODE_ENV"] ||= ENV["RAILS_ENV"] + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require "bundler/setup" +require "rake" +require "webpacker" +require "webpacker/dev_server_runner" + +# Recommendation is to generate packs before compilation +Rake.application.load_rakefile +Rake::Task["react_on_rails:generate_packs"].invoke + +APP_ROOT = File.expand_path("..", __dir__) +Dir.chdir(APP_ROOT) do + Webpacker::DevServerRunner.run(ARGV) +end diff --git a/spec/dummy/config/webpack/commonWebpackConfig.js b/spec/dummy/config/webpack/commonWebpackConfig.js index 6e64e8440..ed1496105 100644 --- a/spec/dummy/config/webpack/commonWebpackConfig.js +++ b/spec/dummy/config/webpack/commonWebpackConfig.js @@ -1,10 +1,10 @@ // Common configuration applying to client and server configuration -const { generateWebpackConfig, merge } = require('shakapacker'); +const { generateWebpackConfig, v6WebpackConfig, merge } = require('shakapacker'); const webpack = require('webpack'); const aliasConfig = require('./alias.js'); -const baseClientWebpackConfig = generateWebpackConfig(); +const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfig(); const commonOptions = { resolve: { diff --git a/spec/dummy/config/webpack/webpack.config.js b/spec/dummy/config/webpack/webpack.config.js index 40089dcf9..eab60a879 100644 --- a/spec/dummy/config/webpack/webpack.config.js +++ b/spec/dummy/config/webpack/webpack.config.js @@ -1,4 +1,4 @@ -const { env, generateWebpackConfig } = require('shakapacker'); +const { env, generateWebpackConfig, v6WebpackConfig } = require('shakapacker'); const { existsSync } = require('fs'); const { resolve } = require('path'); @@ -8,7 +8,7 @@ const envSpecificConfig = () => { console.log(`Loading ENV specific webpack configuration file ${path}`); return require(path); } else { - return generateWebpackConfig(); + return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfig(); } }; diff --git a/spec/dummy/config/webpacker.yml b/spec/dummy/config/webpacker.yml new file mode 100644 index 000000000..632e9ac22 --- /dev/null +++ b/spec/dummy/config/webpacker.yml @@ -0,0 +1,73 @@ +# Note: You must restart bin/shakapacker-dev-server for changes to take effect + +default: &default + source_path: client/app + source_entry_path: packs + public_root_path: public + + cache_path: tmp/cache/webpacker + webpack_compile_output: false + ensure_consistent_versioning: true + + # Additional paths webpack should lookup modules + # ['app/assets', 'engine/foo/app/assets'] + additional_paths: [] + + # Reload manifest.json on all requests so we reload latest compiled packs + cache_manifest: false + nested_entries: true + +development: + <<: *default + # Turn this to true if you want to use the rails/shakapacker check that the test + # bundles need building. Also, remove the customization to spec/rails_helper.rb. + compile: false + + public_output_path: webpack/development + + # Reference: https://webpack.js.org/configuration/dev-server/ + dev_server: + https: false + host: localhost + port: 3035 + # Hot Module Replacement updates modules while the application is running without a full reload + hmr: true + # Defaults to the inverse of hmr. Uncomment to manually set this. + # live_reload: true + client: + # Should we show a full-screen overlay in the browser when there are compiler errors or warnings? + overlay: true + # May also be a string + # webSocketURL: + # hostname: "0.0.0.0" + # pathname: "/ws" + # port: 8080 + # Should we use gzip compression? + compress: true + # Note that apps that do not check the host are vulnerable to DNS rebinding attacks + allowed_hosts: "all" + pretty: true + headers: + 'Access-Control-Allow-Origin': '*' + static: + watch: + ignored: '**/node_modules/**' + + +test: + <<: *default + compile: false + + # Compile test packs to a separate directory + public_output_path: webpack/test + +production: + <<: *default + + public_output_path: webpack/production + + # Production depends on precompilation of packs prior to booting for performance. + compile: false + + # Cache manifest.json for performance + cache_manifest: true From 0d82c0268232e42d39f55fdf3b0373019d14dfec Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 13 Jun 2024 21:17:15 -0500 Subject: [PATCH 18/81] still wip --- .github/workflows/main.yml | 29 +++++++++--------- .github/workflows/rspec-package-specs.yml | 2 +- CONTRIBUTING.md | 21 +++++-------- appraisals | 4 +-- ...acker_6.gemfile => shakapacker_v6.gemfile} | 0 ...mfile.lock => shakapacker_v6.gemfile.lock} | 0 ...acker_8.gemfile => shakapacker_v8.gemfile} | 0 ...mfile.lock => shakapacker_v8.gemfile.lock} | 0 package.json | 4 +-- rakelib/dummy_apps.rake | 30 ------------------- rakelib/run_rspec.rake | 4 +-- spec/dummy/package.json | 1 - spec/dummy/yarn.lock | 25 ---------------- 13 files changed, 29 insertions(+), 91 deletions(-) rename gemfiles/{shakapacker_6.gemfile => shakapacker_v6.gemfile} (100%) rename gemfiles/{shakapacker_6.gemfile.lock => shakapacker_v6.gemfile.lock} (100%) rename gemfiles/{shakapacker_8.gemfile => shakapacker_v8.gemfile} (100%) rename gemfiles/{shakapacker_8.gemfile.lock => shakapacker_v8.gemfile.lock} (100%) delete mode 100644 rakelib/dummy_apps.rake diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0cfa1a42..9a9c130f4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,11 +10,11 @@ jobs: build-dummy-app-webpack-test-bundles: strategy: matrix: - versions: ['oldest_versions', 'newest_versions'] + versions: ['shakapacker_v6', 'shakapacker_v8'] runs-on: ubuntu-22.04 env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps - BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/shakapacker_${{ matrix.versions == 'oldest_versions' && '6' || '8' }}.gemfile + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.versions }}.gemfile steps: - uses: actions/checkout@v4 with: @@ -22,16 +22,17 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.versions == 'oldest_versions' && '3.0' || '3.3' }} + ruby-version: ${{ matrix.versions == 'shakapacker_v6' && '3.0' || '3.3' }} bundler: 2.5.9 # libyaml-dev is needed for psych v5 # this gem depends on sdoc which depends on rdoc which depends on psych + - run: gem install appraisal - name: Fix dependency for libyaml-dev run: sudo apt install libyaml-dev - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.versions == 'oldest_versions' && '16' || '20' }} + node-version: ${{ matrix.versions == 'shakapacker_v6' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -57,22 +58,23 @@ jobs: uses: actions/cache@v3 with: path: spec/dummy/node_modules - key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }} + key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}-${{ matrix.versions }} - name: yalc add react-on-rails run: cd spec/dummy && yalc add react-on-rails - name: Install Node modules with Yarn for dummy app run: cd spec/dummy && yarn install --no-progress --no-emoji + - run: cd spec/dummy && yarn install "shakapacker@${{ matrix.versions == 'shakapacker_v6' && '6.6.0' || '8.0.0' }}" - name: Save dummy app ruby gems to cache uses: actions/cache@v3 with: path: spec/dummy/vendor/bundle - key: v5-dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }} + key: dummy-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.versions)) }} - name: Install Ruby Gems for dummy app run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: generate file system-based packs run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs - name: Build test bundles for dummy app - run: cd spec/dummy && yarn run build:test + run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'shakapacker_v6' && 'web' || 'shaka' }}packer - id: get-sha run: echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Save test webpack bundles to cache (for build number checksum used by rspec job) @@ -85,11 +87,11 @@ jobs: needs: build-dummy-app-webpack-test-bundles strategy: matrix: - versions: ['oldest_versions', 'newest_versions'] + versions: ['shakapacker_v6', 'shakapacker_v8'] runs-on: ubuntu-22.04 env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps - BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/shakapacker_${{ matrix.versions == 'oldest_versions' && '6' || '8' }}.gemfile + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.versions }}.gemfile steps: - uses: actions/checkout@v4 with: @@ -97,12 +99,12 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.versions == 'oldest_versions' && '3.0' || '3.3' }} + ruby-version: ${{ matrix.versions == 'shakapacker_v6' && '3.0' || '3.3' }} bundler: 2.5.9 - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.versions == 'oldest_versions' && '16' || '20' }} + node-version: ${{ matrix.versions == 'shakapacker_v6' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -126,12 +128,12 @@ jobs: uses: actions/cache@v3 with: path: spec/dummy/vendor/bundle - key: v5-dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }} + key: dummy-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.versions)) }} - name: Save spec/dummy/node_modules to cache uses: actions/cache@v3 with: path: spec/dummy/node_modules - key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }} + key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}-${{ matrix.versions }} - id: get-sha run: echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Save test webpack bundles to cache (for build number checksum used by rspec job) @@ -142,7 +144,6 @@ jobs: - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji - yarn run eslint -v sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index 287e53114..0dc22b974 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -11,7 +11,6 @@ jobs: strategy: matrix: ruby: [3.0, 3.3] - node: [16, 20] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -36,6 +35,7 @@ jobs: with: path: vendor/bundle key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }} + - run: gem install appraisal - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Run rspec tests diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ec28a59e..982cf7b5d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,17 +132,6 @@ yarn yarn build ``` -Or run this which builds the yarn package, then the webpack files for spec/dummy, and runs tests in -spec/dummy. - - -```sh -# Optionally change default selenium_firefox driver -export DRIVER=selenium_firefox -cd react_on_rails/ -yarn run dummy:spec -``` - ### Run NPM JS tests ```sh @@ -153,11 +142,17 @@ yarn test ### Run spec/dummy tests ```sh -cd react_on_rails/spec/dummy +cd react_on_rails +npm -g i yalc +bundle && yarn +yalc publish +cd spec/dummy +bundle && yarn +yarn add shakapacker rspec ``` -### Run most tests and linting +### Run package tests and linting ```sh cd react_on_rails/ diff --git a/appraisals b/appraisals index 5d30481be..d8291ef00 100644 --- a/appraisals +++ b/appraisals @@ -1,7 +1,7 @@ -appraise 'shakapacker_6' do +appraise 'shakapacker_v6' do gem 'shakapacker', '~> 6.6.0' end -appraise 'shakapacker_8' do +appraise 'shakapacker_v8' do gem 'shakapacker', '~> 8.0.0' end diff --git a/gemfiles/shakapacker_6.gemfile b/gemfiles/shakapacker_v6.gemfile similarity index 100% rename from gemfiles/shakapacker_6.gemfile rename to gemfiles/shakapacker_v6.gemfile diff --git a/gemfiles/shakapacker_6.gemfile.lock b/gemfiles/shakapacker_v6.gemfile.lock similarity index 100% rename from gemfiles/shakapacker_6.gemfile.lock rename to gemfiles/shakapacker_v6.gemfile.lock diff --git a/gemfiles/shakapacker_8.gemfile b/gemfiles/shakapacker_v8.gemfile similarity index 100% rename from gemfiles/shakapacker_8.gemfile rename to gemfiles/shakapacker_v8.gemfile diff --git a/gemfiles/shakapacker_8.gemfile.lock b/gemfiles/shakapacker_v8.gemfile.lock similarity index 100% rename from gemfiles/shakapacker_8.gemfile.lock rename to gemfiles/shakapacker_v8.gemfile.lock diff --git a/package.json b/package.json index 2a38b0e12..2ab94f69b 100644 --- a/package.json +++ b/package.json @@ -70,9 +70,7 @@ "prerelease": "yarn run check && yarn run clean && yarn run build", "release:patch": "node_package/scripts/release patch", "release:minor": "node_package/scripts/release minor", - "release:major": "node_package/scripts/release major", - "dummy:install": "rake dummy_apps", - "dummy:spec": "rake run_rspec:dummy" + "release:major": "node_package/scripts/release major" }, "repository": { "type": "git", diff --git a/rakelib/dummy_apps.rake b/rakelib/dummy_apps.rake deleted file mode 100644 index 577763149..000000000 --- a/rakelib/dummy_apps.rake +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require_relative "task_helpers" - -namespace :dummy_apps do - include ReactOnRails::TaskHelpers - - task :yarn_install do - yarn_install_cmd = "yarn install --mutex network" - sh_in_dir(dummy_app_dir, yarn_install_cmd) - sh_in_dir(dummy_app_dir, "yalc link react-on-rails") - end - - task dummy_app: [:yarn_install] do - dummy_app_dir = File.join(gem_root, "spec/dummy") - bundle_install_in(dummy_app_dir) - end - - task :generate_packs do - dummy_app_dir = File.join(gem_root, "spec/dummy") - sh_in_dir(dummy_app_dir, "bundle exec rake react_on_rails:generate_packs") - end - - task dummy_apps: %i[dummy_app node_package generate_packs] do - puts "Prepared all Dummy Apps" - end -end - -desc "Prepares all dummy apps by installing dependencies" -task dummy_apps: ["dummy_apps:dummy_apps"] diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 510d84b3c..24b0f3c3b 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -19,12 +19,12 @@ namespace :run_rspec do end desc "Runs dummy rspec with turbolinks" - task dummy: ["dummy_apps:dummy_app"] do + task :dummy do run_tests_in(spec_dummy_dir) end desc "Runs dummy rspec without turbolinks" - task dummy_no_turbolinks: ["dummy_apps:dummy_app"] do + task :dummy_no_turbolinks do run_tests_in(spec_dummy_dir, env_vars: "DISABLE_TURBOLINKS=TRUE", command_name: "dummy_no_turbolinks") diff --git a/spec/dummy/package.json b/spec/dummy/package.json index 9ee3eba05..94d4b4b5a 100644 --- a/spec/dummy/package.json +++ b/spec/dummy/package.json @@ -50,7 +50,6 @@ "sass": "^1.43.4", "sass-loader": "^12.3.0", "sass-resources-loader": "^2.1.0", - "shakapacker": "8.0.0", "style-loader": "^3.3.1", "terser-webpack-plugin": "5.3.1", "url-loader": "^4.0.0", diff --git a/spec/dummy/yarn.lock b/spec/dummy/yarn.lock index 2c66fbf79..308c7ad96 100644 --- a/spec/dummy/yarn.lock +++ b/spec/dummy/yarn.lock @@ -2657,11 +2657,6 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== - arity-n@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/arity-n/-/arity-n-1.0.4.tgz#d9e76b11733e08569c0847ae7b39b2860b30b745" @@ -5051,13 +5046,6 @@ js-yaml@^3.9.0: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" - integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== - dependencies: - argparse "^2.0.1" - jsesc@^2.5.1: version "2.5.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" @@ -5881,11 +5869,6 @@ path-browserify@0.0.1: resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== -path-complete-extname@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/path-complete-extname/-/path-complete-extname-1.0.0.tgz#f889985dc91000c815515c0bfed06c5acda0752b" - integrity sha512-CVjiWcMRdGU8ubs08YQVzhutOR5DEfO97ipRIlOGMK5Bek5nQySknBpuxVAVJ36hseTNs+vdIcv57ZrWxH7zvg== - path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" @@ -7029,14 +7012,6 @@ sha.js@^2.4.0, sha.js@^2.4.8: inherits "^2.0.1" safe-buffer "^5.0.1" -shakapacker@8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-8.0.0.tgz#f29537c19078af7318758c92e7a1bca4cee96bdd" - integrity sha512-HCdpITzIKXzGEyUWQhKzPbpwwOsgTamaPH+0kXdhM59VQxZ3NWnT5cL3DlJdAT3sGsWCJskEl3eMkQlnh9DjhA== - dependencies: - js-yaml "^4.1.0" - path-complete-extname "^1.0.0" - shallow-clone@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" From 2ec90b89552d514667ae43e0ea133cef5ce30d43 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 13 Jun 2024 23:12:32 -0500 Subject: [PATCH 19/81] getting there? --- .github/workflows/examples.yml | 2 +- .github/workflows/lint-js-and-ruby.yml | 3 +-- .github/workflows/main.yml | 2 +- .github/workflows/rspec-package-specs.yml | 11 +++++++---- spec/react_on_rails/configuration_spec.rb | 18 +++++++++--------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 24c82d121..adc9b05f1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -56,10 +56,10 @@ jobs: - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji - yarn run eslint -v sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish + - run: gem install appraisal - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index edfa9077a..d5cf878d4 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -49,8 +49,7 @@ jobs: - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji - yarn run eslint -v - sudo yarn global add yalc + - run: gem install appraisal - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Linting of Ruby diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9a9c130f4..1fe2d2f7a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,7 +63,7 @@ jobs: run: cd spec/dummy && yalc add react-on-rails - name: Install Node modules with Yarn for dummy app run: cd spec/dummy && yarn install --no-progress --no-emoji - - run: cd spec/dummy && yarn install "shakapacker@${{ matrix.versions == 'shakapacker_v6' && '6.6.0' || '8.0.0' }}" + - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'shakapacker_v6' && '6.6.0' || '8.0.0' }}" - name: Save dummy app ruby gems to cache uses: actions/cache@v3 with: diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index 0dc22b974..0003fd472 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -7,11 +7,14 @@ on: pull_request: jobs: - build: + rspec-package-tests: strategy: matrix: - ruby: [3.0, 3.3] + versions: ['shakapacker_v6', 'shakapacker_v8'] runs-on: ubuntu-22.04 + env: + # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.versions }}.gemfile steps: - uses: actions/checkout@v4 with: @@ -19,7 +22,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: ${{ matrix.versions == 'shakapacker_v6' && '3.0' || '3.3' }} bundler: 2.5.9 - name: Print system information run: | @@ -34,7 +37,7 @@ jobs: uses: actions/cache@v3 with: path: vendor/bundle - key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }} + key: package-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.versions)) }} - run: gem install appraisal - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index 49dcfe17e..ef12daf5b 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -27,7 +27,7 @@ module ReactOnRails before do allow(Rails).to receive(:root).and_return(File.expand_path(".")) - allow(Shakapacker).to receive_message_chain("config.public_output_path") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.public_output_path") .and_return(packer_public_output_path) end @@ -83,7 +83,7 @@ module ReactOnRails end it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure do |config| @@ -93,7 +93,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure do |config| @@ -103,7 +103,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -111,7 +111,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -127,7 +127,7 @@ module ReactOnRails end it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure do |config| @@ -137,7 +137,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure do |config| @@ -147,7 +147,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -155,7 +155,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock From ae8fba821f26654eb38818d81d30edc4e761203a Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 13 Jun 2024 23:36:01 -0500 Subject: [PATCH 20/81] more wip --- .github/workflows/examples.yml | 1 - .github/workflows/lint-js-and-ruby.yml | 1 - .github/workflows/main.yml | 1 - .github/workflows/rspec-package-specs.yml | 1 - Gemfile | 22 ++++------------------ Gemfile.lock | 5 ----- gemfiles/shakapacker_v6.gemfile | 2 +- gemfiles/shakapacker_v8.gemfile | 2 +- 8 files changed, 6 insertions(+), 29 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index adc9b05f1..da9e95c22 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -59,7 +59,6 @@ jobs: sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish - - run: gem install appraisal - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index d5cf878d4..33105e89a 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -49,7 +49,6 @@ jobs: - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji - - run: gem install appraisal - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Linting of Ruby diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1fe2d2f7a..f4dc366f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,6 @@ jobs: bundler: 2.5.9 # libyaml-dev is needed for psych v5 # this gem depends on sdoc which depends on rdoc which depends on psych - - run: gem install appraisal - name: Fix dependency for libyaml-dev run: sudo apt install libyaml-dev - name: Setup Node diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index 0003fd472..c6fefacc1 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -38,7 +38,6 @@ jobs: with: path: vendor/bundle key: package-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.versions)) }} - - run: gem install appraisal - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Run rspec tests diff --git a/Gemfile b/Gemfile index f02a91151..31ff12b67 100644 --- a/Gemfile +++ b/Gemfile @@ -1,25 +1,11 @@ # frozen_string_literal: true -require 'appraisal/bundler_dsl' -::Appraisal::BundlerDSL.class_eval do - def eval_gemfile(path, contents = nil) - (@eval_gemfile ||= []) << [path, contents] - end - - private - - def eval_gemfile_entry - @eval_gemfile.map { |(p, c)| "eval_gemfile(#{p.inspect}#{", #{c.inspect}" if c})" } * "\n\n" - end - - alias_method :eval_gemfile_entry_for_dup, :eval_gemfile_entry - - self::PARTS << 'eval_gemfile' -end unless ::Appraisal::BundlerDSL::PARTS[-1] == 'eval_gemfile' - source "https://rubygems.org" -gem "appraisal" +# to use appraisal to update ci gemfiles, see https://github.com/thoughtbot/appraisal/issues/154 +# following appraisal use, you will need to modify the created gemfiles to use relative paths instead of absolute paths +# gem "appraisal" + # Specify your gem"s dependencies in react_on_rails.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 3aaafb193..1d4f5d315 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,10 +88,6 @@ GEM addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) amazing_print (1.6.0) - appraisal (2.5.0) - bundler - rake - thor (>= 0.14.0) ast (2.4.2) base64 (0.2.0) bigdecimal (3.1.8) @@ -390,7 +386,6 @@ PLATFORMS DEPENDENCIES amazing_print - appraisal bootsnap capybara capybara-screenshot diff --git a/gemfiles/shakapacker_v6.gemfile b/gemfiles/shakapacker_v6.gemfile index ad4aa2af9..0a2e95175 100644 --- a/gemfiles/shakapacker_v6.gemfile +++ b/gemfiles/shakapacker_v6.gemfile @@ -7,4 +7,4 @@ gem "shakapacker", "~> 6.6.0" gemspec path: "../" -eval_gemfile("/Users/judahmeek/apps/react_on_rails/Gemfile.development_dependencies") +File.expand_path("../Gemfile.development_dependencies", __dir__) diff --git a/gemfiles/shakapacker_v8.gemfile b/gemfiles/shakapacker_v8.gemfile index fd0bd954c..623d1a7c8 100644 --- a/gemfiles/shakapacker_v8.gemfile +++ b/gemfiles/shakapacker_v8.gemfile @@ -7,4 +7,4 @@ gem "shakapacker", "~> 8.0.0" gemspec path: "../" -eval_gemfile("/Users/judahmeek/apps/react_on_rails/Gemfile.development_dependencies") +File.expand_path("../Gemfile.development_dependencies", __dir__) From bfaf2443801fac611c7c5af42454b21453e654e9 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 14 Jun 2024 00:36:34 -0500 Subject: [PATCH 21/81] remove appraisal and dynamically modify gemfiles --- .github/workflows/examples.yml | 11 +- .github/workflows/lint-js-and-ruby.yml | 9 +- .github/workflows/main.yml | 31 +- .github/workflows/rspec-package-specs.yml | 8 +- Gemfile | 4 - appraisals | 7 - gemfiles/shakapacker_v6.gemfile | 10 - gemfiles/shakapacker_v6.gemfile.lock | 476 --------------------- gemfiles/shakapacker_v8.gemfile | 10 - gemfiles/shakapacker_v8.gemfile.lock | 478 ---------------------- spec/dummy/Gemfile | 1 - spec/dummy/Gemfile.lock | 11 - 12 files changed, 31 insertions(+), 1025 deletions(-) delete mode 100644 appraisals delete mode 100644 gemfiles/shakapacker_v6.gemfile delete mode 100644 gemfiles/shakapacker_v6.gemfile.lock delete mode 100644 gemfiles/shakapacker_v8.gemfile delete mode 100644 gemfiles/shakapacker_v8.gemfile.lock diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index da9e95c22..6e8a8558e 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -8,6 +8,9 @@ on: jobs: examples: + strategy: + matrix: + versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -26,12 +29,12 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} bundler: 2.5.9 - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 20 + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -50,7 +53,7 @@ jobs: uses: actions/cache@v3 with: path: vendor/bundle - key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }} + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - id: get-sha run: echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Install Node modules with Yarn for renderer package @@ -59,6 +62,8 @@ jobs: sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 33105e89a..5db779843 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -10,9 +10,6 @@ on: jobs: build: strategy: - matrix: - ruby: [3] - node: [20] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -21,12 +18,12 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} + ruby-version: 3 bundler: 2.5.9 - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node }} + node-version: 20 - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -45,7 +42,7 @@ jobs: uses: actions/cache@v3 with: path: vendor/bundle - key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }} + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4dc366f5..4837e6c00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,11 +10,8 @@ jobs: build-dummy-app-webpack-test-bundles: strategy: matrix: - versions: ['shakapacker_v6', 'shakapacker_v8'] + versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 - env: - # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps - BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.versions }}.gemfile steps: - uses: actions/checkout@v4 with: @@ -22,7 +19,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.versions == 'shakapacker_v6' && '3.0' || '3.3' }} + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} bundler: 2.5.9 # libyaml-dev is needed for psych v5 # this gem depends on sdoc which depends on rdoc which depends on psych @@ -31,7 +28,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.versions == 'shakapacker_v6' && '16' || '20' }} + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -57,23 +54,25 @@ jobs: uses: actions/cache@v3 with: path: spec/dummy/node_modules - key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}-${{ matrix.versions }} + key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} - name: yalc add react-on-rails run: cd spec/dummy && yalc add react-on-rails - name: Install Node modules with Yarn for dummy app run: cd spec/dummy && yarn install --no-progress --no-emoji - - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'shakapacker_v6' && '6.6.0' || '8.0.0' }}" + - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - name: Save dummy app ruby gems to cache uses: actions/cache@v3 with: path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.versions)) }} + key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for dummy app run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: generate file system-based packs run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs - name: Build test bundles for dummy app - run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'shakapacker_v6' && 'web' || 'shaka' }}packer + run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer - id: get-sha run: echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Save test webpack bundles to cache (for build number checksum used by rspec job) @@ -86,7 +85,7 @@ jobs: needs: build-dummy-app-webpack-test-bundles strategy: matrix: - versions: ['shakapacker_v6', 'shakapacker_v8'] + versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps @@ -98,12 +97,12 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.versions == 'shakapacker_v6' && '3.0' || '3.3' }} + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} bundler: 2.5.9 - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.versions == 'shakapacker_v6' && '16' || '20' }} + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -122,17 +121,17 @@ jobs: uses: actions/cache@v3 with: path: vendor/bundle - key: v5-package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }} + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - name: Save dummy app ruby gems to cache uses: actions/cache@v3 with: path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.versions)) }} + key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - name: Save spec/dummy/node_modules to cache uses: actions/cache@v3 with: path: spec/dummy/node_modules - key: v5-dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/yarn.lock') }}-${{ matrix.versions }} + key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} - id: get-sha run: echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Save test webpack bundles to cache (for build number checksum used by rspec job) diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index c6fefacc1..e3ac36458 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -10,7 +10,7 @@ jobs: rspec-package-tests: strategy: matrix: - versions: ['shakapacker_v6', 'shakapacker_v8'] + versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps @@ -22,7 +22,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.versions == 'shakapacker_v6' && '3.0' || '3.3' }} + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} bundler: 2.5.9 - name: Print system information run: | @@ -37,7 +37,9 @@ jobs: uses: actions/cache@v3 with: path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.versions)) }} + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }} + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Run rspec tests diff --git a/Gemfile b/Gemfile index 31ff12b67..18a965c64 100644 --- a/Gemfile +++ b/Gemfile @@ -2,10 +2,6 @@ source "https://rubygems.org" -# to use appraisal to update ci gemfiles, see https://github.com/thoughtbot/appraisal/issues/154 -# following appraisal use, you will need to modify the created gemfiles to use relative paths instead of absolute paths -# gem "appraisal" - # Specify your gem"s dependencies in react_on_rails.gemspec gemspec diff --git a/appraisals b/appraisals deleted file mode 100644 index d8291ef00..000000000 --- a/appraisals +++ /dev/null @@ -1,7 +0,0 @@ -appraise 'shakapacker_v6' do - gem 'shakapacker', '~> 6.6.0' -end - -appraise 'shakapacker_v8' do - gem 'shakapacker', '~> 8.0.0' -end diff --git a/gemfiles/shakapacker_v6.gemfile b/gemfiles/shakapacker_v6.gemfile deleted file mode 100644 index 0a2e95175..000000000 --- a/gemfiles/shakapacker_v6.gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "appraisal" -gem "shakapacker", "~> 6.6.0" - -gemspec path: "../" - -File.expand_path("../Gemfile.development_dependencies", __dir__) diff --git a/gemfiles/shakapacker_v6.gemfile.lock b/gemfiles/shakapacker_v6.gemfile.lock deleted file mode 100644 index b7c920b13..000000000 --- a/gemfiles/shakapacker_v6.gemfile.lock +++ /dev/null @@ -1,476 +0,0 @@ -PATH - remote: .. - specs: - react_on_rails (14.0.2) - addressable - connection_pool - execjs (~> 2.5) - rails (>= 5.2) - rainbow (~> 3.0) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) - nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) - timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) - marcel (~> 1.0) - activesupport (7.1.3.4) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) - amazing_print (1.6.0) - appraisal (2.5.0) - bundler - rake - thor (>= 0.14.0) - ast (2.4.2) - base64 (0.2.0) - bigdecimal (3.1.8) - bootsnap (1.18.3) - msgpack (~> 1.2) - builder (3.3.0) - byebug (11.1.3) - capybara (3.40.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.11) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - capybara-screenshot (1.0.26) - capybara (>= 1.0, < 4) - launchy - childprocess (5.0.0) - coderay (1.1.3) - concurrent-ruby (1.3.3) - connection_pool (2.4.1) - coveralls (0.8.23) - json (>= 1.8, < 3) - simplecov (~> 0.16.1) - term-ansicolor (~> 1.3) - thor (>= 0.19.4, < 2.0) - tins (~> 1.6) - crass (1.0.6) - date (3.3.4) - debug (1.9.2) - irb (~> 1.10) - reline (>= 0.3.8) - diff-lcs (1.5.1) - docile (1.4.0) - drb (2.2.1) - equivalent-xml (0.6.0) - nokogiri (>= 1.4.3) - erubi (1.13.0) - execjs (2.9.1) - ffi (1.17.0-aarch64-linux-gnu) - ffi (1.17.0-aarch64-linux-musl) - ffi (1.17.0-arm-linux-gnu) - ffi (1.17.0-arm-linux-musl) - ffi (1.17.0-arm64-darwin) - ffi (1.17.0-x86-linux-gnu) - ffi (1.17.0-x86-linux-musl) - ffi (1.17.0-x86_64-darwin) - ffi (1.17.0-x86_64-linux-gnu) - ffi (1.17.0-x86_64-linux-musl) - gem-release (2.2.2) - generator_spec (0.10.0) - activesupport (>= 3.0.0) - railties (>= 3.0.0) - globalid (1.2.1) - activesupport (>= 6.1) - i18n (1.14.5) - concurrent-ruby (~> 1.0) - interception (0.5) - io-console (0.7.2) - irb (1.13.1) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jbuilder (2.12.0) - actionview (>= 5.0.0) - activesupport (>= 5.0.0) - jquery-rails (4.6.0) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - json (2.7.2) - language_server-protocol (3.17.0.3) - launchy (3.0.1) - addressable (~> 2.8) - childprocess (~> 5.0) - listen (3.9.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.22.0) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.4) - matrix (0.4.2) - method_source (1.1.0) - mini_mime (1.1.5) - minitest (5.23.1) - msgpack (1.7.2) - mutex_m (0.2.0) - net-imap (0.4.12) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.0) - net-protocol - nio4r (2.7.3) - nokogiri (1.16.6-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.6-arm-linux) - racc (~> 1.4) - nokogiri (1.16.6-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86-linux) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) - racc (~> 1.4) - parallel (1.25.1) - parser (3.3.3.0) - ast (~> 2.4.1) - racc - pry (0.14.2) - coderay (~> 1.1) - method_source (~> 1.0) - pry-byebug (3.10.1) - byebug (~> 11.0) - pry (>= 0.13, < 0.15) - pry-doc (1.5.0) - pry (~> 0.11) - yard (~> 0.9.11) - pry-rails (0.3.9) - pry (>= 0.10.4) - pry-rescue (1.6.0) - interception (>= 0.5) - pry (>= 0.12.0) - psych (5.1.2) - stringio - public_suffix (5.0.5) - puma (6.4.2) - nio4r (~> 2.0) - racc (1.8.0) - rack (3.1.3) - rack-proxy (0.7.7) - rack - rack-session (2.0.0) - rack (>= 3.0.0) - rack-test (2.1.0) - rack (>= 1.3) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - bundler (>= 1.15.0) - railties (= 7.1.3.4) - rails-dom-testing (2.2.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rainbow (3.1.1) - rake (13.2.1) - rb-fsevent (0.11.2) - rb-inotify (0.11.1) - ffi (~> 1.0) - rdoc (6.7.0) - psych (>= 4.0.0) - regexp_parser (2.9.2) - reline (0.5.9) - io-console (~> 0.5) - rexml (3.3.0) - strscan - rspec-core (3.13.0) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-rails (6.1.2) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) - rspec-core (~> 3.13) - rspec-expectations (~> 3.13) - rspec-mocks (~> 3.13) - rspec-support (~> 3.13) - rspec-retry (0.6.2) - rspec-core (> 3.3) - rspec-support (3.13.1) - rspec_junit_formatter (0.6.0) - rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.61.0) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) - rubocop-capybara (2.21.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.26.1) - rubocop (~> 1.61) - rubocop-performance (1.20.2) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.31.0) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) - rubocop-rspec_rails (~> 2.28) - rubocop-rspec_rails (2.29.1) - rubocop (~> 1.61) - ruby-progressbar (1.13.0) - rubyzip (2.3.2) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (6.0.0) - sassc-rails (~> 2.1, >= 2.1.1) - sassc (2.4.0) - ffi (~> 1.9) - sassc-rails (2.1.2) - railties (>= 4.0.0) - sassc (>= 2.0) - sprockets (> 3.0) - sprockets-rails - tilt - scss_lint (0.60.0) - sass (~> 3.5, >= 3.5.5) - sdoc (2.6.1) - rdoc (>= 5.0) - selenium-webdriver (4.9.0) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - semantic_range (3.0.0) - shakapacker (6.6.0) - activesupport (>= 5.2) - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) - simplecov (0.16.1) - docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - spring (4.2.1) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - sqlite3 (1.7.3-aarch64-linux) - sqlite3 (1.7.3-arm-linux) - sqlite3 (1.7.3-arm64-darwin) - sqlite3 (1.7.3-x86-linux) - sqlite3 (1.7.3-x86_64-darwin) - sqlite3 (1.7.3-x86_64-linux) - stringio (3.1.1) - strscan (3.1.0) - sync (0.5.0) - term-ansicolor (1.8.0) - tins (~> 1.0) - thor (1.3.1) - tilt (2.3.0) - timeout (0.4.1) - tins (1.33.0) - bigdecimal - sync - turbolinks (5.2.1) - turbolinks-source (~> 5.2) - turbolinks-source (5.2.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uglifier (4.2.0) - execjs (>= 0.3.0, < 3) - unicode-display_width (2.5.0) - webdrivers (5.3.0) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (~> 4.0, < 4.11) - webrick (1.8.1) - websocket (1.2.10) - websocket-driver (0.7.6) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - yard (0.9.36) - zeitwerk (2.6.15) - -PLATFORMS - aarch64-linux - aarch64-linux-gnu - aarch64-linux-musl - arm-linux - arm-linux-gnu - arm-linux-musl - arm64-darwin - x86-linux - x86-linux-gnu - x86-linux-musl - x86_64-darwin - x86_64-linux - x86_64-linux-gnu - x86_64-linux-musl - -DEPENDENCIES - amazing_print - appraisal - bootsnap - capybara - capybara-screenshot - coveralls - debug - equivalent-xml - gem-release - generator_spec - jbuilder - jquery-rails - launchy - listen - pry - pry-byebug - pry-doc - pry-rails - pry-rescue - puma (~> 6.0) - rails (~> 7.1) - rake (~> 13.2.1) - react_on_rails! - rspec-rails - rspec-retry - rspec_junit_formatter - rubocop (= 1.61.0) - rubocop-performance (~> 1.20.0) - rubocop-rspec (~> 2.26) - sass-rails (~> 6.0) - scss_lint - sdoc - selenium-webdriver (= 4.9.0) - shakapacker (~> 6.6.0) - spring (~> 4.0) - sprockets (~> 4.0) - sqlite3 (~> 1.6) - turbolinks - uglifier - webdrivers (= 5.3.0) - -BUNDLED WITH - 2.5.9 diff --git a/gemfiles/shakapacker_v8.gemfile b/gemfiles/shakapacker_v8.gemfile deleted file mode 100644 index 623d1a7c8..000000000 --- a/gemfiles/shakapacker_v8.gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# This file was generated by Appraisal - -source "https://rubygems.org" - -gem "appraisal" -gem "shakapacker", "~> 8.0.0" - -gemspec path: "../" - -File.expand_path("../Gemfile.development_dependencies", __dir__) diff --git a/gemfiles/shakapacker_v8.gemfile.lock b/gemfiles/shakapacker_v8.gemfile.lock deleted file mode 100644 index 19c962860..000000000 --- a/gemfiles/shakapacker_v8.gemfile.lock +++ /dev/null @@ -1,478 +0,0 @@ -PATH - remote: .. - specs: - react_on_rails (14.0.2) - addressable - connection_pool - execjs (~> 2.5) - rails (>= 5.2) - rainbow (~> 3.0) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) - nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) - timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) - marcel (~> 1.0) - activesupport (7.1.3.4) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - addressable (2.8.6) - public_suffix (>= 2.0.2, < 6.0) - amazing_print (1.6.0) - appraisal (2.5.0) - bundler - rake - thor (>= 0.14.0) - ast (2.4.2) - base64 (0.2.0) - bigdecimal (3.1.8) - bootsnap (1.18.3) - msgpack (~> 1.2) - builder (3.3.0) - byebug (11.1.3) - capybara (3.40.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.11) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - capybara-screenshot (1.0.26) - capybara (>= 1.0, < 4) - launchy - childprocess (5.0.0) - coderay (1.1.3) - concurrent-ruby (1.3.3) - connection_pool (2.4.1) - coveralls (0.8.23) - json (>= 1.8, < 3) - simplecov (~> 0.16.1) - term-ansicolor (~> 1.3) - thor (>= 0.19.4, < 2.0) - tins (~> 1.6) - crass (1.0.6) - date (3.3.4) - debug (1.9.2) - irb (~> 1.10) - reline (>= 0.3.8) - diff-lcs (1.5.1) - docile (1.4.0) - drb (2.2.1) - equivalent-xml (0.6.0) - nokogiri (>= 1.4.3) - erubi (1.13.0) - execjs (2.9.1) - ffi (1.17.0-aarch64-linux-gnu) - ffi (1.17.0-aarch64-linux-musl) - ffi (1.17.0-arm-linux-gnu) - ffi (1.17.0-arm-linux-musl) - ffi (1.17.0-arm64-darwin) - ffi (1.17.0-x86-linux-gnu) - ffi (1.17.0-x86-linux-musl) - ffi (1.17.0-x86_64-darwin) - ffi (1.17.0-x86_64-linux-gnu) - ffi (1.17.0-x86_64-linux-musl) - gem-release (2.2.2) - generator_spec (0.10.0) - activesupport (>= 3.0.0) - railties (>= 3.0.0) - globalid (1.2.1) - activesupport (>= 6.1) - i18n (1.14.5) - concurrent-ruby (~> 1.0) - interception (0.5) - io-console (0.7.2) - irb (1.13.1) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jbuilder (2.12.0) - actionview (>= 5.0.0) - activesupport (>= 5.0.0) - jquery-rails (4.6.0) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - json (2.7.2) - language_server-protocol (3.17.0.3) - launchy (3.0.1) - addressable (~> 2.8) - childprocess (~> 5.0) - listen (3.9.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.22.0) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.4) - matrix (0.4.2) - method_source (1.1.0) - mini_mime (1.1.5) - minitest (5.23.1) - msgpack (1.7.2) - mutex_m (0.2.0) - net-imap (0.4.12) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.0) - net-protocol - nio4r (2.7.3) - nokogiri (1.16.6-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.6-arm-linux) - racc (~> 1.4) - nokogiri (1.16.6-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86-linux) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) - racc (~> 1.4) - package_json (0.1.0) - parallel (1.25.1) - parser (3.3.3.0) - ast (~> 2.4.1) - racc - pry (0.14.2) - coderay (~> 1.1) - method_source (~> 1.0) - pry-byebug (3.10.1) - byebug (~> 11.0) - pry (>= 0.13, < 0.15) - pry-doc (1.5.0) - pry (~> 0.11) - yard (~> 0.9.11) - pry-rails (0.3.9) - pry (>= 0.10.4) - pry-rescue (1.6.0) - interception (>= 0.5) - pry (>= 0.12.0) - psych (5.1.2) - stringio - public_suffix (5.0.5) - puma (6.4.2) - nio4r (~> 2.0) - racc (1.8.0) - rack (3.1.3) - rack-proxy (0.7.7) - rack - rack-session (2.0.0) - rack (>= 3.0.0) - rack-test (2.1.0) - rack (>= 1.3) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - bundler (>= 1.15.0) - railties (= 7.1.3.4) - rails-dom-testing (2.2.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rainbow (3.1.1) - rake (13.2.1) - rb-fsevent (0.11.2) - rb-inotify (0.11.1) - ffi (~> 1.0) - rdoc (6.7.0) - psych (>= 4.0.0) - regexp_parser (2.9.2) - reline (0.5.9) - io-console (~> 0.5) - rexml (3.3.0) - strscan - rspec-core (3.13.0) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-rails (6.1.2) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) - rspec-core (~> 3.13) - rspec-expectations (~> 3.13) - rspec-mocks (~> 3.13) - rspec-support (~> 3.13) - rspec-retry (0.6.2) - rspec-core (> 3.3) - rspec-support (3.13.1) - rspec_junit_formatter (0.6.0) - rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.61.0) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.3.0.2) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.31.3) - parser (>= 3.3.1.0) - rubocop-capybara (2.21.0) - rubocop (~> 1.41) - rubocop-factory_bot (2.26.1) - rubocop (~> 1.61) - rubocop-performance (1.20.2) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.31.0) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) - rubocop-rspec_rails (~> 2.28) - rubocop-rspec_rails (2.29.1) - rubocop (~> 1.61) - ruby-progressbar (1.13.0) - rubyzip (2.3.2) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (6.0.0) - sassc-rails (~> 2.1, >= 2.1.1) - sassc (2.4.0) - ffi (~> 1.9) - sassc-rails (2.1.2) - railties (>= 4.0.0) - sassc (>= 2.0) - sprockets (> 3.0) - sprockets-rails - tilt - scss_lint (0.60.0) - sass (~> 3.5, >= 3.5.5) - sdoc (2.6.1) - rdoc (>= 5.0) - selenium-webdriver (4.9.0) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - semantic_range (3.0.0) - shakapacker (8.0.0) - activesupport (>= 5.2) - package_json - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) - simplecov (0.16.1) - docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - spring (4.2.1) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - sqlite3 (1.7.3-aarch64-linux) - sqlite3 (1.7.3-arm-linux) - sqlite3 (1.7.3-arm64-darwin) - sqlite3 (1.7.3-x86-linux) - sqlite3 (1.7.3-x86_64-darwin) - sqlite3 (1.7.3-x86_64-linux) - stringio (3.1.1) - strscan (3.1.0) - sync (0.5.0) - term-ansicolor (1.8.0) - tins (~> 1.0) - thor (1.3.1) - tilt (2.3.0) - timeout (0.4.1) - tins (1.33.0) - bigdecimal - sync - turbolinks (5.2.1) - turbolinks-source (~> 5.2) - turbolinks-source (5.2.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uglifier (4.2.0) - execjs (>= 0.3.0, < 3) - unicode-display_width (2.5.0) - webdrivers (5.3.0) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (~> 4.0, < 4.11) - webrick (1.8.1) - websocket (1.2.10) - websocket-driver (0.7.6) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - xpath (3.2.0) - nokogiri (~> 1.8) - yard (0.9.36) - zeitwerk (2.6.15) - -PLATFORMS - aarch64-linux - aarch64-linux-gnu - aarch64-linux-musl - arm-linux - arm-linux-gnu - arm-linux-musl - arm64-darwin - x86-linux - x86-linux-gnu - x86-linux-musl - x86_64-darwin - x86_64-linux - x86_64-linux-gnu - x86_64-linux-musl - -DEPENDENCIES - amazing_print - appraisal - bootsnap - capybara - capybara-screenshot - coveralls - debug - equivalent-xml - gem-release - generator_spec - jbuilder - jquery-rails - launchy - listen - pry - pry-byebug - pry-doc - pry-rails - pry-rescue - puma (~> 6.0) - rails (~> 7.1) - rake (~> 13.2.1) - react_on_rails! - rspec-rails - rspec-retry - rspec_junit_formatter - rubocop (= 1.61.0) - rubocop-performance (~> 1.20.0) - rubocop-rspec (~> 2.26) - sass-rails (~> 6.0) - scss_lint - sdoc - selenium-webdriver (= 4.9.0) - shakapacker (~> 8.0.0) - spring (~> 4.0) - sprockets (~> 4.0) - sqlite3 (~> 1.6) - turbolinks - uglifier - webdrivers (= 5.3.0) - -BUNDLED WITH - 2.5.9 diff --git a/spec/dummy/Gemfile b/spec/dummy/Gemfile index 12cd863af..a2bcc402b 100644 --- a/spec/dummy/Gemfile +++ b/spec/dummy/Gemfile @@ -2,7 +2,6 @@ source "https://rubygems.org" -gem "shakapacker" eval_gemfile File.expand_path("../../Gemfile.development_dependencies", __dir__) gem "react_on_rails", path: "../.." diff --git a/spec/dummy/Gemfile.lock b/spec/dummy/Gemfile.lock index f0499bc1c..0c275212f 100644 --- a/spec/dummy/Gemfile.lock +++ b/spec/dummy/Gemfile.lock @@ -185,7 +185,6 @@ GEM nokogiri (1.15.3) mini_portile2 (~> 2.8.2) racc (~> 1.4) - package_json (0.1.0) parallel (1.24.0) parser (3.3.0.2) ast (~> 2.4.1) @@ -211,8 +210,6 @@ GEM nio4r (~> 2.0) racc (1.7.1) rack (2.2.8) - rack-proxy (0.7.7) - rack rack-session (1.0.2) rack (< 3) rack-test (2.1.0) @@ -331,13 +328,6 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - semantic_range (3.0.0) - shakapacker (8.0.0) - activesupport (>= 5.2) - package_json - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -419,7 +409,6 @@ DEPENDENCIES scss_lint sdoc selenium-webdriver (= 4.9.0) - shakapacker spring (~> 4.0) sprockets (~> 4.0) sqlite3 (~> 1.6) From d33ad0a24fe68e56fac601ca365d6ca01ee5e242 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 14 Jun 2024 02:06:31 -0500 Subject: [PATCH 22/81] wip again --- .github/workflows/package-js-tests.yml | 4 ++-- .github/workflows/rspec-package-specs.yml | 3 --- rakelib/examples.rake | 1 + spec/dummy/config/webpack/commonWebpackConfig.js | 4 ++++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/package-js-tests.yml b/.github/workflows/package-js-tests.yml index c1828990d..7b826b02f 100644 --- a/.github/workflows/package-js-tests.yml +++ b/.github/workflows/package-js-tests.yml @@ -11,7 +11,7 @@ jobs: build: strategy: matrix: - node: [16, 20] + versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -20,7 +20,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node }} + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index e3ac36458..f56778d87 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -12,9 +12,6 @@ jobs: matrix: versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 - env: - # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps - BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.versions }}.gemfile steps: - uses: actions/checkout@v4 with: diff --git a/rakelib/examples.rake b/rakelib/examples.rake index 9c315ef3a..f32fc116a 100644 --- a/rakelib/examples.rake +++ b/rakelib/examples.rake @@ -7,6 +7,7 @@ require "yaml" require "rails/version" +require "react_on_rails" require_relative "example_type" require_relative "task_helpers" diff --git a/spec/dummy/config/webpack/commonWebpackConfig.js b/spec/dummy/config/webpack/commonWebpackConfig.js index ed1496105..a0e1249fc 100644 --- a/spec/dummy/config/webpack/commonWebpackConfig.js +++ b/spec/dummy/config/webpack/commonWebpackConfig.js @@ -4,6 +4,10 @@ const webpack = require('webpack'); const aliasConfig = require('./alias.js'); +if(typeof generateWebpackConfig == 'undefined') { + generateWebpackConfig = () => undefined; +} + const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfig(); const commonOptions = { From 446c0908ba0d4d8c0ed0452d1a3aeec9022a4e54 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 14 Jun 2024 02:42:16 -0500 Subject: [PATCH 23/81] more fixes --- lib/tasks/assets.rake | 2 +- .../config/webpack/commonWebpackConfig.js | 6 ++-- .../webpack_assets_status_checker_spec.rb | 2 +- spec/react_on_rails/utils_spec.rb | 32 +++++++++---------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 685b8fbaf..27b786b71 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -5,7 +5,7 @@ namespace :react_on_rails do namespace :assets do desc <<~DESC If config.build_production_command is defined, this command is automatically - added to task assets:precompile and the regular #{ReactOnRails::PackerUtils.packer_type.upcase_first} compile will not run. + added to task assets:precompile and the regular packer compile will not run. The defined command is either a script or a module with a method `call`. DESC task webpack: :locale do diff --git a/spec/dummy/config/webpack/commonWebpackConfig.js b/spec/dummy/config/webpack/commonWebpackConfig.js index a0e1249fc..a3ea0da4a 100644 --- a/spec/dummy/config/webpack/commonWebpackConfig.js +++ b/spec/dummy/config/webpack/commonWebpackConfig.js @@ -4,11 +4,9 @@ const webpack = require('webpack'); const aliasConfig = require('./alias.js'); -if(typeof generateWebpackConfig == 'undefined') { - generateWebpackConfig = () => undefined; -} +const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined -const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfig(); +const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias(); const commonOptions = { resolve: { diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index d1782bd31..606a9e88b 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -74,7 +74,7 @@ .and_return(File.join(generated_assets_full_path, "manifest.json")) allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) .with("server-bundle.js") - .and_raise(Shakapacker::Manifest::MissingEntryError) + .and_raise(ReactOnRails::PackerUtils.packer::Manifest::MissingEntryError) touch_files_in_dir(generated_assets_full_path) end diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index 0b1786ed0..d6b37acb7 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -28,9 +28,9 @@ module ReactOnRails before do allow(ReactOnRails).to receive_message_chain(:configuration, :generated_assets_dir) .and_return("") - allow(Shakapacker).to receive_message_chain("dev_server.running?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.dev_server.running?") .and_return(false) - allow(Shakapacker).to receive_message_chain("config.public_output_path") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.public_output_path") .and_return(packer_public_output_path) allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(true) end @@ -40,7 +40,7 @@ module ReactOnRails # Note Shakapacker manifest lookup is inside of the public_output_path # [2] (pry) ReactOnRails::PackerUtils: 0> Shakapacker.manifest.lookup("app-bundle.js") # "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js" - allow(Shakapacker).to receive_message_chain("manifest.lookup!") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") .with("webpack-bundle.js") .and_return("/webpack/dev/webpack-bundle-0123456789abcdef.js") allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") @@ -74,7 +74,7 @@ module ReactOnRails it "returns false if node_modules is blank" do allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("") - allow(Shakapacker).to receive_message_chain("config.send").with(:data) + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send").with(:data) .and_return({}) expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(false) @@ -83,7 +83,7 @@ module ReactOnRails it "returns false if source_path is defined in the config/webpacker.yml and node_modules defined" do allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("client") - allow(Shakapacker).to receive_message_chain("config.send").with(:data) + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send").with(:data) .and_return(source_path: "client/app") expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(false) @@ -92,7 +92,7 @@ module ReactOnRails it "returns true if node_modules is not blank and the source_path is not defined in config/webpacker.yml" do allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("node_modules") - allow(Shakapacker).to receive_message_chain("config.send").with(:data) + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send").with(:data) .and_return({}) expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(true) @@ -103,7 +103,7 @@ module ReactOnRails before do allow(Rails).to receive(:root).and_return(Pathname.new(".")) allow(ReactOnRails::PackerUtils).to receive(:using_packer?).and_return(true) - allow(Shakapacker).to receive_message_chain("config.public_output_path") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.public_output_path") .and_return(Pathname.new("public/webpack/development")) end @@ -112,9 +112,9 @@ module ReactOnRails server_bundle_name = "server-bundle.js" allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return(server_bundle_name) - allow(Shakapacker).to receive_message_chain("manifest.lookup!") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") .with(server_bundle_name) - .and_raise(Shakapacker::Manifest::MissingEntryError) + .and_raise(ReactOnRails::PackerUtils.packer::Manifest::MissingEntryError) path = described_class.server_bundle_js_file_path @@ -128,7 +128,7 @@ module ReactOnRails .and_return("webpack-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") .and_return(true) - allow(Shakapacker).to receive_message_chain("manifest.lookup!") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") .with("webpack-bundle.js") .and_return("webpack/development/webpack-bundle-123456.js") @@ -143,13 +143,13 @@ module ReactOnRails .and_return("webpack-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") .and_return(true) - allow(Shakapacker).to receive_message_chain("dev_server.running?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.dev_server.running?") .and_return(true) - allow(Shakapacker).to receive_message_chain("dev_server.protocol") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.dev_server.protocol") .and_return("http") - allow(Shakapacker).to receive_message_chain("dev_server.host_with_port") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.dev_server.host_with_port") .and_return("localhost:3035") - allow(Shakapacker).to receive_message_chain("manifest.lookup!") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") .with("webpack-bundle.js") .and_return("/webpack/development/webpack-bundle-123456.js") @@ -167,10 +167,10 @@ module ReactOnRails .and_return("server-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") .and_return(false) - allow(Shakapacker).to receive_message_chain("manifest.lookup!") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") .with("server-bundle.js") .and_return("webpack/development/server-bundle-123456.js") - allow(Shakapacker).to receive_message_chain("dev_server.running?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.dev_server.running?") .and_return(true) path = described_class.server_bundle_js_file_path From 8a0003ed3f22808a5f77144d303e5c029b5a17a6 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 14 Jun 2024 03:42:26 -0500 Subject: [PATCH 24/81] fixes more --- .github/workflows/rspec-package-specs.yml | 1 + rakelib/examples.rake | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index f56778d87..1f2ef5e8c 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -39,6 +39,7 @@ jobs: run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - run: git commit -am "to stop generators from complaining about uncommitted code" - name: Run rspec tests run: bundle exec rspec spec/react_on_rails - name: Store test results diff --git a/rakelib/examples.rake b/rakelib/examples.rake index f32fc116a..f1e23607b 100644 --- a/rakelib/examples.rake +++ b/rakelib/examples.rake @@ -7,7 +7,6 @@ require "yaml" require "rails/version" -require "react_on_rails" require_relative "example_type" require_relative "task_helpers" @@ -36,7 +35,11 @@ namespace :examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "touch .gitignore") append_to_gemfile(example_type.gemfile, example_type.required_gems) bundle_install_in(example_type.dir) - sh_in_dir(example_type.dir, "rake #{ReactOnRails::PackerUtils.packer_type}:install") + begin + sh_in_dir(example_type.dir, "rake webpacker:install") + rescue + sh_in_dir(example_type.dir, "rake shakapacker:install") + end sh_in_dir(example_type.dir, example_type.generator_shell_commands) sh_in_dir(example_type.dir, "yarn") end From 15db710c61eaf28e8d3c9fac758265734d1048e3 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 14 Jun 2024 14:04:40 -0500 Subject: [PATCH 25/81] still fixing --- .github/workflows/rspec-package-specs.yml | 6 +++++- rakelib/example_type.rb | 10 --------- rakelib/examples.rake | 21 +++++++++++-------- .../config/webpack/commonWebpackConfig.js | 9 ++++---- spec/dummy/config/webpack/webpack.config.js | 7 +++++-- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index 1f2ef5e8c..03b428b7c 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -39,7 +39,11 @@ jobs: run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - run: git commit -am "to stop generators from complaining about uncommitted code" + - name: Git Stuff + run: | + git config user.email "you@example.com" + git config user.name "Your Name" + git commit -am "stop generators from complaining about uncommitted code" - name: Run rspec tests run: bundle exec rspec spec/react_on_rails - name: Store test results diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 441a4e989..3ca33d57d 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "rake" -require "pathname" require_relative "task_helpers" @@ -42,15 +41,6 @@ def gemfile File.join(dir, "Gemfile") end - # Gems we need to add to the Gemfile before bundle installing - def required_gems - relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) - [ - "gem 'react_on_rails', path: '#{relative_gem_root}'", - "gem 'shakapacker'" - ] - end - # Options we pass when running `rails new` from the command-line. attr_writer :rails_options diff --git a/rakelib/examples.rake b/rakelib/examples.rake index f1e23607b..42e68f314 100644 --- a/rakelib/examples.rake +++ b/rakelib/examples.rake @@ -7,11 +7,12 @@ require "yaml" require "rails/version" +require "pathname" require_relative "example_type" require_relative "task_helpers" -namespace :examples do # rubocop:disable Metrics/BlockLength +namespace :examples [:packer_type] do # rubocop:disable Metrics/BlockLength include ReactOnRails::TaskHelpers # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) @@ -33,13 +34,9 @@ namespace :examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(example_type.gemfile, example_type.required_gems) + append_to_gemfile(packer_type, example_type.gemfile) bundle_install_in(example_type.dir) - begin - sh_in_dir(example_type.dir, "rake webpacker:install") - rescue - sh_in_dir(example_type.dir, "rake shakapacker:install") - end + sh_in_dir(example_type.dir, "rake #{packer_type.to_s}:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) sh_in_dir(example_type.dir, "yarn") end @@ -55,13 +52,19 @@ namespace :examples do # rubocop:disable Metrics/BlockLength end desc "Generates all example apps. Run `rake -D examples` to see all available options" -task examples: ["examples:gen_all"] +task :examples, [:packer_type] => "examples:gen_all" private # Appends each string in an array as a new line of text in the given Gemfile. # Automatically adds line returns. -def append_to_gemfile(gemfile, lines) +def append_to_gemfile(packer_type, gemfile) + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) + shakapacker_version = packer_type.to_s == 'webpacker' ? '6.6.0' : '8.0.0' + lines = [ + "gem 'react_on_rails', path: '#{relative_gem_root}'", + "gem 'shakapacker', '~> #{shakapacker_version}'" + ] old_text = File.read(gemfile) new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } File.open(gemfile, "w") { |f| f.puts(new_text) } diff --git a/spec/dummy/config/webpack/commonWebpackConfig.js b/spec/dummy/config/webpack/commonWebpackConfig.js index a3ea0da4a..4e15f613e 100644 --- a/spec/dummy/config/webpack/commonWebpackConfig.js +++ b/spec/dummy/config/webpack/commonWebpackConfig.js @@ -1,13 +1,14 @@ // Common configuration applying to client and server configuration -const { generateWebpackConfig, v6WebpackConfig, merge } = require('shakapacker'); -const webpack = require('webpack'); - -const aliasConfig = require('./alias.js'); +const { generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias(); +const webpack = require('webpack'); + +const aliasConfig = require('./alias.js'); + const commonOptions = { resolve: { extensions: ['.css', '.ts', '.tsx'], diff --git a/spec/dummy/config/webpack/webpack.config.js b/spec/dummy/config/webpack/webpack.config.js index eab60a879..f25e68c4e 100644 --- a/spec/dummy/config/webpack/webpack.config.js +++ b/spec/dummy/config/webpack/webpack.config.js @@ -1,4 +1,7 @@ -const { env, generateWebpackConfig, v6WebpackConfig } = require('shakapacker'); +const { generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); + +const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined + const { existsSync } = require('fs'); const { resolve } = require('path'); @@ -8,7 +11,7 @@ const envSpecificConfig = () => { console.log(`Loading ENV specific webpack configuration file ${path}`); return require(path); } else { - return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfig(); + return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias();; } }; From 789958e923fc369da9dec439419fb29bde3c791b Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 14 Jun 2024 16:19:51 -0500 Subject: [PATCH 26/81] hopefully getting somewhere --- lib/react_on_rails/configuration.rb | 4 ++-- lib/react_on_rails/packer_utils.rb | 2 +- rakelib/examples.rake | 2 +- spec/dummy/config/webpack/webpack.config.js | 2 +- spec/react_on_rails/configuration_spec.rb | 16 ++++++++-------- .../webpack_assets_status_checker_spec.rb | 4 ++-- spec/react_on_rails/utils_spec.rb | 3 ++- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index c1ceb316a..9d169e975 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -111,7 +111,7 @@ def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender # on ReactOnRails def setup_config_values - check_autobundling_requirements_if_configured + check_autobundling_requirements if auto_load_bundle ensure_webpack_generated_files_exists configure_generated_assets_dirs_deprecation configure_skip_display_none_deprecation @@ -124,7 +124,7 @@ def setup_config_values private - def check_autobundling_requirements_if_configured + def check_autobundling_requirements raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present? return unless components_subdirectory.present? diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index 6566305d3..c40bb2787 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -162,7 +162,7 @@ def self.raise_shakapacker_version_incompatible_for_autobundling def self.raise_shakapacker_not_installed msg = <<~MSG **ERROR** ReactOnRails: Missing Shakapacker gem. Please upgrade to use Shakapacker \ - #{semver_to_string(minimum_required_shakapacker_version)} or above to use the \ + #{semver_to_string(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)} or above to use the \ automated bundle generation feature. MSG diff --git a/rakelib/examples.rake b/rakelib/examples.rake index 42e68f314..f64f311d9 100644 --- a/rakelib/examples.rake +++ b/rakelib/examples.rake @@ -12,7 +12,7 @@ require "pathname" require_relative "example_type" require_relative "task_helpers" -namespace :examples [:packer_type] do # rubocop:disable Metrics/BlockLength +namespace :examples, [:packer_type] do # rubocop:disable Metrics/BlockLength include ReactOnRails::TaskHelpers # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) diff --git a/spec/dummy/config/webpack/webpack.config.js b/spec/dummy/config/webpack/webpack.config.js index f25e68c4e..dde204f1c 100644 --- a/spec/dummy/config/webpack/webpack.config.js +++ b/spec/dummy/config/webpack/webpack.config.js @@ -1,4 +1,4 @@ -const { generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); +const { env, generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index ef12daf5b..e8b147855 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -83,7 +83,7 @@ module ReactOnRails end it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(true) expect do ReactOnRails.configure do |config| @@ -93,7 +93,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(false) expect do ReactOnRails.configure do |config| @@ -103,7 +103,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -111,7 +111,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -127,7 +127,7 @@ module ReactOnRails end it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(true) expect do ReactOnRails.configure do |config| @@ -137,7 +137,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(false) expect do ReactOnRails.configure do |config| @@ -147,7 +147,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -155,7 +155,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.shakapacker_precompile?") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index 606a9e88b..611860104 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -63,7 +63,7 @@ let(:fixture_dirname) { "assets_with_manifest_exist_server_bundle_separate" } before do - require "shakapacker" + Packer = ReactOnRails::PackerUtils.packer allow(ReactOnRails::PackerUtils).to receive_messages( manifest_exists?: true, packer_public_output_path: generated_assets_full_path @@ -74,7 +74,7 @@ .and_return(File.join(generated_assets_full_path, "manifest.json")) allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) .with("server-bundle.js") - .and_raise(ReactOnRails::PackerUtils.packer::Manifest::MissingEntryError) + .and_raise(Packer::Manifest::MissingEntryError) touch_files_in_dir(generated_assets_full_path) end diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index d6b37acb7..65434eb33 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -109,12 +109,13 @@ module ReactOnRails context "with server file not in manifest", :shakapacker do it "returns the unhashed server path" do + Packer = ReactOnRails::PackerUtils.packer server_bundle_name = "server-bundle.js" allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return(server_bundle_name) allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") .with(server_bundle_name) - .and_raise(ReactOnRails::PackerUtils.packer::Manifest::MissingEntryError) + .and_raise(Packer::Manifest::MissingEntryError) path = described_class.server_bundle_js_file_path From 96bcb5f84c092afbf20a64539cf7f20a74dc083e Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 14 Jun 2024 23:50:56 -0500 Subject: [PATCH 27/81] more fixes --- .github/workflows/examples.yml | 2 +- .github/workflows/main.yml | 5 +- rakelib/run_rspec.rake | 12 +++- rakelib/shakapacker_examples.rake | 71 +++++++++++++++++++ ...{examples.rake => webpacker_examples.rake} | 6 +- spec/react_on_rails/configuration_spec.rb | 30 +++----- spec/react_on_rails/utils_spec.rb | 5 +- 7 files changed, 98 insertions(+), 33 deletions(-) create mode 100644 rakelib/shakapacker_examples.rake rename rakelib/{examples.rake => webpacker_examples.rake} (92%) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 6e8a8558e..7cbb5aabb 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -82,7 +82,7 @@ jobs: run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - name: Main CI if: steps.changed-files.outputs.any_changed == 'true' - run: bundle exec rake run_rspec:examples + run: bundle exec rake run_rspec:${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer_examples - name: Store test results uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4837e6c00..b0dcc5357 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -81,15 +81,12 @@ jobs: path: spec/dummy/public/webpack key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} - main: + dummy-app-integration-tests: needs: build-dummy-app-webpack-test-bundles strategy: matrix: versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 - env: - # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps - BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.versions }}.gemfile steps: - uses: actions/checkout@v4 with: diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 24b0f3c3b..3507749a7 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -38,8 +38,13 @@ namespace :run_rspec do end end - desc "Runs Rspec for example apps only" - task examples: "examples:gen_all" do + desc "Runs Rspec for webpacker example apps only" + task webpacker_examples: "webpacker_examples:gen_all" do + ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } + end + + desc "Runs Rspec for shakapacker example apps only" + task shakapacker_examples: "shakapacker_examples:gen_all" do ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } end @@ -56,7 +61,8 @@ namespace :run_rspec do end desc "run all tests" - task run_rspec: %i[all_but_examples examples] do + task :run_rspec, [:packer] => ["all_but_examples"] do + Rake::Task["run_rspec:#{packer}_examples"].invoke puts "Completed all RSpec tests" end end diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake new file mode 100644 index 000000000..cfd002856 --- /dev/null +++ b/rakelib/shakapacker_examples.rake @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +# Defines tasks related to generating example apps using the gem's generator. +# Allows us to create and test apps generated using a wide range of options. +# +# Also see example_type.rb + +require "yaml" +require "rails/version" +require "pathname" + +require_relative "example_type" +require_relative "task_helpers" + +namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength + include ReactOnRails::TaskHelpers + # Loads data from examples_config.yml and instantiates corresponding ExampleType objects + examples_config_file = File.expand_path("examples_config.yml", __dir__) + examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) + examples_config[:example_type_data].each { |example_type_data| ExampleType.new(**symbolize_keys(example_type_data)) } + + # Define tasks for each example type + ExampleType.all.each do |example_type| + # CLOBBER + desc "Clobbers (deletes) #{example_type.name_pretty}" + task example_type.clobber_task_name_short do + rm_rf(example_type.dir) + end + + # GENERATE + desc "Generates #{example_type.name_pretty}" + task example_type.gen_task_name_short => example_type.clobber_task_name do + mkdir_p(example_type.dir) + example_type.rails_options += "--skip-javascript" + sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") + sh_in_dir(example_type.dir, "touch .gitignore") + append_to_gemfile(packer_type, example_type.gemfile) + bundle_install_in(example_type.dir) + sh_in_dir(example_type.dir, "rake shakapacker:install") + sh_in_dir(example_type.dir, example_type.generator_shell_commands) + sh_in_dir(example_type.dir, "yarn") + end + end + + desc "Clobbers (deletes) all example apps" + task :clobber do + rm_rf(examples_dir) + end + + desc "Generates all example apps" + task gen_all: ExampleType.all.map(&:gen_task_name) +end + +desc "Generates all example apps. Run `rake -D examples` to see all available options" +task shakapacker_examples: ["shakapacker_examples:gen_all"] + +private + +# Appends each string in an array as a new line of text in the given Gemfile. +# Automatically adds line returns. +def append_to_gemfile(packer_type, gemfile) + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) + shakapacker_version = packer_type.to_s == 'shakapacker' ? '6.6.0' : '8.0.0' + lines = [ + "gem 'react_on_rails', path: '#{relative_gem_root}'", + "gem 'shakapacker', '~> #{shakapacker_version}'" + ] + old_text = File.read(gemfile) + new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } + File.open(gemfile, "w") { |f| f.puts(new_text) } +end diff --git a/rakelib/examples.rake b/rakelib/webpacker_examples.rake similarity index 92% rename from rakelib/examples.rake rename to rakelib/webpacker_examples.rake index f64f311d9..6cef0fe9c 100644 --- a/rakelib/examples.rake +++ b/rakelib/webpacker_examples.rake @@ -12,7 +12,7 @@ require "pathname" require_relative "example_type" require_relative "task_helpers" -namespace :examples, [:packer_type] do # rubocop:disable Metrics/BlockLength +namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength include ReactOnRails::TaskHelpers # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) @@ -36,7 +36,7 @@ namespace :examples, [:packer_type] do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "touch .gitignore") append_to_gemfile(packer_type, example_type.gemfile) bundle_install_in(example_type.dir) - sh_in_dir(example_type.dir, "rake #{packer_type.to_s}:install") + sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) sh_in_dir(example_type.dir, "yarn") end @@ -52,7 +52,7 @@ namespace :examples, [:packer_type] do # rubocop:disable Metrics/BlockLength end desc "Generates all example apps. Run `rake -D examples` to see all available options" -task :examples, [:packer_type] => "examples:gen_all" +task webpacker_examples: ["webpacker_examples:gen_all"] private diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index e8b147855..c4e764f67 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -75,15 +75,10 @@ module ReactOnRails end describe ".build_production_command" do - context "when using Shakapacker 7" do - before do - allow(ReactOnRails::PackerUtils) - .to receive("shakapacker_version") - .and_return("7.0.0") - end + context "when using Shakapacker 7", :unless ReactOnRails::PackerUtils.packer_type == "shakapacker" do it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") .and_return(true) expect do ReactOnRails.configure do |config| @@ -93,7 +88,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") .and_return(false) expect do ReactOnRails.configure do |config| @@ -103,7 +98,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -111,7 +106,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -119,15 +114,10 @@ module ReactOnRails end end - context "when using Shakapacker 8" do - before do - allow(ReactOnRails::PackerUtils) - .to receive("shakapacker_version") - .and_return("8.0.0") - end + context "when using Shakapacker 8", :unless ReactOnRails::PackerUtils.packer_type == "shakapacker" do it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure do |config| @@ -137,7 +127,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure do |config| @@ -147,7 +137,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(true) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock @@ -155,7 +145,7 @@ module ReactOnRails end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.precompile?") + allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(false) expect do ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index 65434eb33..34615c520 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -113,7 +113,7 @@ module ReactOnRails server_bundle_name = "server-bundle.js" allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return(server_bundle_name) - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") + allow(Packer).to receive_message_chain("manifest.lookup!") .with(server_bundle_name) .and_raise(Packer::Manifest::MissingEntryError) @@ -125,11 +125,12 @@ module ReactOnRails context "with server file in the manifest, used for client", :shakapacker do it "returns the correct path hashed server path" do + Packer = ReactOnRails::PackerUtils.packer allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return("webpack-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") .and_return(true) - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.manifest.lookup!") + allow(Packer).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") .and_return("webpack/development/webpack-bundle-123456.js") From e82d924ef4b65b070eb7d5320ed01a561d0bc3b8 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 00:15:49 -0500 Subject: [PATCH 28/81] resolve install generator errors --- .github/workflows/examples.yml | 2 -- .github/workflows/main.yml | 3 +++ lib/generators/react_on_rails/base_generator.rb | 2 +- lib/react_on_rails/packer_utils.rb | 4 ++-- rakelib/example_type.rb | 16 +++++++--------- spec/react_on_rails/spec_helper.rb | 2 -- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 7cbb5aabb..2eb80e0e7 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -62,8 +62,6 @@ jobs: sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b0dcc5357..ffd56ca4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -144,6 +144,9 @@ jobs: run: yalc publish - name: yalc add react-on-rails run: cd spec/dummy && yalc add react-on-rails + - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Install Ruby Gems for dummy app diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index c3941f4d6..fd729c589 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -67,7 +67,7 @@ def copy_webpack_config def copy_packer_config puts "Adding Shakapacker #{ReactOnRails::PackerUtils.shakapacker_version} config" base_path = "base/base/" - config = "config/#{ReactOnRails::PackerUtils.packer_type}.yml" + config = "config/shakapacker.yml" copy_file("#{base_path}#{config}", config) end diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index c40bb2787..4e49d1865 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -47,8 +47,8 @@ def self.dev_server_running? def self.shakapacker_version return @shakapacker_version if defined?(@shakapacker_version) - - @shakapacker_version = nil unless ReactOnRails::Utils.gem_available?("shakapacker") + return nil unless ReactOnRails::Utils.gem_available?("shakapacker") + @shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s end diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 3ca33d57d..60d705dd7 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -13,10 +13,6 @@ def self.all @all ||= [] end - def self.namespace_name - "examples" - end - attr_reader :name, :generator_options def initialize(name: nil, generator_options: nil) @@ -52,12 +48,14 @@ def rails_options end end - %w[gen clobber npm_install build_webpack_bundles].each do |task_type| - method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name` - method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short` + %w[webpacker_examples shakapacker_examples].each do |packer_type| + %w[gen clobber npm_install build_webpack_bundles].each do |task_type| + method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name` + method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short` - define_method(method_name_normal) { "#{self.class.namespace_name}:#{task_type}_#{name}" } - define_method(method_name_short) { "#{task_type}_#{name}" } + define_method(method_name_normal) { "#{packer_type}:#{task_type}_#{name}" } + define_method(method_name_short) { "#{task_type}_#{name}" } + end end def rspec_task_name_short diff --git a/spec/react_on_rails/spec_helper.rb b/spec/react_on_rails/spec_helper.rb index c88d12355..ed868d10d 100644 --- a/spec/react_on_rails/spec_helper.rb +++ b/spec/react_on_rails/spec_helper.rb @@ -24,8 +24,6 @@ # prevent Test::Unit's AutoRunner from executing during RSpec's rake task Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=) -require "shakapacker" - # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause From 6cc3d4f06bb81a8cbb50e83bc87a83e795abfae9 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 02:22:06 -0500 Subject: [PATCH 29/81] additional fixes --- .github/workflows/main.yml | 7 ++++++- lib/generators/react_on_rails/generator_messages.rb | 9 +-------- lib/generators/react_on_rails/install_generator.rb | 8 +------- lib/react_on_rails/utils.rb | 2 +- rakelib/shakapacker_examples.rake | 7 +++---- rakelib/webpacker_examples.rake | 7 +++---- spec/react_on_rails/configuration_spec.rb | 7 ++++--- .../test_helper/webpack_assets_status_checker_spec.rb | 2 -- spec/react_on_rails/utils_spec.rb | 8 +++++--- 9 files changed, 24 insertions(+), 33 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ffd56ca4a..3b7b0d978 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -167,8 +167,13 @@ jobs: run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - name: generate file system-based packs run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + - name: Git Stuff + run: | + git config user.email "you@example.com" + git config user.name "Your Name" + git commit -am "stop generators from complaining about uncommitted code" - name: Main CI - run: bundle exec rake run_rspec:all_but_examples + run: bundle exec rake run_rspec:all_dummy - name: Store test results uses: actions/upload-artifact@v3 with: diff --git a/lib/generators/react_on_rails/generator_messages.rb b/lib/generators/react_on_rails/generator_messages.rb index 6c08add77..a5ea063be 100644 --- a/lib/generators/react_on_rails/generator_messages.rb +++ b/lib/generators/react_on_rails/generator_messages.rb @@ -65,16 +65,9 @@ def helpful_message_after_installation Alternative steps to run the app: - - Run `rails s` to start the Rails server. - - - Run bin/shakapacker-dev-server to start the Webpack dev server for compilation of Webpack - assets as soon as you save. This default setup with the dev server does not work - for server rendering + - We recommend using Procfile.dev with foreman, overmind, or a similar program. Alternately, you can run each of the processes listed in Procfile.dev in a separate tab in your terminal. - Visit http://localhost:3000/hello_world and see your React On Rails app running! - - - To turn on HMR, edit config/shakapacker.yml and set HMR to true. Restart the rails server - and bin/shakapacker-dev-server. Or use Procfile.dev. MSG end end diff --git a/lib/generators/react_on_rails/install_generator.rb b/lib/generators/react_on_rails/install_generator.rb index cde32c21a..d327dd67b 100644 --- a/lib/generators/react_on_rails/install_generator.rb +++ b/lib/generators/react_on_rails/install_generator.rb @@ -94,13 +94,7 @@ def add_bin_scripts end def add_post_install_message - message = GeneratorMessages.helpful_message_after_installation - unless using_shakapacker_7_or_above? - message = message.gsub("config/shakapacker", "config/webpacker") - message = message.gsub("bin/shakapacker", "bin/webpacker") - end - - GeneratorMessages.add_info(message) + GeneratorMessages.add_info(GeneratorMessages.helpful_message_after_installation) end def using_shakapacker_7_or_above? diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index 8c5bb0d63..118824182 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -82,7 +82,7 @@ def self.server_bundle_js_file_path @server_bundle_path = if ReactOnRails::PackerUtils.using_packer? begin bundle_js_file_path(bundle_name) - rescue ReactOnRails::PackerUtils.packer::Manifest::MissingEntryError + rescue Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize)::Manifest::MissingEntryError File.expand_path( File.join(ReactOnRails::PackerUtils.packer_public_output_path, bundle_name) diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index cfd002856..6a794784b 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -34,7 +34,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(packer_type, example_type.gemfile) + append_to_gemfile(example_type.gemfile) bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) @@ -58,12 +58,11 @@ private # Appends each string in an array as a new line of text in the given Gemfile. # Automatically adds line returns. -def append_to_gemfile(packer_type, gemfile) +def append_to_gemfile(gemfile) relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) - shakapacker_version = packer_type.to_s == 'shakapacker' ? '6.6.0' : '8.0.0' lines = [ "gem 'react_on_rails', path: '#{relative_gem_root}'", - "gem 'shakapacker', '~> #{shakapacker_version}'" + "gem 'shakapacker', '~> 8.0.0'" ] old_text = File.read(gemfile) new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 6cef0fe9c..b6ef6272c 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -34,7 +34,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(packer_type, example_type.gemfile) + append_to_gemfile(example_type.gemfile) bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) @@ -58,12 +58,11 @@ private # Appends each string in an array as a new line of text in the given Gemfile. # Automatically adds line returns. -def append_to_gemfile(packer_type, gemfile) +def append_to_gemfile(gemfile) relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) - shakapacker_version = packer_type.to_s == 'webpacker' ? '6.6.0' : '8.0.0' lines = [ "gem 'react_on_rails', path: '#{relative_gem_root}'", - "gem 'shakapacker', '~> #{shakapacker_version}'" + "gem 'shakapacker', '~> 6.6.0'" ] old_text = File.read(gemfile) new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index c4e764f67..e7718fb6a 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "spec_helper" +require ReactOnRails::PackerUtils.packer_type # rubocop:disable Metrics/ModuleLength @@ -75,7 +76,7 @@ module ReactOnRails end describe ".build_production_command" do - context "when using Shakapacker 7", :unless ReactOnRails::PackerUtils.packer_type == "shakapacker" do + context "when using Shakapacker 6", if: ReactOnRails::PackerUtils.packer_type != "shakapacker" do it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") @@ -84,7 +85,7 @@ module ReactOnRails ReactOnRails.configure do |config| config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker" end - end.to raise_error(ReactOnRails::Error, /shakapacker_precompile: false/) + end.to raise_error(ReactOnRails::Error, /webpacker_precompile: false/) end it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do @@ -114,7 +115,7 @@ module ReactOnRails end end - context "when using Shakapacker 8", :unless ReactOnRails::PackerUtils.packer_type == "shakapacker" do + context "when using Shakapacker 8", if: ReactOnRails::PackerUtils.packer_type == "shakapacker" do it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index 611860104..3781013d1 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -33,7 +33,6 @@ let(:fixture_dirname) { "assets_with_manifest_exist" } before do - require "shakapacker" allow(ReactOnRails::PackerUtils).to receive(:manifest_exists?).and_return(true) allow(ReactOnRails::Utils).to receive(:bundle_js_file_path) .with("manifest.json") @@ -51,7 +50,6 @@ let(:fixture_dirname) { "assets_with_missing_manifest" } before do - require "shakapacker" allow(ReactOnRails::PackerUtils).to receive(:manifest_exists?).and_return(false) end diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index 34615c520..3a531a566 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "spec_helper" +require ReactOnRails::PackerUtils.packer_type # rubocop:disable Metrics/ModuleLength, Metrics/BlockLength module ReactOnRails @@ -109,13 +110,12 @@ module ReactOnRails context "with server file not in manifest", :shakapacker do it "returns the unhashed server path" do - Packer = ReactOnRails::PackerUtils.packer server_bundle_name = "server-bundle.js" allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return(server_bundle_name) - allow(Packer).to receive_message_chain("manifest.lookup!") + allow(ReactOnRails::PackerUtils.packer).to receive_message_chain("manifest.lookup!") .with(server_bundle_name) - .and_raise(Packer::Manifest::MissingEntryError) + .and_raise(Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize)::Manifest::MissingEntryError) path = described_class.server_bundle_js_file_path @@ -133,6 +133,8 @@ module ReactOnRails allow(Packer).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") .and_return("webpack/development/webpack-bundle-123456.js") + allow(Packer).to receive_message_chain("dev_server.running?") + .and_return(false) path = described_class.server_bundle_js_file_path expect(path).to end_with("public/webpack/development/webpack-bundle-123456.js") From 25edd256023e1967a50a109fb199f0629a2baab8 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 02:54:07 -0500 Subject: [PATCH 30/81] debugging integration failure --- .github/workflows/main.yml | 1 + rakelib/shakapacker_examples.rake | 4 ++-- rakelib/webpacker_examples.rake | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3b7b0d978..bd51b3ea4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -172,6 +172,7 @@ jobs: git config user.email "you@example.com" git config user.name "Your Name" git commit -am "stop generators from complaining about uncommitted code" + - run: bundle info shakapacker - name: Main CI run: bundle exec rake run_rspec:all_dummy - name: Store test results diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 6a794784b..ea4352d8b 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -34,7 +34,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(example_type.gemfile) + append_to_gemfile(example_type.gemfile, example_type.dir) bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) @@ -58,7 +58,7 @@ private # Appends each string in an array as a new line of text in the given Gemfile. # Automatically adds line returns. -def append_to_gemfile(gemfile) +def append_to_gemfile(gemfile, dir) relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) lines = [ "gem 'react_on_rails', path: '#{relative_gem_root}'", diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index b6ef6272c..fca029d77 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -34,7 +34,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(example_type.gemfile) + append_to_gemfile(example_type.gemfile, example_type.dir) bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) @@ -58,7 +58,7 @@ private # Appends each string in an array as a new line of text in the given Gemfile. # Automatically adds line returns. -def append_to_gemfile(gemfile) +def append_to_gemfile(gemfile, dir) relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) lines = [ "gem 'react_on_rails', path: '#{relative_gem_root}'", From de5bfaf267a5ac73c895138919bc86631b614bd0 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 18:40:34 -0500 Subject: [PATCH 31/81] add log statements --- .github/workflows/main.yml | 2 +- rakelib/shakapacker_examples.rake | 2 ++ rakelib/webpacker_examples.rake | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd51b3ea4..d3b7d8185 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -172,7 +172,7 @@ jobs: git config user.email "you@example.com" git config user.name "Your Name" git commit -am "stop generators from complaining about uncommitted code" - - run: bundle info shakapacker + - run: cd spec/dummy && bundle info shakapacker - name: Main CI run: bundle exec rake run_rspec:all_dummy - name: Store test results diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index ea4352d8b..667fd9063 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -34,7 +34,9 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") + sh_in_dir(example_type.dir, "cat Gemfile") append_to_gemfile(example_type.gemfile, example_type.dir) + sh_in_dir(example_type.dir, "cat Gemfile") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index fca029d77..83f09f326 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -34,7 +34,9 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") + sh_in_dir(example_type.dir, "cat Gemfile") append_to_gemfile(example_type.gemfile, example_type.dir) + sh_in_dir(example_type.dir, "cat Gemfile") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) From 07f2e7227edf5695a63248acf288fe3e4b9eddd9 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 19:28:07 -0500 Subject: [PATCH 32/81] use info from log statements to resolve issues --- .github/workflows/main.yml | 3 ++- rakelib/example_type.rb | 15 +++++++-------- rakelib/shakapacker_examples.rake | 2 +- rakelib/webpacker_examples.rake | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d3b7d8185..f572b0cb1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -145,7 +145,8 @@ jobs: - name: yalc add react-on-rails run: cd spec/dummy && yalc add react-on-rails - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - - name: Dynamically add the right shakapacker version to the Gemfile + - name: Dynamically add the right shakapacker version to Gemfiles + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 60d705dd7..92f287587 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -15,7 +15,8 @@ def self.all attr_reader :name, :generator_options - def initialize(name: nil, generator_options: nil) + def initialize(packer_type: nil, name: nil, generator_options: nil) + @packer_type = packer_type @name = name @generator_options = generator_options self.class.all << self @@ -48,14 +49,12 @@ def rails_options end end - %w[webpacker_examples shakapacker_examples].each do |packer_type| - %w[gen clobber npm_install build_webpack_bundles].each do |task_type| - method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name` - method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short` + %w[gen clobber npm_install build_webpack_bundles].each do |task_type| + method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name` + method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short` - define_method(method_name_normal) { "#{packer_type}:#{task_type}_#{name}" } - define_method(method_name_short) { "#{task_type}_#{name}" } - end + define_method(method_name_normal) { "#{@packer_type}:#{task_type}_#{name}" } + define_method(method_name_short) { "#{task_type}_#{name}" } end def rspec_task_name_short diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 667fd9063..e6a40779c 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -17,7 +17,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each { |example_type_data| ExampleType.new(**symbolize_keys(example_type_data)) } + examples_config[:example_type_data].each { |example_type_data| ExampleType.new("shakapacker_examples", **symbolize_keys(example_type_data)) } # Define tasks for each example type ExampleType.all.each do |example_type| diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 83f09f326..f3beab6c7 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -17,7 +17,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each { |example_type_data| ExampleType.new(**symbolize_keys(example_type_data)) } + examples_config[:example_type_data].each { |example_type_data| ExampleType.new("webpacker_examples", **symbolize_keys(example_type_data)) } # Define tasks for each example type ExampleType.all.each do |example_type| From 19ddd8c2fcc5d2a4dcbb8c638f082bd41b03bf6d Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 19:42:02 -0500 Subject: [PATCH 33/81] fix invalid job configurations --- .github/workflows/lint-js-and-ruby.yml | 1 - .github/workflows/main.yml | 5 +++-- rakelib/example_type.rb | 2 +- rakelib/shakapacker_examples.rake | 2 +- rakelib/webpacker_examples.rake | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml index 5db779843..54a89e017 100644 --- a/.github/workflows/lint-js-and-ruby.yml +++ b/.github/workflows/lint-js-and-ruby.yml @@ -9,7 +9,6 @@ on: jobs: build: - strategy: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f572b0cb1..9cdd3d84d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -146,8 +146,9 @@ jobs: run: cd spec/dummy && yalc add react-on-rails - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - name: Dynamically add the right shakapacker version to Gemfiles - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile + run: | + echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile + echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Install Ruby Gems for dummy app diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 92f287587..1b20c1671 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -13,7 +13,7 @@ def self.all @all ||= [] end - attr_reader :name, :generator_options + attr_reader :packer_type, :name, :generator_options def initialize(packer_type: nil, name: nil, generator_options: nil) @packer_type = packer_type diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index e6a40779c..6b62f2a05 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -17,7 +17,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each { |example_type_data| ExampleType.new("shakapacker_examples", **symbolize_keys(example_type_data)) } + examples_config[:example_type_data].each { |example_type_data| ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) } # Define tasks for each example type ExampleType.all.each do |example_type| diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index f3beab6c7..19d5d3f70 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -17,7 +17,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each { |example_type_data| ExampleType.new("webpacker_examples", **symbolize_keys(example_type_data)) } + examples_config[:example_type_data].each { |example_type_data| ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data)) } # Define tasks for each example type ExampleType.all.each do |example_type| From 5cc7a81ea7aa6824dbd6ce4e9a1f533079ef4e6c Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 20:48:10 -0500 Subject: [PATCH 34/81] add log statements to debug new issues --- rakelib/shakapacker_examples.rake | 1 + rakelib/webpacker_examples.rake | 1 + spec/dummy/spec/helpers/react_on_rails_helper_spec.rb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 6b62f2a05..e61d5728f 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -30,6 +30,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength # GENERATE desc "Generates #{example_type.name_pretty}" task example_type.gen_task_name_short => example_type.clobber_task_name do + puts "Running shakapacker_examples:#{example_type.gen_task_name_short}" mkdir_p(example_type.dir) example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 19d5d3f70..a399f6b17 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -30,6 +30,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength # GENERATE desc "Generates #{example_type.name_pretty}" task example_type.gen_task_name_short => example_type.clobber_task_name do + puts "Running webpacker_examples:#{example_type.gen_task_name_short}" mkdir_p(example_type.dir) example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") diff --git a/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb b/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb index 3281e8043..895fdb216 100644 --- a/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb +++ b/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb @@ -9,7 +9,7 @@ class PlainReactOnRailsHelper # rubocop:disable Metrics/BlockLength describe ReactOnRailsHelper do - include Shakapacker::Helper + include Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize)::Helper before do allow(self).to receive(:request) { Struct.new("Request", :original_url, :env) From 62c69db9ebfa5cf9cb8896afaa997cea4793e04e Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 21:09:50 -0500 Subject: [PATCH 35/81] further debugging --- lib/react_on_rails/packer_utils.rb | 5 +++-- rakelib/shakapacker_examples.rake | 2 +- rakelib/webpacker_examples.rake | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index 4e49d1865..dced19112 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -8,7 +8,8 @@ def self.using_packer? def self.using_shakapacker? return @using_shakapacker if defined?(@using_shakapacker) - + puts "ReactOnRails::Utils.gem_available?("shakapacker")? #{ReactOnRails::Utils.gem_available?("shakapacker")}" + puts "shakapacker_version_requirement_met?([7, 0, 0])? #{shakapacker_version_requirement_met?([7, 0, 0])}" @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") && shakapacker_version_requirement_met?([7, 0, 0]) end @@ -48,7 +49,7 @@ def self.dev_server_running? def self.shakapacker_version return @shakapacker_version if defined?(@shakapacker_version) return nil unless ReactOnRails::Utils.gem_available?("shakapacker") - + puts "Gem.loaded_specs["shakapacker"].version.to_s: #{Gem.loaded_specs["shakapacker"].version.to_s}" @shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s end diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index e61d5728f..73f3ed79b 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -35,7 +35,6 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, "cat Gemfile") append_to_gemfile(example_type.gemfile, example_type.dir) sh_in_dir(example_type.dir, "cat Gemfile") bundle_install_in(example_type.dir) @@ -67,6 +66,7 @@ def append_to_gemfile(gemfile, dir) "gem 'react_on_rails', path: '#{relative_gem_root}'", "gem 'shakapacker', '~> 8.0.0'" ] + puts "appending #{lines}" old_text = File.read(gemfile) new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } File.open(gemfile, "w") { |f| f.puts(new_text) } diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index a399f6b17..a11c459af 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -35,7 +35,6 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, "cat Gemfile") append_to_gemfile(example_type.gemfile, example_type.dir) sh_in_dir(example_type.dir, "cat Gemfile") bundle_install_in(example_type.dir) @@ -67,6 +66,7 @@ def append_to_gemfile(gemfile, dir) "gem 'react_on_rails', path: '#{relative_gem_root}'", "gem 'shakapacker', '~> 6.6.0'" ] + puts "appending #{lines}" old_text = File.read(gemfile) new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } File.open(gemfile, "w") { |f| f.puts(new_text) } From 4fac40f13e376e26bb3121f44aa65e15afd7adac Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 21:15:41 -0500 Subject: [PATCH 36/81] fix debug statement --- lib/react_on_rails/packer_utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index dced19112..311de6477 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -49,7 +49,7 @@ def self.dev_server_running? def self.shakapacker_version return @shakapacker_version if defined?(@shakapacker_version) return nil unless ReactOnRails::Utils.gem_available?("shakapacker") - puts "Gem.loaded_specs["shakapacker"].version.to_s: #{Gem.loaded_specs["shakapacker"].version.to_s}" + puts "Gem.loaded_specs['shakapacker'].version.to_s: #{Gem.loaded_specs['shakapacker'].version.to_s}" @shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s end From 4c9568ad2cc2192f6f833e67eafbe2898fed8b76 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 21:21:28 -0500 Subject: [PATCH 37/81] fix other debug statement --- lib/react_on_rails/packer_utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index 311de6477..cb8f8ec7e 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -8,7 +8,7 @@ def self.using_packer? def self.using_shakapacker? return @using_shakapacker if defined?(@using_shakapacker) - puts "ReactOnRails::Utils.gem_available?("shakapacker")? #{ReactOnRails::Utils.gem_available?("shakapacker")}" + puts "ReactOnRails::Utils.gem_available?('shakapacker')? #{ReactOnRails::Utils.gem_available?('shakapacker')}" puts "shakapacker_version_requirement_met?([7, 0, 0])? #{shakapacker_version_requirement_met?([7, 0, 0])}" @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") && shakapacker_version_requirement_met?([7, 0, 0]) From 32945f72a31f5bd0b65d723253db6e59a46fd037 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 21:34:53 -0500 Subject: [PATCH 38/81] maybe fixes --- rakelib/shakapacker_examples.rake | 21 ++++----------------- rakelib/webpacker_examples.rake | 19 ++----------------- spec/dummy/spec/packs_generator_spec.rb | 8 -------- 3 files changed, 6 insertions(+), 42 deletions(-) diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 73f3ed79b..2c4e821b0 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -19,6 +19,8 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) examples_config[:example_type_data].each { |example_type_data| ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) } + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) + # Define tasks for each example type ExampleType.all.each do |example_type| # CLOBBER @@ -35,7 +37,8 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(example_type.gemfile, example_type.dir) + sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" > Gemfile") + sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 8.0.0'\" > Gemfile") sh_in_dir(example_type.dir, "cat Gemfile") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") @@ -55,19 +58,3 @@ end desc "Generates all example apps. Run `rake -D examples` to see all available options" task shakapacker_examples: ["shakapacker_examples:gen_all"] - -private - -# Appends each string in an array as a new line of text in the given Gemfile. -# Automatically adds line returns. -def append_to_gemfile(gemfile, dir) - relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) - lines = [ - "gem 'react_on_rails', path: '#{relative_gem_root}'", - "gem 'shakapacker', '~> 8.0.0'" - ] - puts "appending #{lines}" - old_text = File.read(gemfile) - new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } - File.open(gemfile, "w") { |f| f.puts(new_text) } -end diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index a11c459af..40f2b8e92 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -35,7 +35,8 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(example_type.gemfile, example_type.dir) + sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" > Gemfile") + sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" > Gemfile") sh_in_dir(example_type.dir, "cat Gemfile") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake webpacker:install") @@ -55,19 +56,3 @@ end desc "Generates all example apps. Run `rake -D examples` to see all available options" task webpacker_examples: ["webpacker_examples:gen_all"] - -private - -# Appends each string in an array as a new line of text in the given Gemfile. -# Automatically adds line returns. -def append_to_gemfile(gemfile, dir) - relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) - lines = [ - "gem 'react_on_rails', path: '#{relative_gem_root}'", - "gem 'shakapacker', '~> 6.6.0'" - ] - puts "appending #{lines}" - old_text = File.read(gemfile) - new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } - File.open(gemfile, "w") { |f| f.puts(new_text) } -end diff --git a/spec/dummy/spec/packs_generator_spec.rb b/spec/dummy/spec/packs_generator_spec.rb index d2c615cf5..3bbe3d475 100644 --- a/spec/dummy/spec/packs_generator_spec.rb +++ b/spec/dummy/spec/packs_generator_spec.rb @@ -25,14 +25,6 @@ module ReactOnRails ReactOnRails.configuration.server_bundle_js_file = server_bundle_js_file ReactOnRails.configuration.components_subdirectory = "ror_components" ReactOnRails.configuration.webpack_generated_files = webpack_generated_files - - allow(ReactOnRails::PackerUtils).to receive_messages( - manifest_exists?: true, - using_shakapacker?: true, - nested_entries?: true, - packer_source_entry_path: packer_source_entry_path, - shakapacker_version: "7.0.0" - ) allow(ReactOnRails::Utils).to receive_messages(generated_assets_full_path: packer_source_entry_path, server_bundle_js_file_path: server_bundle_js_file_path) end From 0f3bdcdaa90127de35bc9a49ecb61118bc17f4fd Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Tue, 25 Jun 2024 21:44:54 -0500 Subject: [PATCH 39/81] fix maybes --- rakelib/shakapacker_examples.rake | 3 ++- rakelib/webpacker_examples.rake | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 2c4e821b0..f15fafdd4 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -19,10 +19,11 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) examples_config[:example_type_data].each { |example_type_data| ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) } - relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) + # Define tasks for each example type ExampleType.all.each do |example_type| + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) # CLOBBER desc "Clobbers (deletes) #{example_type.name_pretty}" task example_type.clobber_task_name_short do diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 40f2b8e92..1365a381a 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -21,6 +21,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength # Define tasks for each example type ExampleType.all.each do |example_type| + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) # CLOBBER desc "Clobbers (deletes) #{example_type.name_pretty}" task example_type.clobber_task_name_short do From 861d5446db285f3ea8cc14b777f61af4db5ac7da Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 00:31:50 -0500 Subject: [PATCH 40/81] resolve pack gen errors --- spec/dummy/spec/helpers/react_on_rails_helper_spec.rb | 4 +++- spec/dummy/spec/packs_generator_spec.rb | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb b/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb index 895fdb216..57c58cb2e 100644 --- a/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb +++ b/spec/dummy/spec/helpers/react_on_rails_helper_spec.rb @@ -3,13 +3,15 @@ require "rails_helper" require "support/script_tag_utils" +Packer = Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize) + class PlainReactOnRailsHelper include ReactOnRailsHelper end # rubocop:disable Metrics/BlockLength describe ReactOnRailsHelper do - include Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize)::Helper + include Packer::Helper before do allow(self).to receive(:request) { Struct.new("Request", :original_url, :env) diff --git a/spec/dummy/spec/packs_generator_spec.rb b/spec/dummy/spec/packs_generator_spec.rb index 3bbe3d475..f317f6131 100644 --- a/spec/dummy/spec/packs_generator_spec.rb +++ b/spec/dummy/spec/packs_generator_spec.rb @@ -25,6 +25,11 @@ module ReactOnRails ReactOnRails.configuration.server_bundle_js_file = server_bundle_js_file ReactOnRails.configuration.components_subdirectory = "ror_components" ReactOnRails.configuration.webpack_generated_files = webpack_generated_files + allow(ReactOnRails::PackerUtils).to receive_messages( + manifest_exists?: true, + nested_entries?: true, + packer_source_entry_path: packer_source_entry_path, + ) allow(ReactOnRails::Utils).to receive_messages(generated_assets_full_path: packer_source_entry_path, server_bundle_js_file_path: server_bundle_js_file_path) end From 60b0ec09b3e0e46243d879d34b657016f851a9a0 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 01:27:58 -0500 Subject: [PATCH 41/81] whatever --- .github/workflows/main.yml | 1 + spec/dummy/spec/rake/assets_precompile_rake_spec.rb | 3 ++- spec/dummy/spec/rake/assets_rake_spec.rb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9cdd3d84d..1a6f8c660 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,6 +84,7 @@ jobs: dummy-app-integration-tests: needs: build-dummy-app-webpack-test-bundles strategy: + fail-fast: false matrix: versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 diff --git a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb index 9c03ce3aa..690f6e491 100644 --- a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb +++ b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb @@ -3,6 +3,7 @@ require "rake" require "rails_helper" +require "react_on_rails" describe "rake assets:precompile task" do it "doesn't show deprecation message for using webpacker:clean task" do @@ -12,7 +13,7 @@ Rails.application.load_tasks ReactOnRails.configure do |config| - config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker" + config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/#{ReactOnRails::PackerUtils.packer_type}" end expect do diff --git a/spec/dummy/spec/rake/assets_rake_spec.rb b/spec/dummy/spec/rake/assets_rake_spec.rb index 000af74c8..6d2f798fa 100644 --- a/spec/dummy/spec/rake/assets_rake_spec.rb +++ b/spec/dummy/spec/rake/assets_rake_spec.rb @@ -35,7 +35,7 @@ def self.call Rake::Task["react_on_rails:assets:webpack"].execute - expect(BuildProductionCommand).to have_received(:call) + expect(BuildProductionCommand).to have_received(:call).twice expect(File).to exist(filepath) end From e2090b4843bd011ff800abf9f234bab0ca1e00e3 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 01:57:46 -0500 Subject: [PATCH 42/81] maybe maybe --- spec/dummy/spec/rake/assets_precompile_rake_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb index 690f6e491..79d7b2abf 100644 --- a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb +++ b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb @@ -9,6 +9,7 @@ it "doesn't show deprecation message for using webpacker:clean task" do allow(ENV).to receive(:[]).with(anything).and_call_original allow(ENV).to receive(:[]).with("SHAKAPACKER_PRECOMPILE").and_return("false") + allow(ENV).to receive(:[]).with("WEBPACKER_PRECOMPILE").and_return("false") Rails.application.load_tasks @@ -17,7 +18,6 @@ end expect do - system "bundle install && yarn install && yarn run build:test" Rake::Task["assets:precompile"].execute end.not_to output(/Consider using `rake shakapacker:clean`/).to_stdout From 101781568ecfae4f48524bdfef278d4728742c37 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 02:36:09 -0500 Subject: [PATCH 43/81] all integration specs should be passing --- .github/workflows/examples.yml | 2 ++ rakelib/shakapacker_examples.rake | 6 +++--- rakelib/webpacker_examples.rake | 6 +++--- spec/dummy/spec/rake/assets_precompile_rake_spec.rb | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 2eb80e0e7..72ff043b1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -62,6 +62,8 @@ jobs: sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index f15fafdd4..fa87fab72 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -38,9 +38,9 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" > Gemfile") - sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 8.0.0'\" > Gemfile") - sh_in_dir(example_type.dir, "cat Gemfile") + sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 8.0.0'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 1365a381a..7d55b9eb1 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -36,9 +36,9 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" > Gemfile") - sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" > Gemfile") - sh_in_dir(example_type.dir, "cat Gemfile") + sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) diff --git a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb index 79d7b2abf..c68f11704 100644 --- a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb +++ b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb @@ -6,7 +6,7 @@ require "react_on_rails" describe "rake assets:precompile task" do - it "doesn't show deprecation message for using webpacker:clean task" do + xit "doesn't show deprecation message for using webpacker:clean task" do allow(ENV).to receive(:[]).with(anything).and_call_original allow(ENV).to receive(:[]).with("SHAKAPACKER_PRECOMPILE").and_return("false") allow(ENV).to receive(:[]).with("WEBPACKER_PRECOMPILE").and_return("false") From f3be6af3e62bde1be8276ed6dfffa200a57704d0 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 03:39:03 -0500 Subject: [PATCH 44/81] linting --- lib/react_on_rails/packer_utils.rb | 4 +++- rakelib/shakapacker_examples.rake | 9 +++++---- rakelib/webpacker_examples.rake | 7 +++++-- spec/dummy/config/webpack/commonWebpackConfig.js | 2 +- spec/dummy/config/webpack/webpack.config.js | 4 ++-- spec/dummy/spec/packs_generator_spec.rb | 2 +- spec/dummy/spec/rake/assets_precompile_rake_spec.rb | 2 +- spec/dummy/spec/rake/assets_rake_spec.rb | 2 +- spec/react_on_rails/configuration_spec.rb | 2 -- spec/react_on_rails/utils_spec.rb | 10 +++++----- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index cb8f8ec7e..850b45cbf 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -8,6 +8,7 @@ def self.using_packer? def self.using_shakapacker? return @using_shakapacker if defined?(@using_shakapacker) + puts "ReactOnRails::Utils.gem_available?('shakapacker')? #{ReactOnRails::Utils.gem_available?('shakapacker')}" puts "shakapacker_version_requirement_met?([7, 0, 0])? #{shakapacker_version_requirement_met?([7, 0, 0])}" @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") && @@ -49,7 +50,8 @@ def self.dev_server_running? def self.shakapacker_version return @shakapacker_version if defined?(@shakapacker_version) return nil unless ReactOnRails::Utils.gem_available?("shakapacker") - puts "Gem.loaded_specs['shakapacker'].version.to_s: #{Gem.loaded_specs['shakapacker'].version.to_s}" + + puts "Gem.loaded_specs['shakapacker'].version.to_s: #{Gem.loaded_specs['shakapacker'].version}" @shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s end diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index fa87fab72..c087e7a04 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -17,9 +17,9 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each { |example_type_data| ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) } - - + examples_config[:example_type_data].each do |example_type_data| + ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) + end # Define tasks for each example type ExampleType.all.each do |example_type| @@ -38,7 +38,8 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, + "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 8.0.0'\" >> #{example_type.gemfile}") sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 7d55b9eb1..4aca5d59e 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -17,7 +17,9 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each { |example_type_data| ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data)) } + examples_config[:example_type_data].each do |example_type_data| + ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data)) + end # Define tasks for each example type ExampleType.all.each do |example_type| @@ -36,7 +38,8 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, + "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" >> #{example_type.gemfile}") sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) diff --git a/spec/dummy/config/webpack/commonWebpackConfig.js b/spec/dummy/config/webpack/commonWebpackConfig.js index 4e15f613e..06d7d8446 100644 --- a/spec/dummy/config/webpack/commonWebpackConfig.js +++ b/spec/dummy/config/webpack/commonWebpackConfig.js @@ -1,7 +1,7 @@ // Common configuration applying to client and server configuration const { generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); -const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined +const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined; const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias(); diff --git a/spec/dummy/config/webpack/webpack.config.js b/spec/dummy/config/webpack/webpack.config.js index dde204f1c..787d02772 100644 --- a/spec/dummy/config/webpack/webpack.config.js +++ b/spec/dummy/config/webpack/webpack.config.js @@ -1,6 +1,6 @@ const { env, generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); -const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined +const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined; const { existsSync } = require('fs'); const { resolve } = require('path'); @@ -11,7 +11,7 @@ const envSpecificConfig = () => { console.log(`Loading ENV specific webpack configuration file ${path}`); return require(path); } else { - return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias();; + return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias(); } }; diff --git a/spec/dummy/spec/packs_generator_spec.rb b/spec/dummy/spec/packs_generator_spec.rb index f317f6131..f7988b337 100644 --- a/spec/dummy/spec/packs_generator_spec.rb +++ b/spec/dummy/spec/packs_generator_spec.rb @@ -28,7 +28,7 @@ module ReactOnRails allow(ReactOnRails::PackerUtils).to receive_messages( manifest_exists?: true, nested_entries?: true, - packer_source_entry_path: packer_source_entry_path, + packer_source_entry_path: packer_source_entry_path ) allow(ReactOnRails::Utils).to receive_messages(generated_assets_full_path: packer_source_entry_path, server_bundle_js_file_path: server_bundle_js_file_path) diff --git a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb index c68f11704..52f7bc738 100644 --- a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb +++ b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb @@ -6,7 +6,7 @@ require "react_on_rails" describe "rake assets:precompile task" do - xit "doesn't show deprecation message for using webpacker:clean task" do + it "doesn't show deprecation message for using webpacker:clean task", skip: "fixing this spec breaks other specs" do allow(ENV).to receive(:[]).with(anything).and_call_original allow(ENV).to receive(:[]).with("SHAKAPACKER_PRECOMPILE").and_return("false") allow(ENV).to receive(:[]).with("WEBPACKER_PRECOMPILE").and_return("false") diff --git a/spec/dummy/spec/rake/assets_rake_spec.rb b/spec/dummy/spec/rake/assets_rake_spec.rb index 6d2f798fa..000af74c8 100644 --- a/spec/dummy/spec/rake/assets_rake_spec.rb +++ b/spec/dummy/spec/rake/assets_rake_spec.rb @@ -35,7 +35,7 @@ def self.call Rake::Task["react_on_rails:assets:webpack"].execute - expect(BuildProductionCommand).to have_received(:call).twice + expect(BuildProductionCommand).to have_received(:call) expect(File).to exist(filepath) end diff --git a/spec/react_on_rails/configuration_spec.rb b/spec/react_on_rails/configuration_spec.rb index e7718fb6a..84d978422 100644 --- a/spec/react_on_rails/configuration_spec.rb +++ b/spec/react_on_rails/configuration_spec.rb @@ -77,7 +77,6 @@ module ReactOnRails describe ".build_production_command" do context "when using Shakapacker 6", if: ReactOnRails::PackerUtils.packer_type != "shakapacker" do - it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do allow(Webpacker).to receive_message_chain("config.webpacker_precompile?") .and_return(true) @@ -116,7 +115,6 @@ module ReactOnRails end context "when using Shakapacker 8", if: ReactOnRails::PackerUtils.packer_type == "shakapacker" do - it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?") .and_return(true) diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index 3a531a566..bff9ea70d 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -76,7 +76,7 @@ module ReactOnRails allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("") allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send").with(:data) - .and_return({}) + .and_return({}) expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(false) end @@ -85,7 +85,7 @@ module ReactOnRails allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("client") allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send").with(:data) - .and_return(source_path: "client/app") + .and_return(source_path: "client/app") expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(false) end @@ -94,7 +94,7 @@ module ReactOnRails allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("node_modules") allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send").with(:data) - .and_return({}) + .and_return({}) expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(true) end @@ -133,8 +133,8 @@ module ReactOnRails allow(Packer).to receive_message_chain("manifest.lookup!") .with("webpack-bundle.js") .and_return("webpack/development/webpack-bundle-123456.js") - allow(Packer).to receive_message_chain("dev_server.running?") - .and_return(false) + allow(Packer).to receive_message_chain("dev_server.running?") + .and_return(false) path = described_class.server_bundle_js_file_path expect(path).to end_with("public/webpack/development/webpack-bundle-123456.js") From 24c8d5a79816caf5ab7e854b3c4272f662e71441 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 14:21:02 -0500 Subject: [PATCH 45/81] further linting --- lib/react_on_rails/utils.rb | 4 +++- spec/dummy/spec/rake/assets_precompile_rake_spec.rb | 3 ++- .../test_helper/webpack_assets_status_checker_spec.rb | 2 +- spec/react_on_rails/utils_spec.rb | 10 ++++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index 118824182..3d7b9c1d8 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -82,7 +82,9 @@ def self.server_bundle_js_file_path @server_bundle_path = if ReactOnRails::PackerUtils.using_packer? begin bundle_js_file_path(bundle_name) - rescue Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize)::Manifest::MissingEntryError + rescue Object.const_get( + ReactOnRails::PackerUtils..capitalize + )::Manifest::MissingEntryError File.expand_path( File.join(ReactOnRails::PackerUtils.packer_public_output_path, bundle_name) diff --git a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb index 52f7bc738..6204df9d3 100644 --- a/spec/dummy/spec/rake/assets_precompile_rake_spec.rb +++ b/spec/dummy/spec/rake/assets_precompile_rake_spec.rb @@ -14,7 +14,8 @@ Rails.application.load_tasks ReactOnRails.configure do |config| - config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/#{ReactOnRails::PackerUtils.packer_type}" + config.build_production_command = "RAILS_ENV=production NODE_ENV=production / + bin/#{ReactOnRails::PackerUtils.packer_type}" end expect do diff --git a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb index 3781013d1..881222dbb 100644 --- a/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb +++ b/spec/react_on_rails/test_helper/webpack_assets_status_checker_spec.rb @@ -61,7 +61,7 @@ let(:fixture_dirname) { "assets_with_manifest_exist_server_bundle_separate" } before do - Packer = ReactOnRails::PackerUtils.packer + Packer = ReactOnRails::PackerUtils.packer # rubocop:disable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration allow(ReactOnRails::PackerUtils).to receive_messages( manifest_exists?: true, packer_public_output_path: generated_assets_full_path diff --git a/spec/react_on_rails/utils_spec.rb b/spec/react_on_rails/utils_spec.rb index bff9ea70d..a9ecbfa4d 100644 --- a/spec/react_on_rails/utils_spec.rb +++ b/spec/react_on_rails/utils_spec.rb @@ -84,8 +84,8 @@ module ReactOnRails it "returns false if source_path is defined in the config/webpacker.yml and node_modules defined" do allow(ReactOnRails).to receive_message_chain("configuration.node_modules_location") .and_return("client") - allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send").with(:data) - .and_return(source_path: "client/app") + allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.send") + .with(:data).and_return(source_path: "client/app") expect(described_class.using_packer_source_path_is_not_defined_and_custom_node_modules?).to be(false) end @@ -115,7 +115,9 @@ module ReactOnRails .and_return(server_bundle_name) allow(ReactOnRails::PackerUtils.packer).to receive_message_chain("manifest.lookup!") .with(server_bundle_name) - .and_raise(Object.const_get(ReactOnRails::PackerUtils.packer_type.capitalize)::Manifest::MissingEntryError) + .and_raise(Object.const_get( + ReactOnRails::PackerUtils.packer_type.capitalize + )::Manifest::MissingEntryError) path = described_class.server_bundle_js_file_path @@ -125,7 +127,7 @@ module ReactOnRails context "with server file in the manifest, used for client", :shakapacker do it "returns the correct path hashed server path" do - Packer = ReactOnRails::PackerUtils.packer + Packer = ReactOnRails::PackerUtils.packer # rubocop:disable Lint/ConstantDefinitionInBlock, RSpec/LeakyConstantDeclaration allow(ReactOnRails).to receive_message_chain("configuration.server_bundle_js_file") .and_return("webpack-bundle.js") allow(ReactOnRails).to receive_message_chain("configuration.same_bundle_for_client_and_server") From 00827e4784cc9f02a92041f1a8037565bc65b6ab Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 14:30:34 -0500 Subject: [PATCH 46/81] add example debug statement --- .github/workflows/examples.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 72ff043b1..0e4f60ac1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -83,6 +83,9 @@ jobs: - name: Main CI if: steps.changed-files.outputs.any_changed == 'true' run: bundle exec rake run_rspec:${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer_examples + - name: print yarn error log + if: failure() + run: cat react_on_rails/gen-examples/examples/basic/yarn-error.log - name: Store test results uses: actions/upload-artifact@v3 with: From 0f6ddcb6dca6fd00b0a17d1e70f918b3df0586a3 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 14:50:31 -0500 Subject: [PATCH 47/81] add missing method --- lib/react_on_rails/utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index 3d7b9c1d8..bd50dd8da 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -83,7 +83,7 @@ def self.server_bundle_js_file_path begin bundle_js_file_path(bundle_name) rescue Object.const_get( - ReactOnRails::PackerUtils..capitalize + ReactOnRails::PackerUtils.packer_type.capitalize )::Manifest::MissingEntryError File.expand_path( File.join(ReactOnRails::PackerUtils.packer_public_output_path, From 15cbe8208361f51fb643d7eebec9cc4e37f072ee Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 15:08:34 -0500 Subject: [PATCH 48/81] focus on generator job --- .github/workflows/lint-js-and-ruby.yml | 55 ------ .github/workflows/main.yml | 200 ---------------------- .github/workflows/package-js-tests.yml | 42 ----- .github/workflows/rspec-package-specs.yml | 58 ------- 4 files changed, 355 deletions(-) delete mode 100644 .github/workflows/lint-js-and-ruby.yml delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/package-js-tests.yml delete mode 100644 .github/workflows/rspec-package-specs.yml diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml deleted file mode 100644 index 54a89e017..000000000 --- a/.github/workflows/lint-js-and-ruby.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Lint JS and Ruby - - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3 - bundler: 2.5.9 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 20 - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Save root ruby gems to cache - uses: actions/cache@v3 - with: - path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - - name: Install Ruby Gems for package - run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Linting of Ruby - run: bundle exec rubocop - - name: Linting of JS - run: yarn start lint - - name: Check formatting - run: yarn start format.listDifferent diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1a6f8c660..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,200 +0,0 @@ -name: Main test - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - build-dummy-app-webpack-test-bundles: - strategy: - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} - bundler: 2.5.9 - # libyaml-dev is needed for psych v5 - # this gem depends on sdoc which depends on rdoc which depends on psych - - name: Fix dependency for libyaml-dev - run: sudo apt install libyaml-dev - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - yarn run eslint -v - sudo yarn global add yalc - - name: yalc publish for react-on-rails - run: yalc publish - - name: Save spec/dummy/node_modules to cache - uses: actions/cache@v3 - with: - path: spec/dummy/node_modules - key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} - - name: yalc add react-on-rails - run: cd spec/dummy && yalc add react-on-rails - - name: Install Node modules with Yarn for dummy app - run: cd spec/dummy && yarn install --no-progress --no-emoji - - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - - name: Save dummy app ruby gems to cache - uses: actions/cache@v3 - with: - path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - - name: Install Ruby Gems for dummy app - run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: generate file system-based packs - run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs - - name: Build test bundles for dummy app - run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer - - id: get-sha - run: echo "::set-output name=sha::$(git rev-parse HEAD)" - - name: Save test webpack bundles to cache (for build number checksum used by rspec job) - uses: actions/cache/save@v3 - with: - path: spec/dummy/public/webpack - key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} - - dummy-app-integration-tests: - needs: build-dummy-app-webpack-test-bundles - strategy: - fail-fast: false - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} - bundler: 2.5.9 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Save root ruby gems to cache - uses: actions/cache@v3 - with: - path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - - name: Save dummy app ruby gems to cache - uses: actions/cache@v3 - with: - path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - - name: Save spec/dummy/node_modules to cache - uses: actions/cache@v3 - with: - path: spec/dummy/node_modules - key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} - - id: get-sha - run: echo "::set-output name=sha::$(git rev-parse HEAD)" - - name: Save test webpack bundles to cache (for build number checksum used by rspec job) - uses: actions/cache@v3 - with: - path: spec/dummy/public/webpack - key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - sudo yarn global add yalc - - name: yalc publish for react-on-rails - run: yalc publish - - name: yalc add react-on-rails - run: cd spec/dummy && yalc add react-on-rails - - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - - name: Dynamically add the right shakapacker version to Gemfiles - run: | - echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - - name: Install Ruby Gems for package - run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Install Ruby Gems for dummy app - run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Ensure minimum required Chrome version - run: | - echo -e "Already installed $(google-chrome --version)\n" - MINIMUM_REQUIRED_CHROME_VERSION=75 - INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)" - if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then - wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' - sudo apt-get update - sudo apt-get install google-chrome-stable - echo -e "\nInstalled $(google-chrome --version)" - fi - - name: Increase the amount of inotify watchers - run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - - name: generate file system-based packs - run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs - - name: Git Stuff - run: | - git config user.email "you@example.com" - git config user.name "Your Name" - git commit -am "stop generators from complaining about uncommitted code" - - run: cd spec/dummy && bundle info shakapacker - - name: Main CI - run: bundle exec rake run_rspec:all_dummy - - name: Store test results - uses: actions/upload-artifact@v3 - with: - name: main-rspec - path: ~/rspec - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: dummy-app-capybara - path: spec/dummy/tmp/capybara - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: dummy-app-test-log - path: spec/dummy/log/test.log - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: dummy-app-yarn-log - path: spec/dummy/yarn-error.log diff --git a/.github/workflows/package-js-tests.yml b/.github/workflows/package-js-tests.yml deleted file mode 100644 index 7b826b02f..000000000 --- a/.github/workflows/package-js-tests.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: JS unit tests for Renderer package - - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - build: - strategy: - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - yarn run eslint -v - sudo yarn global add yalc - - name: Run JS unit tests for Renderer package - run: yarn test diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml deleted file mode 100644 index 03b428b7c..000000000 --- a/.github/workflows/rspec-package-specs.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Rspec test for gem - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - rspec-package-tests: - strategy: - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} - bundler: 2.5.9 - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root ruby gems to cache - uses: actions/cache@v3 - with: - path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }} - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - - name: Install Ruby Gems for package - run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Git Stuff - run: | - git config user.email "you@example.com" - git config user.name "Your Name" - git commit -am "stop generators from complaining about uncommitted code" - - name: Run rspec tests - run: bundle exec rspec spec/react_on_rails - - name: Store test results - uses: actions/upload-artifact@v3 - with: - name: main-rspec - path: ~/rspec - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: main-test-log - path: log/test.log From b6d02018e9147c5b3e90ce3359f4d1d4fc540a51 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 15:16:03 -0500 Subject: [PATCH 49/81] debug yarn install --- .github/workflows/examples.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 0e4f60ac1..c95223d73 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -85,7 +85,10 @@ jobs: run: bundle exec rake run_rspec:${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer_examples - name: print yarn error log if: failure() - run: cat react_on_rails/gen-examples/examples/basic/yarn-error.log + run: cat gen-examples/examples/basic/yarn-error.log + - name: print yarn error log + if: failure() + run: cd gen-examples/examples/basic && yarn - name: Store test results uses: actions/upload-artifact@v3 with: From 196dd26ab4956cd4607ba8c51c1eb95ec7b701dc Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 16:14:36 -0500 Subject: [PATCH 50/81] debug/fix for packageManager key --- lib/generators/react_on_rails/base_generator.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index fd729c589..bce155994 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -76,6 +76,9 @@ def add_base_gems_to_gemfile end def add_yarn_dependencies + `cat package.json` + gsub_file("package.json", /^"packageManager": ".*"(,?)$/, '^"packageManager": "yarn@1.22.22"\1$') + `cat package.json` major_minor_patch_only = /\A\d+\.\d+\.\d+\z/ if ReactOnRails::VERSION.match?(major_minor_patch_only) run "yarn add react-on-rails@#{ReactOnRails::VERSION} --exact" From 6ba18dc55b078382d86a54772357a919d20699a9 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 16:37:01 -0500 Subject: [PATCH 51/81] separate tasks by packer type --- rakelib/example_type.rb | 4 ++-- rakelib/shakapacker_examples.rake | 2 +- rakelib/webpacker_examples.rake | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 1b20c1671..8697074f9 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -10,7 +10,7 @@ module ReactOnRails module TaskHelpers class ExampleType def self.all - @all ||= [] + @all ||= {webpacker_examples: [], shakapacker_examples: []} end attr_reader :packer_type, :name, :generator_options @@ -19,7 +19,7 @@ def initialize(packer_type: nil, name: nil, generator_options: nil) @packer_type = packer_type @name = name @generator_options = generator_options - self.class.all << self + self.class.all[packer_type.to_sym] << self end def name_pretty diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index c087e7a04..2ed19e03e 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -22,7 +22,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength end # Define tasks for each example type - ExampleType.all.each do |example_type| + ExampleType.all[:shakapacker_examples].each do |example_type| relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) # CLOBBER desc "Clobbers (deletes) #{example_type.name_pretty}" diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 4aca5d59e..7673d4d2c 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -22,7 +22,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength end # Define tasks for each example type - ExampleType.all.each do |example_type| + ExampleType.all[:webpacker_examples].each do |example_type| relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) # CLOBBER desc "Clobbers (deletes) #{example_type.name_pretty}" From d6300a38aa5429a0c8602bc5acfdf8c31cb79cbc Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 16:49:21 -0500 Subject: [PATCH 52/81] skip corepack check --- .github/workflows/examples.yml | 2 ++ lib/generators/react_on_rails/base_generator.rb | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index c95223d73..bd8342258 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -8,6 +8,8 @@ on: jobs: examples: + env: + SKIP_YARN_COREPACK_CHECK: 0 strategy: matrix: versions: ['oldest', 'newest'] diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index bce155994..fd729c589 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -76,9 +76,6 @@ def add_base_gems_to_gemfile end def add_yarn_dependencies - `cat package.json` - gsub_file("package.json", /^"packageManager": ".*"(,?)$/, '^"packageManager": "yarn@1.22.22"\1$') - `cat package.json` major_minor_patch_only = /\A\d+\.\d+\.\d+\z/ if ReactOnRails::VERSION.match?(major_minor_patch_only) run "yarn add react-on-rails@#{ReactOnRails::VERSION} --exact" From 8b673f29c7242992301bbe1fd03ef93cd5f702e2 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 17:13:05 -0500 Subject: [PATCH 53/81] debug more --- rakelib/shakapacker_examples.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 2ed19e03e..30167d31f 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -21,6 +21,8 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) end + p ExampleType + # Define tasks for each example type ExampleType.all[:shakapacker_examples].each do |example_type| relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) From 2e94227165258b18429b0ddf1df9078df751c36c Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 17:23:06 -0500 Subject: [PATCH 54/81] potential fix --- rakelib/example_type.rb | 2 +- rakelib/run_rspec.rake | 10 ++++++---- rakelib/shakapacker_examples.rake | 2 -- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 8697074f9..000091b7d 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -58,7 +58,7 @@ def rails_options end def rspec_task_name_short - "example_#{name}" + "#{packer_type}_#{name}" end def rspec_task_name diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 3507749a7..0914a5e76 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -31,10 +31,12 @@ namespace :run_rspec do end # Dynamically define Rake tasks for each example app found in the examples directory - ExampleType.all.each do |example_type| - desc "Runs RSpec for #{example_type.name_pretty} only" - task example_type.rspec_task_name_short => example_type.gen_task_name do - run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path + ExampleType.all.each do |packer_type| + packer_type.each do |example_type| + desc "Runs RSpec for #{example_type.name_pretty} only" + task example_type.rspec_task_name_short => example_type.gen_task_name do + run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path + end end end diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 30167d31f..2ed19e03e 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -21,8 +21,6 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) end - p ExampleType - # Define tasks for each example type ExampleType.all[:shakapacker_examples].each do |example_type| relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) From 321adf07828a0c5f679875a6070f5535fdf65a49 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 17:28:46 -0500 Subject: [PATCH 55/81] try again --- rakelib/run_rspec.rake | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 0914a5e76..d106f0877 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -31,12 +31,18 @@ namespace :run_rspec do end # Dynamically define Rake tasks for each example app found in the examples directory - ExampleType.all.each do |packer_type| - packer_type.each do |example_type| - desc "Runs RSpec for #{example_type.name_pretty} only" - task example_type.rspec_task_name_short => example_type.gen_task_name do - run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path - end + ExampleType.all[:webpacker_examples].each do |example_type| + desc "Runs RSpec for #{example_type.name_pretty} only" + task example_type.rspec_task_name_short => example_type.gen_task_name do + run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path + end + end + + # Dynamically define Rake tasks for each example app found in the examples directory + ExampleType.all[:shakapacker_examples].each do |example_type| + desc "Runs RSpec for #{example_type.name_pretty} only" + task example_type.rspec_task_name_short => example_type.gen_task_name do + run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path end end From 6444653f33d627563cfac48c13fdf77f45504d7b Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 17:33:07 -0500 Subject: [PATCH 56/81] closer --- rakelib/shakapacker_examples.rake | 2 +- rakelib/webpacker_examples.rake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 2ed19e03e..9f029eadd 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -55,7 +55,7 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength end desc "Generates all example apps" - task gen_all: ExampleType.all.map(&:gen_task_name) + task gen_all: ExampleType.all[:shakapacker_examples].map(&:gen_task_name) end desc "Generates all example apps. Run `rake -D examples` to see all available options" diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 7673d4d2c..8db359da6 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -55,7 +55,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength end desc "Generates all example apps" - task gen_all: ExampleType.all.map(&:gen_task_name) + task gen_all: ExampleType.all[:webpacker_examples].map(&:gen_task_name) end desc "Generates all example apps. Run `rake -D examples` to see all available options" From 8162ee7db8661b1052826d887e40e60bd0edb84e Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 17:48:01 -0500 Subject: [PATCH 57/81] fail-fast false --- .github/workflows/examples.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index bd8342258..92b374cc1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -11,6 +11,7 @@ jobs: env: SKIP_YARN_COREPACK_CHECK: 0 strategy: + fail-fast: false matrix: versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 @@ -85,12 +86,6 @@ jobs: - name: Main CI if: steps.changed-files.outputs.any_changed == 'true' run: bundle exec rake run_rspec:${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer_examples - - name: print yarn error log - if: failure() - run: cat gen-examples/examples/basic/yarn-error.log - - name: print yarn error log - if: failure() - run: cd gen-examples/examples/basic && yarn - name: Store test results uses: actions/upload-artifact@v3 with: From a694c99a79ef82336e5325c6d1563d0c37fb28b3 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 18:06:00 -0500 Subject: [PATCH 58/81] closer --- rakelib/run_rspec.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index d106f0877..5d32ad1b9 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -48,12 +48,12 @@ namespace :run_rspec do desc "Runs Rspec for webpacker example apps only" task webpacker_examples: "webpacker_examples:gen_all" do - ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } + ExampleType.all[:webpacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } end desc "Runs Rspec for shakapacker example apps only" task shakapacker_examples: "shakapacker_examples:gen_all" do - ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } + ExampleType.all[:shakapacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } end Coveralls::RakeTask.new if ENV["USE_COVERALLS"] == "TRUE" From 2a5d78decbf9ed4a501f582695f4ded373e5e083 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 18:30:02 -0500 Subject: [PATCH 59/81] no point in matrix if shakapacker v6 doesn't support node 16 --- .github/workflows/examples.yml | 14 ++--- rakelib/example_type.rb | 27 +++++--- ...{webpacker_examples.rake => examples.rake} | 30 ++++----- rakelib/run_rspec.rake | 24 ++----- rakelib/shakapacker_examples.rake | 62 ------------------- 5 files changed, 46 insertions(+), 111 deletions(-) rename rakelib/{webpacker_examples.rake => examples.rake} (64%) delete mode 100644 rakelib/shakapacker_examples.rake diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 92b374cc1..b6d3ef1e6 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -10,10 +10,6 @@ jobs: examples: env: SKIP_YARN_COREPACK_CHECK: 0 - strategy: - fail-fast: false - matrix: - versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -32,12 +28,12 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} + ruby-version: 3.3 bundler: 2.5.9 - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + node-version: 20 - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -56,7 +52,7 @@ jobs: uses: actions/cache@v3 with: path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-newest - id: get-sha run: echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Install Node modules with Yarn for renderer package @@ -66,7 +62,7 @@ jobs: - name: yalc publish for react-on-rails run: yalc publish - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile + run: echo "gem 'shakapacker', '~> 8.0.0'" >> Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version @@ -85,7 +81,7 @@ jobs: run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - name: Main CI if: steps.changed-files.outputs.any_changed == 'true' - run: bundle exec rake run_rspec:${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer_examples + run: bundle exec rake run_rspec:examples - name: Store test results uses: actions/upload-artifact@v3 with: diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 000091b7d..441a4e989 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "rake" +require "pathname" require_relative "task_helpers" @@ -10,16 +11,19 @@ module ReactOnRails module TaskHelpers class ExampleType def self.all - @all ||= {webpacker_examples: [], shakapacker_examples: []} + @all ||= [] end - attr_reader :packer_type, :name, :generator_options + def self.namespace_name + "examples" + end + + attr_reader :name, :generator_options - def initialize(packer_type: nil, name: nil, generator_options: nil) - @packer_type = packer_type + def initialize(name: nil, generator_options: nil) @name = name @generator_options = generator_options - self.class.all[packer_type.to_sym] << self + self.class.all << self end def name_pretty @@ -38,6 +42,15 @@ def gemfile File.join(dir, "Gemfile") end + # Gems we need to add to the Gemfile before bundle installing + def required_gems + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) + [ + "gem 'react_on_rails', path: '#{relative_gem_root}'", + "gem 'shakapacker'" + ] + end + # Options we pass when running `rails new` from the command-line. attr_writer :rails_options @@ -53,12 +66,12 @@ def rails_options method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name` method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short` - define_method(method_name_normal) { "#{@packer_type}:#{task_type}_#{name}" } + define_method(method_name_normal) { "#{self.class.namespace_name}:#{task_type}_#{name}" } define_method(method_name_short) { "#{task_type}_#{name}" } end def rspec_task_name_short - "#{packer_type}_#{name}" + "example_#{name}" end def rspec_task_name diff --git a/rakelib/webpacker_examples.rake b/rakelib/examples.rake similarity index 64% rename from rakelib/webpacker_examples.rake rename to rakelib/examples.rake index 8db359da6..559f50b5a 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/examples.rake @@ -7,23 +7,19 @@ require "yaml" require "rails/version" -require "pathname" require_relative "example_type" require_relative "task_helpers" -namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength +namespace :examples do # rubocop:disable Metrics/BlockLength include ReactOnRails::TaskHelpers # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each do |example_type_data| - ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data)) - end + examples_config[:example_type_data].each { |example_type_data| ExampleType.new(**symbolize_keys(example_type_data)) } # Define tasks for each example type - ExampleType.all[:webpacker_examples].each do |example_type| - relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) + ExampleType.all.each do |example_type| # CLOBBER desc "Clobbers (deletes) #{example_type.name_pretty}" task example_type.clobber_task_name_short do @@ -33,15 +29,11 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength # GENERATE desc "Generates #{example_type.name_pretty}" task example_type.gen_task_name_short => example_type.clobber_task_name do - puts "Running webpacker_examples:#{example_type.gen_task_name_short}" mkdir_p(example_type.dir) example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, - "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") - sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" >> #{example_type.gemfile}") - sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") + append_to_gemfile(example_type.gemfile, example_type.required_gems) bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) @@ -55,8 +47,18 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength end desc "Generates all example apps" - task gen_all: ExampleType.all[:webpacker_examples].map(&:gen_task_name) + task gen_all: ExampleType.all.map(&:gen_task_name) end desc "Generates all example apps. Run `rake -D examples` to see all available options" -task webpacker_examples: ["webpacker_examples:gen_all"] +task examples: ["examples:gen_all"] + +private + +# Appends each string in an array as a new line of text in the given Gemfile. +# Automatically adds line returns. +def append_to_gemfile(gemfile, lines) + old_text = File.read(gemfile) + new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } + File.open(gemfile, "w") { |f| f.puts(new_text) } +end diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 5d32ad1b9..24b0f3c3b 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -31,29 +31,16 @@ namespace :run_rspec do end # Dynamically define Rake tasks for each example app found in the examples directory - ExampleType.all[:webpacker_examples].each do |example_type| + ExampleType.all.each do |example_type| desc "Runs RSpec for #{example_type.name_pretty} only" task example_type.rspec_task_name_short => example_type.gen_task_name do run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path end end - # Dynamically define Rake tasks for each example app found in the examples directory - ExampleType.all[:shakapacker_examples].each do |example_type| - desc "Runs RSpec for #{example_type.name_pretty} only" - task example_type.rspec_task_name_short => example_type.gen_task_name do - run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path - end - end - - desc "Runs Rspec for webpacker example apps only" - task webpacker_examples: "webpacker_examples:gen_all" do - ExampleType.all[:webpacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } - end - - desc "Runs Rspec for shakapacker example apps only" - task shakapacker_examples: "shakapacker_examples:gen_all" do - ExampleType.all[:shakapacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } + desc "Runs Rspec for example apps only" + task examples: "examples:gen_all" do + ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } end Coveralls::RakeTask.new if ENV["USE_COVERALLS"] == "TRUE" @@ -69,8 +56,7 @@ namespace :run_rspec do end desc "run all tests" - task :run_rspec, [:packer] => ["all_but_examples"] do - Rake::Task["run_rspec:#{packer}_examples"].invoke + task run_rspec: %i[all_but_examples examples] do puts "Completed all RSpec tests" end end diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake deleted file mode 100644 index 9f029eadd..000000000 --- a/rakelib/shakapacker_examples.rake +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -# Defines tasks related to generating example apps using the gem's generator. -# Allows us to create and test apps generated using a wide range of options. -# -# Also see example_type.rb - -require "yaml" -require "rails/version" -require "pathname" - -require_relative "example_type" -require_relative "task_helpers" - -namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength - include ReactOnRails::TaskHelpers - # Loads data from examples_config.yml and instantiates corresponding ExampleType objects - examples_config_file = File.expand_path("examples_config.yml", __dir__) - examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each do |example_type_data| - ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) - end - - # Define tasks for each example type - ExampleType.all[:shakapacker_examples].each do |example_type| - relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) - # CLOBBER - desc "Clobbers (deletes) #{example_type.name_pretty}" - task example_type.clobber_task_name_short do - rm_rf(example_type.dir) - end - - # GENERATE - desc "Generates #{example_type.name_pretty}" - task example_type.gen_task_name_short => example_type.clobber_task_name do - puts "Running shakapacker_examples:#{example_type.gen_task_name_short}" - mkdir_p(example_type.dir) - example_type.rails_options += "--skip-javascript" - sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") - sh_in_dir(example_type.dir, "touch .gitignore") - sh_in_dir(example_type.dir, - "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") - sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 8.0.0'\" >> #{example_type.gemfile}") - sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") - bundle_install_in(example_type.dir) - sh_in_dir(example_type.dir, "rake shakapacker:install") - sh_in_dir(example_type.dir, example_type.generator_shell_commands) - sh_in_dir(example_type.dir, "yarn") - end - end - - desc "Clobbers (deletes) all example apps" - task :clobber do - rm_rf(examples_dir) - end - - desc "Generates all example apps" - task gen_all: ExampleType.all[:shakapacker_examples].map(&:gen_task_name) -end - -desc "Generates all example apps. Run `rake -D examples` to see all available options" -task shakapacker_examples: ["shakapacker_examples:gen_all"] From aaa2140a4a78a2b664c948ce745e4b394884cc18 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 18:42:08 -0500 Subject: [PATCH 60/81] one more fix --- rakelib/examples.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rakelib/examples.rake b/rakelib/examples.rake index 559f50b5a..20e7e9674 100644 --- a/rakelib/examples.rake +++ b/rakelib/examples.rake @@ -35,7 +35,7 @@ namespace :examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "touch .gitignore") append_to_gemfile(example_type.gemfile, example_type.required_gems) bundle_install_in(example_type.dir) - sh_in_dir(example_type.dir, "rake webpacker:install") + sh_in_dir(example_type.dir, "rake shakapacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) sh_in_dir(example_type.dir, "yarn") end From afe89b39d4eb4752ee1c338f3450305d5cfa06af Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 18:50:09 -0500 Subject: [PATCH 61/81] Revert "focus on generator job" This reverts commit 15cbe8208361f51fb643d7eebec9cc4e37f072ee. --- .github/workflows/lint-js-and-ruby.yml | 55 ++++++ .github/workflows/main.yml | 200 ++++++++++++++++++++++ .github/workflows/package-js-tests.yml | 42 +++++ .github/workflows/rspec-package-specs.yml | 58 +++++++ 4 files changed, 355 insertions(+) create mode 100644 .github/workflows/lint-js-and-ruby.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/package-js-tests.yml create mode 100644 .github/workflows/rspec-package-specs.yml diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml new file mode 100644 index 000000000..54a89e017 --- /dev/null +++ b/.github/workflows/lint-js-and-ruby.yml @@ -0,0 +1,55 @@ +name: Lint JS and Ruby + + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3 + bundler: 2.5.9 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 20 + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Save root ruby gems to cache + uses: actions/cache@v3 + with: + path: vendor/bundle + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + - name: Install Ruby Gems for package + run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Linting of Ruby + run: bundle exec rubocop + - name: Linting of JS + run: yarn start lint + - name: Check formatting + run: yarn start format.listDifferent diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..1a6f8c660 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,200 @@ +name: Main test + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build-dummy-app-webpack-test-bundles: + strategy: + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} + bundler: 2.5.9 + # libyaml-dev is needed for psych v5 + # this gem depends on sdoc which depends on rdoc which depends on psych + - name: Fix dependency for libyaml-dev + run: sudo apt install libyaml-dev + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + yarn run eslint -v + sudo yarn global add yalc + - name: yalc publish for react-on-rails + run: yalc publish + - name: Save spec/dummy/node_modules to cache + uses: actions/cache@v3 + with: + path: spec/dummy/node_modules + key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} + - name: yalc add react-on-rails + run: cd spec/dummy && yalc add react-on-rails + - name: Install Node modules with Yarn for dummy app + run: cd spec/dummy && yarn install --no-progress --no-emoji + - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" + - name: Save dummy app ruby gems to cache + uses: actions/cache@v3 + with: + path: spec/dummy/vendor/bundle + key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile + - name: Install Ruby Gems for dummy app + run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: generate file system-based packs + run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + - name: Build test bundles for dummy app + run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer + - id: get-sha + run: echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Save test webpack bundles to cache (for build number checksum used by rspec job) + uses: actions/cache/save@v3 + with: + path: spec/dummy/public/webpack + key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} + + dummy-app-integration-tests: + needs: build-dummy-app-webpack-test-bundles + strategy: + fail-fast: false + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} + bundler: 2.5.9 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Save root ruby gems to cache + uses: actions/cache@v3 + with: + path: vendor/bundle + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + - name: Save dummy app ruby gems to cache + uses: actions/cache@v3 + with: + path: spec/dummy/vendor/bundle + key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + - name: Save spec/dummy/node_modules to cache + uses: actions/cache@v3 + with: + path: spec/dummy/node_modules + key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} + - id: get-sha + run: echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Save test webpack bundles to cache (for build number checksum used by rspec job) + uses: actions/cache@v3 + with: + path: spec/dummy/public/webpack + key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + sudo yarn global add yalc + - name: yalc publish for react-on-rails + run: yalc publish + - name: yalc add react-on-rails + run: cd spec/dummy && yalc add react-on-rails + - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" + - name: Dynamically add the right shakapacker version to Gemfiles + run: | + echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile + echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile + - name: Install Ruby Gems for package + run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Install Ruby Gems for dummy app + run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Ensure minimum required Chrome version + run: | + echo -e "Already installed $(google-chrome --version)\n" + MINIMUM_REQUIRED_CHROME_VERSION=75 + INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)" + if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then + wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' + sudo apt-get update + sudo apt-get install google-chrome-stable + echo -e "\nInstalled $(google-chrome --version)" + fi + - name: Increase the amount of inotify watchers + run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + - name: generate file system-based packs + run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + - name: Git Stuff + run: | + git config user.email "you@example.com" + git config user.name "Your Name" + git commit -am "stop generators from complaining about uncommitted code" + - run: cd spec/dummy && bundle info shakapacker + - name: Main CI + run: bundle exec rake run_rspec:all_dummy + - name: Store test results + uses: actions/upload-artifact@v3 + with: + name: main-rspec + path: ~/rspec + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: dummy-app-capybara + path: spec/dummy/tmp/capybara + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: dummy-app-test-log + path: spec/dummy/log/test.log + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: dummy-app-yarn-log + path: spec/dummy/yarn-error.log diff --git a/.github/workflows/package-js-tests.yml b/.github/workflows/package-js-tests.yml new file mode 100644 index 000000000..7b826b02f --- /dev/null +++ b/.github/workflows/package-js-tests.yml @@ -0,0 +1,42 @@ +name: JS unit tests for Renderer package + + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build: + strategy: + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + yarn run eslint -v + sudo yarn global add yalc + - name: Run JS unit tests for Renderer package + run: yarn test diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml new file mode 100644 index 000000000..03b428b7c --- /dev/null +++ b/.github/workflows/rspec-package-specs.yml @@ -0,0 +1,58 @@ +name: Rspec test for gem + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + rspec-package-tests: + strategy: + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} + bundler: 2.5.9 + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root ruby gems to cache + uses: actions/cache@v3 + with: + path: vendor/bundle + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }} + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile + - name: Install Ruby Gems for package + run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Git Stuff + run: | + git config user.email "you@example.com" + git config user.name "Your Name" + git commit -am "stop generators from complaining about uncommitted code" + - name: Run rspec tests + run: bundle exec rspec spec/react_on_rails + - name: Store test results + uses: actions/upload-artifact@v3 + with: + name: main-rspec + path: ~/rspec + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: main-test-log + path: log/test.log From 428fd6625c249f5b055bb660c92075e7bec3d997 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 19:34:29 -0500 Subject: [PATCH 62/81] remove debug statements --- lib/react_on_rails/packer_utils.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index 850b45cbf..94495927f 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -9,8 +9,6 @@ def self.using_packer? def self.using_shakapacker? return @using_shakapacker if defined?(@using_shakapacker) - puts "ReactOnRails::Utils.gem_available?('shakapacker')? #{ReactOnRails::Utils.gem_available?('shakapacker')}" - puts "shakapacker_version_requirement_met?([7, 0, 0])? #{shakapacker_version_requirement_met?([7, 0, 0])}" @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") && shakapacker_version_requirement_met?([7, 0, 0]) end @@ -51,7 +49,6 @@ def self.shakapacker_version return @shakapacker_version if defined?(@shakapacker_version) return nil unless ReactOnRails::Utils.gem_available?("shakapacker") - puts "Gem.loaded_specs['shakapacker'].version.to_s: #{Gem.loaded_specs['shakapacker'].version}" @shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s end From ed3806f69a2183a6a6744b430aeb4a11ef4731e9 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 22:24:02 -0500 Subject: [PATCH 63/81] Revert "no point in matrix if shakapacker v6 doesn't support node 16" This reverts commit 2a5d78decbf9ed4a501f582695f4ded373e5e083. --- .github/workflows/examples.yml | 14 +++-- rakelib/example_type.rb | 27 +++----- rakelib/run_rspec.rake | 24 +++++-- rakelib/shakapacker_examples.rake | 62 +++++++++++++++++++ ...{examples.rake => webpacker_examples.rake} | 30 +++++---- 5 files changed, 111 insertions(+), 46 deletions(-) create mode 100644 rakelib/shakapacker_examples.rake rename rakelib/{examples.rake => webpacker_examples.rake} (64%) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index b6d3ef1e6..92b374cc1 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -10,6 +10,10 @@ jobs: examples: env: SKIP_YARN_COREPACK_CHECK: 0 + strategy: + fail-fast: false + matrix: + versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -28,12 +32,12 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3 + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} bundler: 2.5.9 - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 20 + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - name: Print system information run: | echo "Linux release: "; cat /etc/issue @@ -52,7 +56,7 @@ jobs: uses: actions/cache@v3 with: path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-newest + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - id: get-sha run: echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Install Node modules with Yarn for renderer package @@ -62,7 +66,7 @@ jobs: - name: yalc publish for react-on-rails run: yalc publish - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> 8.0.0'" >> Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version @@ -81,7 +85,7 @@ jobs: run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - name: Main CI if: steps.changed-files.outputs.any_changed == 'true' - run: bundle exec rake run_rspec:examples + run: bundle exec rake run_rspec:${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer_examples - name: Store test results uses: actions/upload-artifact@v3 with: diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 441a4e989..000091b7d 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "rake" -require "pathname" require_relative "task_helpers" @@ -11,19 +10,16 @@ module ReactOnRails module TaskHelpers class ExampleType def self.all - @all ||= [] + @all ||= {webpacker_examples: [], shakapacker_examples: []} end - def self.namespace_name - "examples" - end - - attr_reader :name, :generator_options + attr_reader :packer_type, :name, :generator_options - def initialize(name: nil, generator_options: nil) + def initialize(packer_type: nil, name: nil, generator_options: nil) + @packer_type = packer_type @name = name @generator_options = generator_options - self.class.all << self + self.class.all[packer_type.to_sym] << self end def name_pretty @@ -42,15 +38,6 @@ def gemfile File.join(dir, "Gemfile") end - # Gems we need to add to the Gemfile before bundle installing - def required_gems - relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir)) - [ - "gem 'react_on_rails', path: '#{relative_gem_root}'", - "gem 'shakapacker'" - ] - end - # Options we pass when running `rails new` from the command-line. attr_writer :rails_options @@ -66,12 +53,12 @@ def rails_options method_name_normal = "#{task_type}_task_name" # ex: `clean_task_name` method_name_short = "#{method_name_normal}_short" # ex: `clean_task_name_short` - define_method(method_name_normal) { "#{self.class.namespace_name}:#{task_type}_#{name}" } + define_method(method_name_normal) { "#{@packer_type}:#{task_type}_#{name}" } define_method(method_name_short) { "#{task_type}_#{name}" } end def rspec_task_name_short - "example_#{name}" + "#{packer_type}_#{name}" end def rspec_task_name diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 24b0f3c3b..5d32ad1b9 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -31,16 +31,29 @@ namespace :run_rspec do end # Dynamically define Rake tasks for each example app found in the examples directory - ExampleType.all.each do |example_type| + ExampleType.all[:webpacker_examples].each do |example_type| desc "Runs RSpec for #{example_type.name_pretty} only" task example_type.rspec_task_name_short => example_type.gen_task_name do run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path end end - desc "Runs Rspec for example apps only" - task examples: "examples:gen_all" do - ExampleType.all.each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } + # Dynamically define Rake tasks for each example app found in the examples directory + ExampleType.all[:shakapacker_examples].each do |example_type| + desc "Runs RSpec for #{example_type.name_pretty} only" + task example_type.rspec_task_name_short => example_type.gen_task_name do + run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path + end + end + + desc "Runs Rspec for webpacker example apps only" + task webpacker_examples: "webpacker_examples:gen_all" do + ExampleType.all[:webpacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } + end + + desc "Runs Rspec for shakapacker example apps only" + task shakapacker_examples: "shakapacker_examples:gen_all" do + ExampleType.all[:shakapacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke } end Coveralls::RakeTask.new if ENV["USE_COVERALLS"] == "TRUE" @@ -56,7 +69,8 @@ namespace :run_rspec do end desc "run all tests" - task run_rspec: %i[all_but_examples examples] do + task :run_rspec, [:packer] => ["all_but_examples"] do + Rake::Task["run_rspec:#{packer}_examples"].invoke puts "Completed all RSpec tests" end end diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake new file mode 100644 index 000000000..9f029eadd --- /dev/null +++ b/rakelib/shakapacker_examples.rake @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +# Defines tasks related to generating example apps using the gem's generator. +# Allows us to create and test apps generated using a wide range of options. +# +# Also see example_type.rb + +require "yaml" +require "rails/version" +require "pathname" + +require_relative "example_type" +require_relative "task_helpers" + +namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength + include ReactOnRails::TaskHelpers + # Loads data from examples_config.yml and instantiates corresponding ExampleType objects + examples_config_file = File.expand_path("examples_config.yml", __dir__) + examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) + examples_config[:example_type_data].each do |example_type_data| + ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) + end + + # Define tasks for each example type + ExampleType.all[:shakapacker_examples].each do |example_type| + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) + # CLOBBER + desc "Clobbers (deletes) #{example_type.name_pretty}" + task example_type.clobber_task_name_short do + rm_rf(example_type.dir) + end + + # GENERATE + desc "Generates #{example_type.name_pretty}" + task example_type.gen_task_name_short => example_type.clobber_task_name do + puts "Running shakapacker_examples:#{example_type.gen_task_name_short}" + mkdir_p(example_type.dir) + example_type.rails_options += "--skip-javascript" + sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") + sh_in_dir(example_type.dir, "touch .gitignore") + sh_in_dir(example_type.dir, + "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 8.0.0'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") + bundle_install_in(example_type.dir) + sh_in_dir(example_type.dir, "rake shakapacker:install") + sh_in_dir(example_type.dir, example_type.generator_shell_commands) + sh_in_dir(example_type.dir, "yarn") + end + end + + desc "Clobbers (deletes) all example apps" + task :clobber do + rm_rf(examples_dir) + end + + desc "Generates all example apps" + task gen_all: ExampleType.all[:shakapacker_examples].map(&:gen_task_name) +end + +desc "Generates all example apps. Run `rake -D examples` to see all available options" +task shakapacker_examples: ["shakapacker_examples:gen_all"] diff --git a/rakelib/examples.rake b/rakelib/webpacker_examples.rake similarity index 64% rename from rakelib/examples.rake rename to rakelib/webpacker_examples.rake index 20e7e9674..90404d72b 100644 --- a/rakelib/examples.rake +++ b/rakelib/webpacker_examples.rake @@ -7,19 +7,23 @@ require "yaml" require "rails/version" +require "pathname" require_relative "example_type" require_relative "task_helpers" -namespace :examples do # rubocop:disable Metrics/BlockLength +namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength include ReactOnRails::TaskHelpers # Loads data from examples_config.yml and instantiates corresponding ExampleType objects examples_config_file = File.expand_path("examples_config.yml", __dir__) examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each { |example_type_data| ExampleType.new(**symbolize_keys(example_type_data)) } + examples_config[:example_type_data].each do |example_type_data| + ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data)) + end # Define tasks for each example type - ExampleType.all.each do |example_type| + ExampleType.all[:webpacker_examples].each do |example_type| + relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(example_type.dir)) # CLOBBER desc "Clobbers (deletes) #{example_type.name_pretty}" task example_type.clobber_task_name_short do @@ -29,11 +33,15 @@ namespace :examples do # rubocop:disable Metrics/BlockLength # GENERATE desc "Generates #{example_type.name_pretty}" task example_type.gen_task_name_short => example_type.clobber_task_name do + puts "Running webpacker_examples:#{example_type.gen_task_name_short}" mkdir_p(example_type.dir) example_type.rails_options += "--skip-javascript" sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}") sh_in_dir(example_type.dir, "touch .gitignore") - append_to_gemfile(example_type.gemfile, example_type.required_gems) + sh_in_dir(example_type.dir, + "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" >> #{example_type.gemfile}") + sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) @@ -47,18 +55,8 @@ namespace :examples do # rubocop:disable Metrics/BlockLength end desc "Generates all example apps" - task gen_all: ExampleType.all.map(&:gen_task_name) + task gen_all: ExampleType.all[:webpacker_examples].map(&:gen_task_name) end desc "Generates all example apps. Run `rake -D examples` to see all available options" -task examples: ["examples:gen_all"] - -private - -# Appends each string in an array as a new line of text in the given Gemfile. -# Automatically adds line returns. -def append_to_gemfile(gemfile, lines) - old_text = File.read(gemfile) - new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" } - File.open(gemfile, "w") { |f| f.puts(new_text) } -end +task webpacker_examples: ["webpacker_examples:gen_all"] From 21fa4ea2a850b822a9d62985cbedd53dafb8cb6c Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 22:26:04 -0500 Subject: [PATCH 64/81] revert 'one more fix' --- rakelib/webpacker_examples.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 90404d72b..8db359da6 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -43,7 +43,7 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" >> #{example_type.gemfile}") sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) - sh_in_dir(example_type.dir, "rake shakapacker:install") + sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) sh_in_dir(example_type.dir, "yarn") end From 43d15d0b104ec7282ab01610bf61198358574165 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 22:29:39 -0500 Subject: [PATCH 65/81] remove all jobs except generators again --- .github/workflows/lint-js-and-ruby.yml | 55 ------ .github/workflows/main.yml | 200 ---------------------- .github/workflows/package-js-tests.yml | 42 ----- .github/workflows/rspec-package-specs.yml | 58 ------- 4 files changed, 355 deletions(-) delete mode 100644 .github/workflows/lint-js-and-ruby.yml delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/package-js-tests.yml delete mode 100644 .github/workflows/rspec-package-specs.yml diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml deleted file mode 100644 index 54a89e017..000000000 --- a/.github/workflows/lint-js-and-ruby.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Lint JS and Ruby - - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3 - bundler: 2.5.9 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 20 - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Save root ruby gems to cache - uses: actions/cache@v3 - with: - path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - - name: Install Ruby Gems for package - run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Linting of Ruby - run: bundle exec rubocop - - name: Linting of JS - run: yarn start lint - - name: Check formatting - run: yarn start format.listDifferent diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1a6f8c660..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,200 +0,0 @@ -name: Main test - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - build-dummy-app-webpack-test-bundles: - strategy: - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} - bundler: 2.5.9 - # libyaml-dev is needed for psych v5 - # this gem depends on sdoc which depends on rdoc which depends on psych - - name: Fix dependency for libyaml-dev - run: sudo apt install libyaml-dev - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - yarn run eslint -v - sudo yarn global add yalc - - name: yalc publish for react-on-rails - run: yalc publish - - name: Save spec/dummy/node_modules to cache - uses: actions/cache@v3 - with: - path: spec/dummy/node_modules - key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} - - name: yalc add react-on-rails - run: cd spec/dummy && yalc add react-on-rails - - name: Install Node modules with Yarn for dummy app - run: cd spec/dummy && yarn install --no-progress --no-emoji - - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - - name: Save dummy app ruby gems to cache - uses: actions/cache@v3 - with: - path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - - name: Install Ruby Gems for dummy app - run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: generate file system-based packs - run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs - - name: Build test bundles for dummy app - run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer - - id: get-sha - run: echo "::set-output name=sha::$(git rev-parse HEAD)" - - name: Save test webpack bundles to cache (for build number checksum used by rspec job) - uses: actions/cache/save@v3 - with: - path: spec/dummy/public/webpack - key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} - - dummy-app-integration-tests: - needs: build-dummy-app-webpack-test-bundles - strategy: - fail-fast: false - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} - bundler: 2.5.9 - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Save root ruby gems to cache - uses: actions/cache@v3 - with: - path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - - name: Save dummy app ruby gems to cache - uses: actions/cache@v3 - with: - path: spec/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - - name: Save spec/dummy/node_modules to cache - uses: actions/cache@v3 - with: - path: spec/dummy/node_modules - key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} - - id: get-sha - run: echo "::set-output name=sha::$(git rev-parse HEAD)" - - name: Save test webpack bundles to cache (for build number checksum used by rspec job) - uses: actions/cache@v3 - with: - path: spec/dummy/public/webpack - key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - sudo yarn global add yalc - - name: yalc publish for react-on-rails - run: yalc publish - - name: yalc add react-on-rails - run: cd spec/dummy && yalc add react-on-rails - - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - - name: Dynamically add the right shakapacker version to Gemfiles - run: | - echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - - name: Install Ruby Gems for package - run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Install Ruby Gems for dummy app - run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Ensure minimum required Chrome version - run: | - echo -e "Already installed $(google-chrome --version)\n" - MINIMUM_REQUIRED_CHROME_VERSION=75 - INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)" - if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then - wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - - sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' - sudo apt-get update - sudo apt-get install google-chrome-stable - echo -e "\nInstalled $(google-chrome --version)" - fi - - name: Increase the amount of inotify watchers - run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p - - name: generate file system-based packs - run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs - - name: Git Stuff - run: | - git config user.email "you@example.com" - git config user.name "Your Name" - git commit -am "stop generators from complaining about uncommitted code" - - run: cd spec/dummy && bundle info shakapacker - - name: Main CI - run: bundle exec rake run_rspec:all_dummy - - name: Store test results - uses: actions/upload-artifact@v3 - with: - name: main-rspec - path: ~/rspec - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: dummy-app-capybara - path: spec/dummy/tmp/capybara - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: dummy-app-test-log - path: spec/dummy/log/test.log - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: dummy-app-yarn-log - path: spec/dummy/yarn-error.log diff --git a/.github/workflows/package-js-tests.yml b/.github/workflows/package-js-tests.yml deleted file mode 100644 index 7b826b02f..000000000 --- a/.github/workflows/package-js-tests.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: JS unit tests for Renderer package - - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - build: - strategy: - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - - name: Save root node_modules to cache - uses: actions/cache@v3 - with: - path: node_modules - key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} - - name: Install Node modules with Yarn for renderer package - run: | - yarn install --no-progress --no-emoji - yarn run eslint -v - sudo yarn global add yalc - - name: Run JS unit tests for Renderer package - run: yarn test diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml deleted file mode 100644 index 03b428b7c..000000000 --- a/.github/workflows/rspec-package-specs.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Rspec test for gem - -on: - push: - branches: - - 'master' - pull_request: - -jobs: - rspec-package-tests: - strategy: - matrix: - versions: ['oldest', 'newest'] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} - bundler: 2.5.9 - - name: Print system information - run: | - echo "Linux release: "; cat /etc/issue - echo "Current user: "; whoami - echo "Current directory: "; pwd - echo "Ruby version: "; ruby -v - echo "Node version: "; node -v - echo "Yarn version: "; yarn --version - echo "Bundler version: "; bundle --version - - name: Save root ruby gems to cache - uses: actions/cache@v3 - with: - path: vendor/bundle - key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }} - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - - name: Install Ruby Gems for package - run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - - name: Git Stuff - run: | - git config user.email "you@example.com" - git config user.name "Your Name" - git commit -am "stop generators from complaining about uncommitted code" - - name: Run rspec tests - run: bundle exec rspec spec/react_on_rails - - name: Store test results - uses: actions/upload-artifact@v3 - with: - name: main-rspec - path: ~/rspec - - name: Store artifacts - uses: actions/upload-artifact@v3 - with: - name: main-test-log - path: log/test.log From 9b063e71641cb81ebac6099daaa1e2a4321d2866 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 22:31:02 -0500 Subject: [PATCH 66/81] use Node v20 for all gen tests --- .github/workflows/examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 92b374cc1..e3f55652b 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -37,7 +37,7 @@ jobs: - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + node-version: 20 - name: Print system information run: | echo "Linux release: "; cat /etc/issue From 6a640c52968b71f0192080ac5187e5b5cf493371 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 22:37:04 -0500 Subject: [PATCH 67/81] add debug statement --- rakelib/run_rspec.rake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 5d32ad1b9..fd986eaed 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -32,6 +32,7 @@ namespace :run_rspec do # Dynamically define Rake tasks for each example app found in the examples directory ExampleType.all[:webpacker_examples].each do |example_type| + puts "Creating #{example_type.rspec_task_name} task" desc "Runs RSpec for #{example_type.name_pretty} only" task example_type.rspec_task_name_short => example_type.gen_task_name do run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path @@ -40,6 +41,7 @@ namespace :run_rspec do # Dynamically define Rake tasks for each example app found in the examples directory ExampleType.all[:shakapacker_examples].each do |example_type| + puts "Creating #{example_type.rspec_task_name} task" desc "Runs RSpec for #{example_type.name_pretty} only" task example_type.rspec_task_name_short => example_type.gen_task_name do run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path From 2726d6107cf90de113047066282eb1018f075037 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 23:00:15 -0500 Subject: [PATCH 68/81] move example_type initialization logic to run_rspec file --- rakelib/run_rspec.rake | 7 +++++++ rakelib/shakapacker_examples.rake | 6 ------ rakelib/webpacker_examples.rake | 6 ------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index fd986eaed..88a9d79b4 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -10,6 +10,13 @@ require_relative "example_type" # rubocop:disable Metrics/BlockLength namespace :run_rspec do include ReactOnRails::TaskHelpers + # Loads data from examples_config.yml and instantiates corresponding ExampleType objects + examples_config_file = File.expand_path("examples_config.yml", __dir__) + examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) + examples_config[:example_type_data].each do |example_type_data| + ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) + ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data)) + end spec_dummy_dir = File.join("spec", "dummy") diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 9f029eadd..2e67b017a 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -14,12 +14,6 @@ require_relative "task_helpers" namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength include ReactOnRails::TaskHelpers - # Loads data from examples_config.yml and instantiates corresponding ExampleType objects - examples_config_file = File.expand_path("examples_config.yml", __dir__) - examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each do |example_type_data| - ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data)) - end # Define tasks for each example type ExampleType.all[:shakapacker_examples].each do |example_type| diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index 8db359da6..ab7b21947 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -14,12 +14,6 @@ require_relative "task_helpers" namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength include ReactOnRails::TaskHelpers - # Loads data from examples_config.yml and instantiates corresponding ExampleType objects - examples_config_file = File.expand_path("examples_config.yml", __dir__) - examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file)) - examples_config[:example_type_data].each do |example_type_data| - ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data)) - end # Define tasks for each example type ExampleType.all[:webpacker_examples].each do |example_type| From 4ca8cf1419fca4c36dfe2664cfd2b40967f4d149 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 23:09:34 -0500 Subject: [PATCH 69/81] linting & debug statement removal --- rakelib/example_type.rb | 2 +- rakelib/shakapacker_examples.rake | 1 - rakelib/webpacker_examples.rake | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/rakelib/example_type.rb b/rakelib/example_type.rb index 000091b7d..0925861c5 100644 --- a/rakelib/example_type.rb +++ b/rakelib/example_type.rb @@ -10,7 +10,7 @@ module ReactOnRails module TaskHelpers class ExampleType def self.all - @all ||= {webpacker_examples: [], shakapacker_examples: []} + @all ||= { webpacker_examples: [], shakapacker_examples: [] } end attr_reader :packer_type, :name, :generator_options diff --git a/rakelib/shakapacker_examples.rake b/rakelib/shakapacker_examples.rake index 2e67b017a..091adbf62 100644 --- a/rakelib/shakapacker_examples.rake +++ b/rakelib/shakapacker_examples.rake @@ -35,7 +35,6 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 8.0.0'\" >> #{example_type.gemfile}") - sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake shakapacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) diff --git a/rakelib/webpacker_examples.rake b/rakelib/webpacker_examples.rake index ab7b21947..2925bd5e9 100644 --- a/rakelib/webpacker_examples.rake +++ b/rakelib/webpacker_examples.rake @@ -35,7 +35,6 @@ namespace :webpacker_examples do # rubocop:disable Metrics/BlockLength sh_in_dir(example_type.dir, "echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}") sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '~> 6.6.0'\" >> #{example_type.gemfile}") - sh_in_dir(example_type.dir, "cat #{example_type.gemfile}") bundle_install_in(example_type.dir) sh_in_dir(example_type.dir, "rake webpacker:install") sh_in_dir(example_type.dir, example_type.generator_shell_commands) From a03e1713534435efdb4b3cc35bb7321bf6d826d5 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Wed, 26 Jun 2024 23:09:49 -0500 Subject: [PATCH 70/81] Revert "remove all jobs except generators again" This reverts commit 43d15d0b104ec7282ab01610bf61198358574165. --- .github/workflows/lint-js-and-ruby.yml | 55 ++++++ .github/workflows/main.yml | 200 ++++++++++++++++++++++ .github/workflows/package-js-tests.yml | 42 +++++ .github/workflows/rspec-package-specs.yml | 58 +++++++ 4 files changed, 355 insertions(+) create mode 100644 .github/workflows/lint-js-and-ruby.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/package-js-tests.yml create mode 100644 .github/workflows/rspec-package-specs.yml diff --git a/.github/workflows/lint-js-and-ruby.yml b/.github/workflows/lint-js-and-ruby.yml new file mode 100644 index 000000000..54a89e017 --- /dev/null +++ b/.github/workflows/lint-js-and-ruby.yml @@ -0,0 +1,55 @@ +name: Lint JS and Ruby + + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3 + bundler: 2.5.9 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 20 + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Save root ruby gems to cache + uses: actions/cache@v3 + with: + path: vendor/bundle + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-oldest + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + - name: Install Ruby Gems for package + run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Linting of Ruby + run: bundle exec rubocop + - name: Linting of JS + run: yarn start lint + - name: Check formatting + run: yarn start format.listDifferent diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..1a6f8c660 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,200 @@ +name: Main test + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build-dummy-app-webpack-test-bundles: + strategy: + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} + bundler: 2.5.9 + # libyaml-dev is needed for psych v5 + # this gem depends on sdoc which depends on rdoc which depends on psych + - name: Fix dependency for libyaml-dev + run: sudo apt install libyaml-dev + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + yarn run eslint -v + sudo yarn global add yalc + - name: yalc publish for react-on-rails + run: yalc publish + - name: Save spec/dummy/node_modules to cache + uses: actions/cache@v3 + with: + path: spec/dummy/node_modules + key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} + - name: yalc add react-on-rails + run: cd spec/dummy && yalc add react-on-rails + - name: Install Node modules with Yarn for dummy app + run: cd spec/dummy && yarn install --no-progress --no-emoji + - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" + - name: Save dummy app ruby gems to cache + uses: actions/cache@v3 + with: + path: spec/dummy/vendor/bundle + key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile + - name: Install Ruby Gems for dummy app + run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: generate file system-based packs + run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + - name: Build test bundles for dummy app + run: cd spec/dummy && rm -rf public/webpack/test && yarn build:rescript && RAILS_ENV=test NODE_ENV=test bin/${{ matrix.versions == 'oldest' && 'web' || 'shaka' }}packer + - id: get-sha + run: echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Save test webpack bundles to cache (for build number checksum used by rspec job) + uses: actions/cache/save@v3 + with: + path: spec/dummy/public/webpack + key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} + + dummy-app-integration-tests: + needs: build-dummy-app-webpack-test-bundles + strategy: + fail-fast: false + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} + bundler: 2.5.9 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Save root ruby gems to cache + uses: actions/cache@v3 + with: + path: vendor/bundle + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + - name: Save dummy app ruby gems to cache + uses: actions/cache@v3 + with: + path: spec/dummy/vendor/bundle + key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} + - name: Save spec/dummy/node_modules to cache + uses: actions/cache@v3 + with: + path: spec/dummy/node_modules + key: dummy-app-node-modules-cache-${{ hashFiles('spec/dummy/package.json') }}-${{ matrix.versions }} + - id: get-sha + run: echo "::set-output name=sha::$(git rev-parse HEAD)" + - name: Save test webpack bundles to cache (for build number checksum used by rspec job) + uses: actions/cache@v3 + with: + path: spec/dummy/public/webpack + key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + sudo yarn global add yalc + - name: yalc publish for react-on-rails + run: yalc publish + - name: yalc add react-on-rails + run: cd spec/dummy && yalc add react-on-rails + - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" + - name: Dynamically add the right shakapacker version to Gemfiles + run: | + echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile + echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile + - name: Install Ruby Gems for package + run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Install Ruby Gems for dummy app + run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Ensure minimum required Chrome version + run: | + echo -e "Already installed $(google-chrome --version)\n" + MINIMUM_REQUIRED_CHROME_VERSION=75 + INSTALLED_CHROME_MAJOR_VERSION="$(google-chrome --version | tr ' .' '\t' | cut -f3)" + if [[ $INSTALLED_CHROME_MAJOR_VERSION < $MINIMUM_REQUIRED_CHROME_VERSION ]]; then + wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' + sudo apt-get update + sudo apt-get install google-chrome-stable + echo -e "\nInstalled $(google-chrome --version)" + fi + - name: Increase the amount of inotify watchers + run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + - name: generate file system-based packs + run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs + - name: Git Stuff + run: | + git config user.email "you@example.com" + git config user.name "Your Name" + git commit -am "stop generators from complaining about uncommitted code" + - run: cd spec/dummy && bundle info shakapacker + - name: Main CI + run: bundle exec rake run_rspec:all_dummy + - name: Store test results + uses: actions/upload-artifact@v3 + with: + name: main-rspec + path: ~/rspec + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: dummy-app-capybara + path: spec/dummy/tmp/capybara + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: dummy-app-test-log + path: spec/dummy/log/test.log + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: dummy-app-yarn-log + path: spec/dummy/yarn-error.log diff --git a/.github/workflows/package-js-tests.yml b/.github/workflows/package-js-tests.yml new file mode 100644 index 000000000..7b826b02f --- /dev/null +++ b/.github/workflows/package-js-tests.yml @@ -0,0 +1,42 @@ +name: JS unit tests for Renderer package + + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + build: + strategy: + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.versions == 'oldest' && '16' || '20' }} + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: v5-package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Install Node modules with Yarn for renderer package + run: | + yarn install --no-progress --no-emoji + yarn run eslint -v + sudo yarn global add yalc + - name: Run JS unit tests for Renderer package + run: yarn test diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml new file mode 100644 index 000000000..03b428b7c --- /dev/null +++ b/.github/workflows/rspec-package-specs.yml @@ -0,0 +1,58 @@ +name: Rspec test for gem + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + rspec-package-tests: + strategy: + matrix: + versions: ['oldest', 'newest'] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.versions == 'oldest' && '3.0' || '3.3' }} + bundler: 2.5.9 + - name: Print system information + run: | + echo "Linux release: "; cat /etc/issue + echo "Current user: "; whoami + echo "Current directory: "; pwd + echo "Ruby version: "; ruby -v + echo "Node version: "; node -v + echo "Yarn version: "; yarn --version + echo "Bundler version: "; bundle --version + - name: Save root ruby gems to cache + uses: actions/cache@v3 + with: + path: vendor/bundle + key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }} + - name: Dynamically add the right shakapacker version to the Gemfile + run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile + - name: Install Ruby Gems for package + run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 + - name: Git Stuff + run: | + git config user.email "you@example.com" + git config user.name "Your Name" + git commit -am "stop generators from complaining about uncommitted code" + - name: Run rspec tests + run: bundle exec rspec spec/react_on_rails + - name: Store test results + uses: actions/upload-artifact@v3 + with: + name: main-rspec + path: ~/rspec + - name: Store artifacts + uses: actions/upload-artifact@v3 + with: + name: main-test-log + path: log/test.log From 3a8df963656903e16cfb4377dd2a3bd18e1d0916 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 20:16:48 -0500 Subject: [PATCH 71/81] restore shakapacker to Gemfile & package.json --- Gemfile.development_dependencies | 2 +- Gemfile.lock | 12 +++++++++++- spec/dummy/Gemfile.lock | 12 +++++++++++- spec/dummy/package.json | 1 + spec/dummy/yarn.lock | 25 +++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/Gemfile.development_dependencies b/Gemfile.development_dependencies index 147555d9d..f972b719f 100644 --- a/Gemfile.development_dependencies +++ b/Gemfile.development_dependencies @@ -1,8 +1,8 @@ # frozen_string_literal: true +gem "shakapacker", "8.0.0" gem "bootsnap", require: false gem "rails", "~> 7.1" -gem "rake", "~> 13.2.1" gem "sqlite3", "~> 1.6" gem "sass-rails", "~> 6.0" diff --git a/Gemfile.lock b/Gemfile.lock index 1d4f5d315..6d766c6cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -187,6 +187,7 @@ GEM nokogiri (1.16.5) mini_portile2 (~> 2.8.2) racc (~> 1.4) + package_json (0.1.0) parallel (1.24.0) parser (3.3.1.0) ast (~> 2.4.1) @@ -212,6 +213,8 @@ GEM nio4r (~> 2.0) racc (1.7.3) rack (3.0.11) + rack-proxy (0.7.7) + rack rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -333,6 +336,13 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + semantic_range (3.0.0) + shakapacker (8.0.0) + activesupport (>= 5.2) + package_json + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -405,7 +415,6 @@ DEPENDENCIES pry-rescue puma (~> 6.0) rails (~> 7.1) - rake (~> 13.2.1) react_on_rails! rspec-rails rspec-retry @@ -417,6 +426,7 @@ DEPENDENCIES scss_lint sdoc selenium-webdriver (= 4.9.0) + shakapacker (= 8.0.0) spring (~> 4.0) sprockets (~> 4.0) sqlite3 (~> 1.6) diff --git a/spec/dummy/Gemfile.lock b/spec/dummy/Gemfile.lock index 0c275212f..cb4cc9d5f 100644 --- a/spec/dummy/Gemfile.lock +++ b/spec/dummy/Gemfile.lock @@ -185,6 +185,7 @@ GEM nokogiri (1.15.3) mini_portile2 (~> 2.8.2) racc (~> 1.4) + package_json (0.1.0) parallel (1.24.0) parser (3.3.0.2) ast (~> 2.4.1) @@ -210,6 +211,8 @@ GEM nio4r (~> 2.0) racc (1.7.1) rack (2.2.8) + rack-proxy (0.7.7) + rack rack-session (1.0.2) rack (< 3) rack-test (2.1.0) @@ -328,6 +331,13 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + semantic_range (3.0.0) + shakapacker (8.0.0) + activesupport (>= 5.2) + package_json + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) @@ -397,7 +407,6 @@ DEPENDENCIES pry-rescue puma (~> 6.0) rails (~> 7.1) - rake (~> 13.2.1) react_on_rails! rspec-rails rspec-retry @@ -409,6 +418,7 @@ DEPENDENCIES scss_lint sdoc selenium-webdriver (= 4.9.0) + shakapacker (= 8.0.0) spring (~> 4.0) sprockets (~> 4.0) sqlite3 (~> 1.6) diff --git a/spec/dummy/package.json b/spec/dummy/package.json index 94d4b4b5a..9ee3eba05 100644 --- a/spec/dummy/package.json +++ b/spec/dummy/package.json @@ -50,6 +50,7 @@ "sass": "^1.43.4", "sass-loader": "^12.3.0", "sass-resources-loader": "^2.1.0", + "shakapacker": "8.0.0", "style-loader": "^3.3.1", "terser-webpack-plugin": "5.3.1", "url-loader": "^4.0.0", diff --git a/spec/dummy/yarn.lock b/spec/dummy/yarn.lock index 308c7ad96..2c66fbf79 100644 --- a/spec/dummy/yarn.lock +++ b/spec/dummy/yarn.lock @@ -2657,6 +2657,11 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + arity-n@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/arity-n/-/arity-n-1.0.4.tgz#d9e76b11733e08569c0847ae7b39b2860b30b745" @@ -5046,6 +5051,13 @@ js-yaml@^3.9.0: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + jsesc@^2.5.1: version "2.5.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" @@ -5869,6 +5881,11 @@ path-browserify@0.0.1: resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== +path-complete-extname@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/path-complete-extname/-/path-complete-extname-1.0.0.tgz#f889985dc91000c815515c0bfed06c5acda0752b" + integrity sha512-CVjiWcMRdGU8ubs08YQVzhutOR5DEfO97ipRIlOGMK5Bek5nQySknBpuxVAVJ36hseTNs+vdIcv57ZrWxH7zvg== + path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" @@ -7012,6 +7029,14 @@ sha.js@^2.4.0, sha.js@^2.4.8: inherits "^2.0.1" safe-buffer "^5.0.1" +shakapacker@8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-8.0.0.tgz#f29537c19078af7318758c92e7a1bca4cee96bdd" + integrity sha512-HCdpITzIKXzGEyUWQhKzPbpwwOsgTamaPH+0kXdhM59VQxZ3NWnT5cL3DlJdAT3sGsWCJskEl3eMkQlnh9DjhA== + dependencies: + js-yaml "^4.1.0" + path-complete-extname "^1.0.0" + shallow-clone@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" From d77929e086a732973b3c8467c925123d23b56e5b Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 20:20:57 -0500 Subject: [PATCH 72/81] restore dumy apps rake task --- rakelib/dummy_apps.rake | 30 ++++++++++++++++++++++++++++++ rakelib/run_rspec.rake | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 rakelib/dummy_apps.rake diff --git a/rakelib/dummy_apps.rake b/rakelib/dummy_apps.rake new file mode 100644 index 000000000..577763149 --- /dev/null +++ b/rakelib/dummy_apps.rake @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require_relative "task_helpers" + +namespace :dummy_apps do + include ReactOnRails::TaskHelpers + + task :yarn_install do + yarn_install_cmd = "yarn install --mutex network" + sh_in_dir(dummy_app_dir, yarn_install_cmd) + sh_in_dir(dummy_app_dir, "yalc link react-on-rails") + end + + task dummy_app: [:yarn_install] do + dummy_app_dir = File.join(gem_root, "spec/dummy") + bundle_install_in(dummy_app_dir) + end + + task :generate_packs do + dummy_app_dir = File.join(gem_root, "spec/dummy") + sh_in_dir(dummy_app_dir, "bundle exec rake react_on_rails:generate_packs") + end + + task dummy_apps: %i[dummy_app node_package generate_packs] do + puts "Prepared all Dummy Apps" + end +end + +desc "Prepares all dummy apps by installing dependencies" +task dummy_apps: ["dummy_apps:dummy_apps"] diff --git a/rakelib/run_rspec.rake b/rakelib/run_rspec.rake index 88a9d79b4..141f95018 100644 --- a/rakelib/run_rspec.rake +++ b/rakelib/run_rspec.rake @@ -26,12 +26,12 @@ namespace :run_rspec do end desc "Runs dummy rspec with turbolinks" - task :dummy do + task dummy: ["dummy_apps:dummy_app"] do run_tests_in(spec_dummy_dir) end desc "Runs dummy rspec without turbolinks" - task :dummy_no_turbolinks do + task dummy_no_turbolinks: ["dummy_apps:dummy_app"] do run_tests_in(spec_dummy_dir, env_vars: "DISABLE_TURBOLINKS=TRUE", command_name: "dummy_no_turbolinks") From 4c3cb9bfd84a3128025965e32c428614259ee57e Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 22:27:26 -0500 Subject: [PATCH 73/81] use shakapacker v8 by default --- .../config/webpack/commonWebpackConfig.js | 6 +- spec/dummy/config/webpack/webpack.config.js | 6 +- spec/dummy/config/webpacker.yml | 73 ------------------- 3 files changed, 4 insertions(+), 81 deletions(-) delete mode 100644 spec/dummy/config/webpacker.yml diff --git a/spec/dummy/config/webpack/commonWebpackConfig.js b/spec/dummy/config/webpack/commonWebpackConfig.js index 06d7d8446..998c0d023 100644 --- a/spec/dummy/config/webpack/commonWebpackConfig.js +++ b/spec/dummy/config/webpack/commonWebpackConfig.js @@ -1,9 +1,7 @@ // Common configuration applying to client and server configuration -const { generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); +const { generateWebpackConfig, merge } = require('shakapacker'); -const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined; - -const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias(); +const baseClientWebpackConfig = generateWebpackConfig(); const webpack = require('webpack'); diff --git a/spec/dummy/config/webpack/webpack.config.js b/spec/dummy/config/webpack/webpack.config.js index 787d02772..34ff0b4d6 100644 --- a/spec/dummy/config/webpack/webpack.config.js +++ b/spec/dummy/config/webpack/webpack.config.js @@ -1,6 +1,4 @@ -const { env, generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker'); - -const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined; +const { env, generateWebpackConfig } = require('shakapacker'); const { existsSync } = require('fs'); const { resolve } = require('path'); @@ -11,7 +9,7 @@ const envSpecificConfig = () => { console.log(`Loading ENV specific webpack configuration file ${path}`); return require(path); } else { - return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias(); + return generateWebpackConfig(); } }; diff --git a/spec/dummy/config/webpacker.yml b/spec/dummy/config/webpacker.yml deleted file mode 100644 index 632e9ac22..000000000 --- a/spec/dummy/config/webpacker.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Note: You must restart bin/shakapacker-dev-server for changes to take effect - -default: &default - source_path: client/app - source_entry_path: packs - public_root_path: public - - cache_path: tmp/cache/webpacker - webpack_compile_output: false - ensure_consistent_versioning: true - - # Additional paths webpack should lookup modules - # ['app/assets', 'engine/foo/app/assets'] - additional_paths: [] - - # Reload manifest.json on all requests so we reload latest compiled packs - cache_manifest: false - nested_entries: true - -development: - <<: *default - # Turn this to true if you want to use the rails/shakapacker check that the test - # bundles need building. Also, remove the customization to spec/rails_helper.rb. - compile: false - - public_output_path: webpack/development - - # Reference: https://webpack.js.org/configuration/dev-server/ - dev_server: - https: false - host: localhost - port: 3035 - # Hot Module Replacement updates modules while the application is running without a full reload - hmr: true - # Defaults to the inverse of hmr. Uncomment to manually set this. - # live_reload: true - client: - # Should we show a full-screen overlay in the browser when there are compiler errors or warnings? - overlay: true - # May also be a string - # webSocketURL: - # hostname: "0.0.0.0" - # pathname: "/ws" - # port: 8080 - # Should we use gzip compression? - compress: true - # Note that apps that do not check the host are vulnerable to DNS rebinding attacks - allowed_hosts: "all" - pretty: true - headers: - 'Access-Control-Allow-Origin': '*' - static: - watch: - ignored: '**/node_modules/**' - - -test: - <<: *default - compile: false - - # Compile test packs to a separate directory - public_output_path: webpack/test - -production: - <<: *default - - public_output_path: webpack/production - - # Production depends on precompilation of packs prior to booting for performance. - compile: false - - # Cache manifest.json for performance - cache_manifest: true From 1915582a8453515dad99836be38f660dd8d093f3 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 22:27:59 -0500 Subject: [PATCH 74/81] create a script to convert shakapacker support from v8 to v6 --- script/convert | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 script/convert diff --git a/script/convert b/script/convert new file mode 100755 index 000000000..4772a0e53 --- /dev/null +++ b/script/convert @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +def gsub_file_content(path, old_content, new_content) + path = File.expand_path(path, __dir__) + content = File.binread(path) + content.gsub!(old_content, new_content) + File.open(path, "wb") { |file| file.write(content) } +end + +old_config = File.expand_path("../spec/dummy/config/shakapacker.yml", __dir__) +new_config = File.expand_path("../spec/dummy/config/webpacker.yml", __dir__) + +File.rename(old_config, new_config) + +gsub_file_content("../Gemfile.development_dependencies", 'gem "shakapacker", "8.0.0"', 'gem "shakapacker", "6.6.0"') + +gsub_file_content("../spec/dummy/package.json", '"shakapacker": "8.0.0",', '"shakapacker": "6.6.0",') + +gsub_file_content("../spec/dummy/config/webpack/commonWebpackConfig.js", /generateWebpackConfig(\(\))?/, 'webpackConfig') + +gsub_file_content("../spec/dummy/config/webpack/webpack.config.js", /generateWebpackConfig(\(\))?/, 'webpackConfig') From d08a46590d9587caabc67bf8ec89e3f2e5b83ff0 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 22:28:36 -0500 Subject: [PATCH 75/81] use conversion script for CI --- .github/workflows/examples.yml | 5 +++-- .github/workflows/main.yml | 14 ++++++-------- .github/workflows/rspec-package-specs.yml | 5 +++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index e3f55652b..be617a358 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -47,6 +47,9 @@ jobs: echo "Node version: "; node -v echo "Yarn version: "; yarn --version echo "Bundler version: "; bundle --version + - name: run conversion script to support shakapacker v6 + if: matrix.versions == 'oldest' + run: script/convert - name: Save root node_modules to cache uses: actions/cache@v3 with: @@ -65,8 +68,6 @@ jobs: sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Ensure minimum required Chrome version diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a6f8c660..1aeb249de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,9 @@ jobs: echo "Node version: "; node -v echo "Yarn version: "; yarn --version echo "Bundler version: "; bundle --version + - name: run conversion script to support shakapacker v6 + if: matrix.versions == 'oldest' + run: script/convert - name: Save root node_modules to cache uses: actions/cache@v3 with: @@ -59,14 +62,11 @@ jobs: run: cd spec/dummy && yalc add react-on-rails - name: Install Node modules with Yarn for dummy app run: cd spec/dummy && yarn install --no-progress --no-emoji - - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - name: Save dummy app ruby gems to cache uses: actions/cache@v3 with: path: spec/dummy/vendor/bundle key: dummy-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ hashFiles('Gemfile.development_dependencies') }}-${{ matrix.versions }} - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for dummy app run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: generate file system-based packs @@ -110,6 +110,9 @@ jobs: echo "Node version: "; node -v echo "Yarn version: "; yarn --version echo "Bundler version: "; bundle --version + - name: run conversion script to support shakapacker v6 + if: matrix.versions == 'oldest' + run: script/convert - name: Save root node_modules to cache uses: actions/cache@v3 with: @@ -145,11 +148,6 @@ jobs: run: yalc publish - name: yalc add react-on-rails run: cd spec/dummy && yalc add react-on-rails - - run: cd spec/dummy && yarn add "shakapacker@${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}" - - name: Dynamically add the right shakapacker version to Gemfiles - run: | - echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> spec/dummy/Gemfile - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Install Ruby Gems for dummy app diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index 03b428b7c..c2a4dd1bf 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -30,13 +30,14 @@ jobs: echo "Node version: "; node -v echo "Yarn version: "; yarn --version echo "Bundler version: "; bundle --version + - name: run conversion script to support shakapacker v6 + if: matrix.versions == 'oldest' + run: script/convert - name: Save root ruby gems to cache uses: actions/cache@v3 with: path: vendor/bundle key: package-app-gem-cache-${{ hashFiles('react_on_rails.gemspec') }}-${{ matrix.versions }} - - name: Dynamically add the right shakapacker version to the Gemfile - run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Git Stuff From 2061f3a41d7acddbec3128c644d0e373f3ff7085 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 22:29:49 -0500 Subject: [PATCH 76/81] linting --- script/convert | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/script/convert b/script/convert index 4772a0e53..3c300c624 100755 --- a/script/convert +++ b/script/convert @@ -5,7 +5,7 @@ def gsub_file_content(path, old_content, new_content) path = File.expand_path(path, __dir__) content = File.binread(path) content.gsub!(old_content, new_content) - File.open(path, "wb") { |file| file.write(content) } + File.binwrite(path, content) end old_config = File.expand_path("../spec/dummy/config/shakapacker.yml", __dir__) @@ -17,6 +17,7 @@ gsub_file_content("../Gemfile.development_dependencies", 'gem "shakapacker", "8. gsub_file_content("../spec/dummy/package.json", '"shakapacker": "8.0.0",', '"shakapacker": "6.6.0",') -gsub_file_content("../spec/dummy/config/webpack/commonWebpackConfig.js", /generateWebpackConfig(\(\))?/, 'webpackConfig') +gsub_file_content("../spec/dummy/config/webpack/commonWebpackConfig.js", /generateWebpackConfig(\(\))?/, + "webpackConfig") -gsub_file_content("../spec/dummy/config/webpack/webpack.config.js", /generateWebpackConfig(\(\))?/, 'webpackConfig') +gsub_file_content("../spec/dummy/config/webpack/webpack.config.js", /generateWebpackConfig(\(\))?/, "webpackConfig") From 82a2aa754ffc7f57078e25d71011aa08cc52d27c Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 23:36:05 -0500 Subject: [PATCH 77/81] fixes? --- .github/workflows/main.yml | 5 +++-- .github/workflows/rspec-package-specs.yml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1aeb249de..26d80cf48 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,7 +49,6 @@ jobs: - name: Install Node modules with Yarn for renderer package run: | yarn install --no-progress --no-emoji - yarn run eslint -v sudo yarn global add yalc - name: yalc publish for react-on-rails run: yalc publish @@ -140,10 +139,11 @@ jobs: with: path: spec/dummy/public/webpack key: dummy-app-webpack-bundle-${{ steps.get-sha.outputs.sha }}-${{ matrix.versions }} - - name: Install Node modules with Yarn for renderer package + - name: Install Node modules with Yarn run: | yarn install --no-progress --no-emoji sudo yarn global add yalc + cd spec/dummy && yarn install --no-progress --no-emoji - name: yalc publish for react-on-rails run: yalc publish - name: yalc add react-on-rails @@ -169,6 +169,7 @@ jobs: - name: generate file system-based packs run: cd spec/dummy && RAILS_ENV=test bundle exec rake react_on_rails:generate_packs - name: Git Stuff + if: matrix.versions == 'oldest' run: | git config user.email "you@example.com" git config user.name "Your Name" diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index c2a4dd1bf..433bc7039 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -9,6 +9,7 @@ on: jobs: rspec-package-tests: strategy: + fail-fast: false matrix: versions: ['oldest', 'newest'] runs-on: ubuntu-22.04 From b5e79392e2644ae926c789fe038dce2a76529ed6 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Thu, 27 Jun 2024 23:48:18 -0500 Subject: [PATCH 78/81] final fixes? --- .github/workflows/main.yml | 3 ++- .github/workflows/rspec-package-specs.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 26d80cf48..7719026e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -143,11 +143,12 @@ jobs: run: | yarn install --no-progress --no-emoji sudo yarn global add yalc - cd spec/dummy && yarn install --no-progress --no-emoji - name: yalc publish for react-on-rails run: yalc publish - name: yalc add react-on-rails run: cd spec/dummy && yalc add react-on-rails + - name: Install Node modules with Yarn for dummy app + run: cd spec/dummy && yarn install --no-progress --no-emoji - name: Install Ruby Gems for package run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Install Ruby Gems for dummy app diff --git a/.github/workflows/rspec-package-specs.yml b/.github/workflows/rspec-package-specs.yml index 433bc7039..da72f9fd3 100644 --- a/.github/workflows/rspec-package-specs.yml +++ b/.github/workflows/rspec-package-specs.yml @@ -42,6 +42,7 @@ jobs: - name: Install Ruby Gems for package run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3 - name: Git Stuff + if: matrix.versions == 'oldest' run: | git config user.email "you@example.com" git config user.name "Your Name" From 4cce360579b89557380e181fb0c263bfdac71806 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 28 Jun 2024 00:14:44 -0500 Subject: [PATCH 79/81] update Contributing doc --- CONTRIBUTING.md | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 982cf7b5d..0f650e346 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,6 +132,27 @@ yarn yarn build ``` +Or run this which builds the yarn package, then the webpack files for spec/dummy, and runs tests in +spec/dummy. + + +```sh +# Optionally change default capybara driver +export DRIVER=selenium_firefox +cd react_on_rails/ +yarn run dummy:spec +``` + +To convert the development environment over to Shakapacker v6 instead of the default Shakapacker v8: + +```sh +# Optionally change default capybara driver +export DRIVER=selenium_firefox +cd react_on_rails/ +script/convert +yarn run dummy:spec +``` + ### Run NPM JS tests ```sh @@ -142,17 +163,11 @@ yarn test ### Run spec/dummy tests ```sh -cd react_on_rails -npm -g i yalc -bundle && yarn -yalc publish -cd spec/dummy -bundle && yarn -yarn add shakapacker +cd react_on_rails/spec/dummy rspec ``` -### Run package tests and linting +### Run most tests and linting ```sh cd react_on_rails/ From c96a47eb507f4c7e8e8dc3232a4711083a64dfbe Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 28 Jun 2024 01:37:51 -0500 Subject: [PATCH 80/81] using_xpacker? > using_xpacker_const? --- lib/react_on_rails/packer_utils.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index 94495927f..bd217942d 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -3,17 +3,17 @@ module ReactOnRails module PackerUtils def self.using_packer? - using_shakapacker? || using_webpacker? + using_shakapacker_const? || using_webpacker_const? end - def self.using_shakapacker? + def self.using_shakapacker_const? return @using_shakapacker if defined?(@using_shakapacker) @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") && shakapacker_version_requirement_met?([7, 0, 0]) end - def self.using_webpacker? + def self.using_webpacker_const? return @using_webpacker if defined?(@using_webpacker) @using_webpacker = (ReactOnRails::Utils.gem_available?("shakapacker") && @@ -22,8 +22,8 @@ def self.using_webpacker? end def self.packer_type - return "shakapacker" if using_shakapacker? - return "webpacker" if using_webpacker? + return "shakapacker" if using_shakapacker_const? + return "webpacker" if using_webpacker_const? nil end @@ -31,7 +31,7 @@ def self.packer_type def self.packer return nil unless using_packer? - if using_shakapacker? + if using_shakapacker_const? require "shakapacker" return ::Shakapacker end @@ -85,8 +85,8 @@ def self.bundle_js_uri_from_packer(bundle_name) end def self.precompile? - return ::Webpacker.config.webpacker_precompile? if using_webpacker? - return ::Shakapacker.config.shakapacker_precompile? if using_shakapacker? + return ::Webpacker.config.webpacker_precompile? if using_webpacker_const? + return ::Shakapacker.config.shakapacker_precompile? if using_shakapacker_const? false end From b8c5d289a200c3189ab2753e2f3a381ed1de5c20 Mon Sep 17 00:00:00 2001 From: Judah Meek Date: Fri, 28 Jun 2024 03:54:18 -0500 Subject: [PATCH 81/81] linting --- lib/react_on_rails/packer_utils.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index bd217942d..20b0cfeec 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -7,18 +7,18 @@ def self.using_packer? end def self.using_shakapacker_const? - return @using_shakapacker if defined?(@using_shakapacker) + return @using_shakapacker_const if defined?(@using_shakapacker_const) - @using_shakapacker = ReactOnRails::Utils.gem_available?("shakapacker") && - shakapacker_version_requirement_met?([7, 0, 0]) + @using_shakapacker_const = ReactOnRails::Utils.gem_available?("shakapacker") && + shakapacker_version_requirement_met?([7, 0, 0]) end def self.using_webpacker_const? - return @using_webpacker if defined?(@using_webpacker) + return @using_webpacker_const if defined?(@using_webpacker_const) - @using_webpacker = (ReactOnRails::Utils.gem_available?("shakapacker") && + @using_webpacker_const = (ReactOnRails::Utils.gem_available?("shakapacker") && shakapacker_version_as_array[0] <= 6) || - ReactOnRails::Utils.gem_available?("webpacker") + ReactOnRails::Utils.gem_available?("webpacker") end def self.packer_type