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
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'produce/lib/produce/itunes_connect.rb', line 18
def create_new_app
application = fetch_application
if application
UI.success("App '#{Produce.config[:app_identifier]}' already exists (#{application.id}), nothing to do on App Store Connect")
else
emails = Produce.config[:itc_users] || []
user_ids = []
unless emails.empty?
UI.message("Verifying users exist before creating app...")
user_ids = find_user_ids(emails: emails)
end
UI.success("Creating new app '#{Produce.config[:app_name]}' on App Store Connect")
platforms = Produce.config[:platforms] || [Produce.config[:platform]]
platforms = platforms.map do |platform|
Spaceship::ConnectAPI::Platform.map(platform)
end
application = Spaceship::ConnectAPI::App.create(
name: Produce.config[:app_name],
version_string: Produce.config[:app_version] || "1.0",
sku: Produce.config[:sku].to_s,
primary_locale: language,
bundle_id: app_identifier,
platforms: platforms,
company_name: Produce.config[:company_name]
)
application = fetch_application
counter = 0
while application.nil?
counter += 1
UI.crash!("Couldn't find newly created app on App Store Connect - please check the website for more information") if counter == 200
UI.message("Waiting for the newly created application to be available on App Store Connect...")
sleep(15)
application = fetch_application
end
UI.crash!("Something went wrong when creating the new app - it's not listed in the App's list") unless application
UI.message("Ensuring version number")
platforms.each do |platform|
application.ensure_version!(Produce.config[:app_version], platform: platform) if Produce.config[:app_version]
end
unless user_ids.empty?
application.add_users(user_ids: user_ids)
UI.message("Successfuly added #{user_ids.size} #{user_ids.count == 1 ? 'user' : 'users'} to app")
end
UI.success("Successfully created new app '#{Produce.config[:app_name]}' on App Store Connect with ID #{application.id}")
end
return application.id
end
|