File: add-yarnpkg-support.patch

package info (click to toggle)
ruby-cssbundling-rails 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 192 kB
  • sloc: ruby: 190; javascript: 7; sh: 6; makefile: 4
file content (75 lines) | stat: -rw-r--r-- 2,461 bytes parent folder | download
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
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Description: add yarnpkg support as yarn is yarnpkg in debian
Author: Ananthu C V <weepingclown@disroot.org>
Last-Update: 2024-11-20
--- a/lib/install/helpers.rb
+++ b/lib/install/helpers.rb
@@ -2,11 +2,23 @@ require 'json'
 
 module Helpers
   def bundler_cmd
-    using_bun? ? "bun" : "yarn"
+    if using_bun?
+      "bun"
+    elsif tool_exists?('yarnpkg')
+      "yarnpkg"
+    else
+      "yarn"
+    end
   end
 
   def bundler_run_cmd
-    using_bun? ? "bun run" : "yarn"
+    if using_bun?
+      "bun"
+    elsif tool_exists?('yarnpkg')
+      "yarnpkg"
+    else
+      "yarn"
+    end
   end
 
   def bundler_x_cmd
@@ -35,11 +47,11 @@ module Helpers
       when 7.1...8.0
         say "Add #{name} script"
         run %(npm set-script #{name} "#{script}")
-        run %(yarn #{name}) if run_script
+        tool_exists?("yarnpkg") ? (run %(yarnpkg #{name}) if run_script): (run %(yarn #{name}) if run_script)
       when (8.0..)
         say "Add #{name} script"
         run %(npm pkg set scripts.#{name}="#{script}")
-        run %(yarn #{name}) if run_script
+        tool_exists?("yarnpkg") ? (run %(yarnpkg #{name}) if run_script): (run %(yarn #{name}) if run_script)
       else
         say %(Add "scripts": { "#{name}": "#{script}" } to your package.json), :green
       end
--- a/lib/tasks/cssbundling/build.rake
+++ b/lib/tasks/cssbundling/build.rake
@@ -23,7 +23,6 @@ module Cssbundling
 
     LOCK_FILES = {
       bun: %w[bun.lockb bun.lock yarn.lock],
-      yarn: %w[yarn.lock],
       pnpm: %w[pnpm-lock.yaml],
       npm: %w[package-lock.json]
     }
@@ -32,9 +31,11 @@ module Cssbundling
       case
       when using_tool?(:bun) then "bun install"
       when using_tool?(:yarn) then "yarn install"
+      when using_tool?(:yarnpkg) then "yarnpkg install"
       when using_tool?(:pnpm) then "pnpm install"
       when using_tool?(:npm) then "npm install"
       else raise "cssbundling-rails: No suitable tool found for installing JavaScript dependencies"
+      when :yarnpkg then "yarnpkg build:css"
       end
     end
 
@@ -42,6 +43,7 @@ module Cssbundling
       case
       when using_tool?(:bun) then "bun run build:css"
       when using_tool?(:yarn) then "yarn build:css"
+      when using_tool?(:yarnpkg) then "yarnpkg build:css"
       when using_tool?(:pnpm) then "pnpm build:css"
       when using_tool?(:npm) then "npm run build:css"
       else raise "cssbundling-rails: No suitable tool found for building CSS"