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



51
52
53
54
55
# File 'lib/ufo/cli/new/init.rb', line 51

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_dockerignoreObject



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

def update_dockerignore
  text = ".ufo\n"
  if File.exist?(".dockerignore")
    append_to_file ".dockerignore", text
  else
    create_file ".dockerignore", text
  end
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 ="    .ufo/tmp\n    .ufo/log\n    .ufo/output\n    .secrets\n  EOL\n  if File.exist?(\".gitignore\")\n    append_to_file \".gitignore\", text\n  else\n    create_file \".gitignore\", text\n  end\nend\n"

#user_messageObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/ufo/cli/new/init.rb', line 57

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