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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +0 -0
  3. data/.github/FUNDING.yml +3 -0
  4. data/.github/workflows/ci.yaml +50 -0
  5. data/.gitignore +5 -2
  6. data/.rubocop.yml +24 -91
  7. data/CHANGELOG.md +69 -45
  8. data/Gemfile +8 -17
  9. data/LICENSE +29 -0
  10. data/README.md +33 -35
  11. data/Rakefile +11 -11
  12. data/bin/console +15 -15
  13. data/bin/setup +8 -8
  14. data/gemfiles/Gemfile-rails.5.2.x +0 -0
  15. data/gemfiles/Gemfile-rails.6.0.x +0 -0
  16. data/lib/webpacker/pnpm/patches.rb +61 -53
  17. data/lib/webpacker/pnpm/railtie.rb +33 -24
  18. data/lib/webpacker/pnpm/version.rb +9 -7
  19. data/lib/webpacker/pnpm.rb +5 -5
  20. data/lib/webpacker/tasks/check_pnpm.rake +42 -27
  21. data/lib/webpacker/tasks/env.rake +22 -20
  22. data/lib/webpacker/tasks/pnpm_install.rake +14 -14
  23. data/test/rake_tasks_test.rb +97 -106
  24. data/test/test_app/.gitignore +6 -6
  25. data/test/test_app/Rakefile +5 -5
  26. data/test/test_app/app/javascript/packs/application.js +10 -10
  27. data/test/test_app/app/javascript/packs/multi_entry.css +3 -3
  28. data/test/test_app/app/javascript/packs/multi_entry.js +4 -4
  29. data/test/test_app/bin/rails +4 -6
  30. data/test/test_app/bin/rake +4 -6
  31. data/test/test_app/bin/setup +25 -27
  32. data/test/test_app/bin/webpack +15 -14
  33. data/test/test_app/bin/webpack-dev-server +15 -14
  34. data/test/test_app/config/application.rb +13 -13
  35. data/test/test_app/config/boot.rb +5 -0
  36. data/test/test_app/config/environment.rb +6 -6
  37. data/test/test_app/config/webpack/development.js +0 -0
  38. data/test/test_app/config/webpack/environment.js +0 -0
  39. data/test/test_app/config/webpacker.yml +0 -0
  40. data/test/test_app/config/webpacker_public_root.yml +19 -19
  41. data/test/test_app/config.ru +7 -7
  42. data/test/test_app/package.json +0 -0
  43. data/test/test_app/pnpm-lock.yaml +0 -0
  44. data/test/test_app/public/packs/manifest.json +31 -31
  45. data/test/test_helper.rb +61 -64
  46. data/webpacker-pnpm.gemspec +44 -36
  47. metadata +72 -42
  48. data/.travis.yml +0 -45
  49. data/gemfiles/Gemfile-rails-edge +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e0c39889bfdad4a14a2fc35250e7eaa33fd49bf48ecc082c44d1985884fbe89
4
- data.tar.gz: 8f27fae2d742a2b4c27e0fa675480dda85771bfd120e283fa706c80ce7414fa5
3
+ metadata.gz: 5e158c9136e7684be56fce973c9272ec8ab16ff20d6c08c5949e0c9f13f2c0e3
4
+ data.tar.gz: bf02dcac8a0165359548569f6fd73c44decd31a9cd05393d35ae0a81377f7bdf
5
5
  SHA512:
6
- metadata.gz: 8715f49514245b10d8ed85169c5edadcb2ab8905880f9afdd273121835336c175dec087f05b639179024eeea4fc1745ca24c73d00c24fc92d06bbb85ab591d02
7
- data.tar.gz: fd7a0f6cc602c9a7d4ba0a2689fc87feae4d7f93c470c9c5fc8b7f62cfd364fd3152839448150a58c523a0e516aa229eed3d9d07cc1083ed0b4ecaeb9938a5b8
6
+ metadata.gz: '058a4834ac5ff8dd02fdc5dfab8253888500c06d0420dfe1643dab0cfc1cb7e50c3157556c34eb8b71b720f5a97e55b2f712be2f0d1d5a7125924024d0ebe885'
7
+ data.tar.gz: 6ced6827e35f59e42f1f979dbadddb54d2eb54f039c7aff2fc25a0de2b0450c7149fe39c6f7a98abc224fb54245d001443280982f82020e163a00bc362cc0e49
data/.gitattributes CHANGED
File without changes
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: thearchitector
@@ -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
@@ -1,3 +1,6 @@
1
1
  /tmp/
2
- /**/*.log
3
- Gemfile.lock
2
+ **/log
3
+ Gemfile.lock
4
+ **/*.gem
5
+ gemfiles/vendor
6
+ .bundle
data/.rubocop.yml CHANGED
@@ -1,91 +1,24 @@
1
- require: rubocop-rails
2
- AllCops:
3
- Exclude:
4
- - "node_modules/**/*"
5
-
6
- # disable length length checking, as it tends to make things worse in the majority
7
- # of cases. however, it is good practice keep lines <= 85 columns so they remain
8
- # readable.
9
- Layout/LineLength:
10
- Enabled: false
11
-
12
- # disable documentation checking. many classes do not require top-level comments,
13
- # and their inclusion can actually obscure their function.
14
- Style/Documentation:
15
- Enabled: false
16
-
17
- # functionalization is important, but the Rails' idiom for returning key-value
18
- # maps can raise a false alarm with the max line number (10). increase the value
19
- # to something more reasonable given the circumstances.
20
- Metrics/MethodLength:
21
- Max: 20
22
- ExcludedMethods:
23
- - test_rake_tasks
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.0] - 2020-05-14
8
-
9
- ### Added
10
-
11
- - Compatibility with Rails' Template API via command execution hooks and keyword substitution.
12
- - Support for existing Yarn Rake task dependence through task aliasing and redirection.
13
- - Additional Rake tasks to test injection and interception logic.
14
- - Utility method for concurrent and scoped `chdir` calls.
15
-
16
- ### Changed
17
-
18
- - Gem dependencies to reflect up-to-date versions.
19
- - RuboCop formatting rules to support latest versions of Ruby.
20
- - Test application structure to allow application booting.
21
- - Rake task tests to utilize concurrent `chdir` calls.
22
- - Tests to support Rails <6.x `[bugfix]`.
23
- - Tests to support Ruby 2.4.9 `[bugfix]`.
24
-
25
- ### Removed
26
-
27
- - Webpacker git submodule as method for replacing default Rails' rake tasks.
28
- - Dependence on a specific version of Webpacker.
29
-
30
- ## [v1.1.0] - 2020-04-19
31
-
32
- ### Changed
33
-
34
- - RuboCop formatting rules to more align with Rails' style guide.
35
- - TypeScript installation tasks based on Webpacker v5.1.0.
36
- - Rake tasks to extend ActiveSupport and utilize concurrent threading.
37
-
38
- ## [v1.0.0] - 2020-04-17
39
-
40
- ### Added
41
-
42
- - Gem specifications and foundational files, generated by Bundler v2.0.2, for defining a Ruby gem.
43
- - Hook into Rails' engine loader for conditional task loading.
44
- - Tasks replacing Yarn with pnpm for Webpacker v5.0.1, included as a submodule.
45
- - Test suite with dummy application.
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
- gem "rack-proxy", require: false
7
- gem "rails", ">= 5.2"
8
- gem "rake", ">= 12.3.3"
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
- ![version](https://img.shields.io/gem/v/webpacker-pnpm?label=version&style=flat-square)
4
- [![status](https://img.shields.io/travis/thearchitector/webpacker-pnpm?style=flat-square)](https://travis-ci.org/github/thearchitector/webpacker-pnpm)
5
- ![downloads](https://img.shields.io/gem/dt/webpacker-pnpm?style=flat-square)
6
- [![license](https://img.shields.io/badge/license-CC--BY--NC--SA--4.0-green?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/)
7
-
8
- `webpacker-pnpm` replaces Rails' Yarn environment with [pnpm](https://pnpm.js.org/), which is a much smarter, efficient, and faster alternative Node.js package manager. 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.html) by Zoltan Kochan, but in essence it reduces dependency resolution times and `node_modules` folder sizes to within reasonable ranges (not 30 seconds and 10 GiB).
9
-
10
- ## Features
11
-
12
- - Production-ready
13
- - Drop-in seamless replacement for Yarn, no config required
14
- - Supports Rails' Template API, including existing templates using Yarn
15
- - Independent of official Webpacker versions
16
- - Provides code sanity without the migraines
17
- - Gives you more disk space
18
-
19
- ## Installation
20
-
21
- In order to use `webpacker-pnpm`, you must install `pnpm`. The official instructions are [here](https://pnpm.js.org/en/installation), but all they say is to run the following command:
22
-
23
- ```sh
24
- $ curl -L https://raw.githubusercontent.com/pnpm/self-installer/master/install.js | node
25
- ```
26
-
27
- After installing `pnpm`, simply add `webpacker-pnpm` to your app's `Gemfile`. There is no need to worry about your official Webpacker gem version, as this gem should be version-agnostic.
28
-
29
- ```ruby
30
- gem "webpacker-pnpm"
31
- ```
32
-
33
- ## License
34
-
35
- This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit <http://creativecommons.org/licenses/by-nc-sa/4.0/> or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
1
+ # webpacker-pnpm
2
+
3
+ [![version](https://img.shields.io/gem/v/webpacker-pnpm?label=version&style=flat-square)](https://rubygems.org/gems/webpacker-pnpm)
4
+ [![status](https://img.shields.io/github/actions/workflow/status/thearchitector/webpacker-pnpm/ci.yaml?label=tests&style=flat-square)](https://travis-ci.org/github/thearchitector/webpacker-pnpm)
5
+ [![downloads](https://img.shields.io/gem/dt/webpacker-pnpm?style=flat-square)](https://rubygems.org/gems/webpacker-pnpm)
6
+ [![license](https://img.shields.io/github/license/thearchitector/webpacker-pnpm?style=flat-square)](LICENSE)
7
+ [![Buy a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen?style=flat-square)](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 default: :test
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
- *config.resolved_paths_globbed,
15
- config.source_path_globbed,
16
- "pnpm-lock.yaml", "package.json",
17
- "config/webpack/**/*"
18
- ].freeze
19
- end
20
- end
21
-
22
- # intercept command execution via Thor to replace yarn with pnpm. this exists in
23
- # order to patch existing Webpacker installation templates that make direct
24
- # calls to install Yarn dependencies. as a result, this isn't a robust patch
25
- Rails::Generators::Actions.module_eval do
26
- def run(command, config = {})
27
- cmd = command.to_s
28
-
29
- if cmd.include?("yarn")
30
- cmd.gsub!("yarn", "pnpm")
31
- cmd.gsub!("--dev", "--save-dev")
32
- end
33
-
34
- super(cmd, config)
35
- end
36
- end
37
-
38
- # intercept generic task loading to clear and alias Yarn tasks
39
- Rails::Engine.class_eval do
40
- alias_method :unfiltered_tasks, :load_tasks
41
-
42
- def load_tasks(_app = self)
43
- unfiltered_tasks
44
- # rather than clear the tasks, alias them to the new pnpm tasks so
45
- # that any external code will still run
46
- Rake::Task["webpacker:check_yarn"].clear.enhance(["webpacker:check_pnpm"])
47
- Rake::Task["webpacker:yarn_install"].clear.enhance(["webpacker:pnpm_install"])
48
- Rake::Task["webpacker:info"].clear.enhance(["webpacker:env"])
49
- Rake::Task["yarn:install"].clear.enhance(["webpacker:pnpm_install"])
50
- end
51
- end
52
- end
53
- end
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