Class: Dependabot::Nuget::FileFetcher
- Inherits:
-
FileFetchers::Base
- Object
- FileFetchers::Base
- Dependabot::Nuget::FileFetcher
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/nuget/file_fetcher.rb,
lib/dependabot/nuget/file_fetcher/import_paths_finder.rb,
lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb
Defined Under Namespace
Classes: ImportPathsFinder, SlnProjectPathsFinder
Constant Summary collapse
- BUILD_FILE_NAMES =
Directory.Build.props, Directory.Build.targets
/^Directory\.Build\.(props|targets)$/i
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_files ⇒ Object
-
#initialize(source:, credentials:, repo_contents_path: nil, options: {}) ⇒ FileFetcher
constructor
A new instance of FileFetcher.
Constructor Details
#initialize(source:, credentials:, repo_contents_path: nil, options: {}) ⇒ FileFetcher
Returns a new instance of FileFetcher.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dependabot/nuget/file_fetcher.rb', line 45 def initialize(source:, credentials:, repo_contents_path: nil, options: {}) super(source: source, credentials: credentials, repo_contents_path: repo_contents_path, options: ) @sln_files = T.let(nil, T.nilable(T::Array[Dependabot::DependencyFile])) @sln_project_files = T.let(nil, T.nilable(T::Array[Dependabot::DependencyFile])) @project_files = T.let([], T::Array[Dependabot::DependencyFile]) @fetched_files = T.let({}, T::Hash[String, T::Array[Dependabot::DependencyFile]]) @nuget_config_files = T.let(nil, T.nilable(T::Array[Dependabot::DependencyFile])) @packages_config_files = T.let(nil, T.nilable(T::Array[Dependabot::DependencyFile])) end |
Class Method Details
.required_files_in?(filenames) ⇒ Boolean
22 23 24 25 26 27 28 29 |
# File 'lib/dependabot/nuget/file_fetcher.rb', line 22 def self.required_files_in?(filenames) return true if filenames.any? { |f| f.match?(/^packages\.config$/i) } return true if filenames.any? { |f| f.end_with?(".sln") } return true if filenames.any? { |f| f.match?("^src$") } return true if filenames.any? { |f| f.end_with?(".proj") } filenames.any? { |name| name.match?(/\.(cs|vb|fs)proj$/) } end |
.required_files_message ⇒ Object
32 33 34 |
# File 'lib/dependabot/nuget/file_fetcher.rb', line 32 def self. "Repo must contain a .proj file, .(cs|vb|fs)proj file, or a packages.config." end |
Instance Method Details
#fetch_files ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dependabot/nuget/file_fetcher.rb', line 57 def fetch_files fetched_files = [] fetched_files += project_files fetched_files += directory_build_files fetched_files += imported_property_files fetched_files += packages_config_files fetched_files += nuget_config_files fetched_files << global_json if global_json fetched_files << dotnet_tools_json if dotnet_tools_json fetched_files << packages_props if packages_props # dedup files based on their absolute path fetched_files = fetched_files.uniq do |fetched_file| Pathname.new(fetched_file.directory).join(fetched_file.name).cleanpath.to_path end if project_files.none? && packages_config_files.none? raise T.must(@missing_sln_project_file_errors.first) if @missing_sln_project_file_errors&.any? raise_dependency_file_not_found end fetched_files end |