Class: Testflight::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/testflight/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



31
32
33
# File 'lib/testflight/cli.rb', line 31

def source_root
  File.expand_path('../../',__FILE__)
end

Instance Method Details

#checkinObject



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
# File 'lib/testflight/cli.rb', line 40

def checkin
  return unless is_project_folder?

  say("\r\nConfiguring #{Testflight::Config.application_name} #{Testflight::Config.type} for deployment to testflightapp.com...")
  ["Provisioning", "Distributions", "build"].each do |name| 
    create_folder(name)
  end

  say("\r\nPlease answer the following questions to prepare you for takeoff.")

  @company_name = ask("What is the name of your company, as it appears in your .cer file from Apple?")
  @should_increment_bundle = yes?("Would you like to automatically increment build numbers (bundle value) for every deployment? (y/n)")

  say("\r\nConfiguring Git commands...")
  if yes?("Do you use git as your SCM? (y/n)")
    @should_commit_changes = yes?("Would you like to commit and push your changes to git as the first step of your deployment? (y/n)")
    if @should_increment_bundle
      @should_tag_build = yes?("Would you like to tag every build in git with the version/build number? (y/n)")
    end
  end

  say("\r\nConfiguring Build commands...")
  say("What iPhone SDK version are you using?")
  sdks = [
    ["1:", "iphoneos4.3"],
    ["2:", "iphoneos5.0"],
    ["3:", "iphoneos5.1"],
    ["4:", "iphoneos6.0"],
    ["5:", "iphoneos6.1"],
  ]
  print_table(sdks)
  num = ask_for_number(5)
  @sdk = sdks[num-1].last

  say("\r\nConfiguring Testflight.com commands...")
  say("For the next question, please get your API TOKEN from the following URL: https://testflightapp.com/account/#api")
  @api_token = ask("Paste your API TOKEN here:")

  say("For the next question, please get your TEAM TOKEN from the following URL: https://testflightapp.com/dashboard/team/edit")
  @team_token = ask("Paste your TEAM TOKEN here:")

  @teams = ask("\r\nPlease enter your distribution lists as you have set them up on testflight (separate team names with a comma):")
  @teams = @teams.split(",").collect{|t| t.strip}

  template 'templates/testflight.yml.erb', "./#{Testflight::Config.path}"

  update_git_ignore

  say("Configuration file '.testflight' has been created. You can edit it manually or run the init command again.")
  say("\r\nOnly a few steps left, but make sure you do them all.")
  say("1). Copy your Ad Hoc Provisioning Profile (.mobileprovision) into the 'Provisioning' folder.")
  say("2). Create a new build profile called AdHoc and make sure you set it as the default profile for command line builds.")
  say("\r\nOnce you are done, you can run: testflight takeoff")
end

#takeoffObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/testflight/cli.rb', line 97

def takeoff
  return unless ready_for_takeoff?

  say("Preparing #{Testflight::Config.application_name} #{Testflight::Config.type} #{Testflight::Config.project_version} for deployment to testflightapp.com...")

  @message = ask("\r\nWhat changes did you make in this build?")
  @teams = ask_with_multiple_options("Which team(s) would you like to distirbute the build to? Provide team number(s, separated by a comma)",
                                     Testflight::Config.distribution_lists)

  @notify = yes?("\r\nWould you like to notify the team members by email about this build? (y/n)")
  
  Testflight::Builder.new(:message => @message, :teams => @teams, :notify => @notify, :cold => options['cold'])

  say("Congratulations, the build has been deployed! Have a safe flight!")
  say
end