dependabot-pub 0.176.0 → 0.177.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55f5860d255487229cc4277f0efc5cdc7811ca4e541ec722a9d657d4212b7f3e
4
- data.tar.gz: a263996e7b0081a8557a20ee97f20fc09635a88733c80c4250ba89611e81bf26
3
+ metadata.gz: 742728ff646203c67750c9afe88a12a5a0b65ca94757a4a7290fc720cbe97b61
4
+ data.tar.gz: b958908581ca1c23a7148343a212a2c4da8e6a4b1243088f5d6ca023f55a6cfe
5
5
  SHA512:
6
- metadata.gz: 3befba7ade7037906a01793ada0cb3736e101c689bb877486d151b8fcac1b6d5c041227b0a1360c9f823026ebcd0e86625d76fd309f15acc616b78cb4dc35b20
7
- data.tar.gz: 65555682c69b9360e6aa9a3ea82bda54047ebd245545289299aa59348f25796df749e235c6f18f114584139e1f7b2004771a8a3f564a49caaa3b5d9f1842eae3
6
+ metadata.gz: ce5d35e1b8ec8c54775c6c12560e15ac056018c26d8ab90bd4023a7c39acddfad24863435bda3a60498caf9797de044063fa893148a0288156092c71197b4d8d
7
+ data.tar.gz: a06f0276dfd6bdbfd1cdecd4b382091f434b2d33d5a0d148307f874150e8aa020a4bd3cf8e2ed264781be87e74dd952e2267f56fbd4cce788346ba3cd53d35aa
@@ -15,7 +15,7 @@ module Dependabot
15
15
  def parse
16
16
  dependency_set = DependencySet.new
17
17
  list.map do |d|
18
- dependency_set << to_dependency(d)
18
+ dependency_set << parse_listed_dependency(d)
19
19
  end
20
20
  dependency_set.dependencies.sort_by(&:name)
21
21
  end
