Class: Pipedream::Init

Inherits:
Sequence
  • Object
show all
Defined in:
lib/pipedream/init.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Sequence

source_paths

Methods included from AwsServices

#cfn, #codepipeline, #s3

Methods included from AwsServices::Helpers

#are_you_sure?, #inferred_pipeline_name, #inferred_stack_name, #pipeline_name_convention, #stack_exists?

Class Method Details

.cli_optionsObject

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
# File 'lib/pipedream/init.rb', line 4

def self.cli_options
  [
    [:name, desc: "CodePipeline project name."],
    [:mode, desc: "Modes: light or full", default: "light" ],
    [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
    [:template, desc: "Custom template to use."],
    [:template_mode, desc: "Template mode: replace or additive."],
  ]
end

Instance Method Details

#copy_projectObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/pipedream/init.rb', line 34

def copy_project
  puts "Initialize pipedream project in .pipedream"

  excludes = %w[.git]
  if @options[:mode] == "light"
    excludes += %w[
      settings.yml
      sns.rb
    ]
  end
  pattern = Regexp.new(excludes.join('|'))

  if @options[:template]
    directory ".", ".pipedream", exclude_pattern: pattern
  else
    directory ".", exclude_pattern: pattern
  end
end

#set_source_pathObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pipedream/init.rb', line 21

def set_source_path
  return unless @options[:template]

  custom_template = "#{ENV['HOME']}/.pipedream/templates/#{full_repo_name}"

  if @options[:template_mode] == "replace" # replace the template entirely
    override_source_paths(custom_template)
  else # additive: modify on top of default template
    default_template = File.expand_path("../../template", __FILE__)
    override_source_paths([custom_template, default_template])
  end
end

#setup_template_repoObject



15
16
17
18
19
# File 'lib/pipedream/init.rb', line 15

def setup_template_repo
  return unless @options[:template]&.include?('/')

  sync_template_repo
end