Class: Dependabot::NpmAndYarn::UpdateChecker::RequirementsUpdater
- Inherits:
-
Object
- Object
- Dependabot::NpmAndYarn::UpdateChecker::RequirementsUpdater
- Defined in:
- lib/dependabot/npm_and_yarn/update_checker/requirements_updater.rb
Constant Summary collapse
- VERSION_REGEX =
/[0-9]+(?:\.[A-Za-z0-9\-_]+)*/
- SEPARATOR =
/(?<=[a-zA-Z0-9*])[\s|]+(?![\s|-])/
- ALLOWED_UPDATE_STRATEGIES =
T.let( [ RequirementsUpdateStrategy::LockfileOnly, RequirementsUpdateStrategy::WidenRanges, RequirementsUpdateStrategy::BumpVersions, RequirementsUpdateStrategy::BumpVersionsIfNecessary ].freeze, T::Array[Dependabot::RequirementsUpdateStrategy] )
Instance Method Summary collapse
-
#initialize(requirements:, updated_source:, update_strategy:, latest_resolvable_version:) ⇒ RequirementsUpdater
constructor
A new instance of RequirementsUpdater.
- #updated_requirements ⇒ Object
Constructor Details
#initialize(requirements:, updated_source:, update_strategy:, latest_resolvable_version:) ⇒ RequirementsUpdater
Returns a new instance of RequirementsUpdater.
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dependabot/npm_and_yarn/update_checker/requirements_updater.rb', line 30 def initialize(requirements:, updated_source:, update_strategy:, latest_resolvable_version:) @requirements = requirements @updated_source = updated_source @update_strategy = update_strategy check_update_strategy return unless latest_resolvable_version @latest_resolvable_version = version_class.new(latest_resolvable_version) end |
Instance Method Details
#updated_requirements ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dependabot/npm_and_yarn/update_checker/requirements_updater.rb', line 44 def updated_requirements return requirements if update_strategy.lockfile_only? requirements.map do |req| req = req.merge(source: updated_source) next req unless latest_resolvable_version next initial_req_after_source_change(req) unless req[:requirement] next req if req[:requirement].match?(/^([A-Za-uw-z]|v[^\d])/) case update_strategy when RequirementsUpdateStrategy::WidenRanges then widen_requirement(req) when RequirementsUpdateStrategy::BumpVersions then update_version_requirement(req) when RequirementsUpdateStrategy::BumpVersionsIfNecessary update_version_requirement_if_needed(req) else raise "Unexpected update strategy: #{update_strategy}" end end end |