dependabot-nuget 0.323.0 → 0.325.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/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +0 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +1 -31
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +0 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyInfo.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +64 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/MSBuildDependencySolver.cs +10 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +31 -41
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Cooldown.cs +83 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ModifiedFilesTracker.cs +9 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGenerator.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +8 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +79 -67
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +10 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +245 -125
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +4 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +4 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +14 -31
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +3 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +12 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +78 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs +126 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolver/MSBuildDependencySolverTests.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +0 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +2 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/ApiModel/CooldownTests.cs +99 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +168 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGeneratorTests.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +70 -39
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests.cs +43 -30
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +76 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +0 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +11 -27
- data/lib/dependabot/nuget.rb +3 -11
- metadata +8 -54
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +0 -49
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +0 -60
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +0 -35
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +0 -58
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +0 -380
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +0 -557
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +0 -37
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +0 -226
- data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +0 -65
- data/lib/dependabot/nuget/analysis/dependency_analysis.rb +0 -66
- data/lib/dependabot/nuget/cache_manager.rb +0 -29
- data/lib/dependabot/nuget/discovery/dependency_details.rb +0 -102
- data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +0 -122
- data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +0 -266
- data/lib/dependabot/nuget/discovery/evaluation_details.rb +0 -63
- data/lib/dependabot/nuget/discovery/project_discovery.rb +0 -104
- data/lib/dependabot/nuget/discovery/property_details.rb +0 -43
- data/lib/dependabot/nuget/discovery/workspace_discovery.rb +0 -61
- data/lib/dependabot/nuget/file_fetcher.rb +0 -46
- data/lib/dependabot/nuget/file_parser.rb +0 -153
- data/lib/dependabot/nuget/file_updater.rb +0 -256
- data/lib/dependabot/nuget/language.rb +0 -98
- data/lib/dependabot/nuget/metadata_finder.rb +0 -197
- data/lib/dependabot/nuget/native_helpers.rb +0 -364
- data/lib/dependabot/nuget/nuget_config_credential_helpers.rb +0 -88
- data/lib/dependabot/nuget/package_manager.rb +0 -51
- data/lib/dependabot/nuget/update_checker/requirements_updater.rb +0 -105
- data/lib/dependabot/nuget/update_checker.rb +0 -210
@@ -1,153 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/dependency"
|
5
|
-
require "dependabot/file_parsers"
|
6
|
-
require "dependabot/file_parsers/base"
|
7
|
-
require "dependabot/nuget/discovery/discovery_json_reader"
|
8
|
-
require "dependabot/nuget/native_helpers"
|
9
|
-
require "sorbet-runtime"
|
10
|
-
require "dependabot/nuget/package_manager"
|
11
|
-
require "dependabot/nuget/language"
|
12
|
-
|
13
|
-
# For details on how dotnet handles version constraints, see:
|
14
|
-
# https://docs.microsoft.com/en-us/nuget/reference/package-versioning
|
15
|
-
module Dependabot
|
16
|
-
module Nuget
|
17
|
-
class FileParser < Dependabot::FileParsers::Base
|
18
|
-
extend T::Sig
|
19
|
-
|
20
|
-
require "dependabot/file_parsers/base/dependency_set"
|
21
|
-
|
22
|
-
sig { override.returns(T::Array[Dependabot::Dependency]) }
|
23
|
-
def parse
|
24
|
-
dependencies
|
25
|
-
end
|
26
|
-
|
27
|
-
sig { returns(Ecosystem) }
|
28
|
-
def ecosystem
|
29
|
-
@ecosystem ||= T.let(
|
30
|
-
Ecosystem.new(
|
31
|
-
name: ECOSYSTEM,
|
32
|
-
package_manager: package_manager,
|
33
|
-
language: language
|
34
|
-
),
|
35
|
-
T.nilable(Ecosystem)
|
36
|
-
)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
sig { returns(T.nilable(T::Array[String])) }
|
42
|
-
def content_json
|
43
|
-
@content_json ||= T.let(begin
|
44
|
-
discovery_json_reader.workspace_discovery&.projects&.map do |framework|
|
45
|
-
T.let(framework.instance_variable_get(:@target_frameworks), T::Array[String]).compact.join(",")
|
46
|
-
end
|
47
|
-
end, T.nilable(T::Array[String]))
|
48
|
-
end
|
49
|
-
|
50
|
-
sig { returns(T::Array[Dependabot::Dependency]) }
|
51
|
-
def dependencies
|
52
|
-
NativeHelpers.install_dotnet_sdks
|
53
|
-
@dependencies ||= T.let(discovery_json_reader.dependency_set.dependencies,
|
54
|
-
T.nilable(T::Array[Dependabot::Dependency]))
|
55
|
-
end
|
56
|
-
|
57
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
58
|
-
sig { override.void }
|
59
|
-
def check_required_files
|
60
|
-
requirement_files = dependencies.flat_map do |dep|
|
61
|
-
dep.requirements.map { |r| T.let(r.fetch(:file), String) }
|
62
|
-
end.uniq
|
63
|
-
|
64
|
-
proj_pattern = /\.(cs|vb|fs)proj$/
|
65
|
-
found_files = discovery_json_reader.dependency_file_paths.select { |f| File.basename(f).match?(proj_pattern) }
|
66
|
-
project_files = requirement_files.select { |f| File.basename(f).match?(proj_pattern) }
|
67
|
-
global_json_file = requirement_files.select { |f| File.basename(f) == "global.json" }
|
68
|
-
dotnet_tools_json_file = requirement_files.select { |f| File.basename(f) == "dotnet-tools.json" }
|
69
|
-
has_files = found_files.any? || project_files.any? || global_json_file.any? || dotnet_tools_json_file.any?
|
70
|
-
return if has_files
|
71
|
-
|
72
|
-
raise Dependabot::DependencyFileNotFound.new(
|
73
|
-
"*.(cs|vb|fs)proj",
|
74
|
-
"No project file."
|
75
|
-
)
|
76
|
-
end
|
77
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
78
|
-
|
79
|
-
sig { returns(DiscoveryJsonReader) }
|
80
|
-
def discovery_json_reader
|
81
|
-
@discovery_json_reader ||= T.let(begin
|
82
|
-
directory = source&.directory || "/"
|
83
|
-
DiscoveryJsonReader.run_discovery_in_directory(
|
84
|
-
repo_contents_path: T.must(repo_contents_path),
|
85
|
-
directory: directory,
|
86
|
-
credentials: credentials
|
87
|
-
)
|
88
|
-
end, T.nilable(DiscoveryJsonReader))
|
89
|
-
end
|
90
|
-
|
91
|
-
sig { returns(T.nilable(Ecosystem::VersionManager)) }
|
92
|
-
def language
|
93
|
-
# Historically new version of language is released with incremental update of
|
94
|
-
# .Net version, so we tie the language with framework version for metric collection
|
95
|
-
|
96
|
-
nomenclature = "#{language_type} #{framework_version&.join(',')}".strip.tr(" ", "-")
|
97
|
-
|
98
|
-
Dependabot.logger.info("Detected language and framework #{nomenclature}")
|
99
|
-
|
100
|
-
case language_type
|
101
|
-
|
102
|
-
when CSharpLanguage::TYPE
|
103
|
-
CSharpLanguage.new(nomenclature)
|
104
|
-
|
105
|
-
when VBLanguage::TYPE
|
106
|
-
VBLanguage.new(nomenclature)
|
107
|
-
|
108
|
-
when FSharpLanguage::TYPE
|
109
|
-
FSharpLanguage.new(nomenclature)
|
110
|
-
|
111
|
-
when DotNet::TYPE
|
112
|
-
DotNet.new(nomenclature)
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
sig { returns(T.nilable(T::Array[String])) }
|
118
|
-
def framework_version
|
119
|
-
content_json
|
120
|
-
rescue StandardError
|
121
|
-
nil
|
122
|
-
end
|
123
|
-
|
124
|
-
sig { returns(T.nilable(String)) }
|
125
|
-
def language_type
|
126
|
-
requirement_files = dependencies.flat_map do |dep|
|
127
|
-
dep.requirements.map { |r| T.let(r.fetch(:file), String) }
|
128
|
-
end.uniq
|
129
|
-
|
130
|
-
return "cs" if requirement_files.any? { |f| File.basename(f).match?(/\.csproj$/) }
|
131
|
-
return "vb" if requirement_files.any? { |f| File.basename(f).match?(/\.vbproj$/) }
|
132
|
-
return "fs" if requirement_files.any? { |f| File.basename(f).match?(/\.fsproj$/) }
|
133
|
-
|
134
|
-
# return a fallback to avoid falling to exception
|
135
|
-
"dotnet"
|
136
|
-
end
|
137
|
-
|
138
|
-
sig { returns(Ecosystem::VersionManager) }
|
139
|
-
def package_manager
|
140
|
-
NugetPackageManager.new(T.must(nuget_version))
|
141
|
-
end
|
142
|
-
|
143
|
-
sig { returns(T.nilable(String)) }
|
144
|
-
def nuget_version
|
145
|
-
SharedHelpers.run_shell_command("dotnet nuget --version").split("Command Line").last&.strip
|
146
|
-
rescue StandardError
|
147
|
-
nil
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
Dependabot::FileParsers.register("nuget", Dependabot::Nuget::FileParser)
|
@@ -1,256 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/dependency_file"
|
5
|
-
require "dependabot/file_updaters"
|
6
|
-
require "dependabot/file_updaters/base"
|
7
|
-
require "dependabot/nuget/discovery/dependency_details"
|
8
|
-
require "dependabot/nuget/discovery/discovery_json_reader"
|
9
|
-
require "dependabot/nuget/discovery/workspace_discovery"
|
10
|
-
require "dependabot/nuget/native_helpers"
|
11
|
-
require "dependabot/shared_helpers"
|
12
|
-
require "sorbet-runtime"
|
13
|
-
|
14
|
-
module Dependabot
|
15
|
-
module Nuget
|
16
|
-
class FileUpdater < Dependabot::FileUpdaters::Base
|
17
|
-
extend T::Sig
|
18
|
-
|
19
|
-
sig { override.returns(T::Array[Regexp]) }
|
20
|
-
def self.updated_files_regex
|
21
|
-
[
|
22
|
-
/.*\.([a-z]{2})?proj$/, # Matches files with any extension like .csproj, .vbproj, etc., in any directory
|
23
|
-
/packages\.lock\.json/, # Matches packages.lock.json in any directory
|
24
|
-
/packages\.config$/i, # Matches packages.config in any directory
|
25
|
-
/app\.config$/i, # Matches app.config in any directory
|
26
|
-
/web\.config$/i, # Matches web.config in any directory
|
27
|
-
/global\.json$/i, # Matches global.json in any directory
|
28
|
-
/dotnet-tools\.json$/i, # Matches dotnet-tools.json in any directory
|
29
|
-
/Directory\.Build\.props$/i, # Matches Directory.Build.props in any directory
|
30
|
-
/Directory\.Build\.targets$/i, # Matches Directory.Build.targets in any directory
|
31
|
-
/Directory\.targets$/i, # Matches Directory.targets in any directory or root directory
|
32
|
-
/Packages\.props$/i, # Matches Packages.props in any directory
|
33
|
-
/.*\.nuspec$/, # Matches any .nuspec files in any directory
|
34
|
-
%r{^\.config/dotnet-tools\.json$} # Matches .config/dotnet-tools.json in only root directory
|
35
|
-
]
|
36
|
-
end
|
37
|
-
|
38
|
-
sig { params(original_content: T.nilable(String), updated_content: String).returns(T::Boolean) }
|
39
|
-
def self.differs_in_more_than_blank_lines?(original_content, updated_content)
|
40
|
-
# Compare the line counts of the original and updated content, but ignore lines only containing white-space.
|
41
|
-
# This prevents false positives when there are trailing empty lines in the original content, for example.
|
42
|
-
original_lines = (original_content&.lines || []).map(&:strip).reject(&:empty?)
|
43
|
-
updated_lines = updated_content.lines.map(&:strip).reject(&:empty?)
|
44
|
-
|
45
|
-
# if the line count differs, then something changed
|
46
|
-
return true unless original_lines.count == updated_lines.count
|
47
|
-
|
48
|
-
# check each line pair, ignoring blanks (filtered above)
|
49
|
-
original_lines.zip(updated_lines).any? { |pair| pair[0] != pair[1] }
|
50
|
-
end
|
51
|
-
|
52
|
-
sig { override.returns(T::Array[Dependabot::DependencyFile]) }
|
53
|
-
def updated_dependency_files
|
54
|
-
base_dir = "/"
|
55
|
-
all_updated_files = SharedHelpers.in_a_temporary_repo_directory(base_dir, repo_contents_path) do
|
56
|
-
dependencies.each do |dependency|
|
57
|
-
try_update_projects(dependency) || try_update_json(dependency)
|
58
|
-
end
|
59
|
-
updated_files = dependency_files.filter_map do |f|
|
60
|
-
dependency_file_path = DiscoveryJsonReader.dependency_file_path(
|
61
|
-
repo_contents_path: T.must(repo_contents_path),
|
62
|
-
dependency_file: f
|
63
|
-
)
|
64
|
-
dependency_file_path = File.join(repo_contents_path, dependency_file_path)
|
65
|
-
updated_content = File.read(dependency_file_path)
|
66
|
-
next if updated_content == f.content
|
67
|
-
|
68
|
-
normalized_content = normalize_content(f, updated_content)
|
69
|
-
next if normalized_content == f.content
|
70
|
-
|
71
|
-
next unless FileUpdater.differs_in_more_than_blank_lines?(f.content, normalized_content)
|
72
|
-
|
73
|
-
puts "The contents of file [#{f.name}] were updated."
|
74
|
-
|
75
|
-
updated_file(file: f, content: normalized_content)
|
76
|
-
end
|
77
|
-
updated_files
|
78
|
-
end
|
79
|
-
|
80
|
-
raise UpdateNotPossible, dependencies.map(&:name) if all_updated_files.empty?
|
81
|
-
|
82
|
-
all_updated_files
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
sig { returns(String) }
|
88
|
-
def job_file_path
|
89
|
-
ENV.fetch("DEPENDABOT_JOB_PATH")
|
90
|
-
end
|
91
|
-
|
92
|
-
sig { params(dependency: Dependabot::Dependency).returns(T::Boolean) }
|
93
|
-
def try_update_projects(dependency)
|
94
|
-
update_ran = T.let(false, T::Boolean)
|
95
|
-
checked_files = Set.new
|
96
|
-
|
97
|
-
# run update for each project file
|
98
|
-
project_files.each do |project_file|
|
99
|
-
project_dependencies = project_dependencies(project_file)
|
100
|
-
dependency_file_path = DiscoveryJsonReader.dependency_file_path(
|
101
|
-
repo_contents_path: T.must(repo_contents_path),
|
102
|
-
dependency_file: project_file
|
103
|
-
)
|
104
|
-
proj_path = dependency_file_path
|
105
|
-
|
106
|
-
next unless project_dependencies.any? { |dep| dep.name.casecmp?(dependency.name) }
|
107
|
-
|
108
|
-
next unless repo_contents_path
|
109
|
-
|
110
|
-
checked_key = "#{project_file.name}-#{dependency.name}#{dependency.version}"
|
111
|
-
call_nuget_updater_tool(dependency, proj_path) unless checked_files.include?(checked_key)
|
112
|
-
|
113
|
-
checked_files.add(checked_key)
|
114
|
-
# We need to check the downstream references even though we're already evaluated the file
|
115
|
-
downstream_files = referenced_project_paths(project_file)
|
116
|
-
downstream_files.each do |downstream_file|
|
117
|
-
checked_files.add("#{downstream_file}-#{dependency.name}#{dependency.version}")
|
118
|
-
end
|
119
|
-
update_ran = true
|
120
|
-
end
|
121
|
-
update_ran
|
122
|
-
end
|
123
|
-
|
124
|
-
sig { params(dependency: Dependabot::Dependency).returns(T::Boolean) }
|
125
|
-
def try_update_json(dependency)
|
126
|
-
if dotnet_tools_json_dependencies.any? { |dep| dep.name.casecmp?(dependency.name) } ||
|
127
|
-
global_json_dependencies.any? { |dep| dep.name.casecmp?(dependency.name) }
|
128
|
-
|
129
|
-
# We just need to feed the updater a project file, grab the first
|
130
|
-
project_file = T.must(project_files.first)
|
131
|
-
dependency_file_path = DiscoveryJsonReader.dependency_file_path(
|
132
|
-
repo_contents_path: T.must(repo_contents_path),
|
133
|
-
dependency_file: project_file
|
134
|
-
)
|
135
|
-
proj_path = dependency_file_path
|
136
|
-
|
137
|
-
return false unless repo_contents_path
|
138
|
-
|
139
|
-
call_nuget_updater_tool(dependency, proj_path)
|
140
|
-
return true
|
141
|
-
end
|
142
|
-
|
143
|
-
false
|
144
|
-
end
|
145
|
-
|
146
|
-
sig { params(dependency: Dependency, proj_path: String).void }
|
147
|
-
def call_nuget_updater_tool(dependency, proj_path)
|
148
|
-
NativeHelpers.run_nuget_updater_tool(job_path: job_file_path, repo_root: T.must(repo_contents_path),
|
149
|
-
proj_path: proj_path, dependency: dependency,
|
150
|
-
is_transitive: !dependency.top_level?, credentials: credentials)
|
151
|
-
|
152
|
-
# Tests need to track how many times we call the tooling updater to ensure we don't recurse needlessly
|
153
|
-
# Ideally we should find a way to not run this code in prod
|
154
|
-
# (or a better way to track calls made to NativeHelpers)
|
155
|
-
@update_tooling_calls ||= T.let({}, T.nilable(T::Hash[String, Integer]))
|
156
|
-
key = "#{proj_path.delete_prefix(T.must(repo_contents_path))}+#{dependency.name}"
|
157
|
-
@update_tooling_calls[key] =
|
158
|
-
if @update_tooling_calls[key]
|
159
|
-
T.must(@update_tooling_calls[key]) + 1
|
160
|
-
else
|
161
|
-
1
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
# Don't call this from outside tests, we're only checking that we aren't recursing needlessly
|
166
|
-
sig { returns(T.nilable(T::Hash[String, Integer])) }
|
167
|
-
def testonly_update_tooling_calls
|
168
|
-
@update_tooling_calls
|
169
|
-
end
|
170
|
-
|
171
|
-
sig { returns(T.nilable(WorkspaceDiscovery)) }
|
172
|
-
def workspace
|
173
|
-
dependency_file_paths = dependency_files.map do |f|
|
174
|
-
DiscoveryJsonReader.dependency_file_path(repo_contents_path: T.must(repo_contents_path),
|
175
|
-
dependency_file: f)
|
176
|
-
end
|
177
|
-
DiscoveryJsonReader.load_discovery_for_dependency_file_paths(dependency_file_paths).workspace_discovery
|
178
|
-
end
|
179
|
-
|
180
|
-
sig { params(project_file: Dependabot::DependencyFile).returns(T::Array[String]) }
|
181
|
-
def referenced_project_paths(project_file)
|
182
|
-
workspace&.projects&.find { |p| p.file_path == project_file.name }&.referenced_project_paths || []
|
183
|
-
end
|
184
|
-
|
185
|
-
sig { params(project_file: Dependabot::DependencyFile).returns(T::Array[DependencyDetails]) }
|
186
|
-
def project_dependencies(project_file)
|
187
|
-
workspace&.projects&.find do |p|
|
188
|
-
full_project_file_path = File.join(project_file.directory, project_file.name)
|
189
|
-
p.file_path == full_project_file_path
|
190
|
-
end&.dependencies || []
|
191
|
-
end
|
192
|
-
|
193
|
-
sig { returns(T::Array[DependencyDetails]) }
|
194
|
-
def global_json_dependencies
|
195
|
-
workspace&.global_json&.dependencies || []
|
196
|
-
end
|
197
|
-
|
198
|
-
sig { returns(T::Array[DependencyDetails]) }
|
199
|
-
def dotnet_tools_json_dependencies
|
200
|
-
workspace&.dotnet_tools_json&.dependencies || []
|
201
|
-
end
|
202
|
-
|
203
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
204
|
-
sig { params(dependency_file: Dependabot::DependencyFile, updated_content: String).returns(String) }
|
205
|
-
def normalize_content(dependency_file, updated_content)
|
206
|
-
# Fix up line endings
|
207
|
-
if dependency_file.content&.include?("\r\n")
|
208
|
-
# The original content contain windows style newlines.
|
209
|
-
if updated_content.match?(/(?<!\r)\n/)
|
210
|
-
# Ensure the updated content also uses windows style newlines.
|
211
|
-
updated_content = updated_content.gsub(/(?<!\r)\n/, "\r\n")
|
212
|
-
puts "Fixing mismatched Windows line endings for [#{dependency_file.name}]."
|
213
|
-
end
|
214
|
-
elsif updated_content.include?("\r\n")
|
215
|
-
# The original content does not contain windows style newlines, but the updated content does.
|
216
|
-
# Ensure the updated content uses unix style newlines.
|
217
|
-
updated_content = updated_content.gsub("\r\n", "\n")
|
218
|
-
puts "Fixing mismatched Unix line endings for [#{dependency_file.name}]."
|
219
|
-
end
|
220
|
-
|
221
|
-
# Fix up BOM
|
222
|
-
if !dependency_file.content&.start_with?("\uFEFF") && updated_content.start_with?("\uFEFF")
|
223
|
-
updated_content = updated_content.delete_prefix("\uFEFF")
|
224
|
-
puts "Removing BOM from [#{dependency_file.name}]."
|
225
|
-
elsif dependency_file.content&.start_with?("\uFEFF") && !updated_content.start_with?("\uFEFF")
|
226
|
-
updated_content = "\uFEFF" + updated_content
|
227
|
-
puts "Adding BOM to [#{dependency_file.name}]."
|
228
|
-
end
|
229
|
-
|
230
|
-
updated_content
|
231
|
-
end
|
232
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
233
|
-
|
234
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
235
|
-
def project_files
|
236
|
-
dependency_files.select { |df| df.name.match?(/\.(cs|vb|fs)proj$/) }
|
237
|
-
end
|
238
|
-
|
239
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
240
|
-
def packages_config_files
|
241
|
-
dependency_files.select do |f|
|
242
|
-
T.must(T.must(f.name.split("/").last).casecmp("packages.config")).zero?
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
sig { override.void }
|
247
|
-
def check_required_files
|
248
|
-
return if project_files.any? || packages_config_files.any?
|
249
|
-
|
250
|
-
raise "No project file or packages.config!"
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
Dependabot::FileUpdaters.register("nuget", Dependabot::Nuget::FileUpdater)
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "sorbet-runtime"
|
5
|
-
require "dependabot/nuget/version"
|
6
|
-
require "dependabot/ecosystem"
|
7
|
-
|
8
|
-
module Dependabot
|
9
|
-
module Nuget
|
10
|
-
class Language < Dependabot::Ecosystem::VersionManager
|
11
|
-
extend T::Sig
|
12
|
-
|
13
|
-
sig { params(language: String, raw_version: String, requirement: T.nilable(Requirement)).void }
|
14
|
-
def initialize(language, raw_version, requirement = nil)
|
15
|
-
super(
|
16
|
-
name: language,
|
17
|
-
version: Version.new(raw_version),
|
18
|
-
requirement: requirement,
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class CSharpLanguage < Dependabot::Ecosystem::VersionManager
|
24
|
-
extend T::Sig
|
25
|
-
|
26
|
-
LANGUAGE = "CSharp"
|
27
|
-
TYPE = "cs"
|
28
|
-
|
29
|
-
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
30
|
-
|
31
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
32
|
-
|
33
|
-
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
34
|
-
def initialize(language, requirement = nil)
|
35
|
-
super(
|
36
|
-
name: language,
|
37
|
-
requirement: requirement,
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class VBLanguage < Dependabot::Ecosystem::VersionManager
|
43
|
-
extend T::Sig
|
44
|
-
|
45
|
-
LANGUAGE = "VB"
|
46
|
-
TYPE = "vb"
|
47
|
-
|
48
|
-
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
49
|
-
|
50
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
51
|
-
|
52
|
-
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
53
|
-
def initialize(language, requirement = nil)
|
54
|
-
super(
|
55
|
-
name: language,
|
56
|
-
requirement: requirement,
|
57
|
-
)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class FSharpLanguage < Dependabot::Ecosystem::VersionManager
|
62
|
-
extend T::Sig
|
63
|
-
|
64
|
-
LANGUAGE = "FSharp"
|
65
|
-
TYPE = "fs"
|
66
|
-
|
67
|
-
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
68
|
-
|
69
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
70
|
-
|
71
|
-
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
72
|
-
def initialize(language, requirement = nil)
|
73
|
-
super(
|
74
|
-
name: language,
|
75
|
-
requirement: requirement,
|
76
|
-
)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class DotNet < Dependabot::Ecosystem::VersionManager
|
81
|
-
extend T::Sig
|
82
|
-
|
83
|
-
TYPE = "dotnet"
|
84
|
-
|
85
|
-
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
86
|
-
|
87
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
88
|
-
|
89
|
-
sig { params(language: String, requirement: T.nilable(Requirement)).void }
|
90
|
-
def initialize(language, requirement = nil)
|
91
|
-
super(
|
92
|
-
name: language,
|
93
|
-
requirement: requirement,
|
94
|
-
)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|