Class: Fastlane::SetupAndroid

Inherits:
Setup
  • Object
show all
Defined in:
lib/fastlane/setup/setup_android.rb

Instance Method Summary collapse

Methods inherited from Setup

#is_android?, #is_ios?, #show_analytics

Instance Method Details

#folderObject



72
73
74
# File 'lib/fastlane/setup/setup_android.rb', line 72

def folder
  FastlaneFolder.path
end

#generate_appfileObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fastlane/setup/setup_android.rb', line 23

def generate_appfile
  UI.message('------------------------------')
  UI.success('To not re-enter your packagename and issuer every time you run one of the fastlane tools or fastlane, these will be stored in a so-called Appfile.')

  package_name = ask('Package Name (com.krausefx.app): '.yellow)
  puts ""
  puts "To automatically upload builds and metadata to Google Play, fastlane needs a service action json secret file".yellow
  puts "Feel free to just click Enter to skip not provide certain things"
  puts "Follow the Setup Guide on how to get the Json file: https://github.com/fastlane/fastlane/tree/master/supply#setup".yellow
  json_key_file = ask('Path to the json secret file: '.yellow)

  template = File.read("#{Helper.gem_path('fastlane')}/lib/assets/AppfileTemplateAndroid")
  template.gsub!('[[JSON_KEY_FILE]]', json_key_file)
  template.gsub!('[[PACKAGE_NAME]]', package_name)
  path = File.join(folder, 'Appfile')
  File.write(path, template)
  UI.success("Created new file '#{path}'. Edit it to manage your preferred app metadata information.")
end

#generate_fastfileObject



42
43
44
45
46
47
48
49
50
# File 'lib/fastlane/setup/setup_android.rb', line 42

def generate_fastfile
  template = File.read("#{Helper.gem_path('fastlane')}/lib/assets/FastfileTemplateAndroid")

  template.gsub!('[[FASTLANE_VERSION]]', Fastlane::VERSION)

  path = File.join(folder, 'Fastfile')
  File.write(path, template)
  UI.success("Created new file '#{path}'. Edit it to manage your own deployment lanes.")
end

#init_supplyObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fastlane/setup/setup_android.rb', line 52

def init_supply
  UI.message("")
  question = "Do you plan on uploading metadata, screenshots and builds to Google Play using fastlane?".yellow
  UI.message(question)
  UI.message("This will download your existing metadata and screenshots into the `fastlane` folder")
  if agree(question + " (y/n) ", true)
    begin
      require 'supply'
      require 'supply/setup'
      Supply.config = FastlaneCore::Configuration.create(Supply::Options.available_options, {})
      Supply::Setup.new.perform_download
    rescue => ex
      UI.error(ex.to_s)
      UI.error("supply failed, but don't worry, you can launch supply using `supply init` whenever you want.")
    end
  else
    UI.success("You can run `supply init` to do so at a later point.")
  end
end

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fastlane/setup/setup_android.rb', line 3

def run
  if FastlaneFolder.setup? and !Helper.is_test?
    UI.important("Fastlane already set up at path #{folder}")
    return
  end

  response = agree('Do you have everything commited in version control? If not please do so now! (y/n)'.yellow, true)
  return unless response

  FastlaneFolder.create_folder! unless Helper.is_test?
  FileUtils.mkdir(File.join(folder, 'actions')) unless File.directory?(File.join(folder, 'actions'))
  generate_appfile
  generate_fastfile
  show_analytics

  init_supply

  UI.success('Successfully finished setting up fastlane')
end