Class: Jets::CLI::Init

Inherits:
Group::Base show all
Includes:
Util::Sure
Defined in:
lib/jets/cli/init.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Group::Helpers

#class_name, #framework, #init_project_name, #package_type, #underscore_name

Methods included from Group::Actions

#comment_out_line, #config_environment, #environment, #optimize_indentation

Class Method Details

.cli_optionsObject



5
6
7
8
9
10
11
# File 'lib/jets/cli/init.rb', line 5

def self.cli_options
  [
    [:env, type: :boolean, desc: "Generate config/jets/env/.env example file"],
    [:force, aliases: :f, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
    [:yes, aliases: :y, type: :boolean, desc: "Skip are you sure prompt"]
  ]
end

Instance Method Details

#are_you_sure?Boolean

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/jets/cli/init.rb', line 64

def are_you_sure?
  return if options[:yes] || options[:force]
  sure?(sure_message)
end

#config_jetsObject



77
78
79
# File 'lib/jets/cli/init.rb', line 77

def config_jets
  directory "config/jets", "config/jets"
end

#configure_environmentObject



81
82
83
84
85
86
87
88
# File 'lib/jets/cli/init.rb', line 81

def configure_environment
  case framework
  when "rails"
    configure_rails
  when "hanami"
    configure_hanami
  end
end

#env_exampleObject



69
70
71
72
73
74
75
# File 'lib/jets/cli/init.rb', line 69

def env_example
  # need to create .env for RAILS_ENV=production
  create_env = @options[:env].nil? ? framework == "rails" : @options[:env]
  if create_env
    template "env/.env.tt", "config/jets/env/.env"
  end
end