@@ -60,6 +60,7 @@ module Dependabot
60
60
  stdout, stderr, status = Open3.capture3(
61
61
  env.compact,
62
62
  "dart",
63
+ "--root-certs-file=/etc/ssl/certs/ca-certificates.crt",
63
64
  "--no-analytics",
64
65
  "pub",
65
66
  "global",
@@ -77,13 +78,15 @@ module Dependabot
77
78
  end
78
79
  end
79
80
 
80
- def to_dependency(json)
81
+ # Parses a dependency as listed by `dependency_services list`.
82
+ def parse_listed_dependency(json)
81
83
  params = {
82
84
  name: json["name"],
83
85
  version: json["version"],
84
86
  package_manager: "pub",
85
87
  requirements: []
86
88
  }
89
+
87
90
  if json["kind"] != "transitive" && !json["constraint"].nil?
88
91
  constraint = json["constraint"]
89
92
  params[:requirements] << {
@@ -93,6 +96,33 @@ module Dependabot
93
96
  file: "pubspec.yaml"
94
97
  }
95
98
  end
99
+ Dependency.new(**params)
100
+ end
101
+
102
+ # Parses the updated dependencies returned by
103
+ # `dependency_services report`.
104
+ #
105
+ # The `requirements_update_strategy`` is
106
+ # used to chose the right updated constraint.
107
+ def parse_updated_dependency(json, requirements_update_strategy: nil)
108
+ params = {
109
+ name: json["name"],
110
+ version: json["version"],
111
+ package_manager: "pub",
112
+ requirements: []
113
+ }
114
+ constraint_field = constraint_field_from_update_strategy(requirements_update_strategy)
115
+
116
+ if json["kind"] != "transitive" && !json[constraint_field].nil?
117
+ constraint = json[constraint_field]
118
+ params[:requirements] << {
119
+ requirement: constraint,
120
+ groups: [json["kind"]],
121
+ source: nil, # TODO: Expose some information about the source
122
+ file: "pubspec.yaml"
123
+ }
124
+ end
125
+
96
126
  if json["previousVersion"]
97
127
  params = {
98
128
  **params,
@@ -112,6 +142,19 @@ module Dependabot
112
142
  Dependency.new(**params)
113
143
  end
114
144
 
145
+ # expects "auto" to already have been resolved to one of the other
146
+ # strategies.
147
+ def constraint_field_from_update_strategy(requirements_update_strategy)
148
+ case requirements_update_strategy
149
+ when "widen_ranges"
150
+ "constraintWidened"
151
+ when "bump_versions"
152
+ "constraintBumped"
153
+ when "bump_versions_if_necessary"
154
+ "constraintBumpedIfNeeded"
155
+ end
156
+ end
157
+
115
158
  def dependencies_to_json(dependencies)
116
159
  if dependencies.nil?
117
160
  nil
@@ -3,7 +3,7 @@
3
3
  require "dependabot/update_checkers"
4
4
  require "dependabot/update_checkers/base"
5
5
  require "dependabot/pub/helpers"
6
-
6
+ require "yaml"
7
7
  module Dependabot
8
8
  module Pub
9
9
  class UpdateChecker < Dependabot::UpdateCheckers::Base
@@ -49,7 +49,8 @@ module Dependabot
49
49
  entry = current_report["singleBreaking"].find { |d| d["name"] == dependency.name }
50
50
  return unless entry
51
51
 
52
- to_dependency(entry).requirements
52
+ parse_updated_dependency(entry, requirements_update_strategy: resolved_requirements_update_strategy).
53
+ requirements
53
54
  end
54
55
 
55
56
  private
@@ -67,7 +68,7 @@ module Dependabot
67
68
  d["kind"] == "transitive"
68
69
  end
69
70
  direct_deps.map do |d|
70
- to_dependency(d)
71
+ parse_updated_dependency(d, requirements_update_strategy: resolved_requirements_update_strategy)
71
72
  end
72
73
  end
73
74
 
@@ -78,6 +79,35 @@ module Dependabot
78
79
  def current_report
79
80
  report.find { |d| d["name"] == dependency.name }
80
81
  end
82
+
83
+ def resolved_requirements_update_strategy
84
+ @resolved_requirements_update_strategy ||= resolve_requirements_update_strategy
85
+ end
86
+
87
+ def resolve_requirements_update_strategy
88
+ raise "Unexpected requirements_update_strategy #{requirements_update_strategy}" unless
89
+ [nil, "widen_ranges", "bump_versions", "bump_versions_if_necessary"].include? requirements_update_strategy
90
+
91
+ if requirements_update_strategy.nil?
92
+ # Check for a version field in the pubspec.yaml. If it is present
93
+ # we assume the package is a library, and the requirement update
94
+ # strategy is widening. Otherwise we assume it is an application, and
95
+ # go for "bump_versions".
96
+ pubspec = dependency_files.find { |d| d.name == "pubspec.yaml" }
97
+ begin
98
+ parsed_pubspec = YAML.safe_load(pubspec.content, aliases: false)
99
+ rescue ScriptError
100
+ return "bump_versions"
101
+ end
102
+ if parsed_pubspec["version"].nil?
103
+ "bump_versions"
104
+ else
105
+ "widen_ranges"
106
+ end
107
+ else
108
+ requirements_update_strategy
109
+ end
110
+ end
81
111
  end
82
112
  end
83
113
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.176.0
4
+ version: 0.177.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-28 00:00:00.000000000 Z
11
+ date: 2022-03-04 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.176.0
19
+ version: 0.177.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.176.0
26
+ version: 0.177.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -198,7 +198,7 @@ homepage: https://github.com/dependabot/dependabot-core
198
198
  licenses:
199
199
  - Nonstandard
200
200
  metadata: {}
201
- post_install_message:
201
+ post_install_message:
202
202
  rdoc_options: []
203
203
  require_paths:
204
204
  - lib
@@ -213,8 +213,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  - !ruby/object:Gem::Version
214
214
  version: 2.5.0
215
215
  requirements: []
216
- rubygems_version: 3.1.4
217
- signing_key:
216
+ rubygems_version: 3.2.32
217
+ signing_key:
218
218
  specification_version: 4
219
219
  summary: Dart (pub) support for dependabot
220
220
  test_files: []