Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4aa7fb1

Browse files
Merge pull request #1306 from G-Rath/use-package_json
feat: support other js package managers
2 parents 7f124c7 + d29a7a4 commit 4aa7fb1

File tree

13 files changed

+89
-25
lines changed

13 files changed

+89
-25
lines changed

‎.github/workflows/ruby.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
matrix:
2121
ruby: [2.7]
2222
runs-on: ubuntu-latest
23+
env:
24+
PACKAGE_JSON_FALLBACK_MANAGER: yarn_classic
2325
steps:
2426
- uses: actions/checkout@v4
2527
with:
@@ -56,6 +58,15 @@ jobs:
5658
strategy:
5759
fail-fast: false
5860
matrix:
61+
js_package_manager:
62+
- name: npm
63+
installer: npm
64+
- name: yarn_classic
65+
installer: yarn
66+
- name: pnpm
67+
installer: pnpm
68+
- name: bun
69+
installer: bun
5970
ruby: [2.7]
6071
gemfile:
6172
# These have shakapacker:
@@ -71,12 +82,14 @@ jobs:
7182
# Workaround b/c upgrading Minitest broke some mocking expectations
7283
# having to do with automatic kwarg splatting
7384
MT_KWARGS_HACK: 1
85+
PACKAGE_JSON_FALLBACK_MANAGER: ${{ matrix.js_package_manager.name }}
86+
SHAKAPACKER_USE_PACKAGE_JSON_GEM: true
7487
steps:
7588
- uses: actions/checkout@v4
7689
with:
7790
persist-credentials: false
7891
- uses: actions/setup-node@v3
79-
- run: npm -g install yalc
92+
- run: npm -g install yalc ${{ matrix.js_package_manager.installer }}
8093
- run: yalc publish
8194
- name: Save root node_modules to cache
8295
uses: actions/cache@v3
@@ -92,14 +105,15 @@ jobs:
92105
with:
93106
bundler: 2.4.9
94107
ruby-version: ${{ matrix.ruby }}
108+
- run: ./test/bin/create-fake-js-package-managers ${{ matrix.js_package_manager.installer }}
95109
- name: Save dummy app ruby gems to cache
96110
uses: actions/cache@v3
97111
with:
98112
path: test/dummy/vendor/bundle
99113
key: dummy-app-gem-cache-${{ hashFiles('${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile.lock') }}
100114
- name: Install Ruby Gems for dummy app
101115
run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=test/dummy/vendor/bundle || bundle _2.4.9_ install --frozen --path=test/dummy/vendor/bundle --jobs=4 --retry=3
102-
- run: cd test/dummy && yalc add react_ujs && yarn
116+
- run: cd test/dummy && yalc add react_ujs && ${{ matrix.js_package_manager.installer }} install
103117
- run: bundle exec rake test
104118
env:
105119
NODE_OPTIONS: --openssl-legacy-provider

‎Appraisals

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end
1616

1717
appraise 'shakapacker' do
1818
gem 'rails', '~> 7.0.x'
19-
gem 'shakapacker', '7.0.2'
19+
gem 'shakapacker', '7.2.0'
2020
end
2121

2222
appraise 'base' do

‎CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ _Please add entries here for your pull requests that are not yet released._
1111

1212
#### Changed
1313
- Make es6 and ts usable at same time. #1299
14+
- Support other JS package managers using `package_json` gem #1306
1415

1516
## [3.1.1] - 2023年08月16日
1617

‎Gemfile.lock

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,16 @@ GEM
102102
matrix (0.4.2)
103103
method_source (1.0.0)
104104
mini_mime (1.0.2)
105-
mini_portile2 (2.8.4)
106105
minitest (5.17.0)
107106
nenv (0.3.0)
108-
nokogiri (1.14.3)
109-
mini_portile2 (~> 2.8.0)
110-
racc (~> 1.4)
111107
nokogiri (1.14.3-x86_64-darwin)
112108
racc (~> 1.4)
113109
nokogiri (1.14.3-x86_64-linux)
114110
racc (~> 1.4)
115111
notiffany (0.1.3)
116112
nenv (~> 0.1)
117113
shellany (~> 0.0)
114+
package_json (0.1.0)
118115
pry (0.14.2)
119116
coderay (~> 1.1)
120117
method_source (~> 1.0)
@@ -166,7 +163,6 @@ GEM
166163
zeitwerk (2.6.6)
167164

168165
PLATFORMS
169-
ruby
170166
x86_64-darwin-20
171167
x86_64-linux
172168

@@ -182,6 +178,7 @@ DEPENDENCIES
182178
guard-minitest
183179
jbuilder
184180
listen (~> 3.0.0)
181+
package_json
185182
pry-byebug
186183
react-rails!
187184
selenium-webdriver

‎Rakefile

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,26 @@ end
88

99
Bundler::GemHelper.install_tasks
1010

11+
require "package_json"
12+
1113
def copy_react_asset(webpack_file, destination_file)
1214
full_webpack_path = File.expand_path("../react-builds/build/#{webpack_file}", __FILE__)
1315
full_destination_path = File.expand_path("../lib/assets/react-source/#{destination_file}", __FILE__)
1416
FileUtils.cp(full_webpack_path, full_destination_path)
1517
end
1618

