codes 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5de44a06df82ccf5f52fb7012beb8fbb45ea091f
4
- data.tar.gz: 3815b7cafc3affe3801c642b72227326d6d89af9
3
+ metadata.gz: 7e7bc733c50117a65733b35ff3397a09a5393ac4
4
+ data.tar.gz: a2c348bd2f3fac7d2d04bf318e3131967adcf650
5
5
  SHA512:
6
- metadata.gz: 12a724b931a13c7d6a04a4f5fa6370fd6bd5a2d67d252e4bad9619b0e68aa36c3929bac652267577f70c94706ec43e8360f6ff6361f58737e24d03a48df585c4
7
- data.tar.gz: 22e7597ee1a3f194f4e4943432f682e0022aa956344fc25196863d685dd3de8bd8cdd0a270cbb397cc55b7ffc86b76870b6678ff2933de427fd36119cdff7bb9
6
+ metadata.gz: 82660fb3b949be5f0903be2fbd9c9acff071d079312e7013e505d7941067311bc78f160f2c14b72127ba3e289747701ff901dcc376d714a964b60f840d182d8a
7
+ data.tar.gz: 22870162284f11dae6016cd587699e5b2c13dd86264baa50eccc78a1775f391fb78a557f6e1e5cfaf3644cba4a9cf2c90933086e818a3ecefa163559ba497ede
data/README.md CHANGED
@@ -22,7 +22,7 @@
22
22
  -------
23
23
 
24
24
  <p align="center">
25
- <img src="assets/codes.png">
25
+ <img src="assets/codes.png" height="110">
26
26
  </p>
27
27
 
28
28
  codes
@@ -36,6 +36,8 @@ codes
36
36
  or
37
37
  ###### Automatically lose money by giving away your app for free...
38
38
 
39
+ ## This tool is not maintained any more
40
+
39
41
 
40
42
  ##### This tool was sponsored by [Max Bäumle](http://maxbaeumle.com) and [Textastic Code Editor](http://www.textasticapp.com)
41
43
 
data/bin/codes CHANGED
@@ -2,12 +2,15 @@
2
2
 
3
3
  $:.push File.expand_path('../../lib', __FILE__)
4
4
 
5
- require 'codes'
6
- require 'commander'
7
- require 'credentials_manager/appfile_config'
5
+ # require 'codes'
6
+ # require 'commander'
7
+ # require 'credentials_manager/appfile_config'
8
8
  require 'fastlane_core'
9
9
 
10
- HighLine.track_eof = false
10
+ # HighLine.track_eof = false
11
+
12
+ puts "This tool is currently not working due to the new iTunes Connect interface".red
13
+ raise "Error"
11
14
 
12
15
  class CodesApplication
13
16
  include Commander::Methods
