dependabot-npm_and_yarn 0.293.0 → 0.295.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "dependabot/shared_helpers"
5
+ require "dependabot/npm_and_yarn/constraint_helper"
5
6
 
6
7
  module Dependabot
7
8
  module NpmAndYarn
@@ -13,18 +14,42 @@ module Dependabot
13
14
  # such as "20.8.7", "8.1.2", "8.21.2",
14
15
  NODE_ENGINE_SUPPORTED_REGEX = /^\d+(?:\.\d+)*$/
15
16
 
16
- sig { params(manifest_json: T::Hash[String, T.untyped], name: String).returns(T::Hash[Symbol, T.untyped]) }
17
- def setup(manifest_json, name)
17
+ # Sets up engine versions from the given manifest JSON.
18
+ #
19
+ # @param manifest_json [Hash] The manifest JSON containing version information.
20
+ # @param name [String] The engine name to match.
21
+ # @return [Hash] A hash with selected versions, if found.
22
+ sig do
23
+ params(
24
+ manifest_json: T::Hash[String, T.untyped],
25
+ name: String,
26
+ dependabot_versions: T.nilable(T::Array[Dependabot::Version])
27
+ )
28
+ .returns(T::Hash[Symbol, T.untyped])
29
+ end
30
+ def setup(manifest_json, name, dependabot_versions = nil)
18
31
  engine_versions = manifest_json["engines"]
19
32
 
33
+ # Return an empty hash if no engine versions are specified
20
34
  return {} if engine_versions.nil?
21
35
 
22
- # Only keep matching specs versions i.e. "20.21.2", "7.1.2",
23
- # Additional specs can be added later
24
- engine_versions.delete_if { |_key, value| !valid_extracted_version?(value) }
25
- version = engine_versions.select { |engine, _value| engine.to_s.match(name) }
36
+ versions = {}
37
+
38
+ if Dependabot::Experiments.enabled?(:enable_engine_version_detection)
39
+ engine_versions.each do |engine, value|
40
+ next unless engine.to_s.match(name)
41
+
42
+ versions[name] = ConstraintHelper.find_highest_version_from_constraint_expression(
43
+ value, dependabot_versions
44
+ )
45
+ end
46
+ else
47
+ versions = engine_versions.select do |engine, value|
48
+ engine.to_s.match(name) && valid_extracted_version?(value)
49
+ end
50
+ end
26
51
 
27
- version
52
+ versions
28
53
  end
29
54
 
30
55
  sig { params(version: String).returns(T::Boolean) }
@@ -146,6 +146,10 @@ module Dependabot
146
146
  # if not package found with specified version
147
147
  YARN_PACKAGE_NOT_FOUND = /MessageError: Couldn't find any versions for "(?<pkg>.*?)" that matches "(?<ver>.*?)"/
148
148
 
149
+ YN0001_DEPS_RESOLUTION_FAILED = T.let({
150
+ DEPS_INCORRECT_MET: /peer dependencies are incorrectly met/
151
+ }.freeze, T::Hash[String, Regexp])
152
+
149
153
  YN0001_FILE_NOT_RESOLVED_CODES = T.let({
150
154
  FIND_PACKAGE_LOCATION: /YN0001:(.*?)UsageError: Couldn't find the (?<pkg>.*) state file/,
151
155
  NO_CANDIDATE_FOUND: /YN0001:(.*?)Error: (?<pkg>.*): No candidates found/,
@@ -165,6 +169,8 @@ module Dependabot
165
169
  REQUIREMENT_NOT_PROVIDED: /(?<dep>.*)(.*?)doesn't provide (?<pkg>.*)(.*?), requested by (?<parent>.*)/
166
170
  }.freeze, T::Hash[String, Regexp])
167
171
 
172
+ YN0086_DEPS_RESOLUTION_FAILED = /peer dependencies are incorrectly met/
173
+
168
174
  # registry returns malformed response
169
175
  REGISTRY_NOT_REACHABLE = /Received malformed response from registry for "(?<ver>.*)". The registry may be down./
170
176
 
@@ -227,6 +233,12 @@ module Dependabot
227
233
  end
228
234
  end
229
235
 
236
+ YN0001_DEPS_RESOLUTION_FAILED.each do |(_yn0001_key, yn0001_regex)|
237
+ if (msg = message.match(yn0001_regex))
238
+ return Dependabot::DependencyFileNotResolvable.new(msg)
239
+ end
240
+ end
241
+
230
242
  Dependabot::DependabotError.new(message)
231
243
  }
232
244
  },
@@ -351,6 +363,13 @@ module Dependabot
351
363
  Dependabot::DependencyNotFound.new(message)
352
364
  end
353
365
  }
366
+ },
367
+ "YN0086" => {
368
+ message: "deps resolution failed",
369
+ handler: lambda { |message, _error, _params|
370
+ msg = message.match(YN0086_DEPS_RESOLUTION_FAILED)
371
+ Dependabot::DependencyFileNotResolvable.new(msg || message)
372
+ }
354
373
  }
355
374
  }.freeze, T::Hash[String, {
356
375
  message: T.any(String, NilClass),
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.293.0
4
+ version: 0.295.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-16 00:00:00.000000000 Z
11
+ date: 2025-01-30 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.293.0
19
+ version: 0.295.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.293.0
26
+ version: 0.295.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -307,6 +307,7 @@ files:
307
307
  - helpers/test/yarn/updater.test.js
308
308
  - lib/dependabot/npm_and_yarn.rb
309
309
  - lib/dependabot/npm_and_yarn/bun_package_manager.rb
310
+ - lib/dependabot/npm_and_yarn/constraint_helper.rb
310
311
  - lib/dependabot/npm_and_yarn/dependency_files_filterer.rb
311
312
  - lib/dependabot/npm_and_yarn/file_fetcher.rb
312
313
  - lib/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder.rb
@@ -323,6 +324,7 @@ files:
323
324
  - lib/dependabot/npm_and_yarn/file_updater/package_json_preparer.rb
324
325
  - lib/dependabot/npm_and_yarn/file_updater/package_json_updater.rb
325
326
  - lib/dependabot/npm_and_yarn/file_updater/pnpm_lockfile_updater.rb
327
+ - lib/dependabot/npm_and_yarn/file_updater/pnpm_workspace_updater.rb
326
328
  - lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb
327
329
  - lib/dependabot/npm_and_yarn/helpers.rb
328
330
  - lib/dependabot/npm_and_yarn/language.rb
@@ -354,7 +356,7 @@ licenses:
354
356
  - MIT
355
357
  metadata:
356
358
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
357
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.293.0
359
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.295.0
358
360
  post_install_message:
359
361
  rdoc_options: []
360
362
  require_paths: