dependabot-npm_and_yarn 0.291.0 → 0.293.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +50 -33
- 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 +9 -1
- 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 +46 -0
- data/lib/dependabot/npm_and_yarn/file_updater.rb +48 -0
- data/lib/dependabot/npm_and_yarn/helpers.rb +42 -4
- 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 +46 -183
- 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 +17 -1
- data/lib/dependabot/npm_and_yarn/yarn_package_manager.rb +56 -0
- metadata +13 -6
@@ -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,152 +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
|
-
raw_version: String,
|
76
|
-
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
77
|
-
).void
|
78
|
-
end
|
79
|
-
def initialize(raw_version, requirement: nil)
|
80
|
-
super(
|
81
|
-
NAME,
|
82
|
-
Version.new(raw_version),
|
83
|
-
DEPRECATED_VERSIONS,
|
84
|
-
SUPPORTED_VERSIONS,
|
85
|
-
requirement
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
|
-
sig { override.returns(T::Boolean) }
|
90
|
-
def deprecated?
|
91
|
-
return false if unsupported?
|
92
|
-
return false unless Dependabot::Experiments.enabled?(:npm_v6_deprecation_warning)
|
93
|
-
|
94
|
-
deprecated_versions.include?(version)
|
95
|
-
end
|
96
|
-
|
97
|
-
sig { override.returns(T::Boolean) }
|
98
|
-
def unsupported?
|
99
|
-
return false unless Dependabot::Experiments.enabled?(:npm_v6_unsupported_error)
|
100
|
-
|
101
|
-
supported_versions.all? { |supported| supported > version }
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class YarnPackageManager < Ecosystem::VersionManager
|
106
|
-
extend T::Sig
|
107
|
-
NAME = "yarn"
|
108
|
-
RC_FILENAME = ".yarnrc"
|
109
|
-
RC_YML_FILENAME = ".yarnrc.yml"
|
110
|
-
LOCKFILE_NAME = "yarn.lock"
|
111
|
-
|
112
|
-
YARN_V1 = "1"
|
113
|
-
YARN_V2 = "2"
|
114
|
-
YARN_V3 = "3"
|
115
|
-
|
116
|
-
SUPPORTED_VERSIONS = T.let([
|
117
|
-
Version.new(YARN_V1),
|
118
|
-
Version.new(YARN_V2),
|
119
|
-
Version.new(YARN_V3)
|
120
|
-
].freeze, T::Array[Dependabot::Version])
|
121
|
-
|
122
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
123
|
-
|
124
|
-
sig do
|
125
|
-
params(
|
126
|
-
raw_version: String,
|
127
|
-
requirement: T.nilable(Requirement)
|
128
|
-
).void
|
129
|
-
end
|
130
|
-
def initialize(raw_version, requirement: nil)
|
131
|
-
super(
|
132
|
-
NAME,
|
133
|
-
Version.new(raw_version),
|
134
|
-
DEPRECATED_VERSIONS,
|
135
|
-
SUPPORTED_VERSIONS,
|
136
|
-
requirement
|
137
|
-
)
|
138
|
-
end
|
139
|
-
|
140
|
-
sig { override.returns(T::Boolean) }
|
141
|
-
def deprecated?
|
142
|
-
false
|
143
|
-
end
|
144
|
-
|
145
|
-
sig { override.returns(T::Boolean) }
|
146
|
-
def unsupported?
|
147
|
-
false
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
class PNPMPackageManager < Ecosystem::VersionManager
|
152
|
-
extend T::Sig
|
153
|
-
NAME = "pnpm"
|
154
|
-
LOCKFILE_NAME = "pnpm-lock.yaml"
|
155
|
-
PNPM_WS_YML_FILENAME = "pnpm-workspace.yaml"
|
156
|
-
|
157
|
-
PNPM_V7 = "7"
|
158
|
-
PNPM_V8 = "8"
|
159
|
-
PNPM_V9 = "9"
|
160
|
-
|
161
|
-
SUPPORTED_VERSIONS = T.let([
|
162
|
-
Version.new(PNPM_V7),
|
163
|
-
Version.new(PNPM_V8),
|
164
|
-
Version.new(PNPM_V9)
|
165
|
-
].freeze, T::Array[Dependabot::Version])
|
166
|
-
|
167
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
168
|
-
|
169
|
-
sig do
|
170
|
-
params(
|
171
|
-
raw_version: String,
|
172
|
-
requirement: T.nilable(Requirement)
|
173
|
-
).void
|
174
|
-
end
|
175
|
-
def initialize(raw_version, requirement: nil)
|
176
|
-
super(
|
177
|
-
NAME,
|
178
|
-
Version.new(raw_version),
|
179
|
-
DEPRECATED_VERSIONS,
|
180
|
-
SUPPORTED_VERSIONS,
|
181
|
-
requirement
|
182
|
-
)
|
183
|
-
end
|
184
|
-
|
185
|
-
sig { override.returns(T::Boolean) }
|
186
|
-
def deprecated?
|
187
|
-
false
|
188
|
-
end
|
189
|
-
|
190
|
-
sig { override.returns(T::Boolean) }
|
191
|
-
def unsupported?
|
192
|
-
false
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
55
|
DEFAULT_PACKAGE_MANAGER = NpmPackageManager::NAME
|
197
56
|
|
198
57
|
# Define a type alias for the expected class interface
|
@@ -210,6 +69,9 @@ module Dependabot
|
|
210
69
|
PNPMPackageManager::NAME => PNPMPackageManager
|
211
70
|
}.freeze, T::Hash[String, NpmAndYarnPackageManagerClassType])
|
212
71
|
|
72
|
+
# Error malformed version number string
|
73
|
+
ERROR_MALFORMED_VERSION_NUMBER = "Malformed version number"
|
74
|
+
|
213
75
|
class PackageManagerDetector
|
214
76
|
extend T::Sig
|
215
77
|
extend T::Helpers
|
@@ -274,41 +136,6 @@ module Dependabot
|
|
274
136
|
end
|
275
137
|
end
|
276
138
|
|
277
|
-
class Language < Ecosystem::VersionManager
|
278
|
-
extend T::Sig
|
279
|
-
NAME = "node"
|
280
|
-
|
281
|
-
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
282
|
-
|
283
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
284
|
-
|
285
|
-
sig do
|
286
|
-
params(
|
287
|
-
raw_version: T.nilable(String),
|
288
|
-
requirement: T.nilable(Requirement)
|
289
|
-
).void
|
290
|
-
end
|
291
|
-
def initialize(raw_version, requirement: nil)
|
292
|
-
super(
|
293
|
-
NAME,
|
294
|
-
Version.new(raw_version),
|
295
|
-
DEPRECATED_VERSIONS,
|
296
|
-
SUPPORTED_VERSIONS,
|
297
|
-
requirement
|
298
|
-
)
|
299
|
-
end
|
300
|
-
|
301
|
-
sig { override.returns(T::Boolean) }
|
302
|
-
def deprecated?
|
303
|
-
false
|
304
|
-
end
|
305
|
-
|
306
|
-
sig { override.returns(T::Boolean) }
|
307
|
-
def unsupported?
|
308
|
-
false
|
309
|
-
end
|
310
|
-
end
|
311
|
-
|
312
139
|
class PackageManagerHelper
|
313
140
|
extend T::Sig
|
314
141
|
extend T::Helpers
|
@@ -349,7 +176,7 @@ module Dependabot
|
|
349
176
|
sig { returns(Ecosystem::VersionManager) }
|
350
177
|
def language
|
351
178
|
@language ||= Language.new(
|
352
|
-
Helpers.node_version,
|
179
|
+
raw_version: Helpers.node_version,
|
353
180
|
requirement: language_requirement
|
354
181
|
)
|
355
182
|
end
|
@@ -393,6 +220,7 @@ module Dependabot
|
|
393
220
|
# rubocop:disable Metrics/CyclomaticComplexity
|
394
221
|
# rubocop:disable Metrics/AbcSize
|
395
222
|
# rubocop:disable Metrics/PerceivedComplexity
|
223
|
+
# rubocop:disable Metrics/MethodLength
|
396
224
|
sig { params(name: String).returns(T.nilable(T.any(Integer, String))) }
|
397
225
|
def setup(name)
|
398
226
|
# we prioritize version mentioned in "packageManager" instead of "engines"
|
@@ -405,6 +233,8 @@ module Dependabot
|
|
405
233
|
return
|
406
234
|
end
|
407
235
|
|
236
|
+
return package_manager.version.to_s if package_manager.deprecated? || package_manager.unsupported?
|
237
|
+
|
408
238
|
if @engines && @manifest_package_manager.nil?
|
409
239
|
# if "packageManager" doesn't exists in manifest file,
|
410
240
|
# we check if we can extract "engines" information
|
@@ -453,6 +283,24 @@ module Dependabot
|
|
453
283
|
# rubocop:enable Metrics/CyclomaticComplexity
|
454
284
|
# rubocop:enable Metrics/AbcSize
|
455
285
|
# rubocop:enable Metrics/PerceivedComplexity
|
286
|
+
# rubocop:enable Metrics/MethodLength
|
287
|
+
|
288
|
+
sig { params(name: String).returns(T.nilable(String)) }
|
289
|
+
def detect_version(name)
|
290
|
+
# we prioritize version mentioned in "packageManager" instead of "engines"
|
291
|
+
if @manifest_package_manager&.start_with?("#{name}@")
|
292
|
+
detected_version = @manifest_package_manager.split("@").last.to_s
|
293
|
+
end
|
294
|
+
|
295
|
+
# if "packageManager" have no version specified, we check if we can extract "engines" information
|
296
|
+
detected_version = check_engine_version(name) if !detected_version || detected_version.empty?
|
297
|
+
|
298
|
+
# if "packageManager" and "engines" both are not present, we check if we can infer the version
|
299
|
+
# from the manifest file lockfileVersion
|
300
|
+
detected_version = guessed_version(name) if !detected_version || detected_version.empty?
|
301
|
+
|
302
|
+
detected_version&.to_s
|
303
|
+
end
|
456
304
|
|
457
305
|
sig { params(name: T.nilable(String)).returns(Ecosystem::VersionManager) }
|
458
306
|
def package_manager_by_name(name)
|
@@ -461,6 +309,16 @@ module Dependabot
|
|
461
309
|
name = ensure_valid_package_manager(name)
|
462
310
|
package_manager_class = T.must(PACKAGE_MANAGER_CLASSES[name])
|
463
311
|
|
312
|
+
detected_version = detect_version(name)
|
313
|
+
|
314
|
+
# if we have a detected version, we check if it is deprecated or unsupported
|
315
|
+
if detected_version
|
316
|
+
package_manager = package_manager_class.new(
|
317
|
+
detected_version: detected_version.to_s
|
318
|
+
)
|
319
|
+
return package_manager if package_manager.deprecated? || package_manager.unsupported?
|
320
|
+
end
|
321
|
+
|
464
322
|
installed_version = installed_version(name)
|
465
323
|
Dependabot.logger.info("Installed version for #{name}: #{installed_version}")
|
466
324
|
|
@@ -472,9 +330,14 @@ module Dependabot
|
|
472
330
|
end
|
473
331
|
|
474
332
|
package_manager_class.new(
|
475
|
-
|
333
|
+
detected_version: detected_version.to_s,
|
334
|
+
raw_version: installed_version,
|
476
335
|
requirement: package_manager_requirement
|
477
336
|
)
|
337
|
+
rescue ArgumentError => e
|
338
|
+
raise DependencyFileNotParseable, e.message if e.message.include?(ERROR_MALFORMED_VERSION_NUMBER)
|
339
|
+
|
340
|
+
raise
|
478
341
|
rescue StandardError => e
|
479
342
|
Dependabot.logger.error("Error resolving package manager for #{name || 'default'}: #{e.message}")
|
480
343
|
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
|
@@ -62,8 +62,10 @@ module Dependabot
|
|
62
62
|
|
63
63
|
sig { override.params(version: VersionParameter).void }
|
64
64
|
def initialize(version)
|
65
|
+
version = clean_version(version)
|
66
|
+
|
65
67
|
@version_string = T.let(version.to_s, String)
|
66
|
-
|
68
|
+
|
67
69
|
@build_info = T.let(nil, T.nilable(String))
|
68
70
|
|
69
71
|
version, @build_info = version.to_s.split("+") if version.to_s.include?("+")
|
@@ -71,6 +73,20 @@ module Dependabot
|
|
71
73
|
super(T.must(version))
|
72
74
|
end
|
73
75
|
|
76
|
+
sig { params(version: VersionParameter).returns(VersionParameter) }
|
77
|
+
def clean_version(version)
|
78
|
+
# Check if version is a string before attempting to match
|
79
|
+
if version.is_a?(String)
|
80
|
+
# Matches @ followed by x.y.z (digits separated by dots)
|
81
|
+
if (match = version.match(/@(\d+\.\d+\.\d+)/))
|
82
|
+
version = match[1] # Just "4.5.3"
|
83
|
+
end
|
84
|
+
version = version&.gsub(/^v/, "")
|
85
|
+
end
|
86
|
+
|
87
|
+
version
|
88
|
+
end
|
89
|
+
|
74
90
|
sig { override.params(version: VersionParameter).returns(Dependabot::NpmAndYarn::Version) }
|
75
91
|
def self.new(version)
|
76
92
|
T.cast(super, Dependabot::NpmAndYarn::Version)
|
@@ -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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-npm_and_yarn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.293.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dependabot-common
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.293.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.293.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: debug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -306,15 +306,18 @@ files:
|
|
306
306
|
- helpers/test/yarn/helpers.js
|
307
307
|
- helpers/test/yarn/updater.test.js
|
308
308
|
- lib/dependabot/npm_and_yarn.rb
|
309
|
+
- lib/dependabot/npm_and_yarn/bun_package_manager.rb
|
309
310
|
- lib/dependabot/npm_and_yarn/dependency_files_filterer.rb
|
310
311
|
- lib/dependabot/npm_and_yarn/file_fetcher.rb
|
311
312
|
- lib/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder.rb
|
312
313
|
- lib/dependabot/npm_and_yarn/file_parser.rb
|
314
|
+
- lib/dependabot/npm_and_yarn/file_parser/bun_lock.rb
|
313
315
|
- lib/dependabot/npm_and_yarn/file_parser/json_lock.rb
|
314
316
|
- lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb
|
315
317
|
- lib/dependabot/npm_and_yarn/file_parser/pnpm_lock.rb
|
316
318
|
- lib/dependabot/npm_and_yarn/file_parser/yarn_lock.rb
|
317
319
|
- lib/dependabot/npm_and_yarn/file_updater.rb
|
320
|
+
- lib/dependabot/npm_and_yarn/file_updater/bun_lockfile_updater.rb
|
318
321
|
- lib/dependabot/npm_and_yarn/file_updater/npm_lockfile_updater.rb
|
319
322
|
- lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb
|
320
323
|
- lib/dependabot/npm_and_yarn/file_updater/package_json_preparer.rb
|
@@ -322,10 +325,13 @@ files:
|
|
322
325
|
- lib/dependabot/npm_and_yarn/file_updater/pnpm_lockfile_updater.rb
|
323
326
|
- lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb
|
324
327
|
- lib/dependabot/npm_and_yarn/helpers.rb
|
328
|
+
- lib/dependabot/npm_and_yarn/language.rb
|
325
329
|
- lib/dependabot/npm_and_yarn/metadata_finder.rb
|
326
330
|
- lib/dependabot/npm_and_yarn/native_helpers.rb
|
331
|
+
- lib/dependabot/npm_and_yarn/npm_package_manager.rb
|
327
332
|
- lib/dependabot/npm_and_yarn/package_manager.rb
|
328
333
|
- lib/dependabot/npm_and_yarn/package_name.rb
|
334
|
+
- lib/dependabot/npm_and_yarn/pnpm_package_manager.rb
|
329
335
|
- lib/dependabot/npm_and_yarn/registry_helper.rb
|
330
336
|
- lib/dependabot/npm_and_yarn/registry_parser.rb
|
331
337
|
- lib/dependabot/npm_and_yarn/requirement.rb
|
@@ -342,12 +348,13 @@ files:
|
|
342
348
|
- lib/dependabot/npm_and_yarn/update_checker/vulnerability_auditor.rb
|
343
349
|
- lib/dependabot/npm_and_yarn/version.rb
|
344
350
|
- lib/dependabot/npm_and_yarn/version_selector.rb
|
351
|
+
- lib/dependabot/npm_and_yarn/yarn_package_manager.rb
|
345
352
|
homepage: https://github.com/dependabot/dependabot-core
|
346
353
|
licenses:
|
347
354
|
- MIT
|
348
355
|
metadata:
|
349
356
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
350
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
357
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.293.0
|
351
358
|
post_install_message:
|
352
359
|
rdoc_options: []
|
353
360
|
require_paths:
|
@@ -363,7 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
363
370
|
- !ruby/object:Gem::Version
|
364
371
|
version: 3.1.0
|
365
372
|
requirements: []
|
366
|
-
rubygems_version: 3.5.
|
373
|
+
rubygems_version: 3.5.22
|
367
374
|
signing_key:
|
368
375
|
specification_version: 4
|
369
376
|
summary: Provides Dependabot support for Javascript (npm and yarn)
|