fastlane-plugin-mobile_center 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5bbe01408fcdb08ca3ef3cb41a41f672ee50db37
4
- data.tar.gz: 22f70357520178ab34052d7185a7d2091fac6fbd
3
+ metadata.gz: c6b928d0dcb6737f976da5100c27d6c0b3095962
4
+ data.tar.gz: 93905991834fc81f357649a3e9112b3c4a395c12
5
5
  SHA512:
6
- metadata.gz: ecf6fef584cbb16506ac0774edf995510c7c6803aeff3ee393f536ec48fc47ef0a2592c32e8604a01d5c93b0430541b56df2d232721c27916bf2ad91ee3ee321
7
- data.tar.gz: d8a13b57851840f12c93ff996af58cd302d9fa0dd48469d4fc1718db1fb90a0849ea537982cbd077d0406a11d9be55a515aa6d39c7812925c4c51f1289998f9c
6
+ metadata.gz: fc6a47bd323e5a681fe8305780fc930612900c92dfa866df5f67736f32339b348ffcd38ff5705c4d5f72b558e549e12dd7d9a444afe9c31f8b286d373aef4ff9
7
+ data.tar.gz: b7dd94584d050b8aa3ad7dc25a7f62bc5c02b6171866eef3d521ba3106702ee158d94290b0e769a81f9a99f151c414cc54b83a9c7c6362f56e809cb3fa669802
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # mobile_center plugin
2
2
 
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-mobile_center)
4
+ [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-mobile_center.svg)](https://badge.fury.io/rb/fastlane-plugin-mobile_center)
5
+ [![Build Status](https://travis-ci.org/Microsoft/mobile-center-plugin-fastlane.svg?branch=master)](https://travis-ci.org/Microsoft/mobile-center-plugin-fastlane)
4
6
 
5
7
  ## Getting Started
6
8
 
@@ -304,12 +304,87 @@ module Fastlane
304
304
  end
305
305
  end
306
306
 
307
+ # returns true if app exists, false in case of 404 and error otherwise
308
+ def self.get_app(api_token, owner_name, app_name)
309
+ connection = self.connection
310
+
311
+ response = connection.get do |req|
312
+ req.url("/v0.1/apps/#{owner_name}/#{app_name}")
313
+ req.headers['X-API-Token'] = api_token
314
+ req.headers['internal-request-source'] = "fastlane"
315
+ end
316
+
317
+ case response.status
318
+ when 200...300
319
+ UI.message("DEBUG: #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
320
+ true
321
+ when 404
322
+ UI.message("DEBUG: #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
323
+ false
324
+ else
325
+ UI.error("Error #{response.status}: #{response.body}")
326
+ false
327
+ end
328
+ end
329
+
330
+ # checks app existance, if ther is no such - creates it
331
+ def self.get_or_create_app(params)
332
+ api_token = params[:api_token]
333
+ owner_name = params[:owner_name]
334
+ app_name = params[:app_name]
335
+
336
+ platforms = {
337
+ "Android" => ['Java', 'React-Native', 'Xamarin'],
338
+ "iOS" => ['Objective-C-Swift', 'React-Native', 'Xamarin']
339
+ }
340
+
341
+ if self.get_app(api_token, owner_name, app_name)
342
+ true
343
+ else
344
+ if Helper.test? || UI.confirm("App with name #{app_name} not found, create one?")
345
+ connection = self.connection
346
+
347
+ os = Helper.test? ? "Android" : UI.select("Select OS", ["Android", "iOS"])
348
+ platform = Helper.test? ? "Java" : UI.select("Select Platform", platforms[os])
349
+
350
+ response = connection.post do |req|
351
+ req.url("/v0.1/apps")
352
+ req.headers['X-API-Token'] = api_token
353
+ req.headers['internal-request-source'] = "fastlane"
354
+ req.body = {
355
+ "display_name" => app_name,
356
+ "name" => app_name,
357
+ "os" => os,
358
+ "platform" => platform
359
+ }
360
+ end
361
+
362
+ case response.status
363
+ when 200...300
364
+ created = response.body
365
+ UI.message("DEBUG: #{JSON.pretty_generate(created)}") if ENV['DEBUG']
366
+ UI.success("Created #{os}/#{platform} app with name \"#{created['name']}\"")
367
+ true
368
+ else
369
+ UI.error("Error creating app #{response.status}: #{response.body}")
370
+ false
371
+ end
372
+ else
373
+ UI.error("Lane aborted")
374
+ false
375
+ end
376
+ end
377
+ end
378
+
307
379
  def self.run(params)
308
380
  values = params.values
309
381
  upload_dsym_only = params[:upload_dsym_only]
310
382
 
311
- self.run_release_upload(params) unless upload_dsym_only
312
- self.run_dsym_upload(params)
383
+ # if app found or successfully created
384
+ if self.get_or_create_app(params)
385
+ self.run_release_upload(params) unless upload_dsym_only
386
+ self.run_dsym_upload(params)
387
+ end
313
388
 
314
389
  return values if Helper.test?
315
390
  end
@@ -350,7 +425,7 @@ module Fastlane
350
425
 
351
426
  FastlaneCore::ConfigItem.new(key: :app_name,
352
427
  env_name: "MOBILE_CENTER_APP_NAME",
353
- description: "App name",
428
+ description: "App name. If there is no app with such name, you will be prompted to create one",
354
429
  optional: false,
355
430
  type: String,
356
431
  verify_block: proc do |value|
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module MobileCenter
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-mobile_center
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-10 00:00:00.000000000 Z
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 2.28.9
89
+ version: 2.29.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.28.9
96
+ version: 2.29.0
97
97
  description:
98
98
  email:
99
99
  executables: []