Class: Jets::CLI::Ci::Init

Inherits:
Group::Base show all
Includes:
Util::Sure
Defined in:
lib/jets/cli/ci/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
# File 'lib/jets/cli/ci/init.rb', line 5

def self.cli_options
  [
    [: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)


87
88
89
90
# File 'lib/jets/cli/ci/init.rb', line 87

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

#check_already_initializedObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/jets/cli/ci/init.rb', line 69

def check_already_initialized
  if File.exist?("config/jets/ci.rb")
    puts "Found config/jets/ci.rb"
    puts "It looks like the Jets project is already initialized for CI"
    exit
  end

  lines = IO.readlines("config/jets/deploy.rb")
  found = lines.detect do |l|
    l.include?("config.deploy.") && !l.match?(/^\s*#/)
  end
  if found
    puts "Found config.ci in config/jets/deploy.rb"
    puts "It looks like the Jets project has already been set up for CI"
    exit
  end
end

#check_jets_initializedObject



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

def check_jets_initialized
  unless File.exist?("config/jets/deploy.rb")
    puts "config/jets/deploy.rb not found."
    puts "Please run: jets init"
    exit 1
  end
end

#config_jets_ciObject



93
94
95
# File 'lib/jets/cli/ci/init.rb', line 93

def config_jets_ci
  template "ci.rb.tt", "config/jets/ci.rb"
end