lib/produce/developer_center.rb in produce-0.2.1 vs lib/produce/developer_center.rb in produce-0.3.0
- old
+ new
@@ -1,71 +1,57 @@
-require 'fastlane_core/developer_center/developer_center'
+require 'spaceship'
+require 'babosa'
module Produce
- class DeveloperCenter < FastlaneCore::DeveloperCenter
- APPS_URL = "https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action"
- CREATE_APP_URL = "https://developer.apple.com/account/ios/identifiers/bundle/bundleCreate.action"
+ class DeveloperCenter
def run(config)
@config = config
+ login
create_new_app
- rescue => ex
- error_occured(ex)
end
def create_new_app
+ ENV["CREATED_NEW_APP_ID"] = Time.now.to_i.to_s
+
if app_exists?
Helper.log.info "App '#{@config[:app_name]}' already exists, nothing to do on the Dev Center".green
ENV["CREATED_NEW_APP_ID"] = nil
# Nothing to do here
else
app_name = valid_name_for(@config[:app_name])
Helper.log.info "Creating new app '#{app_name}' on the Apple Dev Center".green
- visit CREATE_APP_URL
- wait_for_elements("*[name='appIdName']").first.set app_name
- wait_for_elements("*[name='explicitIdentifier']").first.set @config[:bundle_identifier]
- click_next
+
+ app = Spaceship.app.create!(bundle_id: @config[:bundle_identifier].to_s,
+ name: app_name)
- sleep 5 # sometimes this takes a while and we don't want to timeout
+ Helper.log.info "Created app #{app}"
+
+ raise "Something went wrong when creating the new app - it's not listed in the apps list" unless app_exists?
- if all(".form-error").count > 0
- error = all(".form-error").collect { |a| a.text }.join("\n")
- raise error.red
- end
+ ENV["CREATED_NEW_APP_ID"] = Time.now.to_i.to_s
- wait_for_elements("form[name='bundleSubmit']") # this will show the summary of the given information
- click_next
-
- sleep 5 # sometimes this takes a while and we don't want to timeout
-
- wait_for_elements(".ios.bundles.confirmForm.complete")
- click_on "Done"
-
- raise "Something went wrong when creating the new app - it's not listed in the App's list" unless app_exists?
-
- ENV["CREATED_NEW_APP_ID"] = Time.now.to_s
-
Helper.log.info "Finished creating new app '#{app_name}' on the Dev Center".green
end
return true
end
+ def valid_name_for(input)
+ latinazed = input.to_slug.transliterate.to_s # remove accents
+ latinazed.gsub(/[^0-9A-Za-z\d\s]/, '') # remove non-valid characters
+ end
private
def app_exists?
- visit APPS_URL
-
- wait_for_elements("td[aria-describedby='grid-table_identifier']").each do |app|
- identifier = app['title']
-
- return true if identifier.to_s == @config[:bundle_identifier].to_s
- end
-
- false
+ Spaceship.app.find(@config[:bundle_identifier].to_s) != nil
end
- def click_next
- wait_for_elements('.button.small.blue.right.submit').last.click
+ def login
+ user = ENV["CERT_USERNAME"] || ENV["DELIVER_USER"] || CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
+ manager = CredentialsManager::PasswordManager.shared_manager(user)
+
+ Spaceship.login(user, manager.password)
+ Spaceship.select_team
end
end
end