2020-07-10 15:09:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module Packages
|
|
|
|
module Npm
|
|
|
|
class PackageFinder
|
|
|
|
attr_reader :project, :package_name
|
|
|
|
|
|
|
|
delegate :find_by_version, to: :execute
|
|
|
|
|
|
|
|
def initialize(project, package_name)
|
|
|
|
@project = project
|
|
|
|
@package_name = package_name
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
2020-11-11 12:09:06 +00:00
|
|
|
return Packages::Package.none unless project
|
|
|
|
|
2020-07-10 15:09:07 +00:00
|
|
|
packages
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def packages
|
|
|
|
project.packages
|
|
|
|
.npm
|
|
|
|
.with_name(package_name)
|
|
|
|
.last_of_each_version
|
|
|
|
.preload_files
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|