Sha256: 4f95af5a1b4f866a38b6780d0850d7a56c4d87537c85169ad41973aa1ad28d67

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'benchmark'

class MonoRepoDeps::Package::Initializer
  include MonoRepoDeps::Mixins

  Inject = MonoRepoDeps::Deps[
    "package.dependency_bypasser",
    "package.repo"
  ]

  include Inject

  sig do
    params(
      package_name: T.any(Symbol, String),
      env: Symbol,
      imported: T::Array[Symbol]
    )
    .void
  end
  def call(package_name, env:, imported: [])
    package_name = package_name.to_sym
    packages_import_order = []

    time = Benchmark.realtime do
      packages_import_order = dependency_bypasser
        .call(package_name: package_name, env: env, imported: imported)
        .map { repo.find(_1) }
        .each { MonoRepoDeps.current_project.loader.push_dir(_1.workdir_path) }
        .tap { MonoRepoDeps.current_project.loader.setup }
        .each { |package| require package.entrypoint_file if File.exist?(package.entrypoint_file) }
    end

    puts "imported package '#{package_name}' with #{packages_import_order.size} dependencies in #{'%.2f' % time} seconds for env: #{env}"

    nil
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mono_repo_deps-0.1.14 lib/mono_repo_deps/package/initializer.rb
mono_repo_deps-0.1.13 lib/mono_repo_deps/package/initializer.rb