Module: Arkana

Defined in:
lib/arkana.rb,
lib/arkana/version.rb

Overview

Top-level namespace for Arkana’s execution entry point. When ran from CLI, ‘Arkana.run` is what is invoked.

Constant Summary collapse

VERSION =
"1.1.1"

Class Method Summary collapse

Class Method Details

.run(arguments) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/arkana.rb', line 13

def self.run(arguments)
  config = ConfigParser.parse(arguments)
  salt = SaltGenerator.generate
  DotenvHelper.load(config)

  begin
    environment_secrets = Encoder.encode!(
      keys: config.environment_keys,
      salt: salt,
      current_flavor: config.current_flavor,
      environments: config.environments,
    )
    global_secrets = Encoder.encode!(
      keys: config.global_secrets,
      salt: salt,
      current_flavor: config.current_flavor,
      environments: config.environments,
    )
  rescue StandardError => e
    # TODO: Improve this by creating an Env/Debug helper
    puts("Something went wrong when parsing and encoding your secrets.")
    puts("Current Flavor: #{config.current_flavor}")
    puts("Dotenv Filepath: #{config.dotenv_filepath}")
    puts("Config Filepath: #{arguments.config_filepath}")
    raise e
  end
  template_arguments = TemplateArguments.new(
    environment_secrets: environment_secrets,
    global_secrets: global_secrets,
    config: config,
    salt: salt,
  )
  SwiftCodeGenerator.generate(
    template_arguments: template_arguments,
    config: config,
  )
end