Sha256: 1c542ecc14255cf1883b84be2f3dc378ac6d8f836002d02acfc6b1463daaf32f

Contents?: true

Size: 1.88 KB

Versions: 5

Compression:

Stored size: 1.88 KB

Contents

require 'fileutils'
require 'colorize'
require 'active_support/core_ext/string'
require 'thor'
require 'bundler'

class Jets::Commands::Sequence < Thor::Group
  include Thor::Actions

  def self.source_root
    File.expand_path("templates/skeleton", File.dirname(__FILE__))
  end

private
  def clone_project
    unless git_installed?
      abort "Unable to detect git installation on your system.  Git needs to be installed in order to use the --repo option."
    end

    if File.exist?(project_folder)
      abort "The folder #{project_folder} already exists."
    else
      run "git clone https://github.com/#{options[:repo]} #{project_folder}"
    end
    confirm_jets_project
  end

  def confirm_jets_project
    jets_project = File.exist?("#{project_folder}/config/application.rb")
    unless jets_project
      puts "It does not look like the repo #{options[:repo]} is a jets project. Maybe double check that it is?  Exited.".colorize(:red)
      exit 1
    end
  end

  def copy_project
    puts "Creating new project called #{@project_name}."
    directory ".", project_folder, copy_options
  end

  def copy_options
    excludes = if @options[:mode] == 'job'
      # For job mode: list of words to include in the exclude pattern and will not be generated.
      %w[
        Procfile
        controllers
        helpers
        javascript
        models/application_
        views
        config.ru
        database.yml
        dynamodb.yml
        routes
        db/
        spec
        yarn
        public
      ]
    elsif !@options[:database]
      # Do not even generated the config/database.yml because
      # jets webpacker:install bombs and tries to load the db since it sees a
      # config/database.yml but has there's no database pg gem configured.
      %w[
        database.yml
        models/application_record
      ]
    end
  end

  def git_installed?
    system("type git > /dev/null")
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jets-1.0.4 lib/jets/commands/sequence.rb
jets-1.0.3 lib/jets/commands/sequence.rb
jets-1.0.2 lib/jets/commands/sequence.rb
jets-1.0.1 lib/jets/commands/sequence.rb
jets-1.0.0 lib/jets/commands/sequence.rb