Method: RokuBuilder::ConfigParser.setup_stage_config

Defined in:
lib/roku_builder/config_parser.rb

.setup_stage_config(configs:, options:, logger:) ⇒ Hash

Setup the project stage config

Parameters:

  • configs (Hash)

    The loaded config hash

  • options (Hash)

    The options hash

Returns:

  • (Hash)

    The stage config hash



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/roku_builder/config_parser.rb', line 113

def self.setup_stage_config(configs:, options:, logger:)
  stage_config = {logger: logger}
  stage = options[:stage].to_sym
  project_config = configs[:project_config]
  stage_config[:root_dir] = project_config[:directory]
  stage_config[:method] = project_config[:stage_method]
  stage_config[:method] ||= :git
  case stage_config[:method]
  when :git
    if options[:ref]
      stage_config[:key] = options[:ref]
    else
      return nil unless project_config[:stages][stage]
      stage_config[:key] = project_config[:stages][stage][:branch]
    end
  when :script
    return nil unless project_config[:stages][stage]
    stage_config[:key] = project_config[:stages][stage][:script]
  end
  configs[:stage_config] = stage_config
  configs[:stage] = stage
  [stage_config, stage]
end