Class: SpmChecker
- Inherits:
-
Object
- Object
- SpmChecker
- Defined in:
- lib/spm_version_updates/spm_checker.rb
Overview
Core SPM version checking logic (migrated from Danger plugin) rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: DisallowedRepositoryHost, Result
Constant Summary collapse
- DEFAULT_VERSION_LOOKUP_WORKERS =
4
Instance Attribute Summary collapse
-
#allow_hosts ⇒ Object
Returns the value of attribute allow_hosts.
-
#check_branches ⇒ Object
Returns the value of attribute check_branches.
-
#check_revisions ⇒ Object
Returns the value of attribute check_revisions.
-
#check_when_exact ⇒ Object
Returns the value of attribute check_when_exact.
-
#ignore_repos ⇒ Object
Returns the value of attribute ignore_repos.
-
#lookup_failure_handler ⇒ Object
Optional callable ‘(package, error)` invoked instead of raising when a git lookup fails, so callers like the Danger plugin can warn and keep checking the remaining packages.
-
#malformed_resolved_handler ⇒ Object
Optional callable ‘(resolved_path, error)` invoked instead of raising when a Package.resolved file is malformed; the file is skipped.
-
#missing_resolved_handler ⇒ Object
Optional callable ‘(missing_paths)` invoked instead of raising when expected Package.resolved files are missing.
-
#report_above_maximum ⇒ Object
Returns the value of attribute report_above_maximum.
-
#report_pre_releases ⇒ Object
Returns the value of attribute report_pre_releases.
-
#repository_update_rules ⇒ Object
Returns the value of attribute repository_update_rules.
-
#version_lookup_workers ⇒ Object
Returns the value of attribute version_lookup_workers.
-
#version_tags_cache_dir ⇒ Object
Returns the value of attribute version_tags_cache_dir.
-
#version_tags_cache_ttl_seconds ⇒ Object
Returns the value of attribute version_tags_cache_ttl_seconds.
Class Method Summary collapse
Instance Method Summary collapse
-
#check_for_updates(xcodeproj_path) ⇒ Result
Check for SPM updates using an Xcode project as the source of dependencies.
-
#check_manifests(manifest_paths, resolved_paths = nil) ⇒ Result
Check for SPM updates using one or more ‘Package.swift` manifests as the source of dependencies.
-
#check_resolved(resolved_paths) ⇒ Result
Check for SPM updates using one or more ‘Package.resolved` files as the source of dependencies.
-
#initialize ⇒ SpmChecker
constructor
A new instance of SpmChecker.
Constructor Details
#initialize ⇒ SpmChecker
Returns a new instance of SpmChecker.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/spm_version_updates/spm_checker.rb', line 212 def initialize @check_when_exact = @check_revisions = @report_above_maximum = @report_pre_releases = false @check_branches = true @lookup_failure_handler = @malformed_resolved_handler = @missing_resolved_handler = nil @ignore_repos = [] @repository_update_rules = RepositoryUpdateRules.empty @allow_hosts = [] @version_lookup_workers = DEFAULT_VERSION_LOOKUP_WORKERS @updates = [] @parse_warnings = [] @version_tags_cache = {} @version_tag_lookup_errors = {} @reported_lookup_failures = {} @version_tags_cache_dir = nil @version_tags_cache_ttl_seconds = VersionTagsPersistentCache::DEFAULT_TTL_SECONDS end |
Instance Attribute Details
#allow_hosts ⇒ Object
Returns the value of attribute allow_hosts.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def allow_hosts @allow_hosts end |
#check_branches ⇒ Object
Returns the value of attribute check_branches.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def check_branches @check_branches end |
#check_revisions ⇒ Object
Returns the value of attribute check_revisions.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def check_revisions @check_revisions end |
#check_when_exact ⇒ Object
Returns the value of attribute check_when_exact.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def check_when_exact @check_when_exact end |
#ignore_repos ⇒ Object
Returns the value of attribute ignore_repos.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def ignore_repos @ignore_repos end |
#lookup_failure_handler ⇒ Object
Optional callable ‘(package, error)` invoked instead of raising when a git lookup fails, so callers like the Danger plugin can warn and keep checking the remaining packages. When nil (the default), lookup failures raise one combined GitOperations::LsRemoteError exactly as before.
195 196 197 |
# File 'lib/spm_version_updates/spm_checker.rb', line 195 def lookup_failure_handler @lookup_failure_handler end |
#malformed_resolved_handler ⇒ Object
Optional callable ‘(resolved_path, error)` invoked instead of raising when a Package.resolved file is malformed; the file is skipped. When nil (the default), PackageResolved::MalformedFileError is raised.
200 201 202 |
# File 'lib/spm_version_updates/spm_checker.rb', line 200 def malformed_resolved_handler @malformed_resolved_handler end |
#missing_resolved_handler ⇒ Object
Optional callable ‘(missing_paths)` invoked instead of raising when expected Package.resolved files are missing. Missing paths are dropped and packages without a resolved version keep the existing “Unable to locate…” behavior: no warning record is created and no version tags are fetched for them.
206 207 208 |
# File 'lib/spm_version_updates/spm_checker.rb', line 206 def missing_resolved_handler @missing_resolved_handler end |
#report_above_maximum ⇒ Object
Returns the value of attribute report_above_maximum.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def report_above_maximum @report_above_maximum end |
#report_pre_releases ⇒ Object
Returns the value of attribute report_pre_releases.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def report_pre_releases @report_pre_releases end |
#repository_update_rules ⇒ Object
Returns the value of attribute repository_update_rules.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def repository_update_rules @repository_update_rules end |
#version_lookup_workers ⇒ Object
Returns the value of attribute version_lookup_workers.
178 179 180 |
# File 'lib/spm_version_updates/spm_checker.rb', line 178 def version_lookup_workers @version_lookup_workers end |
#version_tags_cache_dir ⇒ Object
Returns the value of attribute version_tags_cache_dir.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def @version_tags_cache_dir end |
#version_tags_cache_ttl_seconds ⇒ Object
Returns the value of attribute version_tags_cache_ttl_seconds.
180 181 182 |
# File 'lib/spm_version_updates/spm_checker.rb', line 180 def @version_tags_cache_ttl_seconds end |
Class Method Details
.redact_credentials(value) ⇒ Object
208 209 210 |
# File 'lib/spm_version_updates/spm_checker.rb', line 208 def self.redact_credentials(value) CredentialRedactor.redact(value) end |
Instance Method Details
#check_for_updates(xcodeproj_path) ⇒ Result
Check for SPM updates using an Xcode project as the source of dependencies.
240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/spm_version_updates/spm_checker.rb', line 240 def check_for_updates(xcodeproj_path) prepare_run remote_packages = XcodeParser.get_packages(xcodeproj_path) resolved_versions = XcodeParser.get_resolved_versions(xcodeproj_path, &@malformed_resolved_handler) puts("Found resolved versions for #{resolved_versions.size} packages") warn_for_empty_xcode_project(remote_packages, resolved_versions, xcodeproj_path) check_packages(remote_packages, resolved_versions) result end |
#check_manifests(manifest_paths, resolved_paths = nil) ⇒ Result
Check for SPM updates using one or more ‘Package.swift` manifests as the source of dependencies.
Resolved pins from every ‘Package.resolved` are merged by normalized repository URL into a single lookup. Each manifest’s direct dependencies are then compared against that lookup, and the originating manifest is attached to every warning so multi-manifest repos can tell where an update applies.
266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/spm_version_updates/spm_checker.rb', line 266 def check_manifests(manifest_paths, resolved_paths = nil) prepare_run resolved_versions = merged_resolved_versions(manifest_paths, resolved_paths) puts("Found resolved versions for #{resolved_versions.size} packages") manifest_paths.each { |manifest_path| check_packages(manifest_packages(manifest_path), resolved_versions, manifest_path) } result end |
#check_resolved(resolved_paths) ⇒ Result
Check for SPM updates using one or more ‘Package.resolved` files as the source of dependencies. Version pins are compared directly with available tags; revision-only pins are reported only when check_revisions is enabled.
285 286 287 288 289 290 291 292 |
# File 'lib/spm_version_updates/spm_checker.rb', line 285 def check_resolved(resolved_paths) prepare_run paths = normalized_resolved_paths(resolved_paths) raise(SpmVersionUpdates::ConfigurationError, "package-resolved-paths must be set") if paths.empty? check_existing_resolved_paths(paths) result end |