17-
# Move to `dirname` and execute `yarn {cmd}`
18-
def yarn_run_in(dirname, cmd)
19-
Dir.chdir(dirname) do
20-
`yarn #{cmd}`
21-
end
22-
end
23-
2419
namespace :react do
2520
desc "Run the JS build process to put files in the gem source"
2621
task update: %i[install build copy]
2722

2823
desc "Install the JavaScript dependencies"
2924
task :install do
30-
yarn_run_in("react-builds","install")
25+
PackageJson.read("react-builds").manager.install
3126
end
3227

3328
desc "Build the JS bundles with Webpack"
3429
task :build do
35-
yarn_run_in("react-builds","build")
30+
PackageJson.read("react-builds").manager.run("build")
3631
end
3732

3833
desc "Copy browser-ready JS files to the gem's asset paths"
@@ -51,12 +46,12 @@ namespace :ujs do
5146

5247
desc "Install the JavaScript dependencies"
5348
task :install do
54-
`yarn install`
49+
PackageJson.read.manager.install
5550
end
5651

5752
desc "Build the JS bundles with Webpack"
5853
task :build do
59-
`yarn build`
54+
PackageJson.read.manager.run("build")
6055
end
6156

6257
desc "Copy browser-ready JS files to the gem's asset paths"
@@ -87,7 +82,7 @@ task default: :test
8782

8883
task :test_setup do
8984
Dir.chdir("./test/dummy") do
90-
`yarn install`
85+
PackageJson.read.manager.install
9186
end
9287
end
9388

‎gemfiles/base.gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ GEM
174174
notiffany (0.1.3)
175175
nenv (~> 0.1)
176176
shellany (~> 0.0)
177+
package_json (0.1.0)
177178
pry (0.14.2)
178179
coderay (~> 1.1)
179180
method_source (~> 1.0)
@@ -258,6 +259,7 @@ DEPENDENCIES
258259
guard-minitest
259260
jbuilder
260261
listen (~> 3.0.0)
262+
package_json
261263
pry-byebug
262264
rails (~> 7.0.x)
263265
react-rails!

‎gemfiles/shakapacker.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
source "http://rubygems.org"
44

55
gem "rails", "~> 7.0.x"
6-
gem "shakapacker", "7.0.2"
6+
gem "shakapacker", "7.2.0"
77

88
gemspec path: "../"

‎gemfiles/shakapacker.gemfile.lock

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ GEM
176176
notiffany (0.1.3)
177177
nenv (~> 0.1)
178178
shellany (~> 0.0)
179+
package_json (0.1.0)
179180
pry (0.14.2)
180181
coderay (~> 1.1)
181182
method_source (~> 1.0)
@@ -185,7 +186,7 @@ GEM
185186
public_suffix (5.0.1)
186187
racc (1.6.2)
187188
rack (2.2.7)
188-
rack-proxy (0.7.6)
189+
rack-proxy (0.7.7)
189190
rack
190191
rack-test (2.1.0)
191192
rack (>= 1.3)
@@ -227,8 +228,9 @@ GEM
227228
rubyzip (>= 1.2.2, < 3.0)
228229
websocket (~> 1.0)
229230
semantic_range (3.0.0)
230-
shakapacker (7.0.2)
231+
shakapacker (7.2.0)
231232
activesupport (>= 5.2)
233+
package_json
232234
rack-proxy (>= 0.6.1)
233235
railties (>= 5.2)
234236
semantic_range (>= 2.3.0)
@@ -268,11 +270,12 @@ DEPENDENCIES
268270
guard-minitest
269271
jbuilder
270272
listen (~> 3.0.0)
273+
package_json
271274
pry-byebug
272275
rails (~> 7.0.x)
273276
react-rails!
274277
selenium-webdriver
275-
shakapacker (= 7.0.2)
278+
shakapacker (= 7.2.0)
276279
test-unit (~> 2.5)
277280

278281
BUNDLED WITH

‎gemfiles/sprockets_3.gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ GEM
178178
notiffany (0.1.3)
179179
nenv (~> 0.1)
180180
shellany (~> 0.0)
181+
package_json (0.1.0)
181182
pry (0.12.2)
182183
coderay (~> 1.1.0)
183184
method_source (~> 0.9.0)
@@ -270,6 +271,7 @@ DEPENDENCIES
270271
jbuilder
271272
listen (~> 3.0.0)
272273
mini_racer
274+
package_json
273275
pry-byebug
274276
rails (~> 7.0.x)
275277
react-rails!

‎gemfiles/sprockets_4.gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ GEM
178178
notiffany (0.1.3)
179179
nenv (~> 0.1)
180180
shellany (~> 0.0)
181+
package_json (0.1.0)
181182
pry (0.12.2)
182183
coderay (~> 1.1.0)
183184
method_source (~> 0.9.0)
@@ -270,6 +271,7 @@ DEPENDENCIES
270271
jbuilder
271272
listen (~> 3.0.0)
272273
mini_racer
274+
package_json
273275
pry-byebug
274276
rails (~> 7.0.x)
275277
react-rails!

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /