dependabot-npm_and_yarn 0.288.0 → 0.289.0
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/lib/dependabot/npm_and_yarn/file_fetcher.rb +28 -0
- data/lib/dependabot/npm_and_yarn/file_parser.rb +4 -2
- data/lib/dependabot/npm_and_yarn/helpers.rb +92 -3
- data/lib/dependabot/npm_and_yarn/package_manager.rb +178 -14
- data/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb +4 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b61a2e379cb066af66a91f9cbfd25d89755129946f7093b2e1d5be7f3642133
|
4
|
+
data.tar.gz: 10995493f890b53c62af1c14f7d29a165ee32096b8b84a529f0822984d6f1480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb1619f2f8ba90e8bbe7945c7b1e179abd09004b940c1d2514d9f4290a7679955ad0fcc0db26ebcb4b810c5903e4d66ddb3f3d0b3ca0a265c9636f34f272519
|
7
|
+
data.tar.gz: ae15d52f683156e2df0ddf213c254e0b9cd6e9324da8eda5367dae8d1c59629497739be437e3c76c6597ce9ccbbbd06509196ba9efad51240e3e98a9c99d91f4
|
@@ -107,6 +107,7 @@ module Dependabot
|
|
107
107
|
fetched_yarn_files << yarn_lock if yarn_lock
|
108
108
|
fetched_yarn_files << yarnrc if yarnrc
|
109
109
|
fetched_yarn_files << yarnrc_yml if yarnrc_yml
|
110
|
+
create_yarn_cache
|
110
111
|
fetched_yarn_files
|
111
112
|
end
|
112
113
|
|
@@ -244,6 +245,20 @@ module Dependabot
|
|
244
245
|
return @pnpm_lock if defined?(@pnpm_lock)
|
245
246
|
|
246
247
|
@pnpm_lock ||= T.let(fetch_file_if_present(PNPMPackageManager::LOCKFILE_NAME), T.nilable(DependencyFile))
|
248
|
+
|
249
|
+
return @pnpm_lock if @pnpm_lock || directory == "/"
|
250
|
+
|
251
|
+
# Loop through parent directories looking for a pnpm-lock
|
252
|
+
(1..directory.split("/").count).each do |i|
|
253
|
+
@pnpm_lock = fetch_file_from_host(("../" * i) + PNPMPackageManager::LOCKFILE_NAME)
|
254
|
+
.tap { |f| f.support_file = true }
|
255
|
+
break if @pnpm_lock
|
256
|
+
rescue Dependabot::DependencyFileNotFound
|
257
|
+
# Ignore errors (pnpm_lock.yaml may not be present)
|
258
|
+
nil
|
259
|
+
end
|
260
|
+
|
261
|
+
@pnpm_lock
|
247
262
|
end
|
248
263
|
|
249
264
|
sig { returns(T.nilable(DependencyFile)) }
|
@@ -655,6 +670,19 @@ module Dependabot
|
|
655
670
|
rescue JSON::ParserError
|
656
671
|
raise Dependabot::DependencyFileNotParseable, T.must(lerna_json).path
|
657
672
|
end
|
673
|
+
|
674
|
+
sig { void }
|
675
|
+
def create_yarn_cache
|
676
|
+
if repo_contents_path.nil?
|
677
|
+
Dependabot.logger.info("Repository contents path is nil")
|
678
|
+
elsif Dir.exist?(T.must(repo_contents_path))
|
679
|
+
Dir.chdir(T.must(repo_contents_path)) do
|
680
|
+
FileUtils.mkdir_p(".yarn/cache")
|
681
|
+
end
|
682
|
+
else
|
683
|
+
Dependabot.logger.info("Repository contents path does not exist")
|
684
|
+
end
|
685
|
+
end
|
658
686
|
end
|
659
687
|
end
|
660
688
|
end
|
@@ -11,6 +11,7 @@ require "dependabot/npm_and_yarn/helpers"
|
|
11
11
|
require "dependabot/npm_and_yarn/native_helpers"
|
12
12
|
require "dependabot/npm_and_yarn/version"
|
13
13
|
require "dependabot/npm_and_yarn/requirement"
|
14
|
+
require "dependabot/npm_and_yarn/package_manager"
|
14
15
|
require "dependabot/npm_and_yarn/registry_parser"
|
15
16
|
require "dependabot/git_metadata_fetcher"
|
16
17
|
require "dependabot/git_commit_checker"
|
@@ -83,7 +84,8 @@ module Dependabot
|
|
83
84
|
@ecosystem ||= T.let(
|
84
85
|
Ecosystem.new(
|
85
86
|
name: ECOSYSTEM,
|
86
|
-
package_manager: package_manager_helper.package_manager
|
87
|
+
package_manager: package_manager_helper.package_manager,
|
88
|
+
language: package_manager_helper.language
|
87
89
|
),
|
88
90
|
T.nilable(Ecosystem)
|
89
91
|
)
|
@@ -477,4 +479,4 @@ module Dependabot
|
|
477
479
|
end
|
478
480
|
|
479
481
|
Dependabot::FileParsers
|
480
|
-
.register(
|
482
|
+
.register(Dependabot::NpmAndYarn::ECOSYSTEM, Dependabot::NpmAndYarn::FileParser)
|
@@ -16,6 +16,7 @@ module Dependabot
|
|
16
16
|
/^.*(?<error>The "yarn-path" option has been set \(in [^)]+\), but the specified location doesn't exist)/
|
17
17
|
|
18
18
|
# NPM Version Constants
|
19
|
+
NPM_V10 = 10
|
19
20
|
NPM_V8 = 8
|
20
21
|
NPM_V6 = 6
|
21
22
|
NPM_DEFAULT_VERSION = NPM_V8
|
@@ -40,6 +41,10 @@ module Dependabot
|
|
40
41
|
# Otherwise, we are going to use old versionining npm 6
|
41
42
|
sig { params(lockfile: T.nilable(DependencyFile)).returns(Integer) }
|
42
43
|
def self.npm_version_numeric(lockfile)
|
44
|
+
if Dependabot::Experiments.enabled?(:enable_corepack_for_npm_and_yarn)
|
45
|
+
return npm_version_numeric_latest(lockfile)
|
46
|
+
end
|
47
|
+
|
43
48
|
fallback_version_npm8 = Dependabot::Experiments.enabled?(:npm_fallback_version_above_v6)
|
44
49
|
|
45
50
|
return npm_version_numeric_npm8_or_higher(lockfile) if fallback_version_npm8
|
@@ -91,6 +96,36 @@ module Dependabot
|
|
91
96
|
NPM_DEFAULT_VERSION # Fallback to default npm version if parsing fails
|
92
97
|
end
|
93
98
|
|
99
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
100
|
+
sig { params(lockfile: T.nilable(DependencyFile)).returns(Integer) }
|
101
|
+
def self.npm_version_numeric_latest(lockfile)
|
102
|
+
lockfile_content = lockfile&.content
|
103
|
+
|
104
|
+
# Return npm 10 as the default if the lockfile is missing or empty
|
105
|
+
return NPM_V10 if lockfile_content.nil? || lockfile_content.strip.empty?
|
106
|
+
|
107
|
+
# Parse the lockfile content to extract the `lockfileVersion`
|
108
|
+
parsed_lockfile = JSON.parse(lockfile_content)
|
109
|
+
lockfile_version = parsed_lockfile["lockfileVersion"]&.to_i
|
110
|
+
|
111
|
+
# Determine the appropriate npm version based on `lockfileVersion`
|
112
|
+
if lockfile_version.nil?
|
113
|
+
NPM_V10 # Use npm 10 if `lockfileVersion` is missing or nil
|
114
|
+
elsif lockfile_version >= 3
|
115
|
+
NPM_V10 # Use npm 10 for lockfileVersion 3 or higher
|
116
|
+
elsif lockfile_version >= 2
|
117
|
+
NPM_V8 # Use npm 8 for lockfileVersion 2
|
118
|
+
elsif lockfile_version >= 1
|
119
|
+
# Use npm 8 if the fallback version flag is enabled, otherwise use npm 6
|
120
|
+
Dependabot::Experiments.enabled?(:npm_fallback_version_above_v6) ? NPM_V8 : NPM_V6
|
121
|
+
else
|
122
|
+
NPM_V10 # Default to npm 10 for unexpected or unsupported versions
|
123
|
+
end
|
124
|
+
rescue JSON::ParserError
|
125
|
+
NPM_V8 # Fallback to npm 8 if the lockfile content cannot be parsed
|
126
|
+
end
|
127
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
128
|
+
|
94
129
|
sig { params(yarn_lock: T.nilable(DependencyFile)).returns(Integer) }
|
95
130
|
def self.yarn_version_numeric(yarn_lock)
|
96
131
|
lockfile_content = yarn_lock&.content
|
@@ -139,6 +174,10 @@ module Dependabot
|
|
139
174
|
def self.npm8?(package_lock)
|
140
175
|
return true unless package_lock&.content
|
141
176
|
|
177
|
+
if Dependabot::Experiments.enabled?(:enable_corepack_for_npm_and_yarn)
|
178
|
+
return npm_version_numeric_latest(package_lock) >= NPM_V8
|
179
|
+
end
|
180
|
+
|
142
181
|
npm_version_numeric(package_lock) == NPM_V8
|
143
182
|
end
|
144
183
|
|
@@ -284,6 +323,37 @@ module Dependabot
|
|
284
323
|
end
|
285
324
|
end
|
286
325
|
|
326
|
+
sig { returns(T.nilable(String)) }
|
327
|
+
def self.node_version
|
328
|
+
version = run_node_command("-v", fingerprint: "-v").strip
|
329
|
+
|
330
|
+
# Validate the output format (e.g., "v20.18.1" or "20.18.1")
|
331
|
+
if version.match?(/^v?\d+(\.\d+){2}$/)
|
332
|
+
version.strip.delete_prefix("v") # Remove the "v" prefix if present
|
333
|
+
end
|
334
|
+
rescue StandardError => e
|
335
|
+
puts "Error retrieving Node.js version: #{e.message}"
|
336
|
+
nil
|
337
|
+
end
|
338
|
+
|
339
|
+
sig { params(command: String, fingerprint: T.nilable(String)).returns(String) }
|
340
|
+
def self.run_node_command(command, fingerprint: nil)
|
341
|
+
full_command = "node #{command}"
|
342
|
+
|
343
|
+
Dependabot.logger.info("Running node command: #{full_command}")
|
344
|
+
|
345
|
+
result = Dependabot::SharedHelpers.run_shell_command(
|
346
|
+
full_command,
|
347
|
+
fingerprint: "node #{fingerprint || command}"
|
348
|
+
)
|
349
|
+
|
350
|
+
Dependabot.logger.info("Command executed successfully: #{full_command}")
|
351
|
+
result
|
352
|
+
rescue StandardError => e
|
353
|
+
Dependabot.logger.error("Error running node command: #{full_command}, Error: #{e.message}")
|
354
|
+
raise
|
355
|
+
end
|
356
|
+
|
287
357
|
# Setup yarn and run a single yarn command returning stdout/stderr
|
288
358
|
sig { params(command: String, fingerprint: T.nilable(String)).returns(String) }
|
289
359
|
def self.run_yarn_command(command, fingerprint: nil)
|
@@ -353,7 +423,15 @@ module Dependabot
|
|
353
423
|
# Get the version of the package manager by using corepack
|
354
424
|
sig { params(name: String).returns(String) }
|
355
425
|
def self.package_manager_version(name)
|
356
|
-
|
426
|
+
Dependabot.logger.info("Fetching version for package manager: #{name}")
|
427
|
+
|
428
|
+
version = package_manager_run_command(name, "-v").strip
|
429
|
+
|
430
|
+
Dependabot.logger.info("Version for #{name}: #{version}")
|
431
|
+
version
|
432
|
+
rescue StandardError => e
|
433
|
+
Dependabot.logger.error("Error fetching version for package manager #{name}: #{e.message}")
|
434
|
+
raise
|
357
435
|
end
|
358
436
|
|
359
437
|
# Run single command on package manager returning stdout/stderr
|
@@ -365,11 +443,22 @@ module Dependabot
|
|
365
443
|
).returns(String)
|
366
444
|
end
|
367
445
|
def self.package_manager_run_command(name, command, fingerprint: nil)
|
368
|
-
|
369
|
-
|
446
|
+
full_command = "corepack #{name} #{command}"
|
447
|
+
|
448
|
+
Dependabot.logger.info("Running package manager command: #{full_command}")
|
449
|
+
|
450
|
+
result = Dependabot::SharedHelpers.run_shell_command(
|
451
|
+
full_command,
|
370
452
|
fingerprint: "corepack #{name} #{fingerprint || command}"
|
371
453
|
).strip
|
454
|
+
|
455
|
+
Dependabot.logger.info("Command executed successfully: #{full_command}")
|
456
|
+
result
|
457
|
+
rescue StandardError => e
|
458
|
+
Dependabot.logger.error("Error running package manager command: #{full_command}, Error: #{e.message}")
|
459
|
+
raise
|
372
460
|
end
|
461
|
+
|
373
462
|
private_class_method :run_single_yarn_command
|
374
463
|
|
375
464
|
sig { params(pnpm_lock: DependencyFile).returns(T.nilable(String)) }
|
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require "dependabot/shared_helpers"
|
5
5
|
require "dependabot/ecosystem"
|
6
|
+
require "dependabot/npm_and_yarn/requirement"
|
6
7
|
require "dependabot/npm_and_yarn/version_selector"
|
7
8
|
|
8
9
|
module Dependabot
|
@@ -10,7 +11,37 @@ module Dependabot
|
|
10
11
|
ECOSYSTEM = "npm_and_yarn"
|
11
12
|
MANIFEST_FILENAME = "package.json"
|
12
13
|
LERNA_JSON_FILENAME = "lerna.json"
|
13
|
-
PACKAGE_MANAGER_VERSION_REGEX =
|
14
|
+
PACKAGE_MANAGER_VERSION_REGEX = /
|
15
|
+
^ # Start of string
|
16
|
+
(?<major>\d+) # Major version (required, numeric)
|
17
|
+
\. # Separator between major and minor versions
|
18
|
+
(?<minor>\d+) # Minor version (required, numeric)
|
19
|
+
\. # Separator between minor and patch versions
|
20
|
+
(?<patch>\d+) # Patch version (required, numeric)
|
21
|
+
( # Start pre-release section
|
22
|
+
-(?<pre_release>[a-zA-Z0-9.]+) # Pre-release label (optional, alphanumeric or dot-separated)
|
23
|
+
)?
|
24
|
+
( # Start build metadata section
|
25
|
+
\+(?<build>[a-zA-Z0-9.]+) # Build metadata (optional, alphanumeric or dot-separated)
|
26
|
+
)?
|
27
|
+
$ # End of string
|
28
|
+
/x # Extended mode for readability
|
29
|
+
|
30
|
+
VALID_REQUIREMENT_CONSTRAINT = /
|
31
|
+
^ # Start of string
|
32
|
+
(?<operator>=|>|>=|<|<=|~>|\\^) # Allowed operators
|
33
|
+
\s* # Optional whitespace
|
34
|
+
(?<major>\d+) # Major version (required)
|
35
|
+
(\.(?<minor>\d+))? # Minor version (optional)
|
36
|
+
(\.(?<patch>\d+))? # Patch version (optional)
|
37
|
+
( # Start pre-release section
|
38
|
+
-(?<pre_release>[a-zA-Z0-9.]+) # Pre-release label (optional)
|
39
|
+
)?
|
40
|
+
( # Start build metadata section
|
41
|
+
\+(?<build>[a-zA-Z0-9.]+) # Build metadata (optional)
|
42
|
+
)?
|
43
|
+
$ # End of string
|
44
|
+
/x # Extended mode for readability
|
14
45
|
|
15
46
|
MANIFEST_PACKAGE_MANAGER_KEY = "packageManager"
|
16
47
|
MANIFEST_ENGINES_KEY = "engines"
|
@@ -26,24 +57,32 @@ module Dependabot
|
|
26
57
|
NPM_V7 = "7"
|
27
58
|
NPM_V8 = "8"
|
28
59
|
NPM_V9 = "9"
|
60
|
+
NPM_V10 = "10"
|
29
61
|
|
30
62
|
# Keep versions in ascending order
|
31
63
|
SUPPORTED_VERSIONS = T.let([
|
32
64
|
Version.new(NPM_V6),
|
33
65
|
Version.new(NPM_V7),
|
34
66
|
Version.new(NPM_V8),
|
35
|
-
Version.new(NPM_V9)
|
67
|
+
Version.new(NPM_V9),
|
68
|
+
Version.new(NPM_V10)
|
36
69
|
].freeze, T::Array[Dependabot::Version])
|
37
70
|
|
38
71
|
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
39
72
|
|
40
|
-
sig
|
41
|
-
|
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)
|
42
80
|
super(
|
43
81
|
NAME,
|
44
82
|
Version.new(raw_version),
|
45
83
|
DEPRECATED_VERSIONS,
|
46
|
-
SUPPORTED_VERSIONS
|
84
|
+
SUPPORTED_VERSIONS,
|
85
|
+
requirement
|
47
86
|
)
|
48
87
|
end
|
49
88
|
|
@@ -77,13 +116,19 @@ module Dependabot
|
|
77
116
|
|
78
117
|
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
79
118
|
|
80
|
-
sig
|
81
|
-
|
119
|
+
sig do
|
120
|
+
params(
|
121
|
+
raw_version: String,
|
122
|
+
requirement: T.nilable(Requirement)
|
123
|
+
).void
|
124
|
+
end
|
125
|
+
def initialize(raw_version, requirement: nil)
|
82
126
|
super(
|
83
127
|
NAME,
|
84
128
|
Version.new(raw_version),
|
85
129
|
DEPRECATED_VERSIONS,
|
86
|
-
SUPPORTED_VERSIONS
|
130
|
+
SUPPORTED_VERSIONS,
|
131
|
+
requirement
|
87
132
|
)
|
88
133
|
end
|
89
134
|
|
@@ -116,13 +161,19 @@ module Dependabot
|
|
116
161
|
|
117
162
|
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
118
163
|
|
119
|
-
sig
|
120
|
-
|
164
|
+
sig do
|
165
|
+
params(
|
166
|
+
raw_version: String,
|
167
|
+
requirement: T.nilable(Requirement)
|
168
|
+
).void
|
169
|
+
end
|
170
|
+
def initialize(raw_version, requirement: nil)
|
121
171
|
super(
|
122
172
|
NAME,
|
123
173
|
Version.new(raw_version),
|
124
174
|
DEPRECATED_VERSIONS,
|
125
|
-
SUPPORTED_VERSIONS
|
175
|
+
SUPPORTED_VERSIONS,
|
176
|
+
requirement
|
126
177
|
)
|
127
178
|
end
|
128
179
|
|
@@ -175,7 +226,20 @@ module Dependabot
|
|
175
226
|
# Defaults to npm if no package manager is detected
|
176
227
|
sig { returns(String) }
|
177
228
|
def detect_package_manager
|
178
|
-
|
229
|
+
package_manager = name_from_lockfiles ||
|
230
|
+
name_from_package_manager_attr ||
|
231
|
+
name_from_engines
|
232
|
+
|
233
|
+
if package_manager
|
234
|
+
Dependabot.logger.info("Detected package manager: #{package_manager}")
|
235
|
+
else
|
236
|
+
package_manager = DEFAULT_PACKAGE_MANAGER
|
237
|
+
Dependabot.logger.info("Default package manager used: #{package_manager}")
|
238
|
+
end
|
239
|
+
package_manager
|
240
|
+
rescue StandardError => e
|
241
|
+
Dependabot.logger.error("Error detecting package manager: #{e.message}")
|
242
|
+
DEFAULT_PACKAGE_MANAGER
|
179
243
|
end
|
180
244
|
|
181
245
|
private
|
@@ -205,6 +269,41 @@ module Dependabot
|
|
205
269
|
end
|
206
270
|
end
|
207
271
|
|
272
|
+
class Language < Ecosystem::VersionManager
|
273
|
+
extend T::Sig
|
274
|
+
NAME = "node"
|
275
|
+
|
276
|
+
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
277
|
+
|
278
|
+
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
279
|
+
|
280
|
+
sig do
|
281
|
+
params(
|
282
|
+
raw_version: T.nilable(String),
|
283
|
+
requirement: T.nilable(Requirement)
|
284
|
+
).void
|
285
|
+
end
|
286
|
+
def initialize(raw_version, requirement: nil)
|
287
|
+
super(
|
288
|
+
NAME,
|
289
|
+
Version.new(raw_version),
|
290
|
+
DEPRECATED_VERSIONS,
|
291
|
+
SUPPORTED_VERSIONS,
|
292
|
+
requirement
|
293
|
+
)
|
294
|
+
end
|
295
|
+
|
296
|
+
sig { override.returns(T::Boolean) }
|
297
|
+
def deprecated?
|
298
|
+
false
|
299
|
+
end
|
300
|
+
|
301
|
+
sig { override.returns(T::Boolean) }
|
302
|
+
def unsupported?
|
303
|
+
false
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
208
307
|
class PackageManagerHelper
|
209
308
|
extend T::Sig
|
210
309
|
extend T::Helpers
|
@@ -223,6 +322,9 @@ module Dependabot
|
|
223
322
|
@engines = T.let(package_json&.fetch(MANIFEST_ENGINES_KEY, nil), T.nilable(T::Hash[String, T.untyped]))
|
224
323
|
|
225
324
|
@installed_versions = T.let({}, T::Hash[String, String])
|
325
|
+
|
326
|
+
@language = T.let(nil, T.nilable(Ecosystem::VersionManager))
|
327
|
+
@language_requirement = T.let(nil, T.nilable(Requirement))
|
226
328
|
end
|
227
329
|
|
228
330
|
sig { returns(Ecosystem::VersionManager) }
|
@@ -232,6 +334,50 @@ module Dependabot
|
|
232
334
|
)
|
233
335
|
end
|
234
336
|
|
337
|
+
sig { returns(Ecosystem::VersionManager) }
|
338
|
+
def language
|
339
|
+
@language ||= Language.new(
|
340
|
+
Helpers.node_version,
|
341
|
+
requirement: language_requirement
|
342
|
+
)
|
343
|
+
end
|
344
|
+
|
345
|
+
sig { returns(T.nilable(Requirement)) }
|
346
|
+
def language_requirement
|
347
|
+
@language_requirement ||= find_engine_constraints_as_requirement(Language::NAME)
|
348
|
+
end
|
349
|
+
|
350
|
+
sig { params(name: String).returns(T.nilable(Requirement)) }
|
351
|
+
def find_engine_constraints_as_requirement(name)
|
352
|
+
Dependabot.logger.info("Processing engine constraints for #{name}")
|
353
|
+
|
354
|
+
return nil unless @engines.is_a?(Hash) && @engines[name]
|
355
|
+
|
356
|
+
raw_constraint = @engines[name].to_s.strip
|
357
|
+
return nil if raw_constraint.empty?
|
358
|
+
|
359
|
+
raw_constraints = raw_constraint.split
|
360
|
+
constraints = raw_constraints.map do |constraint|
|
361
|
+
case constraint
|
362
|
+
when /^\d+$/
|
363
|
+
">=#{constraint}.0.0 <#{constraint.to_i + 1}.0.0"
|
364
|
+
when /^\d+\.\d+$/
|
365
|
+
">=#{constraint} <#{constraint.split('.').first.to_i + 1}.0.0"
|
366
|
+
when /^\d+\.\d+\.\d+$/
|
367
|
+
"=#{constraint}"
|
368
|
+
else
|
369
|
+
Dependabot.logger.warn("Unrecognized constraint format for #{name}: #{constraint}")
|
370
|
+
constraint
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
Dependabot.logger.info("Parsed constraints for #{name}: #{constraints.join(', ')}")
|
375
|
+
Requirement.new(constraints)
|
376
|
+
rescue StandardError => e
|
377
|
+
Dependabot.logger.error("Error processing constraints for #{name}: #{e.message}")
|
378
|
+
nil
|
379
|
+
end
|
380
|
+
|
235
381
|
# rubocop:disable Metrics/CyclomaticComplexity
|
236
382
|
# rubocop:disable Metrics/PerceivedComplexity
|
237
383
|
# rubocop:disable Metrics/AbcSize
|
@@ -295,13 +441,31 @@ module Dependabot
|
|
295
441
|
|
296
442
|
sig { params(name: T.nilable(String)).returns(Ecosystem::VersionManager) }
|
297
443
|
def package_manager_by_name(name)
|
298
|
-
name
|
444
|
+
Dependabot.logger.info("Resolving package manager for: #{name || 'default'}")
|
299
445
|
|
446
|
+
name = ensure_valid_package_manager(name)
|
300
447
|
package_manager_class = T.must(PACKAGE_MANAGER_CLASSES[name])
|
301
448
|
|
302
449
|
installed_version = installed_version(name)
|
450
|
+
Dependabot.logger.info("Installed version for #{name}: #{installed_version}")
|
451
|
+
|
452
|
+
package_manager_requirement = find_engine_constraints_as_requirement(name)
|
453
|
+
if package_manager_requirement
|
454
|
+
Dependabot.logger.info("Version requirement for #{name}: #{package_manager_requirement}")
|
455
|
+
else
|
456
|
+
Dependabot.logger.info("No version requirement found for #{name}")
|
457
|
+
end
|
458
|
+
|
459
|
+
package_manager_instance = package_manager_class.new(
|
460
|
+
installed_version,
|
461
|
+
requirement: package_manager_requirement
|
462
|
+
)
|
303
463
|
|
304
|
-
|
464
|
+
Dependabot.logger.info("Package manager resolved for #{name}: #{package_manager_instance}")
|
465
|
+
package_manager_instance
|
466
|
+
rescue StandardError => e
|
467
|
+
Dependabot.logger.error("Error resolving package manager for #{name || 'default'}: #{e.message}")
|
468
|
+
raise
|
305
469
|
end
|
306
470
|
|
307
471
|
# rubocop:enable Metrics/CyclomaticComplexity
|
@@ -70,8 +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 Helpers.npm8?(lockfile)
|
74
|
-
|
73
|
+
elsif !Helpers.npm8?(lockfile)
|
74
|
+
run_npm6_updater(path, lockfile_name)
|
75
75
|
else
|
76
76
|
run_npm_updater(path, lockfile_name)
|
77
77
|
end
|
@@ -143,7 +143,7 @@ module Dependabot
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
def
|
146
|
+
def run_npm_updater(path, lockfile_name)
|
147
147
|
SharedHelpers.with_git_configured(credentials: credentials) do
|
148
148
|
Dir.chdir(path) do
|
149
149
|
NativeHelpers.run_npm8_subdependency_update_command([dependency.name])
|
@@ -153,7 +153,7 @@ module Dependabot
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
def
|
156
|
+
def run_npm6_updater(path, lockfile_name)
|
157
157
|
SharedHelpers.with_git_configured(credentials: credentials) do
|
158
158
|
Dir.chdir(path) do
|
159
159
|
SharedHelpers.run_helper_subprocess(
|
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.289.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-05 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.289.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.289.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: debug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -346,7 +346,7 @@ licenses:
|
|
346
346
|
- MIT
|
347
347
|
metadata:
|
348
348
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
349
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
349
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.289.0
|
350
350
|
post_install_message:
|
351
351
|
rdoc_options: []
|
352
352
|
require_paths:
|