Sha256: 37f4ba98695779802cc101c86f3f7563387de7e9f4e8226529bbe1a6096846bd

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

class MonoRepoDeps::Task::Manager
  include MonoRepoDeps::Mixins

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

  include Inject

  sig do
    params(
      method_name: Symbol,
      args: T.anything,
      kwargs: T.anything
    )
    .returns(T::Boolean)
  end
  def method_missing(method_name, *args, **kwargs)
    task = MonoRepoDeps.current_project.tasks.detect { _1.name == method_name } || (raise StandardError.new("task '#{method_name}' not found for project"))

    case task.on
    when :package
      statuses = kwargs[:packages].inject({}) do |result, package_name|
        package = packages_repo.find!(package_name.to_sym)
        result[package.name] = task.block.call(package, kwargs[:args])
        result
      end

      failed_packages = statuses.reject {|package_name, exitstatus| exitstatus == 0}

      failed_packages.any? ? false : true
    else
      raise StandardError.new("unsupported task subject: #{task.on}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mono_repo_deps-0.2.1 lib/mono_repo_deps/task/manager.rb