Sha256: 4829e3b4925318717cf28f57800fdabae04b9a39a97f147616be87ad86b24110

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'securerandom'

module UnlightCLI
  module Commands
    # Create OpenUnlight Project
    #
    # @since 0.1.0
    # @api private
    class Initialize < Thor::Group
      include Thor::Actions

      argument :name, default: 'OpenUnlight'
      desc 'Initialize OpenUnlight server'

      # @since 0.1.0
      # @api private
      def self.source_root
        UnlightCLI.root
      end

      # Create default project files
      #
      # @since 0.1.0
      # @api private
      def create_project
        template('templates/env.erb', "#{name}/.env")
        template('templates/docker-compose.yml.erb',
                 "#{name}/docker-compose.yml")
      end

      # Initialize Load
      #
      # @since 0.1.0
      # @api private
      def initialize_load
        Dir.chdir name do
          # TODO: Improve invoke action
          invoke 'unlight_c_l_i:commands:update'
          invoke 'unlight_c_l_i:commands:start'
        end
      end

      # Setup finished message
      #
      # @since 0.1.0
      # @api private
      def messages
        puts "The database root password is #{database_password}"
      end

      private

      # Generated Database Password
      #
      # @since 0.1.0
      # @api private
      def database_password
        @database_password ||= SecureRandom.base64(24)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unlight-cli-0.1.0 lib/unlight_cli/commands/initialize.rb