applebot 0.0.1

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.
@@ -0,0 +1,5 @@
1
+ module AppleBot
2
+ VERSION = "0.0.1"
3
+ DESCRIPTION = 'A robot for Apple Developer Center and iTunes Connect tasks'
4
+ WEBSITE = 'https://github.com/usepropeller/applebot'
5
+ end
data/lib/applebot.rb ADDED
@@ -0,0 +1,109 @@
1
+ require 'shellwords'
2
+ require 'tempfile'
3
+ require 'json'
4
+ require 'open3'
5
+
6
+ require 'active_support/core_ext/hash/indifferent_access'
7
+ require 'active_support/core_ext/object/blank'
8
+ require 'active_support/core_ext/module/attribute_accessors'
9
+ require 'active_support/core_ext/class/attribute'
10
+ require 'active_support/core_ext/hash/except'
11
+
12
+ require 'terminal-table'
13
+
14
+ module AppleBot
15
+ module_function
16
+
17
+ def applebot_root_path
18
+ File.expand_path(File.join(File.dirname(__FILE__), '..'))
19
+ end
20
+
21
+ def phantom_scripts_path
22
+ File.join(applebot_root_path, 'phantom')
23
+ end
24
+
25
+ def command_file_path(command)
26
+ file = command
27
+ if !file.end_with?(".js")
28
+ file << ".js"
29
+ end
30
+ File.join(phantom_scripts_path, file)
31
+ end
32
+
33
+ def casper_installed?
34
+ !!find_executable("casperjs")
35
+ end
36
+
37
+ def shell
38
+ @shell ||= Shell.new
39
+ end
40
+ end
41
+
42
+ require_relative 'applebot/commands'
43
+ require_relative 'applebot/version'
44
+ require_relative 'applebot/error'
45
+ require_relative 'applebot/shell'
46
+ require_relative 'applebot/mkmf'
47
+ require_relative 'applebot/command_proxy'
48
+
49
+ module AppleBot
50
+ module_function
51
+
52
+ def set_credentials(options = {})
53
+ @username = options[:username]
54
+ @password = options[:password]
55
+ true
56
+ end
57
+
58
+ def with_credentials(options = {})
59
+ set_credentials(options)
60
+ yield(self).tap do |res|
61
+ set_credentials({})
62
+ end
63
+ end
64
+
65
+ def run_command(command, options = {})
66
+ raise "CasperJS is not installed - `brew install caspjerjs --devel` or visit http://casperjs.org/" if !casper_installed?
67
+
68
+ options = options.with_indifferent_access
69
+ verbose = options.delete(:verbose)
70
+ format = options.delete(:format).to_s
71
+ print_result = options.delete(:print_result)
72
+
73
+ if options[:manifest]
74
+ options = File.open(options[:manifest], 'r') { |f|
75
+ JSON.parse(f.read).with_indifferent_access
76
+ }
77
+ end
78
+
79
+ command_file = command_file_path(command)
80
+ manifest_file = Tempfile.new('manifest.json')
81
+ begin
82
+ write_options = {
83
+ "output_format" => 'json',
84
+ "username" => options[:username] || @username || ENV['APPLEBOT_USERNAME'],
85
+ "password" => options[:password] || @password || ENV['APPLEBOT_PASSWORD'],
86
+ "applebot_root_path" => AppleBot.applebot_root_path
87
+ }.merge(options)
88
+ manifest_file.write(write_options.to_json)
89
+
90
+ manifest_file.close
91
+
92
+ sys_command = "casperjs #{command_file} --manifest=#{manifest_file.path.to_s.shellescape}"
93
+ command_result = shell.command(sys_command, verbose, format)
94
+
95
+ if command_result != nil
96
+ shell.result(command_result, format, print_result)
97
+ else
98
+ true
99
+ end
100
+ ensure
101
+ manifest_file.unlink
102
+ end
103
+ end
104
+
105
+ AppleBot.commands.each { |command|
106
+ command_proxy = CommandProxy.for(command)
107
+ command_proxy.attach_to(self)
108
+ }
109
+ end
@@ -0,0 +1,318 @@
1
+ {
2
+ "create_app.js": {
3
+ "namespace": "app",
4
+ "action": "create",
5
+ "description": "Create App",
6
+ "options": {
7
+ "required": [
8
+ {
9
+ "key":"title",
10
+ "description": "App's title"
11
+ }, {
12
+ "key": "sku",
13
+ "description": "App's SKU"
14
+ }, {
15
+ "key": "id",
16
+ "description": "App's bundle identifier"
17
+ }, {
18
+ "key": "app_version",
19
+ "description": "App version number"
20
+ }, {
21
+ "key": "copyright",
22
+ "description": "App copyright info"
23
+ }, {
24
+ "key": "first_name",
25
+ "description": "Contact Info first name"
26
+ }, {
27
+ "key": "last_name",
28
+ "description": "Contact Info last name"
29
+ }, {
30
+ "key": "email",
31
+ "description": "Contact Info email"
32
+ }, {
33
+ "key": "phone",
34
+ "description": "Contact Info phone number"
35
+ }, {
36
+ "key": "primary_category",
37
+ "description": "Primary Category of your app",
38
+ "values": ["book", "business", "catalogs",
39
+ "education", "entertainment", "finance",
40
+ "food_and_drink", "games", "health_and_fitness",
41
+ "lifestyle", "medical", "music", "navigation",
42
+ "news", "photo_and_video", "productivity",
43
+ "reference", "social_networking", "sports",
44
+ "travel", "utilities", "weather"]
45
+ }, {
46
+ "key": "secondary_category",
47
+ "description": "Secondary Category of your app",
48
+ "values": ["book", "business", "catalogs",
49
+ "education", "entertainment", "finance",
50
+ "food_and_drink", "games", "health_and_fitness",
51
+ "lifestyle", "medical", "music", "navigation",
52
+ "news", "photo_and_video", "productivity",
53
+ "reference", "social_networking", "sports",
54
+ "travel", "utilities", "weather"]
55
+ }, {
56
+ "key": "description",
57
+ "description": "App description"
58
+ }, {
59
+ "key": "keywords",
60
+ "description": "App keywords"
61
+ }, {
62
+ "key": "support_url",
63
+ "description": "App support URL"
64
+ }, {
65
+ "key": "large_icon",
66
+ "description": "File path for iTunes app icon (1024x1024x)"
67
+ }, {
68
+ "key": "screenshots_35",
69
+ "description": "JSON array of paths for screenshots of app on 3.5\" devices"
70
+ }, {
71
+ "key": "screenshots_4",
72
+ "description": "JSON array of paths for screenshots of app on 4\" devices"
73
+ }
74
+ ],
75
+ "optional": [
76
+ {
77
+ "key": "availability_date",
78
+ "description": "Date to make the app available (MM/DD/YYYY)",
79
+ "default": "as soon as approved"
80
+ }, {
81
+ "key": "price_tier",
82
+ "description": "App's price tier - either 'free' or a number",
83
+ "default": "'free'"
84
+ }, {
85
+ "key": "marketing_url",
86
+ "description": "App marketing URL"
87
+ }, {
88
+ "batch": true,
89
+ "keys": [
90
+ "alcohol_tobacco_or_drug_use_or_references", "cartoon_or_fantasy_violence",
91
+ "graphic_sexual_content_and_nudity", "horror_fear_themes",
92
+ "medical_treatment_information",
93
+ "mature_suggestive_themes", "profanity_or_crude_humor",
94
+ "prolonged_graphic_or_sadistic_realistic_violence", "realistic_violence",
95
+ "sexual_content_or_nudity", "simulated_gambling"
96
+ ],
97
+ "description": "Content frequency for app",
98
+ "values": ["none", "infrequent", "frequent"],
99
+ "default": "'none'"
100
+ }, {
101
+ "batch": true,
102
+ "keys": ["unrestricted_web_access", "gambling_and_contests"],
103
+ "description": "Content occurance for app",
104
+ "values": ["no", "yes"],
105
+ "default": "'no'"
106
+ }
107
+ ]
108
+ }
109
+ },
110
+
111
+ "update_app.js": {
112
+ "namespace": "app",
113
+ "action": "update",
114
+ "description": "Update App",
115
+ "options": {
116
+ "required": [
117
+ {
118
+ "key":"title",
119
+ "description": "App's existing title"
120
+ }, {
121
+ "key": "app_version",
122
+ "description": "Update version number"
123
+ }, {
124
+ "key": "update_description",
125
+ "description": "Update release notes"
126
+ }
127
+ ],
128
+ "optional": [
129
+ {
130
+ "key":"new_title",
131
+ "description": "App's new title"
132
+ }, {
133
+ "key": "large_icon",
134
+ "description": "File path for new iTunes app icon (1024x1024x)"
135
+ }, {
136
+ "key": "screenshots_35",
137
+ "description": "JSON array of paths for new screenshots of app on 3.5\" devices"
138
+ }, {
139
+ "key": "screenshots_4",
140
+ "description": "JSON array of paths for new screenshots of app on 4\" devices"
141
+ }
142
+ ]
143
+ }
144
+ },
145
+ "remove_from_sale_app.js": {
146
+ "namespace": "app",
147
+ "action": "remove_from_sale",
148
+ "description": "Remove app from sale",
149
+ "options": {
150
+ "required": [
151
+ {
152
+ "key":"title",
153
+ "description": "App's existing title"
154
+ }
155
+ ]
156
+ }
157
+ },
158
+ "reject_binary_app.js": {
159
+ "namespace": "app",
160
+ "action": "reject_binary",
161
+ "description": "Reject the binary of an pending release",
162
+ "options": {
163
+ "required": [
164
+ {
165
+ "key": "title",
166
+ "description": "App title"
167
+ }
168
+ ],
169
+ "optional": [
170
+ {
171
+ "key": "app_version",
172
+ "description": "App version"
173
+ }
174
+ ]
175
+ }
176
+ },
177
+
178
+ "create_app_id.js": {
179
+ "namespace": "app_id",
180
+ "action": "create",
181
+ "description": "Create App ID",
182
+ "options": {
183
+ "required": [
184
+ {
185
+ "key": "name",
186
+ "description": "App ID description"
187
+ }, {
188
+ "key":"app_id",
189
+ "description": "App bundle identifier"
190
+ }
191
+ ],
192
+ "optional": [
193
+ {
194
+ "key": "data_protection",
195
+ "description": "Use Data Protection service for app ID",
196
+ "values": ["complete", "unless_open", "until_first_auth"]
197
+ }, {
198
+ "key": "icloud",
199
+ "description": "Use iCloud with app ID",
200
+ "values": ["true", "false"],
201
+ "default": "'false'"
202
+ }, {
203
+ "key": "inter_app_audio",
204
+ "description": "Use Inter-App Audio with app id",
205
+ "values": ["true", "false"],
206
+ "default": "'false'"
207
+ }, {
208
+ "key": "passbook",
209
+ "description": "Use Passbook with app id",
210
+ "values": ["true", "false"],
211
+ "default": "'false'"
212
+ }, {
213
+ "key": "push",
214
+ "description": "Use Push Notifications/APNS with app id",
215
+ "values": ["true", "false"],
216
+ "default": "'false'"
217
+ }
218
+ ]
219
+ }
220
+ },
221
+ "delete_app_id.js": {
222
+ "namespace": "app_id",
223
+ "action": "delete",
224
+ "description": "Delete App ID",
225
+ "options": {
226
+ "required": [
227
+ {
228
+ "key": "name",
229
+ "description": "App ID description"
230
+ }
231
+ ]
232
+ }
233
+ },
234
+ "list_app_id.js": {
235
+ "namespace": "app_id",
236
+ "action": "list",
237
+ "description": "List App IDs",
238
+ "options": {
239
+ "optional": [
240
+ {
241
+ "key": "source",
242
+ "description": "The source to list bundle IDs from (iTunes Connect or Apple Developer Connection)",
243
+ "values": ["itc", "adc"],
244
+ "default": "'adc'"
245
+ }
246
+ ]
247
+ }
248
+ },
249
+
250
+ "create_profile.js": {
251
+ "namespace": "profile",
252
+ "action": "create",
253
+ "description": "Create Provisioning Profile",
254
+ "options": {
255
+ "required": [
256
+ {
257
+ "key": "environment",
258
+ "description": "The type of profile to create",
259
+ "values": ["development", "store", "adhoc", "inhouse"]
260
+ }, {
261
+ "key": "name",
262
+ "description": "Profile name"
263
+ }, {
264
+ "key":"app_id",
265
+ "description": "App bundle identifier"
266
+ }],
267
+ "optional": [{
268
+ "key": "certificate",
269
+ "description": "Certificate name to create the profile with",
270
+ "default": "The first certificate listed"
271
+ },
272
+ {
273
+ "key":"download_to",
274
+ "description": "File path to download the profile to"
275
+ }
276
+ ]
277
+ }
278
+ },
279
+ "download_profile.js": {
280
+ "namespace": "profile",
281
+ "action": "download",
282
+ "description": "Download a Provisioning Profile",
283
+ "options": {
284
+ "required": [
285
+ {
286
+ "key":"app_id",
287
+ "description": "App bundle identifier"
288
+ }, {
289
+ "key":"download_to",
290
+ "description": "File path to download the profile to"
291
+ }
292
+ ],
293
+ "optional": [
294
+ {
295
+ "key": "profile_type",
296
+ "description": "The type of profile to use",
297
+ "values": ["development", "distribution"],
298
+ "default": "'development'"
299
+ }
300
+ ]
301
+ }
302
+ },
303
+ "list_profile.js": {
304
+ "namespace": "profile",
305
+ "action": "list",
306
+ "description": "List Provisioning Profiles",
307
+ "options": {
308
+ "optional": [
309
+ {
310
+ "key": "profile_type",
311
+ "description": "The type of profile to use",
312
+ "values": ["development", "distribution"],
313
+ "default": "'development'"
314
+ }
315
+ ]
316
+ }
317
+ }
318
+ }