Class: Flint::CommandsGenerator

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/fastlane/plugin/flint/helper/commands_generator.rb

Instance Method Summary collapse

Instance Method Details

#runObject



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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fastlane/plugin/flint/helper/commands_generator.rb', line 15

def run

  global_option('--verbose') { FastlaneCore::Globals.verbose = true }

  command :run do |c|
    c.syntax = 'fastlane flint'
    c.description = Flint::DESCRIPTION

    FastlaneCore::CommanderGenerator.new.generate(Flint::Options.available_options, command: c)

    c.action do |args, options|
      if args.count > 0
        FastlaneCore::UI.user_error!("Please run `fastlane flint [type]`, allowed values: development or release")
      end

      params = FastlaneCore::Configuration.create(Flint::Options.available_options, options.__hash__)
      params.load_configuration_file("Flintfile")
      Flint::Runner.new.run(params)
    end
  end

  Flint.environments.each do |type|
    command type do |c|
      c.syntax = "fastlane flint #{type}"
      c.description = "Run flint for a #{type} profile"

      FastlaneCore::CommanderGenerator.new.generate(Flint::Options.available_options, command: c)

      c.action do |args, options|
        params = FastlaneCore::Configuration.create(Flint::Options.available_options, options.__hash__)
        params.load_configuration_file("Flintfile") # this has to be done *before* overwriting the value
        params[:type] = type.to_s
        Flint::Runner.new.run(params)
      end
    end
  end

  command :decrypt do |c|
    c.syntax = "fastlane flint decrypt"
    c.description = "Decrypts the repository and keeps it on the filesystem"

    FastlaneCore::CommanderGenerator.new.generate(Flint::Options.available_options, command: c)

    c.action do |args, options|
      params = FastlaneCore::Configuration.create(Flint::Options.available_options, options.__hash__)
      params.load_configuration_file("Flintfile")
      encrypt = Encrypt.new
      decrypted_repo = Flint::GitHelper.clone(params[:git_url],
                                              params[:shallow_clone],
                                              branch: params[:git_branch],
                                              clone_branch_directly: params[:clone_branch_directly], 
                                              encrypt: encrypt)
      UI.success("Repo is at: '#{decrypted_repo}'")
    end
  end

  command "nuke" do |c|
    # We have this empty command here, since otherwise the normal `flint` command will be executed
    c.syntax = "fastlane flint nuke"
    c.description = "Delete all keystores"
    c.action do |args, options|
      FastlaneCore::UI.user_error!("Please run `fastlane flint nuke [type], allowed values: development and release.")
    end
  end

  ["development", "release"].each do |type|
    command "nuke #{type}" do |c|
      c.syntax = "fastlane flint nuke #{type}"
      c.description = "Delete all keystores of the type #{type}"

      FastlaneCore::CommanderGenerator.new.generate(Flint::Options.available_options, command: c)

      c.action do |args, options|
        params = FastlaneCore::Configuration.create(Flint::Options.available_options, options.__hash__)
        params.load_configuration_file("Flintfile")
        Flint::Nuke.new.run(params, type: type.to_s)
      end
    end
  end

  default_command(:run)

  run!
end