Class: Ufo::CLI::New::Init

Inherits:
Sequence
  • Object
show all
Defined in:
lib/ufo/cli/new/init.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Logging

#logger

Class Method Details

.optionsObject



3
4
5
6
7
8
9
10
# File 'lib/ufo/cli/new/init.rb', line 3

def self.options
  [
    [:app, aliases: :a, desc: "App name.  If not specified, it's inferred from the folder name"],
    [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
    # note: aliases: :r messes up Usage help: ufo init -h so not using it
    [:repo, required: true, desc: "Docker repo to use. Example: ORG/REPO"],
  ]
end

Instance Method Details

#create_dockefileObject



42
43
44
45
46
# File 'lib/ufo/cli/new/init.rb', line 42

def create_dockefile
  return if File.exist?("Dockerfile")
  set_template_source("docker")
  directory ".", "."
end

#generateObject



23
24
25
26
# File 'lib/ufo/cli/new/init.rb', line 23

def generate
  puts "Generating .ufo structure"
  directory "."
end

#set_sourceObject



13
14
15
16
# File 'lib/ufo/cli/new/init.rb', line 13

def set_source
  set_template_source("init")
  self.destination_root = '.'
end

#set_variablesObject



18
19
20
21
# File 'lib/ufo/cli/new/init.rb', line 18

def set_variables
  @app = options[:app] || inferred_app
  @repo = options[:repo]
end

#update_gitignoreObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ufo/cli/new/init.rb', line 28

def update_gitignore
  text =<<~EOL
    .ufo/tmp
    .ufo/log
    .ufo/output
    .secrets
  EOL
  if File.exist?(".gitignore")
    append_to_file ".gitignore", text
  else
    create_file ".gitignore", text
  end
end

#user_messageObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/ufo/cli/new/init.rb', line 48

def user_message
  puts "Starter .ufo files created"
  puts <<~EOL
    Congrats. You have successfully set up your project with ufo.
    To deploy to ECS:

        ufo ship

  EOL
end