Sha256: 7e488b64136d20d5eaace7069a62a7ef8f740f7279261b3918541362b6fced89

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

# typed: strict
# frozen_string_literal: true

module Packwerk
  module Generators
    class RootPackage
      extend T::Sig

      class << self
        extend T::Sig

        sig { params(root: String, out: T.any(IO, StringIO)).returns(T::Boolean) }
        def generate(root:, out:)
          new(root: root, out: out).generate
        end
      end

      sig { params(root: String, out: T.any(IO, StringIO)).void }
      def initialize(root:, out: $stdout)
        @root = root
        @out = out
      end

      sig { returns(T::Boolean) }
      def generate
        if Dir.glob("#{@root}/package.yml").any?
          @out.puts("⚠️  Root package already exists.")
          return true
        end

        @out.puts("📦 Generating `package.yml` file for root package...")

        source_file_path = File.join(__dir__, "/templates/package.yml")
        FileUtils.cp(source_file_path, @root)

        @out.puts("✅ `package.yml` for the root package generated in #{@root}")
        true
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
packwerk-3.2.2 lib/packwerk/generators/root_package.rb
packwerk-3.2.1 lib/packwerk/generators/root_package.rb
packwerk-3.2.0 lib/packwerk/generators/root_package.rb
packwerk-3.1.0 lib/packwerk/generators/root_package.rb
packwerk-3.0.1 lib/packwerk/generators/root_package.rb
packwerk-3.0.0 lib/packwerk/generators/root_package.rb