Class: Spaceship::SpaceauthRunner
- Inherits:
-
Object
- Object
- Spaceship::SpaceauthRunner
- Defined in:
- spaceship/lib/spaceship/spaceauth_runner.rb
Instance Method Summary collapse
-
#initialize(username: nil, copy_to_clipboard: nil) ⇒ SpaceauthRunner
constructor
A new instance of SpaceauthRunner.
- #load_cookies(content) ⇒ Object
- #mac? ⇒ Boolean
- #run ⇒ Object
- #session_string ⇒ Object
Constructor Details
#initialize(username: nil, copy_to_clipboard: nil) ⇒ SpaceauthRunner
Returns a new instance of SpaceauthRunner.
10 11 12 13 14 15 |
# File 'spaceship/lib/spaceship/spaceauth_runner.rb', line 10 def initialize(username: nil, copy_to_clipboard: nil) @username = username @username ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id) @username ||= ask("Username: ") @copy_to_clipboard = copy_to_clipboard end |
Instance Method Details
#load_cookies(content) ⇒ Object
70 71 72 73 74 75 76 |
# File 'spaceship/lib/spaceship/spaceauth_runner.rb', line 70 def (content) YAML.safe_load( content, permitted_classes: [HTTP::Cookie, Time], aliases: true ) end |
#mac? ⇒ Boolean
83 84 85 |
# File 'spaceship/lib/spaceship/spaceauth_runner.rb', line 83 def mac? (/darwin/ =~ RUBY_PLATFORM) != nil end |
#run ⇒ Object
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 |
# File 'spaceship/lib/spaceship/spaceauth_runner.rb', line 17 def run begin puts("Logging into to App Store Connect (#{@username})...") unless Spaceship::Globals.check_session Spaceship::Tunes.login(@username) puts("Successfully logged in to App Store Connect".green) puts("") rescue => ex puts("Could not login to App Store Connect".red) puts("Please check your credentials and try again.".yellow) puts("This could be an issue with App Store Connect,".yellow) puts("Please try unsetting the FASTLANE_SESSION environment variable by calling 'unset FASTLANE_SESSION'".yellow) puts("(if it is set) and re-run `fastlane spaceauth`".yellow) puts("") puts("Exception type: #{ex.class}") raise ex end = Spaceship::Tunes.client. # The only value we actually need is the "DES5c148586daa451e55afb017aa62418f91" cookie # We're not sure if the key changes # # Example: # name: DES5c148586daa451e55afb017aa62418f91 # value: HSARMTKNSRVTWFlaF/ek8asaa9lymMA0dN8JQ6pY7B3F5kdqTxJvMT19EVEFX8EQudB/uNwBHOHzaa30KYTU/eCP/UF7vGTgxs6PAnlVWKscWssOVHfP2IKWUPaa4Dn+I6ilA7eAFQsiaaVT = () # We remove all the un-needed cookies .select! do || .name.start_with?("myacinfo") || .name == "dqsid" || .name.start_with?("DES") end @yaml = .to_yaml.gsub("\n", "\\n") puts("---") puts("") puts("Pass the following via the FASTLANE_SESSION environment variable:") puts(@yaml.cyan.underline) puts("") puts("") puts("Example:") puts("export FASTLANE_SESSION='#{@yaml}'".cyan.underline) if @copy_to_clipboard == false puts("Skipped asking to copy the session string into your clipboard ⏭️".green) elsif @copy_to_clipboard || (mac? && Spaceship::Client::UserInterface.interactive? && agree("🙄 Should fastlane copy the cookie into your clipboard, so you can easily paste it? (y/n)", true)) FastlaneCore::Clipboard.copy(content: @yaml) puts("Successfully copied the session string into your clipboard 🎨".green) end return self end |
#session_string ⇒ Object
78 79 80 81 |
# File 'spaceship/lib/spaceship/spaceauth_runner.rb', line 78 def session_string FastlaneCore::UI.user_error!("`#{__method__}` method called before calling `run` in `SpaceauthRunner`") unless @yaml @yaml end |