Sha256: cd886e36a3eeb70e192401246eae87f8ae1e99f424785ce5af5bc38564c0cff4

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Karafka
  # Karafka framework Cli
  class Cli < Thor
    # Install Karafka Cli action
    class Install < Base
      desc 'Install all required things for Karafka application in current directory'

      # Directories created by default
      INSTALL_DIRS = %w[
        app/consumers
        app/responders
        config
        log
        tmp/pids
      ].freeze

      # Where should we map proper files from templates
      INSTALL_FILES_MAP = {
        'karafka.rb.example' => Karafka.boot_file.basename,
        'application_consumer.rb.example' => 'app/consumers/application_consumer.rb',
        'application_responder.rb.example' => 'app/responders/application_responder.rb'
      }.freeze

      # Install all required things for Karafka application in current directory
      def call
        INSTALL_DIRS.each do |dir|
          FileUtils.mkdir_p Karafka.root.join(dir)
        end

        INSTALL_FILES_MAP.each do |source, target|
          target = Karafka.root.join(target)
          next if File.exist?(target)

          source = Karafka.core_root.join("templates/#{source}")
          FileUtils.cp_r(source, target)
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
karafka-1.2.13 lib/karafka/cli/install.rb
karafka-1.2.12 lib/karafka/cli/install.rb
karafka-1.2.11 lib/karafka/cli/install.rb
karafka-1.2.10 lib/karafka/cli/install.rb
karafka-1.2.9 lib/karafka/cli/install.rb
karafka-1.2.8 lib/karafka/cli/install.rb
karafka-1.2.7 lib/karafka/cli/install.rb
karafka-1.2.6 lib/karafka/cli/install.rb
karafka-1.2.5 lib/karafka/cli/install.rb
karafka-1.2.4 lib/karafka/cli/install.rb
karafka-1.2.3 lib/karafka/cli/install.rb
karafka-1.2.2 lib/karafka/cli/install.rb
karafka-1.2.1 lib/karafka/cli/install.rb
karafka-1.2.0 lib/karafka/cli/install.rb
karafka-1.2.0.beta4 lib/karafka/cli/install.rb
karafka-1.2.0.beta3 lib/karafka/cli/install.rb
karafka-1.2.0.beta2 lib/karafka/cli/install.rb
karafka-1.2.0.beta1 lib/karafka/cli/install.rb