From 74d38efe79e81bda5f4327e4b042bbc3ebc82cb3 Mon Sep 17 00:00:00 2001 From: Mikhail Boutylin Date: Tue, 11 Jun 2024 10:48:54 +0400 Subject: [PATCH] added support for sp 8+, removed css files from base example --- lib/generators/react_on_rails/base_generator.rb | 3 +-- lib/generators/react_on_rails/install_generator.rb | 8 ++++---- .../bundles/HelloWorld/components/HelloWorld.jsx | 3 +-- .../bundles/HelloWorld/components/HelloWorld.module.css | 4 ---- .../bundles/HelloWorld/components/HelloWorld.jsx | 3 +-- spec/dummy/client/app/components/HelloWorld.module.scss | 3 --- 6 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css delete mode 100644 spec/dummy/client/app/components/HelloWorld.module.scss diff --git a/lib/generators/react_on_rails/base_generator.rb b/lib/generators/react_on_rails/base_generator.rb index 08f76b53f..14148dfc9 100644 --- a/lib/generators/react_on_rails/base_generator.rb +++ b/lib/generators/react_on_rails/base_generator.rb @@ -40,8 +40,7 @@ def copy_base_files def copy_js_bundle_files base_path = "base/base/" base_files = %w[app/javascript/packs/server-bundle.js - app/javascript/bundles/HelloWorld/components/HelloWorldServer.js - app/javascript/bundles/HelloWorld/components/HelloWorld.module.css] + app/javascript/bundles/HelloWorld/components/HelloWorldServer.js] base_files.each { |file| copy_file("#{base_path}#{file}", file) } end diff --git a/lib/generators/react_on_rails/install_generator.rb b/lib/generators/react_on_rails/install_generator.rb index a3d7c36f2..651af8d04 100644 --- a/lib/generators/react_on_rails/install_generator.rb +++ b/lib/generators/react_on_rails/install_generator.rb @@ -54,7 +54,7 @@ def invoke_generators invoke "react_on_rails:react_no_redux" end - invoke "react_on_rails:adapt_for_older_shakapacker" unless using_shakapacker_7? + 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,7 +95,7 @@ def add_bin_scripts def add_post_install_message message = GeneratorMessages.helpful_message_after_installation - unless using_shakapacker_7? + unless using_shakapacker_7_or_above? message = message.gsub("config/shakapacker", "config/webpacker") message = message.gsub("bin/shakapacker", "bin/webpacker") end @@ -103,9 +103,9 @@ def add_post_install_message GeneratorMessages.add_info(message) end - def using_shakapacker_7? + def using_shakapacker_7_or_above? shakapacker_gem = Gem::Specification.find_by_name("shakapacker") - shakapacker_gem.version.segments.first == 7 + shakapacker_gem.version.segments.first >= 7 rescue Gem::MissingSpecError # In case using Webpacker false diff --git a/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx b/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx index 70cff370f..e6e19dfe4 100644 --- a/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +++ b/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx @@ -1,6 +1,5 @@ import PropTypes from 'prop-types'; import React, { useState } from 'react'; -import style from './HelloWorld.module.css'; const HelloWorld = (props) => { const [name, setName] = useState(props.name); @@ -10,7 +9,7 @@ const HelloWorld = (props) => {

Hello, {name}!


-