dependabot-npm_and_yarn 0.292.0 → 0.294.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/lib/npm/vulnerability-auditor.js +16 -16
- data/helpers/lib/npm6/updater.js +1 -1
- data/lib/dependabot/npm_and_yarn/bun_package_manager.rb +46 -0
- data/lib/dependabot/npm_and_yarn/dependency_files_filterer.rb +2 -1
- data/lib/dependabot/npm_and_yarn/file_fetcher.rb +61 -35
- data/lib/dependabot/npm_and_yarn/file_parser/bun_lock.rb +141 -0
- data/lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb +33 -27
- data/lib/dependabot/npm_and_yarn/file_parser/pnpm_lock.rb +47 -0
- data/lib/dependabot/npm_and_yarn/file_parser.rb +17 -9
- data/lib/dependabot/npm_and_yarn/file_updater/bun_lockfile_updater.rb +144 -0
- data/lib/dependabot/npm_and_yarn/file_updater/pnpm_lockfile_updater.rb +127 -12
- data/lib/dependabot/npm_and_yarn/file_updater.rb +66 -0
- data/lib/dependabot/npm_and_yarn/helpers.rb +54 -2
- data/lib/dependabot/npm_and_yarn/language.rb +45 -0
- data/lib/dependabot/npm_and_yarn/npm_package_manager.rb +70 -0
- data/lib/dependabot/npm_and_yarn/package_manager.rb +16 -196
- data/lib/dependabot/npm_and_yarn/pnpm_package_manager.rb +55 -0
- data/lib/dependabot/npm_and_yarn/sub_dependency_files_filterer.rb +1 -0
- data/lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb +14 -7
- data/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb +14 -0
- data/lib/dependabot/npm_and_yarn/update_checker/version_resolver.rb +19 -0
- data/lib/dependabot/npm_and_yarn/version.rb +4 -0
- data/lib/dependabot/npm_and_yarn/yarn_package_manager.rb +56 -0
- metadata +12 -5
@@ -0,0 +1,45 @@
|
|
1
|
+
# typed: strong
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "dependabot/npm_and_yarn/package_manager"
|
5
|
+
|
6
|
+
module Dependabot
|
7
|
+
module NpmAndYarn
|
8
|
+
class Language < Ecosystem::VersionManager
|
9
|
+
extend T::Sig
|
10
|
+
NAME = "node"
|
11
|
+
|
12
|
+
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
13
|
+
|
14
|
+
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
15
|
+
|
16
|
+
sig do
|
17
|
+
params(
|
18
|
+
detected_version: T.nilable(String),
|
19
|
+
raw_version: T.nilable(String),
|
20
|
+
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
21
|
+
).void
|
22
|
+
end
|
23
|
+
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
24
|
+
super(
|
25
|
+
name: NAME,
|
26
|
+
detected_version: detected_version ? Version.new(detected_version) : nil,
|
27
|
+
version: raw_version ? Version.new(raw_version) : nil,
|
28
|
+
deprecated_versions: DEPRECATED_VERSIONS,
|
29
|
+
supported_versions: SUPPORTED_VERSIONS,
|
30
|
+
requirement: requirement
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
sig { override.returns(T::Boolean) }
|
35
|
+
def deprecated?
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
sig { override.returns(T::Boolean) }
|
40
|
+
def unsupported?
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# typed: strong
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "dependabot/npm_and_yarn/package_manager"
|
5
|
+
|
6
|
+
module Dependabot
|
7
|
+
module NpmAndYarn
|
8
|
+
class NpmPackageManager < Ecosystem::VersionManager
|
9
|
+
extend T::Sig
|
10
|
+
NAME = "npm"
|
11
|
+
RC_FILENAME = ".npmrc"
|
12
|
+
LOCKFILE_NAME = "package-lock.json"
|
13
|
+
SHRINKWRAP_LOCKFILE_NAME = "npm-shrinkwrap.json"
|
14
|
+
|
15
|
+
NPM_V6 = "6"
|
16
|
+
NPM_V7 = "7"
|
17
|
+
NPM_V8 = "8"
|
18
|
+
NPM_V9 = "9"
|
19
|
+
NPM_V10 = "10"
|
20
|
+
|
21
|
+
# Keep versions in ascending order
|
22
|
+
SUPPORTED_VERSIONS = T.let([
|
23
|
+
Version.new(NPM_V7),
|
24
|
+
Version.new(NPM_V8),
|
25
|
+
Version.new(NPM_V9),
|
26
|
+
Version.new(NPM_V10)
|
27
|
+
].freeze, T::Array[Dependabot::Version])
|
28
|
+
|
29
|
+
DEPRECATED_VERSIONS = T.let([Version.new(NPM_V6)].freeze, T::Array[Dependabot::Version])
|
30
|
+
|
31
|
+
sig do
|
32
|
+
params(
|
33
|
+
detected_version: T.nilable(String),
|
34
|
+
raw_version: T.nilable(String),
|
35
|
+
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
36
|
+
).void
|
37
|
+
end
|
38
|
+
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
39
|
+
super(
|
40
|
+
name: NAME,
|
41
|
+
detected_version: detected_version ? Version.new(detected_version) : nil,
|
42
|
+
version: raw_version ? Version.new(raw_version) : nil,
|
43
|
+
deprecated_versions: DEPRECATED_VERSIONS,
|
44
|
+
supported_versions: SUPPORTED_VERSIONS,
|
45
|
+
requirement: requirement
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
sig { override.returns(T::Boolean) }
|
50
|
+
def deprecated?
|
51
|
+
return false unless detected_version
|
52
|
+
|
53
|
+
return false if unsupported?
|
54
|
+
|
55
|
+
return false unless Dependabot::Experiments.enabled?(:npm_v6_deprecation_warning)
|
56
|
+
|
57
|
+
deprecated_versions.include?(detected_version)
|
58
|
+
end
|
59
|
+
|
60
|
+
sig { override.returns(T::Boolean) }
|
61
|
+
def unsupported?
|
62
|
+
return false unless detected_version
|
63
|
+
|
64
|
+
return false unless Dependabot::Experiments.enabled?(:npm_v6_unsupported_error)
|
65
|
+
|
66
|
+
supported_versions.all? { |supported| supported > detected_version }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -6,6 +6,11 @@ require "dependabot/ecosystem"
|
|
6
6
|
require "dependabot/npm_and_yarn/requirement"
|
7
7
|
require "dependabot/npm_and_yarn/version_selector"
|
8
8
|
require "dependabot/npm_and_yarn/registry_helper"
|
9
|
+
require "dependabot/npm_and_yarn/npm_package_manager"
|
10
|
+
require "dependabot/npm_and_yarn/yarn_package_manager"
|
11
|
+
require "dependabot/npm_and_yarn/pnpm_package_manager"
|
12
|
+
require "dependabot/npm_and_yarn/bun_package_manager"
|
13
|
+
require "dependabot/npm_and_yarn/language"
|
9
14
|
|
10
15
|
module Dependabot
|
11
16
|
module NpmAndYarn
|
@@ -47,163 +52,6 @@ module Dependabot
|
|
47
52
|
MANIFEST_PACKAGE_MANAGER_KEY = "packageManager"
|
48
53
|
MANIFEST_ENGINES_KEY = "engines"
|
49
54
|
|
50
|
-
class NpmPackageManager < Ecosystem::VersionManager
|
51
|
-
extend T::Sig
|
52
|
-
NAME = "npm"
|
53
|
-
RC_FILENAME = ".npmrc"
|
54
|
-
LOCKFILE_NAME = "package-lock.json"
|
55
|
-
SHRINKWRAP_LOCKFILE_NAME = "npm-shrinkwrap.json"
|
56
|
-
|
57
|
-
NPM_V6 = "6"
|
58
|
-
NPM_V7 = "7"
|
59
|
-
NPM_V8 = "8"
|
60
|
-
NPM_V9 = "9"
|
61
|
-
NPM_V10 = "10"
|
62
|
-
|
63
|
-
# Keep versions in ascending order
|
64
|
-
SUPPORTED_VERSIONS = T.let([
|
65
|
-
Version.new(NPM_V7),
|
66
|
-
Version.new(NPM_V8),
|
67
|
-
Version.new(NPM_V9),
|
68
|
-
Version.new(NPM_V10)
|
69
|
-
].freeze, T::Array[Dependabot::Version])
|
70
|
-
|
71
|
-
DEPRECATED_VERSIONS = T.let([Version.new(NPM_V6)].freeze, T::Array[Dependabot::Version])
|
72
|
-
|
73
|
-
sig do
|
74
|
-
params(
|
75
|
-
detected_version: T.nilable(String),
|
76
|
-
raw_version: T.nilable(String),
|
77
|
-
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
78
|
-
).void
|
79
|
-
end
|
80
|
-
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
81
|
-
super(
|
82
|
-
name: NAME,
|
83
|
-
detected_version: detected_version ? Version.new(detected_version) : nil,
|
84
|
-
version: raw_version ? Version.new(raw_version) : nil,
|
85
|
-
deprecated_versions: DEPRECATED_VERSIONS,
|
86
|
-
supported_versions: SUPPORTED_VERSIONS,
|
87
|
-
requirement: requirement
|
88
|
-
)
|
89
|
-
end
|
90
|
-
|
91
|
-
sig { override.returns(T::Boolean) }
|
92
|
-
def deprecated?
|
93
|
-
return false unless detected_version
|
94
|
-
|
95
|
-
return false if unsupported?
|
96
|
-
|
97
|
-
return false unless Dependabot::Experiments.enabled?(:npm_v6_deprecation_warning)
|
98
|
-
|
99
|
-
deprecated_versions.include?(detected_version)
|
100
|
-
end
|
101
|
-
|
102
|
-
sig { override.returns(T::Boolean) }
|
103
|
-
def unsupported?
|
104
|
-
return false unless detected_version
|
105
|
-
|
106
|
-
return false unless Dependabot::Experiments.enabled?(:npm_v6_unsupported_error)
|
107
|
-
|
108
|
-
supported_versions.all? { |supported| supported > detected_version }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
class YarnPackageManager < Ecosystem::VersionManager
|
113
|
-
extend T::Sig
|
114
|
-
NAME = "yarn"
|
115
|
-
RC_FILENAME = ".yarnrc"
|
116
|
-
RC_YML_FILENAME = ".yarnrc.yml"
|
117
|
-
LOCKFILE_NAME = "yarn.lock"
|
118
|
-
|
119
|
-
YARN_V1 = "1"
|
120
|
-
YARN_V2 = "2"
|
121
|
-
YARN_V3 = "3"
|
122
|
-
|
123
|
-
SUPPORTED_VERSIONS = T.let([
|
124
|
-
Version.new(YARN_V1),
|
125
|
-
Version.new(YARN_V2),
|
126
|
-
Version.new(YARN_V3)
|
127
|
-
].freeze, T::Array[Dependabot::Version])
|
128
|
-
|
129
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
130
|
-
|
131
|
-
sig do
|
132
|
-
params(
|
133
|
-
detected_version: T.nilable(String),
|
134
|
-
raw_version: T.nilable(String),
|
135
|
-
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
136
|
-
).void
|
137
|
-
end
|
138
|
-
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
139
|
-
super(
|
140
|
-
name: NAME,
|
141
|
-
detected_version: detected_version ? Version.new(detected_version) : nil,
|
142
|
-
version: raw_version ? Version.new(raw_version) : nil,
|
143
|
-
deprecated_versions: DEPRECATED_VERSIONS,
|
144
|
-
supported_versions: SUPPORTED_VERSIONS,
|
145
|
-
requirement: requirement
|
146
|
-
)
|
147
|
-
end
|
148
|
-
|
149
|
-
sig { override.returns(T::Boolean) }
|
150
|
-
def deprecated?
|
151
|
-
false
|
152
|
-
end
|
153
|
-
|
154
|
-
sig { override.returns(T::Boolean) }
|
155
|
-
def unsupported?
|
156
|
-
false
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
class PNPMPackageManager < Ecosystem::VersionManager
|
161
|
-
extend T::Sig
|
162
|
-
NAME = "pnpm"
|
163
|
-
LOCKFILE_NAME = "pnpm-lock.yaml"
|
164
|
-
PNPM_WS_YML_FILENAME = "pnpm-workspace.yaml"
|
165
|
-
|
166
|
-
PNPM_V7 = "7"
|
167
|
-
PNPM_V8 = "8"
|
168
|
-
PNPM_V9 = "9"
|
169
|
-
|
170
|
-
SUPPORTED_VERSIONS = T.let([
|
171
|
-
Version.new(PNPM_V7),
|
172
|
-
Version.new(PNPM_V8),
|
173
|
-
Version.new(PNPM_V9)
|
174
|
-
].freeze, T::Array[Dependabot::Version])
|
175
|
-
|
176
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
177
|
-
|
178
|
-
sig do
|
179
|
-
params(
|
180
|
-
detected_version: T.nilable(String),
|
181
|
-
raw_version: T.nilable(String),
|
182
|
-
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
183
|
-
).void
|
184
|
-
end
|
185
|
-
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
186
|
-
super(
|
187
|
-
name: NAME,
|
188
|
-
detected_version: detected_version ? Version.new(detected_version) : nil,
|
189
|
-
version: raw_version ? Version.new(raw_version) : nil,
|
190
|
-
deprecated_versions: DEPRECATED_VERSIONS,
|
191
|
-
supported_versions: SUPPORTED_VERSIONS,
|
192
|
-
requirement: requirement
|
193
|
-
)
|
194
|
-
end
|
195
|
-
|
196
|
-
sig { override.returns(T::Boolean) }
|
197
|
-
def deprecated?
|
198
|
-
false
|
199
|
-
end
|
200
|
-
|
201
|
-
sig { override.returns(T::Boolean) }
|
202
|
-
def unsupported?
|
203
|
-
false
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
55
|
DEFAULT_PACKAGE_MANAGER = NpmPackageManager::NAME
|
208
56
|
|
209
57
|
# Define a type alias for the expected class interface
|
@@ -211,16 +59,21 @@ module Dependabot
|
|
211
59
|
T.any(
|
212
60
|
T.class_of(Dependabot::NpmAndYarn::NpmPackageManager),
|
213
61
|
T.class_of(Dependabot::NpmAndYarn::YarnPackageManager),
|
214
|
-
T.class_of(Dependabot::NpmAndYarn::PNPMPackageManager)
|
62
|
+
T.class_of(Dependabot::NpmAndYarn::PNPMPackageManager),
|
63
|
+
T.class_of(Dependabot::NpmAndYarn::BunPackageManager)
|
215
64
|
)
|
216
65
|
end
|
217
66
|
|
218
67
|
PACKAGE_MANAGER_CLASSES = T.let({
|
219
68
|
NpmPackageManager::NAME => NpmPackageManager,
|
220
69
|
YarnPackageManager::NAME => YarnPackageManager,
|
221
|
-
PNPMPackageManager::NAME => PNPMPackageManager
|
70
|
+
PNPMPackageManager::NAME => PNPMPackageManager,
|
71
|
+
BunPackageManager::NAME => BunPackageManager
|
222
72
|
}.freeze, T::Hash[String, NpmAndYarnPackageManagerClassType])
|
223
73
|
|
74
|
+
# Error malformed version number string
|
75
|
+
ERROR_MALFORMED_VERSION_NUMBER = "Malformed version number"
|
76
|
+
|
224
77
|
class PackageManagerDetector
|
225
78
|
extend T::Sig
|
226
79
|
extend T::Helpers
|
@@ -285,43 +138,6 @@ module Dependabot
|
|
285
138
|
end
|
286
139
|
end
|
287
140
|
|
288
|
-
class Language < Ecosystem::VersionManager
|
289
|
-
extend T::Sig
|
290
|
-
NAME = "node"
|
291
|
-
|
292
|
-
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
293
|
-
|
294
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
295
|
-
|
296
|
-
sig do
|
297
|
-
params(
|
298
|
-
detected_version: T.nilable(String),
|
299
|
-
raw_version: T.nilable(String),
|
300
|
-
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
301
|
-
).void
|
302
|
-
end
|
303
|
-
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
304
|
-
super(
|
305
|
-
name: NAME,
|
306
|
-
detected_version: detected_version ? Version.new(detected_version) : nil,
|
307
|
-
version: raw_version ? Version.new(raw_version) : nil,
|
308
|
-
deprecated_versions: DEPRECATED_VERSIONS,
|
309
|
-
supported_versions: SUPPORTED_VERSIONS,
|
310
|
-
requirement: requirement
|
311
|
-
)
|
312
|
-
end
|
313
|
-
|
314
|
-
sig { override.returns(T::Boolean) }
|
315
|
-
def deprecated?
|
316
|
-
false
|
317
|
-
end
|
318
|
-
|
319
|
-
sig { override.returns(T::Boolean) }
|
320
|
-
def unsupported?
|
321
|
-
false
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
141
|
class PackageManagerHelper
|
326
142
|
extend T::Sig
|
327
143
|
extend T::Helpers
|
@@ -520,6 +336,10 @@ module Dependabot
|
|
520
336
|
raw_version: installed_version,
|
521
337
|
requirement: package_manager_requirement
|
522
338
|
)
|
339
|
+
rescue ArgumentError => e
|
340
|
+
raise DependencyFileNotParseable, e.message if e.message.include?(ERROR_MALFORMED_VERSION_NUMBER)
|
341
|
+
|
342
|
+
raise
|
523
343
|
rescue StandardError => e
|
524
344
|
Dependabot.logger.error("Error resolving package manager for #{name || 'default'}: #{e.message}")
|
525
345
|
raise
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# typed: strong
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "dependabot/npm_and_yarn/package_manager"
|
5
|
+
|
6
|
+
module Dependabot
|
7
|
+
module NpmAndYarn
|
8
|
+
class PNPMPackageManager < Ecosystem::VersionManager
|
9
|
+
extend T::Sig
|
10
|
+
NAME = "pnpm"
|
11
|
+
LOCKFILE_NAME = "pnpm-lock.yaml"
|
12
|
+
PNPM_WS_YML_FILENAME = "pnpm-workspace.yaml"
|
13
|
+
|
14
|
+
PNPM_V7 = "7"
|
15
|
+
PNPM_V8 = "8"
|
16
|
+
PNPM_V9 = "9"
|
17
|
+
|
18
|
+
SUPPORTED_VERSIONS = T.let([
|
19
|
+
Version.new(PNPM_V7),
|
20
|
+
Version.new(PNPM_V8),
|
21
|
+
Version.new(PNPM_V9)
|
22
|
+
].freeze, T::Array[Dependabot::Version])
|
23
|
+
|
24
|
+
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
25
|
+
|
26
|
+
sig do
|
27
|
+
params(
|
28
|
+
detected_version: T.nilable(String),
|
29
|
+
raw_version: T.nilable(String),
|
30
|
+
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
31
|
+
).void
|
32
|
+
end
|
33
|
+
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
34
|
+
super(
|
35
|
+
name: NAME,
|
36
|
+
detected_version: detected_version ? Version.new(detected_version) : nil,
|
37
|
+
version: raw_version ? Version.new(raw_version) : nil,
|
38
|
+
deprecated_versions: DEPRECATED_VERSIONS,
|
39
|
+
supported_versions: SUPPORTED_VERSIONS,
|
40
|
+
requirement: requirement
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
sig { override.returns(T::Boolean) }
|
45
|
+
def deprecated?
|
46
|
+
false
|
47
|
+
end
|
48
|
+
|
49
|
+
sig { override.returns(T::Boolean) }
|
50
|
+
def unsupported?
|
51
|
+
false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -49,6 +49,12 @@ module Dependabot
|
|
49
49
|
.select { |f| f.name.end_with?("pnpm-lock.yaml") }
|
50
50
|
end
|
51
51
|
|
52
|
+
def bun_locks
|
53
|
+
@bun_locks ||=
|
54
|
+
dependency_files
|
55
|
+
.select { |f| f.name.end_with?("bun.lock") }
|
56
|
+
end
|
57
|
+
|
52
58
|
def root_yarn_lock
|
53
59
|
@root_yarn_lock ||=
|
54
60
|
dependency_files
|
@@ -61,6 +67,12 @@ module Dependabot
|
|
61
67
|
.find { |f| f.name == "pnpm-lock.yaml" }
|
62
68
|
end
|
63
69
|
|
70
|
+
def root_bun_lock
|
71
|
+
@root_bun_lock ||=
|
72
|
+
dependency_files
|
73
|
+
.find { |f| f.name == "bun.lock" }
|
74
|
+
end
|
75
|
+
|
64
76
|
def shrinkwraps
|
65
77
|
@shrinkwraps ||=
|
66
78
|
dependency_files
|
@@ -68,7 +80,7 @@ module Dependabot
|
|
68
80
|
end
|
69
81
|
|
70
82
|
def lockfiles
|
71
|
-
[*package_locks, *shrinkwraps, *yarn_locks, *pnpm_locks]
|
83
|
+
[*package_locks, *shrinkwraps, *yarn_locks, *pnpm_locks, *bun_locks]
|
72
84
|
end
|
73
85
|
|
74
86
|
def package_files
|
@@ -89,12 +101,7 @@ module Dependabot
|
|
89
101
|
File.write(f.name, prepared_yarn_lockfile_content(f.content))
|
90
102
|
end
|
91
103
|
|
92
|
-
pnpm_locks.each do |f|
|
93
|
-
FileUtils.mkdir_p(Pathname.new(f.name).dirname)
|
94
|
-
File.write(f.name, f.content)
|
95
|
-
end
|
96
|
-
|
97
|
-
[*package_locks, *shrinkwraps].each do |f|
|
104
|
+
[*package_locks, *shrinkwraps, *pnpm_locks, *bun_locks].each do |f|
|
98
105
|
FileUtils.mkdir_p(Pathname.new(f.name).dirname)
|
99
106
|
File.write(f.name, f.content)
|
100
107
|
end
|
@@ -70,6 +70,8 @@ module Dependabot
|
|
70
70
|
run_yarn_updater(path, lockfile_name)
|
71
71
|
elsif lockfile.name.end_with?("pnpm-lock.yaml")
|
72
72
|
run_pnpm_updater(path, lockfile_name)
|
73
|
+
elsif lockfile.name.end_with?("bun.lock")
|
74
|
+
run_bun_updater(path, lockfile_name)
|
73
75
|
elsif !Helpers.npm8?(lockfile)
|
74
76
|
run_npm6_updater(path, lockfile_name)
|
75
77
|
else
|
@@ -153,6 +155,18 @@ module Dependabot
|
|
153
155
|
end
|
154
156
|
end
|
155
157
|
|
158
|
+
def run_bun_updater(path, lockfile_name)
|
159
|
+
SharedHelpers.with_git_configured(credentials: credentials) do
|
160
|
+
Dir.chdir(path) do
|
161
|
+
Helpers.run_bun_command(
|
162
|
+
"update #{dependency.name} --save-text-lockfile",
|
163
|
+
fingerprint: "update <dependency_name> --save-text-lockfile"
|
164
|
+
)
|
165
|
+
{ lockfile_name => File.read(lockfile_name) }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
156
170
|
def run_npm6_updater(path, lockfile_name)
|
157
171
|
SharedHelpers.with_git_configured(credentials: credentials) do
|
158
172
|
Dir.chdir(path) do
|
@@ -413,6 +413,8 @@ module Dependabot
|
|
413
413
|
end
|
414
414
|
|
415
415
|
def error_details_from_captures(captures)
|
416
|
+
return {} unless captures.is_a?(Hash)
|
417
|
+
|
416
418
|
required_dep_captures = captures.fetch("required_dep")
|
417
419
|
requiring_dep_captures = captures.fetch("requiring_dep")
|
418
420
|
return {} unless required_dep_captures && requiring_dep_captures
|
@@ -549,12 +551,18 @@ module Dependabot
|
|
549
551
|
npm_lockfiles = lockfiles_for_path(lockfiles: dependency_files_builder.package_locks, path: path)
|
550
552
|
return run_npm_checker(path: path, version: version) if npm_lockfiles.any?
|
551
553
|
|
554
|
+
bun_lockfiles = lockfiles_for_path(lockfiles: dependency_files_builder.bun_locks, path: path)
|
555
|
+
return run_bun_checker(path: path, version: version) if bun_lockfiles.any?
|
556
|
+
|
552
557
|
root_yarn_lock = dependency_files_builder.root_yarn_lock
|
553
558
|
return run_yarn_checker(path: path, version: version, lockfile: root_yarn_lock) if root_yarn_lock
|
554
559
|
|
555
560
|
root_pnpm_lock = dependency_files_builder.root_pnpm_lock
|
556
561
|
return run_pnpm_checker(path: path, version: version) if root_pnpm_lock
|
557
562
|
|
563
|
+
root_bun_lock = dependency_files_builder.root_bun_lock
|
564
|
+
return run_bun_checker(path: path, version: version) if root_bun_lock
|
565
|
+
|
558
566
|
run_npm_checker(path: path, version: version)
|
559
567
|
rescue SharedHelpers::HelperSubprocessFailed => e
|
560
568
|
handle_peer_dependency_errors(e.message)
|
@@ -583,6 +591,17 @@ module Dependabot
|
|
583
591
|
end
|
584
592
|
end
|
585
593
|
|
594
|
+
def run_bun_checker(path:, version:)
|
595
|
+
SharedHelpers.with_git_configured(credentials: credentials) do
|
596
|
+
Dir.chdir(path) do
|
597
|
+
Helpers.run_bun_command(
|
598
|
+
"update #{dependency.name}@#{version} --save-text-lockfile",
|
599
|
+
fingerprint: "update <dependency_name>@<version> --save-text-lockfile"
|
600
|
+
)
|
601
|
+
end
|
602
|
+
end
|
603
|
+
end
|
604
|
+
|
586
605
|
def run_yarn_berry_checker(path:, version:)
|
587
606
|
# This method mimics calling a native helper in order to comply with the caller's expectations
|
588
607
|
# Specifically we add the dependency at the specified updated version
|
@@ -80,6 +80,10 @@ module Dependabot
|
|
80
80
|
# Matches @ followed by x.y.z (digits separated by dots)
|
81
81
|
if (match = version.match(/@(\d+\.\d+\.\d+)/))
|
82
82
|
version = match[1] # Just "4.5.3"
|
83
|
+
|
84
|
+
# Extract version in case the output contains Corepack verbose data
|
85
|
+
elsif version.include?("Corepack")
|
86
|
+
version = T.must(T.must(version.tr("\n", " ").match(/(\d+\.\d+\.\d+)/))[-1])
|
83
87
|
end
|
84
88
|
version = version&.gsub(/^v/, "")
|
85
89
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# typed: strong
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "dependabot/npm_and_yarn/package_manager"
|
5
|
+
|
6
|
+
module Dependabot
|
7
|
+
module NpmAndYarn
|
8
|
+
class YarnPackageManager < Ecosystem::VersionManager
|
9
|
+
extend T::Sig
|
10
|
+
NAME = "yarn"
|
11
|
+
RC_FILENAME = ".yarnrc"
|
12
|
+
RC_YML_FILENAME = ".yarnrc.yml"
|
13
|
+
LOCKFILE_NAME = "yarn.lock"
|
14
|
+
|
15
|
+
YARN_V1 = "1"
|
16
|
+
YARN_V2 = "2"
|
17
|
+
YARN_V3 = "3"
|
18
|
+
|
19
|
+
SUPPORTED_VERSIONS = T.let([
|
20
|
+
Version.new(YARN_V1),
|
21
|
+
Version.new(YARN_V2),
|
22
|
+
Version.new(YARN_V3)
|
23
|
+
].freeze, T::Array[Dependabot::Version])
|
24
|
+
|
25
|
+
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
26
|
+
|
27
|
+
sig do
|
28
|
+
params(
|
29
|
+
detected_version: T.nilable(String),
|
30
|
+
raw_version: T.nilable(String),
|
31
|
+
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
32
|
+
).void
|
33
|
+
end
|
34
|
+
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
35
|
+
super(
|
36
|
+
name: NAME,
|
37
|
+
detected_version: detected_version ? Version.new(detected_version) : nil,
|
38
|
+
version: raw_version ? Version.new(raw_version) : nil,
|
39
|
+
deprecated_versions: DEPRECATED_VERSIONS,
|
40
|
+
supported_versions: SUPPORTED_VERSIONS,
|
41
|
+
requirement: requirement
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
sig { override.returns(T::Boolean) }
|
46
|
+
def deprecated?
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
sig { override.returns(T::Boolean) }
|
51
|
+
def unsupported?
|
52
|
+
false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|