Sha256: 8cdb8ad8acd7fb941f715831de27802326baa67c444e3cdf52e59fe9a692c4bf

Contents?: true

Size: 1.33 KB

Versions: 26

Compression:

Stored size: 1.33 KB

Contents

require_relative "monorepo/project"

module Foobara
  class << self
    def require_project_file(project, path)
      require_relative("../../../#{project}/src/#{path}")
    end

    def reset_alls
      Monorepo.reset_alls
    end
  end

  # TODO: We should rename this to Projects or something else because we need to manage this stuff for projects
  # inside and outside of the monorepo.
  module Monorepo
    class << self
      attr_accessor :is_installed

      def all_projects
        @all_projects ||= {}
      end

      def projects(*symbols)
        symbols.each do |symbol|
          project(symbol)
        end
      end

      def project(symbol)
        if all_projects.key?(symbol)
          # :nocov:
          raise ArgumentError, "Project #{symbol} already loaded"
          # :nocov:
        end

        project = Project.new(symbol)
        project.load

        all_projects[symbol] = project

        if is_installed
          project.install!

          all_projects.each_pair do |key, existing_project|
            next if key == symbol

            existing_project.new_project_added(project)
          end
        end
      end

      def install!
        self.is_installed = true
        all_projects.each_value(&:install!)
      end

      def reset_alls
        all_projects.each_value(&:reset_all)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.25 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.24 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.23 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.22 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.21 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.20 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.19 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.18 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.17 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.16 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.15 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.14 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.13 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.12 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.11 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.10 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.9 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.8 projects/monorepo/lib/foobara/monorepo.rb
foobara-0.0.7 projects/monorepo/lib/foobara/monorepo.rb