webpacker-pnpm 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitattributes +0 -0
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/ci.yaml +50 -0
- data/.gitignore +5 -2
- data/.rubocop.yml +24 -91
- data/CHANGELOG.md +69 -45
- data/Gemfile +8 -17
- data/LICENSE +29 -0
- data/README.md +33 -35
- data/Rakefile +11 -11
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/gemfiles/Gemfile-rails.5.2.x +0 -0
- data/gemfiles/Gemfile-rails.6.0.x +0 -0
- data/lib/webpacker/pnpm/patches.rb +61 -53
- data/lib/webpacker/pnpm/railtie.rb +33 -24
- data/lib/webpacker/pnpm/version.rb +9 -7
- data/lib/webpacker/pnpm.rb +5 -5
- data/lib/webpacker/tasks/check_pnpm.rake +42 -27
- data/lib/webpacker/tasks/env.rake +22 -20
- data/lib/webpacker/tasks/pnpm_install.rake +14 -14
- data/test/rake_tasks_test.rb +97 -106
- data/test/test_app/.gitignore +6 -6
- data/test/test_app/Rakefile +5 -5
- data/test/test_app/app/javascript/packs/application.js +10 -10
- data/test/test_app/app/javascript/packs/multi_entry.css +3 -3
- data/test/test_app/app/javascript/packs/multi_entry.js +4 -4
- data/test/test_app/bin/rails +4 -6
- data/test/test_app/bin/rake +4 -6
- data/test/test_app/bin/setup +25 -27
- data/test/test_app/bin/webpack +15 -14
- data/test/test_app/bin/webpack-dev-server +15 -14
- data/test/test_app/config/application.rb +13 -13
- data/test/test_app/config/boot.rb +5 -0
- data/test/test_app/config/environment.rb +6 -6
- data/test/test_app/config/webpack/development.js +0 -0
- data/test/test_app/config/webpack/environment.js +0 -0
- data/test/test_app/config/webpacker.yml +0 -0
- data/test/test_app/config/webpacker_public_root.yml +19 -19
- data/test/test_app/config.ru +7 -7
- data/test/test_app/package.json +0 -0
- data/test/test_app/pnpm-lock.yaml +0 -0
- data/test/test_app/public/packs/manifest.json +31 -31
- data/test/test_helper.rb +61 -64
- data/webpacker-pnpm.gemspec +44 -36
- metadata +72 -42
- data/.travis.yml +0 -45
- data/gemfiles/Gemfile-rails-edge +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e158c9136e7684be56fce973c9272ec8ab16ff20d6c08c5949e0c9f13f2c0e3
|
4
|
+
data.tar.gz: bf02dcac8a0165359548569f6fd73c44decd31a9cd05393d35ae0a81377f7bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '058a4834ac5ff8dd02fdc5dfab8253888500c06d0420dfe1643dab0cfc1cb7e50c3157556c34eb8b71b720f5a97e55b2f712be2f0d1d5a7125924024d0ebe885'
|
7
|
+
data.tar.gz: 6ced6827e35f59e42f1f979dbadddb54d2eb54f039c7aff2fc25a0de2b0450c7149fe39c6f7a98abc224fb54245d001443280982f82020e163a00bc362cc0e49
|
data/.gitattributes
CHANGED
File without changes
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.4', '2.5', '2.6', '2.7' ]
|
11
|
+
gemfile: [ '5.2.x', '6.0.x' ]
|
12
|
+
exclude:
|
13
|
+
- ruby: '2.4'
|
14
|
+
gemfile: '6.0.x'
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
env:
|
17
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/Gemfile-rails.${{ matrix.gemfile }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v3
|
20
|
+
- name: Setup Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
- name: Setup Node
|
26
|
+
uses: actions/setup-node@v3
|
27
|
+
with:
|
28
|
+
node-version: 14
|
29
|
+
- name: Setup pnpm
|
30
|
+
uses: pnpm/action-setup@v2
|
31
|
+
id: pnpm-install
|
32
|
+
with:
|
33
|
+
version: 7
|
34
|
+
run_install: false
|
35
|
+
- name: Define pnpm cache
|
36
|
+
id: pnpm-cache
|
37
|
+
shell: bash
|
38
|
+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
39
|
+
- uses: actions/cache@v3
|
40
|
+
with:
|
41
|
+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
42
|
+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
43
|
+
restore-keys: |
|
44
|
+
${{ runner.os }}-pnpm-store-
|
45
|
+
- run: pnpm install --frozen-lockfile
|
46
|
+
working-directory: ./test/test_app
|
47
|
+
- name: Check formatting and syntax
|
48
|
+
run: bundle exec rubocop
|
49
|
+
- name: Run tests
|
50
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,91 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
# if you're specifying access modifiers, it is likely intentional. force RuboCop
|
26
|
-
# to trust your decision making.
|
27
|
-
Lint/UselessAccessModifier:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
# flag potential memory leaks, like when opening a file.
|
31
|
-
Style/AutoResourceCleanup:
|
32
|
-
Enabled: true
|
33
|
-
|
34
|
-
# single quotes are meant for single characters. double quotes are meant for
|
35
|
-
# strings, which are arrays of multiple characters. there are a whole host of
|
36
|
-
# other differences and functions; if you're creating a string, you nearly always
|
37
|
-
# should use double quotes.
|
38
|
-
#
|
39
|
-
# https://en.wikipedia.org/wiki/Delimiter#Bracket_delimiters
|
40
|
-
# Schwartz, Randal (2005). Learning Perl. ISBN 978-0-596-10105-3.
|
41
|
-
Style/StringLiterals:
|
42
|
-
Enabled: true
|
43
|
-
EnforcedStyle: double_quotes
|
44
|
-
|
45
|
-
# flags methods that violate the default ABC magnitude (15). The ABC metric
|
46
|
-
# quantizes the size of a method, and is calculated based on the number of
|
47
|
-
# assignment operations, possible execution branches, and number of conditionals.
|
48
|
-
#
|
49
|
-
# https://en.wikipedia.org/wiki/ABC_Software_Metric
|
50
|
-
Metrics/AbcSize:
|
51
|
-
Enabled: true
|
52
|
-
IgnoredMethods:
|
53
|
-
- test_rake_tasks
|
54
|
-
- chdir_concurrent
|
55
|
-
|
56
|
-
# this simply doesn't work in a cross-platform development environment. Bit
|
57
|
-
# flags across UNIX and Windows platforms are volatile, and thus there is no
|
58
|
-
# way to ensure this passes besides explicitly granting execute permissions
|
59
|
-
# in CI config (which would defeat the purpose).
|
60
|
-
Lint/ScriptPermission:
|
61
|
-
Enabled: false
|
62
|
-
|
63
|
-
Layout/SpaceAroundMethodCallOperator:
|
64
|
-
Enabled: true
|
65
|
-
|
66
|
-
Lint/RaiseException:
|
67
|
-
Enabled: true
|
68
|
-
|
69
|
-
Lint/StructNewOverride:
|
70
|
-
Enabled: true
|
71
|
-
|
72
|
-
Style/ExponentialNotation:
|
73
|
-
Enabled: true
|
74
|
-
|
75
|
-
Style/HashEachMethods:
|
76
|
-
Enabled: true
|
77
|
-
|
78
|
-
Style/HashTransformKeys:
|
79
|
-
Enabled: true
|
80
|
-
|
81
|
-
Style/HashTransformValues:
|
82
|
-
Enabled: true
|
83
|
-
|
84
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
85
|
-
Enabled: true
|
86
|
-
|
87
|
-
Style/SlicingWithRange:
|
88
|
-
Enabled: true
|
89
|
-
|
90
|
-
Style/RescueModifier:
|
91
|
-
Enabled: false
|
1
|
+
#
|
2
|
+
# RuboCop is a Ruby static code analyzer and code formatter that tries to enforce many
|
3
|
+
# of the guidelines outlined in the community Ruby and Rails style guides.
|
4
|
+
#
|
5
|
+
# https://docs.rubocop.org/en/latest/
|
6
|
+
# https://rubystyle.guide/
|
7
|
+
# https://rails.rubystyle.guide/
|
8
|
+
inherit_gem:
|
9
|
+
practical-pig: rubocop-base.yaml
|
10
|
+
inherit_mode:
|
11
|
+
merge:
|
12
|
+
- Include
|
13
|
+
- Exclude
|
14
|
+
- IgnoredMethods
|
15
|
+
- AllowedMethods
|
16
|
+
|
17
|
+
# cop-specific excludes are not inherited for some reason (likely a bug in RuboCop) so
|
18
|
+
# we need to manually re-omit the intended files and directories.
|
19
|
+
Layout/LineLength:
|
20
|
+
Exclude:
|
21
|
+
- "**/config/initializers/**/*"
|
22
|
+
Style/MethodCallWithArgsParentheses:
|
23
|
+
Exclude:
|
24
|
+
- "**/Gemfile"
|
data/CHANGELOG.md
CHANGED
@@ -1,45 +1,69 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file.
|
4
|
-
|
5
|
-
The format is based on Keep a Changelog (<https://keepachangelog.com/en/1.0.0/>). This project adheres to Semantic Versioning (<https://semver.org/spec/v2.0.0.html>).
|
6
|
-
|
7
|
-
## [v1.2.
|
8
|
-
|
9
|
-
###
|
10
|
-
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
-
|
19
|
-
-
|
20
|
-
-
|
21
|
-
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
- Rake
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
###
|
41
|
-
|
42
|
-
- Gem
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on Keep a Changelog (<https://keepachangelog.com/en/1.0.0/>). This project adheres to Semantic Versioning (<https://semver.org/spec/v2.0.0.html>).
|
6
|
+
|
7
|
+
## [v1.2.2] - 2023-01-13
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- Watched paths for cross-version compatibility. (credit: [HipsterBrown](https://github.com/thearchitector/webpacker-pnpm/pull/4))
|
12
|
+
|
13
|
+
## [v1.2.1] - 2020-05-16
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- Informative error messages when pnpm is not installed.
|
18
|
+
- Pessimistic gem dependency version specifications to avoid installation conflicts.
|
19
|
+
- Full-length gem description.
|
20
|
+
- Forced shameful hoisting of installed pnpm dependencies via `webpacker:pnpm_install`.
|
21
|
+
- Practical Pig development dependency for external RuboCop linting.
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Commented and adjusted RuboCop formatting rules to clarify design decisions.
|
26
|
+
|
27
|
+
### Removed
|
28
|
+
|
29
|
+
- Testing configs for bleeding-edge Rails.
|
30
|
+
|
31
|
+
## [v1.2.0] - 2020-05-14
|
32
|
+
|
33
|
+
### Added
|
34
|
+
|
35
|
+
- Compatibility with Rails' Template API via command execution hooks and keyword substitution.
|
36
|
+
- Support for existing Yarn Rake task dependence through task aliasing and redirection.
|
37
|
+
- Additional Rake tasks to test injection and interception logic.
|
38
|
+
- Utility method for concurrent and scoped `chdir` calls.
|
39
|
+
|
40
|
+
### Changed
|
41
|
+
|
42
|
+
- Gem dependencies to reflect up-to-date versions.
|
43
|
+
- RuboCop formatting rules to support latest versions of Ruby.
|
44
|
+
- Test application structure to allow application booting.
|
45
|
+
- Rake task tests to utilize concurrent `chdir` calls.
|
46
|
+
- Tests to support Rails <6.x `[bugfix]`.
|
47
|
+
- Tests to support Ruby 2.4.9 `[bugfix]`.
|
48
|
+
|
49
|
+
### Removed
|
50
|
+
|
51
|
+
- Webpacker git submodule as method for replacing default Rails' rake tasks.
|
52
|
+
- Dependence on a specific version of Webpacker.
|
53
|
+
|
54
|
+
## [v1.1.0] - 2020-04-19
|
55
|
+
|
56
|
+
### Changed
|
57
|
+
|
58
|
+
- RuboCop formatting rules to more align with Rails' style guide.
|
59
|
+
- TypeScript installation tasks based on Webpacker v5.1.0.
|
60
|
+
- Rake tasks to extend ActiveSupport and utilize concurrent threading.
|
61
|
+
|
62
|
+
## [v1.0.0] - 2020-04-17
|
63
|
+
|
64
|
+
### Added
|
65
|
+
|
66
|
+
- Gem specifications and foundational files, generated by Bundler v2.0.2, for defining a Ruby gem.
|
67
|
+
- Hook into Rails' engine loader for conditional task loading.
|
68
|
+
- Tasks replacing Yarn with pnpm for Webpacker v5.0.1, included as a submodule.
|
69
|
+
- Test suite with dummy application.
|
data/Gemfile
CHANGED
@@ -1,17 +1,8 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
|
7
|
-
gem "
|
8
|
-
|
9
|
-
gem "semantic_range", require: false
|
10
|
-
|
11
|
-
install_if -> { Gem.win_platform? } do
|
12
|
-
gem "tzinfo-data"
|
13
|
-
end
|
14
|
-
|
15
|
-
group :test do
|
16
|
-
gem "minitest", ">= 5"
|
17
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
install_if -> { Gem.win_platform? } do
|
7
|
+
gem "tzinfo-data"
|
8
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
BSD 3-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2023, Elias Gabriel
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
17
|
+
contributors may be used to endorse or promote products derived from
|
18
|
+
this software without specific prior written permission.
|
19
|
+
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,35 +1,33 @@
|
|
1
|
-
# webpacker-pnpm
|
2
|
-
|
3
|
-

|
4
|
-
[
|
6
|
-
[](https://rubygems.org/gems/webpacker-pnpm)
|
4
|
+
[](https://travis-ci.org/github/thearchitector/webpacker-pnpm)
|
5
|
+
[](https://rubygems.org/gems/webpacker-pnpm)
|
6
|
+
[](LICENSE)
|
7
|
+
[](https://ecologi.com/eliasgabriel?r=6128126916bfab8bd051026c)
|
8
|
+
|
9
|
+
`webpacker-pnpm` replaces Rails' Yarn environment with [pnpm](https://pnpm.io), a better, smarter, and more efficient Node.js package manager. As a result, applications become less prone to dependency hell, more functional, more stable, and more flexible. And as an added bonus, dependency resolution times and `node_modules` folder sizes reduce to within reasonable ranges (not 45 seconds and 10 GiB).
|
10
|
+
|
11
|
+
You can read about the philosophy and technology behind `pnpm` in [this convincing blog post](https://www.kochan.io/nodejs/why-should-we-use-pnpm) by Zoltan Kochan (<https://www.kochan.io/nodejs/why-should-we-use-pnpm>).
|
12
|
+
|
13
|
+
## Features
|
14
|
+
|
15
|
+
- Production-ready
|
16
|
+
- Drop-in seamless replacement for Yarn, no config required
|
17
|
+
- Supports Rails' Template API, including existing templates using Yarn
|
18
|
+
- Provides code sanity without the migraines
|
19
|
+
- Gives you more disk space
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
In order to use `webpacker-pnpm`, you must install `pnpm`. The official instructions are [here](https://pnpm.io/installation). After installing `pnpm`, simply add `webpacker-pnpm` to your app's `Gemfile`.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem "webpacker-pnpm"
|
27
|
+
```
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
This software is licensed under the [BSD 3-Clause License](LICENSE).
|
32
|
+
|
33
|
+
This package is Treeware. If you use it in production, consider buying the world a tree to thank me for my work. By contributing to my forest, you’ll be creating employment for local families and restoring wildlife habitats.
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
require "rake/testtask"
|
5
|
-
|
6
|
-
Rake::TestTask.new do |t|
|
7
|
-
t.libs << "test"
|
8
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
9
|
-
end
|
10
|
-
|
11
|
-
task
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
9
|
+
end
|
10
|
+
|
11
|
+
task(default: :test)
|
data/bin/console
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "webpacker/pnpm"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "webpacker/pnpm"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
File without changes
|
File without changes
|
@@ -1,53 +1,61 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rails/generators"
|
4
|
-
require "webpacker/runner"
|
5
|
-
require "webpacker/compiler"
|
6
|
-
|
7
|
-
module Webpacker
|
8
|
-
module PNPM
|
9
|
-
# remove Yarn's lockfile from and add pnpm's lockfile to the default list of
|
10
|
-
# watched paths
|
11
|
-
Webpacker::Compiler.class_eval do
|
12
|
-
def default_watched_paths
|
13
|
-
[
|
14
|
-
*
|
15
|
-
config.source_path_globbed,
|
16
|
-
"pnpm-lock.yaml", "package.json",
|
17
|
-
"config/webpack/**/*"
|
18
|
-
].freeze
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
require "webpacker/runner"
|
5
|
+
require "webpacker/compiler"
|
6
|
+
|
7
|
+
module Webpacker
|
8
|
+
module PNPM
|
9
|
+
# remove Yarn's lockfile from and add pnpm's lockfile to the default list of
|
10
|
+
# watched paths
|
11
|
+
Webpacker::Compiler.class_eval do
|
12
|
+
def default_watched_paths
|
13
|
+
[
|
14
|
+
*configured_paths,
|
15
|
+
config.source_path_globbed,
|
16
|
+
"pnpm-lock.yaml", "package.json",
|
17
|
+
"config/webpack/**/*"
|
18
|
+
].freeze
|
19
|
+
end
|
20
|
+
|
21
|
+
def configured_paths
|
22
|
+
if config.method_defined?(:additional_paths_globbed)
|
23
|
+
config.additional_paths_globbed
|
24
|
+
else
|
25
|
+
config.resolved_paths_globbed
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# intercept command execution via Thor to replace yarn with pnpm. this exists in
|
31
|
+
# order to patch existing Webpacker installation templates that make direct
|
32
|
+
# calls to install Yarn dependencies. as a result, this isn't a robust patch
|
33
|
+
Rails::Generators::Actions.module_eval do
|
34
|
+
def run(command, config = {})
|
35
|
+
cmd = command.to_s
|
36
|
+
|
37
|
+
if cmd.include?("yarn")
|
38
|
+
cmd.gsub!("yarn", "pnpm")
|
39
|
+
cmd.gsub!("--dev", "--save-dev")
|
40
|
+
end
|
41
|
+
|
42
|
+
super(cmd, config)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# intercept generic task loading to clear and alias Yarn tasks
|
47
|
+
Rails::Engine.class_eval do
|
48
|
+
alias_method :unfiltered_tasks, :load_tasks
|
49
|
+
|
50
|
+
def load_tasks(_app = self)
|
51
|
+
unfiltered_tasks
|
52
|
+
# rather than clear the tasks, alias them to the new pnpm tasks so
|
53
|
+
# that any external code will still run
|
54
|
+
Rake::Task["webpacker:check_yarn"].clear.enhance(["webpacker:check_pnpm"])
|
55
|
+
Rake::Task["webpacker:yarn_install"].clear.enhance(["webpacker:pnpm_install"])
|
56
|
+
Rake::Task["webpacker:info"].clear.enhance(["webpacker:env"])
|
57
|
+
Rake::Task["yarn:install"].clear.enhance(["webpacker:pnpm_install"])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|