Sha256: b327ba4d769a969ffa21ed48ea1610fcabe5373c80429965e3a959489863bdb5

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

require 'set'

class MonoRepoDeps::Package::DependencyBypasser
  include MonoRepoDeps::Mixins

  Inject = MonoRepoDeps::Deps[
    packages_repo: "package.repo"
  ]

  include Inject

  sig do
    params(
      package_name: Symbol,
      env: Symbol,
    )
    .returns(T::Array[Symbol])
  end
  def call(package_name:, env:)
    walk(package_name: package_name, env: env, imported: Set.new)
  end

  private

  def walk(package_name:, env:, imported:, packages_order: [])
    package = packages_repo.find!(package_name)

    return if !imported.add?(package_name)

    package_dependencies = package.get_dependencies(env)

    package_dependencies.each do |name|
      walk(
        package_name: name,
        imported: imported,
        packages_order: packages_order,
        env: env# MonoRepoDeps::Package::DEFAULT_ENV,
      )
    end

    packages_order.push(package_name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mono_repo_deps-0.2.0 lib/mono_repo_deps/package/dependency_bypasser.rb