Sha256: a860696741c9c8f7a6930c70de41f3f2abaf3453c0bf15a97613ab46a543c73b

Contents?: true

Size: 1.75 KB

Versions: 14

Compression:

Stored size: 1.75 KB

Contents

# frozen_string_literal: true

module Bridgetown
  module Commands
    class Configure < Thor::Group
      include Thor::Actions
      include Actions
      extend Summarizable

      Registrations.register do
        register(Configure, "configure", "configure CONFIGURATION", Configure.summary)
      end

      def self.banner
        "bridgetown configure CONFIGURATION(S)"
      end
      summary "Set up bundled Bridgetown configurations"

      def self.exit_on_failure?
        true
      end

      def perform_configurations
        @logger = Bridgetown.logger
        list_configurations if args.empty?

        args.each do |configuration|
          configure configuration
        rescue Thor::Error
          @logger.error "Error:".red, "🚨 Configuration doesn't exist: #{configuration}"
        end
      end

      def self.source_root
        File.expand_path("../configurations", __dir__)
      end

      protected

      def configure(configuration)
        configuration_file = find_in_source_paths("#{configuration}.rb")

        inside(New.created_site_dir || Dir.pwd) do
          apply configuration_file, verbose: false
        end
      end

      def list_configurations
        say "Please specify a valid packaged configuration from the below list:\n\n"
        configurations.each do |configuration|
          configuration = set_color configuration, :blue, :bold
          say configuration
        end
        say "\n"

        docs_url = "https://www.bridgetownrb.com/docs/bundled-configurations".yellow.bold
        say "For more info, check out the docs at: #{docs_url}"
      end

      def configurations
        inside self.class.source_root do
          return Dir.glob("*.rb").map { |file| file.sub(".rb", "") }
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
bridgetown-core-1.0.0.alpha6 lib/bridgetown-core/commands/configure.rb
bridgetown-core-1.0.0.alpha5 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.5 lib/bridgetown-core/commands/configure.rb
bridgetown-core-1.0.0.alpha4 lib/bridgetown-core/commands/configure.rb
bridgetown-core-1.0.0.alpha3 lib/bridgetown-core/commands/configure.rb
bridgetown-core-1.0.0.alpha2 lib/bridgetown-core/commands/configure.rb
bridgetown-core-1.0.0.alpha1 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.4 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.3 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.2 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.1 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.0 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.0.beta4 lib/bridgetown-core/commands/configure.rb
bridgetown-core-0.21.0.beta3 lib/bridgetown-core/commands/configure.rb