Skip to content

Commit c281479

Browse files
committed
fixed shakapacker detection during the installation generator work
1 parent 4c9bb28 commit c281479

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
react_on_rails (14.0.0)
4+
react_on_rails (14.0.2)
55
addressable
66
connection_pool
77
execjs (~> 2.5)
@@ -119,6 +119,9 @@ GEM
119119
tins (~> 1.6)
120120
crass (1.0.6)
121121
date (3.3.4)
122+
debug (1.9.2)
123+
irb (~> 1.10)
124+
reline (>= 0.3.8)
122125
diff-lcs (1.5.1)
123126
docile (1.4.0)
124127
drb (2.2.1)
@@ -397,6 +400,7 @@ DEPENDENCIES
397400
capybara
398401
capybara-screenshot
399402
coveralls
403+
debug
400404
equivalent-xml
401405
gem-release
402406
generator_spec

lib/generators/react_on_rails/base_generator.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,28 @@ def add_yarn_dependencies
8888

8989
puts "Adding React dependencies"
9090
package_json.manager.add([
91-
"react",
92-
"react-dom",
93-
"@babel/preset-react",
94-
"prop-types",
95-
"babel-plugin-transform-react-remove-prop-types",
96-
"babel-plugin-macros"
97-
])
91+
"react",
92+
"react-dom",
93+
"@babel/preset-react",
94+
"prop-types",
95+
"babel-plugin-transform-react-remove-prop-types",
96+
"babel-plugin-macros"
97+
])
9898

9999
puts "Adding CSS handlers"
100100

101-
package_json.manager.add([
102-
"css-loader",
103-
"css-minimizer-webpack-plugin",
104-
"mini-css-extract-plugin",
105-
"style-loader"
106-
])
101+
package_json.manager.add(%w[
102+
css-loader
103+
css-minimizer-webpack-plugin
104+
mini-css-extract-plugin
105+
style-loader
106+
])
107107

108108
puts "Adding dev dependencies"
109109
package_json.manager.add([
110-
"@pmmmwh/react-refresh-webpack-plugin",
111-
"react-refresh"
112-
], type: :dev)
110+
"@pmmmwh/react-refresh-webpack-plugin",
111+
"react-refresh"
112+
], type: :dev)
113113
end
114114

115115
def append_to_spec_rails_helper

lib/generators/react_on_rails/generator_helper.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
# frozen_string_literal: true
22

3+
require "package_json"
34
require "rainbow"
45

56
module GeneratorHelper
6-
def require_package_json_gem
7-
require "bundler/inline"
8-
9-
gemfile { gem "package_json", github: "G-Rath/package_json" }
10-
11-
puts "using package_json v#{PackageJson::VERSION}"
12-
end
13-
147
def package_json
15-
if @package_json.nil?
16-
require_package_json_gem
17-
18-
@package_json = PackageJson.read(@app_path)
19-
end
20-
21-
@package_json
8+
@package_json ||= PackageJson.read(Rails.root.to_s)
229
end
2310

2411
# Takes a relative path from the destination root, such as `.gitignore` or `app/assets/javascripts/application.js`

0 commit comments

Comments
 (0)