fastlane-plugin-appcircle_testing_distribution 0.2.3 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04a8808916e178499dd62526d02d5408c1161d6a7faf2b3dab95c5e4f71d83bc
4
- data.tar.gz: 5cca9f900d1a7a4ac55be0c3672850c11b66b5ec10d6a954f02a8b740b5838b0
3
+ metadata.gz: ceb1940fa8c0d58e985bded6be73f61f64afb0599e852c52431811159af01212
4
+ data.tar.gz: 130705717aba452336764a57fe29a5c14c29b648e8d528e1ce3edae406e66359
5
5
  SHA512:
6
- metadata.gz: 6f56fd4fe450019acf7f09b21782fd27ecef0126512ec9ed12685c768218cfc41ac31f48b6b23eeb63442d1af017610be27d3bcacb637279204082accf6bfada
7
- data.tar.gz: 5bd6a6082c8f950098c48cc4a741c4969627bda212e1a3f2246f06301c0c7219aa3be370da94a13d3c8517daf6803637e96329c0b6679d4953ac703e99f624a7
6
+ metadata.gz: c1537e66400a4f57df3553ce8ef8fcadc89bee630557aa2eed668e7862e32327f391e0e6c280a7b01d7b9568ce3e3677608d771f089a4eb9aeb79f9ee0792405
7
+ data.tar.gz: f39fbbe473f79aceeac915a63fdbe9a638eb56a91172b8c7403d34367d95883a31e32f78cafb4fdb9ef3526108b534c4efb58a449f740ea906264aed08e4fb4b
@@ -37,6 +37,7 @@ module Fastlane
37
37
  UI.user_error!("Message field is required. Please provide a valid message")
38
38
  end
39
39
 
40
+
40
41
  authToken = self.ac_login(personalAPIToken, personalAccessKey)
41
42
 
42
43
  profileId = TDUploadService.get_profile_id(authToken, profileName, createProfileIfNotExists)
@@ -44,25 +45,27 @@ module Fastlane
44
45
  end
45
46
 
46
47
  def self.ac_login(personalAPIToken, personalAccessKey)
47
- if personalAccessKey
48
- user = TDAuthService.get_ac_token_with_personal_access_key(personal_access_key: personalAccessKey)
49
- else
50
- user = TDAuthService.get_ac_token(pat: personalAPIToken)
48
+ begin
49
+ if personalAccessKey
50
+ user = TDAuthService.get_ac_token_with_personal_access_key(personal_access_key: personalAccessKey)
51
+ else
52
+ user = TDAuthService.get_ac_token(pat: personalAPIToken)
53
+ end
54
+ UI.success("Login is successful.")
55
+ return user.accessToken
56
+ rescue => e
57
+ UI.user_error!("Login failed: #{e.message}")
51
58
  end
52
- UI.success("Login is successful.")
53
- return user.accessToken
54
- rescue StandardError => e
55
- UI.user_error!("Login failed: #{e.message}")
56
59
  end
57
-
60
+
58
61
  def self.checkTaskStatus(authToken, taskId)
59
62
  uri = URI.parse("https://api.appcircle.io/task/v1/tasks/#{taskId}")
60
63
  timeout = 1
61
-
64
+
62
65
  response = self.send_request(uri, authToken)
63
- if response.kind_of?(Net::HTTPSuccess)
66
+ if response.is_a?(Net::HTTPSuccess)
64
67
  stateValue = JSON.parse(response.body)["stateValue"]
65
-
68
+
66
69
  if stateValue == 1
67
70
  sleep(1)
68
71
  return checkTaskStatus(authToken, taskId)
@@ -87,15 +90,17 @@ module Fastlane
87
90
  end
88
91
 
89
92
  def self.ac_upload(token, appPath, profileID, message)
90
- response = TDUploadService.upload_artifact(token: token, message: message, app: appPath, dist_profile_id: profileID)
91
- result = self.checkTaskStatus(token, response['taskId'])
93
+ begin
94
+ response = TDUploadService.upload_artifact(token: token, message: message, app: appPath, dist_profile_id: profileID)
95
+ result = self.checkTaskStatus(token, response['taskId'])
92
96
 
93
- if result
94
- UI.success("#{appPath} Uploaded to profile id #{profileID} successfully 🎉")
97
+ if result
98
+ UI.success("#{appPath} Uploaded to profile id #{profileID} successfully 🎉")
99
+ end
100
+ rescue => e
101
+ status_code = e.respond_to?(:response) && e.response ? e.response.code : 'unknown'
102
+ UI.user_error!("Upload failed with status code #{status_code}, with message '#{e.message}'")
95
103
  end
96
- rescue StandardError => e
97
- status_code = e.respond_to?(:response) && e.response ? e.response.code : 'unknown'
98
- UI.user_error!("Upload failed with status code #{status_code}, with message '#{e.message}'")
99
104
  end
100
105
 
101
106
  def self.description
@@ -122,19 +127,19 @@ module Fastlane
122
127
  description: "Provide Personal API Token to authenticate connections to Appcircle services (alternative to personalAccessKey)",
123
128
  optional: true,
124
129
  type: String),
125
-
130
+
126
131
  FastlaneCore::ConfigItem.new(key: :personalAccessKey,
127
132
  env_name: "AC_PERSONAL_ACCESS_KEY",
128
133
  description: "Provide Personal Access Key to authenticate connections to Appcircle services (alternative to personalAPIToken)",
129
134
  optional: true,
130
135
  type: String),
131
-
136
+
132
137
  FastlaneCore::ConfigItem.new(key: :profileName,
133
138
  env_name: "AC_PROFILE_NAME",
134
139
  description: "Enter the profile name of the Appcircle distribution profile. This name uniquely identifies the profile under which your applications will be distributed",
135
140
  optional: false,
136
141
  type: String),