@@ -0,0 +1,64 @@
1
+ require 'capybara'
2
+ require 'capybara/poltergeist'
3
+ require 'credentials_manager/password_manager'
4
+ require 'phantomjs/poltergeist' # this will download and store phantomjs
5
+
6
+ require 'fastlane_core/itunes_connect/itunes_connect_helper.rb'
7
+ require 'fastlane_core/itunes_connect/itunes_connect_login.rb'
8
+ require 'fastlane_core/itunes_connect/itunes_connect_apple_id.rb'
9
+
10
+ module Codes
11
+ # Everything that can't be achived using the {Codes::ItunesTransporter}
12
+ # will be scripted using the iTunesConnect frontend.
13
+ #
14
+ # Every method you call here, might take a time
15
+ class ItunesConnect
16
+ # This error occurs only if there is something wrong with the given login data
17
+ class ItunesConnectLoginError < StandardError
18
+ end
19
+
20
+ # This error can occur for many reaons. It is
21
+ # usually raised when an UI element could not be found
22
+ class ItunesConnectGeneralError < StandardError
23
+ end
24
+
25
+ include Capybara::DSL
26
+
27
+ ITUNESCONNECT_URL = "https://itunesconnect.apple.com/"
28
+ APP_DETAILS_URL = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/[[app_id]]"
29
+
30
+ BUTTON_STRING_NEW_VERSION = "New Version"
31
+ BUTTON_STRING_SUBMIT_FOR_REVIEW = "Submit for Review"
32
+
33
+ WAITING_FOR_REVIEW = "Waiting For Review"
34
+
35
+ def initialize
36
+ super
37
+
38
+ return if Helper.is_test?
39
+
40
+ Capybara.run_server = false
41
+ Capybara.default_driver = :poltergeist
42
+ Capybara.javascript_driver = :poltergeist
43
+ Capybara.current_driver = :poltergeist
44
+ Capybara.app_host = ITUNESCONNECT_URL
45
+
46
+ # Since Apple has some SSL errors, we have to configure the client properly:
47
+ # https://github.com/ariya/phantomjs/issues/11239
48
+ Capybara.register_driver :poltergeist do |a|
49
+ conf = ['--debug=no', '--ignore-ssl-errors=yes', '--ssl-protocol=TLSv1']
50
+ Capybara::Poltergeist::Driver.new(a, {
51
+ phantomjs: Phantomjs.path,
52
+ phantomjs_options: conf,
53
+ phantomjs_logger: File.open("/tmp/poltergeist_log.txt", "a"),
54
+ js_errors: false,
55
+ timeout: 90
56
+ })
57
+ end
58
+
59
+ page.driver.headers = { "Accept-Language" => "en" }
60
+
61
+ login
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,85 @@
1
+ module Codes
2
+ class ItunesConnect
3
+ # All the private helpers
4
+
5
+ private
6
+
7
+ # Opens the app details page of the given app.
8
+ # @param app (Deliver::App) the app that should be opened
9
+ # @return (bool) true if everything worked fine
10
+ # @raise [ItunesConnectGeneralError] General error while executing
11
+ # this action
12
+ # @raise [ItunesConnectLoginError] Login data is wrong
13
+ def open_app_page(app)
14
+ verify_app(app)
15
+
16
+ Helper.log.info "Opening detail page for app #{app}"
17
+
18
+ visit APP_DETAILS_URL.gsub("[[app_id]]", app.apple_id.to_s)
19
+
20
+ wait_for_elements('.page-subnav')
21
+ sleep 5
22
+
23
+ if current_url.include? "wa/defaultError" # app could not be found
24
+ raise "Could not open app details for app '#{app}'. Make sure you're using the correct Apple ID and the correct Apple developer account (#{CredentialsManager::PasswordManager.shared_manager.username}).".red
25
+ end
26
+
27
+ true
28
+ rescue => ex
29
+ error_occured(ex)
30
+ end
31
+
32
+ def verify_app(app)
33
+ raise ItunesConnectGeneralError.new("No valid Deliver::App given") unless app.kind_of? Deliver::App
34
+ raise ItunesConnectGeneralError.new("App is missing information (apple_id not given)") unless (app.apple_id || '').to_s.length > 5
35
+ end
36
+
37
+ def error_occured(ex)
38
+ snap
39
+ raise ex # re-raise the error after saving the snapshot
40
+ end
41
+
42
+ def snap
43
+ path = File.expand_path("Error#{Time.now.to_i}.png")
44
+ # rubocop:disable Lint/Debugger
45
+ save_screenshot(path, full: true)
46
+ # rubocop:enable Lint/Debugger
47
+ system("open '#{path}'") unless ENV['SIGH_DISABLE_OPEN_ERROR']
48
+ end
49
+
50
+ # Since Apple takes for ages, after the upload is properly processed, we have to wait here
51
+ def wait_for_preprocessing
52
+ started = Time.now
53
+
54
+ # Wait, while iTunesConnect is processing the uploaded file
55
+ while page.has_content? "Uploaded"
56
+ # iTunesConnect is super slow... so we have to wait...
57
+ Helper.log.info("Sorry, we have to wait for iTunesConnect, since it's still processing the uploaded ipa file\n" \
58
+ "If this takes longer than 45 minutes, you have to re-upload the ipa file again.\n" \
59
+ "You can always open the browser page yourself: '#{current_url}'\n" \
60
+ "Passed time: ~#{((Time.now - started) / 60.0).to_i} minute(s)")
61
+ sleep 30
62
+ visit current_url
63
+ sleep 30
64
+ end
65
+ end
66
+
67
+ def wait_for_elements(name)
68
+ counter = 0
69
+ results = all(name)
70
+ while results.count == 0
71
+ # Helper.log.debug "Waiting for #{name}"
72
+ sleep 0.2
73
+
74
+ results = all(name)
75
+
76
+ counter += 1
77
+ if counter > 100
78
+ Helper.log.debug caller
79
+ raise ItunesConnectGeneralError.new("Couldn't find element '#{name}' after waiting for quite some time")
80
+ end
81
+ end
82
+ return results
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,65 @@
1
+ module Codes
2
+ # Login code
3
+ class ItunesConnect
4
+ # Loggs in a user with the given login data on the iTC Frontend.
5
+ # You don't need to pass a username and password. It will
6
+ # Automatically be fetched using the {CredentialsManager::PasswordManager}.
7
+ # This method will also automatically be called when triggering other
8
+ # actions like {#open_app_page}
9
+ # @param user (String) (optional) The username/email address
10
+ # @param password (String) (optional) The password
11
+ # @return (bool) true if everything worked fine
12
+ # @raise [ItunesConnectGeneralError] General error while executing
13
+ # this action
14
+ # @raise [ItunesConnectLoginError] Login data is wrong
15
+ def login(user = nil, password = nil)
16
+ Helper.log.info "Logging into iTunesConnect"
17
+
18
+ user ||= CredentialsManager::PasswordManager.shared_manager.username
19
+ password ||= CredentialsManager::PasswordManager.shared_manager.password
20
+
21
+ result = visit ITUNESCONNECT_URL
22
+ raise "Could not open iTunesConnect" unless result['status'] == 'success'
23
+
24
+ sleep 3
25
+
26
+ if page.has_content? "My Apps"
27
+ # Already logged in
28
+ return true
29
+ end
30
+
31
+ begin
32
+ wait_for_elements('#accountpassword')
33
+ rescue
34
+ # when the user is already logged in, this will raise an exception
35
+ end
36
+
37
+ fill_in "accountname", with: user
38
+ fill_in "accountpassword", with: password
39
+
40
+ begin
41
+ page.evaluate_script "appleConnectForm.submit()"
42
+ sleep 7
43
+
44
+ if page.has_content? "My Apps"
45
+ # Everything looks good
46
+ else
47
+ visit current_url # iTC sometimes is super buggy, try reloading the site
48
+ sleep 3
49
+ unless page.has_content? "My Apps"
50
+ raise ItunesConnectLoginError.new("Looks like your login data was correct, but you do not have access to the apps.".red)
51
+ end
52
+ end
53
+ rescue => ex
54
+ Helper.log.debug(ex)
55
+ raise ItunesConnectLoginError.new("Error logging in user #{user} with the given password. Make sure you entered them correctly.".red)
56
+ end
57
+
58
+ Helper.log.info "Successfully logged into iTunesConnect"
59
+
60
+ true
61
+ rescue => ex
62
+ error_occured(ex)
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Codes
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-08 00:00:00.000000000 Z
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane_core
@@ -115,7 +115,7 @@ dependencies:
115
115
  - !ruby/object:Gem::Version
116
116
  version: 1.19.0
117
117
  - !ruby/object:Gem::Dependency
118
- name: codeclimate-test-reporter
118
+ name: coveralls
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
@@ -128,6 +128,34 @@ dependencies:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: fastlane
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: rubocop
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '0.34'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '0.34'
131
159
  description: Create promo codes for iOS Apps using the command line
132
160
  email:
133
161
  - codes@krausefx.com
@@ -143,6 +171,9 @@ files:
143
171
  - lib/codes/codes_runner.rb
144
172
  - lib/codes/dependency_checker.rb
145
173
  - lib/codes/itunes_connect.rb
174
+ - lib/codes/itunes_connect/itunes_connect.rb
175
+ - lib/codes/itunes_connect/itunes_connect_helper.rb
176
+ - lib/codes/itunes_connect/itunes_connect_login.rb
146
177
  - lib/codes/version.rb
147
178
  homepage: https://fastlane.tools
148
179
  licenses:
@@ -164,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
195
  version: '0'
165
196
  requirements: []
166
197
  rubyforge_project:
167
- rubygems_version: 2.4.6
198
+ rubygems_version: 2.5.0
168
199
  signing_key:
169
200
  specification_version: 4
170
201
  summary: Create promo codes for iOS Apps using the command line