Class: Codebuild::Init
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Sequence
source_paths
#cfn, #codebuild
#are_you_sure?, #inferred_project_name, #inferred_stack_name, #project_name_convention, #stack_exists?
Class Method Details
.cli_options ⇒ Object
Ugly, this is how I can get the options from to match with this Thor::Group
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/codebuild/init.rb', line 4
def self.cli_options
[
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
[:name, desc: "CodeBuild project name"],
[:template, desc: "Custom template to use"],
[:template_mode, desc: "Template mode: replace or additive"],
[:type, desc: "Type option creates a subfolder under .codebuild"],
[:variables, type: :boolean, default: false, desc: "Create variables starter files"],
]
end
|
Instance Method Details
#copy_project ⇒ Object
45
46
47
48
49
50
|
# File 'lib/codebuild/init.rb', line 45
def copy_project
puts "Initialize codebuild project in .codebuild"
dest = ".codebuild"
dest = "#{dest}/#{@options[:type]}" if @options[:type]
directory "project", dest, exclude_pattern: /.git/
end
|
#copy_top_level ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/codebuild/init.rb', line 36
def copy_top_level
puts "Initialize codebuild top-level folder"
dest = ".codebuild"
excludes = %w[.git]
excludes << %w[variables] unless @options[:variables]
pattern = Regexp.new(excludes.join('|'))
directory "top", dest, exclude_pattern: pattern
end
|
#set_source_path ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/codebuild/init.rb', line 22
def set_source_path
return unless @options[:template]
custom_template = "#{ENV['HOME']}/.codebuild/templates/#{full_repo_name}"
if @options[:template_mode] == "replace" override_source_paths(custom_template)
else default_template = File.expand_path("../../template", __FILE__)
puts "default_template: #{default_template}"
override_source_paths([custom_template, default_template])
end
end
|
#setup_template_repo ⇒ Object
16
17
18
19
20
|
# File 'lib/codebuild/init.rb', line 16
def setup_template_repo
return unless @options[:template]&.include?('/')
sync_template_repo
end
|