1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
require "librarian/resolver"
require "librarian/spec_change_set"
require "librarian/action/base"
require "librarian/action/persist_resolution_mixin"
module Librarian
module Action
class Resolve < Base
include PersistResolutionMixin
def run
if force? || !lockfile_path.exist?
spec = specfile.read
manifests = []
else
lock = lockfile.read
spec = specfile.read(lock.sources)
changes = spec_change_set(spec, lock)
if changes.same?
debug { "The specfile is unchanged: nothing to do." }
return
end
manifests = changes.analyze
end
spec.dependencies, duplicated = Dependency.remove_duplicate_dependencies(spec.dependencies)
duplicated.each do |name, dependencies_same_name|
environment.logger.info { "Dependency '#{name}' duplicated for module, merging: #{dependencies_same_name.map{|d| d.to_s}}" }
end
resolution = resolver.resolve(spec, manifests)
persist_resolution(resolution)
resolution
end
private
def force?
options[:force]
end
def resolver
Resolver.new(environment)
end
def spec_change_set(spec, lock)
SpecChangeSet.new(environment, spec, lock)
end
end
end
end
|