dependabot-common 0.272.0 → 0.273.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/notices.rb +91 -49
- data/lib/dependabot/pull_request_creator/message_builder.rb +1 -2
- data/lib/dependabot.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0c28765d665424088cb737d933cf376c29d931e1d642f96562d362c406fcf0
|
4
|
+
data.tar.gz: de8f912ee099ed27b8d14811f7fb67f9b83119dc7db2483645947b2cd12b380d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e45c119606e121da9f919de9e40ff1ae63e22ad0167308bcb1e74b626296607fa8d05634ccb7ac922943d547c0f99820fab5c89fe105580146b5dc2224fbd97a
|
7
|
+
data.tar.gz: 2bc6a5d526316d9d81cbfb0e03d06699a28e03757ff36f07a46d870a1e55a89794ffd834f3c1c8e21c7ccf737ed325bc1af111a2e22234641c54e1bb9d8cd56b
|
data/lib/dependabot/notices.rb
CHANGED
@@ -6,32 +6,51 @@ require "dependabot/package_manager"
|
|
6
6
|
|
7
7
|
module Dependabot
|
8
8
|
class Notice
|
9
|
+
module NoticeMode
|
10
|
+
INFO = "INFO"
|
11
|
+
WARN = "WARN"
|
12
|
+
ERROR = "ERROR"
|
13
|
+
end
|
14
|
+
|
9
15
|
extend T::Sig
|
10
16
|
|
11
17
|
sig { returns(String) }
|
12
|
-
attr_reader :mode, :type, :package_manager_name, :
|
18
|
+
attr_reader :mode, :type, :package_manager_name, :title, :description
|
19
|
+
|
20
|
+
sig { returns(T::Boolean) }
|
21
|
+
attr_reader :show_in_pr, :show_alert
|
13
22
|
|
14
23
|
# Initializes a new Notice object.
|
15
24
|
# @param mode [String] The mode of the notice (e.g., "WARN", "ERROR").
|
16
25
|
# @param type [String] The type of the notice (e.g., "bundler_deprecated_warn").
|
17
26
|
# @param package_manager_name [String] The name of the package manager (e.g., "bundler").
|
18
|
-
# @param
|
19
|
-
# @param
|
27
|
+
# @param title [String] The title of the notice.
|
28
|
+
# @param description [String] The main description of the notice.
|
29
|
+
# @param show_in_pr [Boolean] Whether the notice should be shown in a pull request.
|
30
|
+
# @param show_alert [Boolean] Whether the notice should be shown in alerts.
|
20
31
|
sig do
|
21
32
|
params(
|
22
33
|
mode: String,
|
23
34
|
type: String,
|
24
35
|
package_manager_name: String,
|
25
|
-
|
26
|
-
|
36
|
+
title: String,
|
37
|
+
description: String,
|
38
|
+
show_in_pr: T::Boolean,
|
39
|
+
show_alert: T::Boolean
|
27
40
|
).void
|
28
41
|
end
|
29
|
-
def initialize(
|
42
|
+
def initialize(
|
43
|
+
mode:, type:, package_manager_name:,
|
44
|
+
title: "", description: "",
|
45
|
+
show_in_pr: false, show_alert: false
|
46
|
+
)
|
30
47
|
@mode = mode
|
31
48
|
@type = type
|
32
49
|
@package_manager_name = package_manager_name
|
33
|
-
@
|
34
|
-
@
|
50
|
+
@title = title
|
51
|
+
@description = description
|
52
|
+
@show_in_pr = show_in_pr
|
53
|
+
@show_alert = show_alert
|
35
54
|
end
|
36
55
|
|
37
56
|
# Converts the Notice object to a hash.
|
@@ -42,23 +61,25 @@ module Dependabot
|
|
42
61
|
mode: @mode,
|
43
62
|
type: @type,
|
44
63
|
package_manager_name: @package_manager_name,
|
45
|
-
|
46
|
-
|
64
|
+
title: @title,
|
65
|
+
description: @description,
|
66
|
+
show_in_pr: @show_in_pr,
|
67
|
+
show_alert: @show_alert
|
47
68
|
}
|
48
69
|
end
|
49
70
|
|
50
|
-
# Generates a
|
71
|
+
# Generates a description for supported versions.
|
51
72
|
# @param supported_versions [Array<Dependabot::Version>, nil] The supported versions of the package manager.
|
52
73
|
# @param support_later_versions [Boolean] Whether later versions are supported.
|
53
|
-
# @return [String, nil] The generated
|
74
|
+
# @return [String, nil] The generated description or nil if no supported versions are provided.
|
54
75
|
sig do
|
55
76
|
params(
|
56
77
|
supported_versions: T.nilable(T::Array[Dependabot::Version]),
|
57
78
|
support_later_versions: T::Boolean
|
58
79
|
).returns(String)
|
59
80
|
end
|
60
|
-
def self.
|
61
|
-
return "" unless supported_versions&.any?
|
81
|
+
def self.generate_supported_versions_description(supported_versions, support_later_versions)
|
82
|
+
return "Please upgrade your package manager version" unless supported_versions&.any?
|
62
83
|
|
63
84
|
versions_string = supported_versions.map { |version| "`v#{version}`" }
|
64
85
|
|
@@ -66,11 +87,11 @@ module Dependabot
|
|
66
87
|
|
67
88
|
versions_string = versions_string.join(", ")
|
68
89
|
|
69
|
-
|
90
|
+
later_description = support_later_versions ? ", or later" : ""
|
70
91
|
|
71
|
-
return "Please upgrade to version #{versions_string}#{
|
92
|
+
return "Please upgrade to version #{versions_string}#{later_description}." if supported_versions.count == 1
|
72
93
|
|
73
|
-
"Please upgrade to one of the following versions: #{versions_string}#{
|
94
|
+
"Please upgrade to one of the following versions: #{versions_string}#{later_description}."
|
74
95
|
end
|
75
96
|
|
76
97
|
# Generates a support notice for the given package manager.
|
@@ -100,30 +121,26 @@ module Dependabot
|
|
100
121
|
def self.generate_pm_deprecation_notice(package_manager)
|
101
122
|
return nil unless package_manager.deprecated?
|
102
123
|
|
103
|
-
mode =
|
104
|
-
|
124
|
+
mode = NoticeMode::WARN
|
125
|
+
supported_versions_description = generate_supported_versions_description(
|
105
126
|
package_manager.supported_versions,
|
106
127
|
package_manager.support_later_versions?
|
107
128
|
)
|
108
|
-
notice_type = "#{package_manager.name}
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
## Add the
|
113
|
-
|
114
|
-
|
115
|
-
## Add the supported versions to the message
|
116
|
-
unless supported_versions_message.empty?
|
117
|
-
message += "\n#{supported_versions_message}\n"
|
118
|
-
markdown += "> #{supported_versions_message}\n>\n"
|
119
|
-
end
|
129
|
+
notice_type = "#{package_manager.name}_deprecated_warn"
|
130
|
+
title = "Package manager deprecation notice"
|
131
|
+
description = "Dependabot will stop supporting `#{package_manager.name} v#{package_manager.version}`!"
|
132
|
+
|
133
|
+
## Add the supported versions to the description
|
134
|
+
description += "\n\n#{supported_versions_description}\n" unless supported_versions_description.empty?
|
120
135
|
|
121
136
|
Notice.new(
|
122
137
|
mode: mode,
|
123
138
|
type: notice_type,
|
124
139
|
package_manager_name: package_manager.name,
|
125
|
-
|
126
|
-
|
140
|
+
title: title,
|
141
|
+
description: description,
|
142
|
+
show_in_pr: true,
|
143
|
+
show_alert: true
|
127
144
|
)
|
128
145
|
end
|
129
146
|
|
@@ -138,31 +155,56 @@ module Dependabot
|
|
138
155
|
def self.generate_pm_unsupported_notice(package_manager)
|
139
156
|
return nil unless package_manager.unsupported?
|
140
157
|
|
141
|
-
mode =
|
142
|
-
|
158
|
+
mode = NoticeMode::ERROR
|
159
|
+
supported_versions_description = generate_supported_versions_description(
|
143
160
|
package_manager.supported_versions,
|
144
161
|
package_manager.support_later_versions?
|
145
162
|
)
|
146
|
-
notice_type = "#{package_manager.name}
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
## Add the
|
151
|
-
|
152
|
-
|
153
|
-
## Add the supported versions to the message
|
154
|
-
unless supported_versions_message.empty?
|
155
|
-
message += "\n#{supported_versions_message}\n"
|
156
|
-
markdown += "> #{supported_versions_message}\n>\n"
|
157
|
-
end
|
163
|
+
notice_type = "#{package_manager.name}_unsupported_error"
|
164
|
+
title = "Package manager unsupported notice"
|
165
|
+
description = "Dependabot no longer supports `#{package_manager.name} v#{package_manager.version}`!"
|
166
|
+
|
167
|
+
## Add the supported versions to the description
|
168
|
+
description += "\n\n#{supported_versions_description}\n" unless supported_versions_description.empty?
|
158
169
|
|
159
170
|
Notice.new(
|
160
171
|
mode: mode,
|
161
172
|
type: notice_type,
|
162
173
|
package_manager_name: package_manager.name,
|
163
|
-
|
164
|
-
|
174
|
+
title: title,
|
175
|
+
description: description,
|
176
|
+
show_in_pr: true,
|
177
|
+
show_alert: true
|
165
178
|
)
|
166
179
|
end
|
180
|
+
|
181
|
+
sig { params(notice: Notice).returns(T.nilable(String)) }
|
182
|
+
def self.markdown_from_description(notice)
|
183
|
+
description = notice.description
|
184
|
+
|
185
|
+
return if description.empty?
|
186
|
+
|
187
|
+
markdown = "> [!#{markdown_mode(notice.mode)}]\n"
|
188
|
+
# Log each non-empty line of the deprecation notice description
|
189
|
+
description.each_line do |line|
|
190
|
+
line = line.strip
|
191
|
+
markdown += "> #{line}\n"
|
192
|
+
end
|
193
|
+
markdown
|
194
|
+
end
|
195
|
+
|
196
|
+
sig { params(mode: String).returns(String) }
|
197
|
+
def self.markdown_mode(mode)
|
198
|
+
case mode
|
199
|
+
when NoticeMode::INFO
|
200
|
+
"INFO"
|
201
|
+
when NoticeMode::WARN
|
202
|
+
"WARNING"
|
203
|
+
when NoticeMode::ERROR
|
204
|
+
"IMPORTANT"
|
205
|
+
else
|
206
|
+
"INFO"
|
207
|
+
end
|
208
|
+
end
|
167
209
|
end
|
168
210
|
end
|
@@ -143,8 +143,7 @@ module Dependabot
|
|
143
143
|
def pr_notices
|
144
144
|
notices = @notices || []
|
145
145
|
unique_messages = notices.filter_map do |notice|
|
146
|
-
|
147
|
-
markdown unless markdown.empty?
|
146
|
+
Dependabot::Notice.markdown_from_description(notice) if notice.show_in_pr
|
148
147
|
end.uniq
|
149
148
|
|
150
149
|
message = unique_messages.join("\n\n")
|
data/lib/dependabot.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.273.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-08-
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-codecommit
|
@@ -600,7 +600,7 @@ licenses:
|
|
600
600
|
- MIT
|
601
601
|
metadata:
|
602
602
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
603
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
603
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.273.0
|
604
604
|
post_install_message:
|
605
605
|
rdoc_options: []
|
606
606
|
require_paths:
|