Skip to content

Commit

Permalink
added support for shakapacker 8+ (#1629)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaukalak authored Jun 11, 2024
1 parent 9c262c1 commit ca21dbd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
### [Unreleased]
Changes since the last non-beta release.

### [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)

### [14.0.1] - 2024-05-16

#### Fixed
Expand Down Expand Up @@ -1128,7 +1133,8 @@ Best done with Object destructing:
##### Fixed
- Fix several generator-related issues.

[Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.1...master
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.2...master
[14.0.2]: https://github.com/shakacode/react_on_rails/compare/14.0.1...14.0.2
[14.0.1]: https://github.com/shakacode/react_on_rails/compare/14.0.0...14.0.1
[14.0.0]: https://github.com/shakacode/react_on_rails/compare/13.4.0...14.0.0
[13.4.0]: https://github.com/shakacode/react_on_rails/compare/13.3.5...13.4.0
Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ You need a Rails application with Shakapacker installed and configured on it. Ch
rails new PROJECT_NAME --skip-javascript
cd PROJECT_NAME
bundle add shakapacker --strict
rails shakapacker:install
# currently react_on_rails uses yarn classic by default
PACKAGE_JSON_FALLBACK_MANAGER=yarn_classic rails shakapacker:install
```

You may need to check [the instructions for installing into an existing Rails app](https://www.shakacode.com/react-on-rails/docs/guides/installation-into-an-existing-rails-app/) if you have an already working Rails application.
Expand Down
3 changes: 1 addition & 2 deletions lib/generators/react_on_rails/base_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]

This comment has been minimized.

Copy link
@justin808

justin808 Jun 23, 2024

Member

@vaukalak why was this file ever removed?

app/javascript/bundles/HelloWorld/components/HelloWorldServer.js]
base_files.each { |file| copy_file("#{base_path}#{file}", file) }
end

Expand Down
8 changes: 4 additions & 4 deletions lib/generators/react_on_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -95,17 +95,17 @@ 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

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
Expand Down

0 comments on commit ca21dbd

Please sign in to comment.