137
-
142
+
138
143
  FastlaneCore::ConfigItem.new(key: :createProfileIfNotExists,
139
144
  env_name: "AC_CREATE_PROFILE_IF_NOT_EXISTS",
140
145
  description: "If the profile does not exist, create a new profile with the given name",
@@ -3,6 +3,7 @@ require 'uri'
3
3
  require 'cgi'
4
4
  require 'json'
5
5
 
6
+
6
7
  class UserResponse
7
8
  attr_accessor :accessToken
8
9
 
@@ -20,7 +21,7 @@ module TDAuthService
20
21
  request = Net::HTTP::Post.new(uri)
21
22
  request.content_type = 'application/x-www-form-urlencoded'
22
23
  request['Accept'] = 'application/json'
23
-
24
+
24
25
  # Encode parameters
25
26
  params = { pat: pat }
26
27
  request.body = URI.encode_www_form(params)
@@ -30,8 +31,10 @@ module TDAuthService
30
31
  http.request(request)
31
32
  end
32
33
 
34
+
35
+
33
36
  # Check response
34
- if response.kind_of?(Net::HTTPSuccess)
37
+ if response.is_a?(Net::HTTPSuccess)
35
38
  response_data = JSON.parse(response.body)
36
39
 
37
40
  user = UserResponse.new(
@@ -52,7 +55,7 @@ module TDAuthService
52
55
  request = Net::HTTP::Post.new(uri)
53
56
  request.content_type = 'application/x-www-form-urlencoded'
54
57
  request['Accept'] = 'application/json'
55
-
58
+
56
59
  # Encode parameters
57
60
  params = { 'personal-access-key' => personal_access_key }
58
61
  request.body = URI.encode_www_form(params)
@@ -63,7 +66,7 @@ module TDAuthService
63
66
  end
64
67
 
65
68
  # Check response
66
- if response.kind_of?(Net::HTTPSuccess)
69
+ if response.is_a?(Net::HTTPSuccess)
67
70
  response_data = JSON.parse(response.body)
68
71
 
69
72
  user = UserResponse.new(
@@ -75,4 +78,4 @@ module TDAuthService
75
78
  raise "HTTP Request failed (#{response.code} #{response.message})"
76
79
  end
77
80
  end
78
- end
81
+ end
@@ -16,14 +16,10 @@ module TDUploadService
16
16
  Message: message,
17
17
  File: File.new(app, 'rb')
18
18
  }
19
-
19
+
20
20
  begin
21
21
  response = RestClient.post(url, payload, headers)
22
- begin
23
- JSON.parse(response.body)
24
- rescue StandardError
25
- response.body
26
- end
22
+ JSON.parse(response.body) rescue response.body
27
23
  rescue RestClient::ExceptionWithResponse => e
28
24
  raise e
29
25
  rescue StandardError => e
@@ -33,16 +29,18 @@ module TDUploadService
33
29
 
34
30
  def self.get_distribution_profiles(auth_token:)
35
31
  url = "#{BASE_URL}/distribution/v2/profiles"
36
-
32
+
37
33
  # Set up the headers with authentication
38
34
  headers = {
39
35
  Authorization: "Bearer #{auth_token}",
40
36
  accept: 'application/json'
41
37
  }
42
-
38
+
43
39
  begin
44
40
  response = RestClient.get(url, headers)
45
- JSON.parse(response.body)
41
+ parsed_response = JSON.parse(response.body)
42
+
43
+ parsed_response
46
44
  rescue RestClient::ExceptionWithResponse => e
47
45
  raise e
48
46
  rescue StandardError => e
@@ -60,7 +58,7 @@ module TDUploadService
60
58
  payload = {
61
59
  name: name
62
60
  }.to_json
63
-
61
+
64
62
  begin
65
63
  response = RestClient.post(url, payload, headers)
66
64
  JSON.parse(response.body)
@@ -81,28 +79,28 @@ module TDUploadService
81
79
  profileId = profile['id']
82
80
  end
83
81
  end
84
- rescue StandardError => e
82
+ rescue => e
85
83
  raise "Something went wrong while fetching profiles: #{e.message}"
86
84
  end
87
-
85
+
88
86
  if profileId.nil? && !createProfileIfNotExists
89
87
  raise "Error: The test profile '#{profileName}' could not be found. The option 'createProfileIfNotExists' is set to false, so no new profile was created. To automatically create a new profile if it doesn't exist, set 'createProfileIfNotExists' to true."
90
88
  end
91
89
 
92
90
  if profileId.nil? && createProfileIfNotExists
93
91
  begin
94
- puts("The test profile '#{profileName}' could not be found. A new profile is being created...")
92
+ puts "The test profile '#{profileName}' could not be found. A new profile is being created..."
95
93
  new_profile = TDUploadService.create_distribution_profile(name: profileName, auth_token: authToken)
96
94
  if new_profile.nil?
97
95
  raise "Error: The new profile could not be created."
98
96
  end
99
-
100
97
  profileId = new_profile['id']
101
- rescue StandardError => e
98
+ rescue => e
102
99
  raise "Something went wrong while creating a new profile: #{e.message}"
103
100
  end
104
101
  end
105
102
 
106
103
  return profileId
107
104
  end
105
+
108
106
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AppcircleTestingDistribution
3
- VERSION = "0.2.3"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appcircle_testing_distribution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - appcircleio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-24 00:00:00.000000000 Z
11
+ date: 2025-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '0'
27
27
  description:
28
28
  email: cloud@appcircle.io
29
29
  executables: []