dependabot-maven 0.398.0 → 0.399.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 633af390f012c6aa9704de839340e18485655cffa7ce230467f78f8b6ee2541b
|
|
4
|
+
data.tar.gz: 7062af128c881f3bfcd9aacffb61957a24700982f86d51db00bf978f8e832d51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5ece07a1b94981cf48b3b1638b18b1d40da3b4a19b90847641b67d226c1a60053335f1a7b2b9ed6c4007d50f733cbec8b4b19900dbde8b57aa6f15cd01ee8c37
|
|
7
|
+
data.tar.gz: f7361f3db224e9158d7f6674edeab58f05e4e2e253f366346bad32247886ced22f6dcc8f9948e0894a76cbe4cfa4b3b393ba4e1ce5b18c1bf349acf328f158a2
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "rexml/parsers/baseparser"
|
|
5
|
+
require "stringio"
|
|
6
|
+
require "dependabot/maven/file_updater"
|
|
7
|
+
|
|
8
|
+
module Dependabot
|
|
9
|
+
module Maven
|
|
10
|
+
class FileUpdater < Dependabot::FileUpdaters::Base
|
|
11
|
+
class DependencyManagementLocator
|
|
12
|
+
extend T::Sig
|
|
13
|
+
|
|
14
|
+
sig { params(content: String).void }
|
|
15
|
+
def initialize(content)
|
|
16
|
+
@stream = T.let(StringIO.new(content), StringIO)
|
|
17
|
+
@parser = T.let(REXML::Parsers::BaseParser.new(@stream), REXML::Parsers::BaseParser)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
sig { params(project_name: String, element_name: String).returns(T::Range[Integer]) }
|
|
21
|
+
def replacement_range(project_name:, element_name:)
|
|
22
|
+
path = T.let([], T::Array[String])
|
|
23
|
+
element_start = T.let(nil, T.nilable(Integer))
|
|
24
|
+
|
|
25
|
+
loop do
|
|
26
|
+
start = byte_position
|
|
27
|
+
event = @parser.pull
|
|
28
|
+
case event.first
|
|
29
|
+
when :start_element
|
|
30
|
+
path << event[1]
|
|
31
|
+
element_start = start if path == [project_name, element_name]
|
|
32
|
+
when :end_element
|
|
33
|
+
return T.must(element_start)...byte_position if path == [project_name, element_name]
|
|
34
|
+
return insertion_range(start) if path == [project_name]
|
|
35
|
+
|
|
36
|
+
path.pop
|
|
37
|
+
when :end_document
|
|
38
|
+
raise "Could not locate project dependency management in the XML content"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
sig { params(start: Integer).returns(T::Range[Integer]) }
|
|
46
|
+
def insertion_range(start)
|
|
47
|
+
raise "Cannot insert dependency management into a self-closing <project> element" if start == byte_position
|
|
48
|
+
|
|
49
|
+
start...start
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# REXML reads ahead and compacts its buffer. Subtract unread bytes from the IO
|
|
53
|
+
# position, converting the decoded buffer back to the document's encoding.
|
|
54
|
+
sig { returns(Integer) }
|
|
55
|
+
def byte_position
|
|
56
|
+
@stream.pos - @parser.source.buffer.encode(@parser.source.encoding).bytesize
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -15,6 +15,7 @@ module Dependabot
|
|
|
15
15
|
extend T::Sig
|
|
16
16
|
|
|
17
17
|
require_relative "file_updater/declaration_finder"
|
|
18
|
+
require_relative "file_updater/dependency_management_locator"
|
|
18
19
|
require_relative "file_updater/dependency_requirement_scopes"
|
|
19
20
|
require_relative "file_updater/property_value_updater"
|
|
20
21
|
require_relative "file_updater/wrapper_updater"
|
|
@@ -219,8 +220,8 @@ module Dependabot
|
|
|
219
220
|
end
|
|
220
221
|
def add_new_declaration(content, dependency, requirement) # rubocop:disable Metrics/AbcSize
|
|
221
222
|
doc = REXML::Document.new(content)
|
|
222
|
-
project = doc.
|
|
223
|
-
raise "<project> element not found in the XML content" unless project
|
|
223
|
+
project = doc.root
|
|
224
|
+
raise "<project> element not found in the XML content" unless project&.name == "project"
|
|
224
225
|
|
|
225
226
|
# Detect indentation of the file from indentation of the project tag children
|
|
226
227
|
indentation_config = detect_indentation_config(project)
|
|
@@ -249,18 +250,15 @@ module Dependabot
|
|
|
249
250
|
# Close all sections with appropriate indentation
|
|
250
251
|
dependencies.add_text("\n#{indentation_config[:levels][:dependency_management]}")
|
|
251
252
|
dependency_management.add_text("\n#{indentation_config[:levels][:base]}") if dependencies_created
|
|
252
|
-
project.add_text("\n") if dependency_management_created
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
# If dependencyManagement was not created, we just replace the existing dependencyManagement element
|
|
259
|
-
# with the updated one, preserving the rest of the document
|
|
260
|
-
content.gsub(
|
|
261
|
-
%r{\<dependencyManagement\>[\s\S]*\</dependencyManagement\>},
|
|
262
|
-
dependency_management.to_s
|
|
254
|
+
range = DependencyManagementLocator.new(content).replacement_range(
|
|
255
|
+
project_name: project.expanded_name,
|
|
256
|
+
element_name: dependency_management.expanded_name
|
|
263
257
|
)
|
|
258
|
+
replacement = dependency_management.to_s
|
|
259
|
+
replacement = "\n#{indentation_config[:levels][:base]}#{replacement}\n" if dependency_management_created
|
|
260
|
+
|
|
261
|
+
T.must(content.byteslice(0...range.begin)) + replacement + T.must(content.byteslice(range.end..))
|
|
264
262
|
end
|
|
265
263
|
|
|
266
264
|
sig do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dependabot-maven
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.399.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.399.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.399.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rexml
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -266,6 +266,7 @@ files:
|
|
|
266
266
|
- lib/dependabot/maven/file_parser/wrapper_mojo.rb
|
|
267
267
|
- lib/dependabot/maven/file_updater.rb
|
|
268
268
|
- lib/dependabot/maven/file_updater/declaration_finder.rb
|
|
269
|
+
- lib/dependabot/maven/file_updater/dependency_management_locator.rb
|
|
269
270
|
- lib/dependabot/maven/file_updater/dependency_requirement_scopes.rb
|
|
270
271
|
- lib/dependabot/maven/file_updater/property_value_updater.rb
|
|
271
272
|
- lib/dependabot/maven/file_updater/wrapper_updater.rb
|
|
@@ -296,7 +297,7 @@ licenses:
|
|
|
296
297
|
- MIT
|
|
297
298
|
metadata:
|
|
298
299
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
299
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
300
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.399.0
|
|
300
301
|
rdoc_options: []
|
|
301
302
|
require_paths:
|
|
302
303
|
- lib
|