fastlane-plugin-huawei_appgallery_connect 1.0.2 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb +9 -5
- data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_get_app_info.rb +76 -0
- data/lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb +40 -23
- data/lib/fastlane/plugin/huawei_appgallery_connect/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58302bbcf0fb6a8711345cf3a1498335a6c0a8a18dea0e4e34b9d0ae74383e5e
|
4
|
+
data.tar.gz: 1e60d771e423f877d9015275bcd4d4fdfe54f32bb80c5b116ccbe29cd1e8361a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66c42655b6fd63deadb0cc51645a7fdd76d366fcea290b3113fc8025160b045bb943df30c2aa91c43afc902b884e1b9d9603676693fcbfc51bb4e1e04884b59
|
7
|
+
data.tar.gz: 27f55e5c0c33a0c8ccc3064c0e0e78c3b61b07e79f415989b04c1357143892c382c7c140af6f80ba89cfb67012e1ec974d006d741823f3c76e935d2146b51a89
|
data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb
CHANGED
@@ -15,11 +15,9 @@ module Fastlane
|
|
15
15
|
Helper::HuaweiAppgalleryConnectHelper.update_appinfo(params[:client_id], token, params[:app_id], params[:privacy_policy_url])
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
upload_app = Helper::HuaweiAppgalleryConnectHelper.upload_app(token, params[:client_id], params[:app_id], params[:apk_path])
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
if upload_app
|
20
|
+
if upload_app && params[:submit_for_review] != false
|
23
21
|
Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
|
24
22
|
end
|
25
23
|
end
|
@@ -123,7 +121,13 @@ module Fastlane
|
|
123
121
|
env_name: "HUAWEI_APPGALLERY_CONNECT_APK_LANGUAGE",
|
124
122
|
description: "Language type. For details, please refer to https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-reference-langtype",
|
125
123
|
optional: true,
|
126
|
-
type: String)
|
124
|
+
type: String),
|
125
|
+
|
126
|
+
FastlaneCore::ConfigItem.new(key: :submit_for_review,
|
127
|
+
env_name: "HUAWEI_APPGALLERY_SUBMIT_FOR_REVIEW",
|
128
|
+
description: "Should submit the app for review. The default value is true. If set false will only upload the app, and you can submit for review from the console",
|
129
|
+
optional: true,
|
130
|
+
type: Boolean)
|
127
131
|
]
|
128
132
|
end
|
129
133
|
|
data/lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_get_app_info.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/huawei_appgallery_connect_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
ANDROID_APPGALLERY_APP_INFO = :ANDROID_APPGALLERY_APP_INFO
|
8
|
+
end
|
9
|
+
class HuaweiAppgalleryConnectGetAppInfoAction < Action
|
10
|
+
|
11
|
+
def self.run(params)
|
12
|
+
token = Helper::HuaweiAppgalleryConnectHelper.get_token(params[:client_id], params[:client_secret])
|
13
|
+
|
14
|
+
if token.nil?
|
15
|
+
UI.message("Cannot retrieve token, please check your client ID and client secret")
|
16
|
+
else
|
17
|
+
appInfo = Helper::HuaweiAppgalleryConnectHelper.get_app_info(token, params[:client_id],params[:app_id])
|
18
|
+
Actions.lane_context[SharedValues::ANDROID_APPGALLERY_APP_INFO] = appInfo
|
19
|
+
return appInfo
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.description
|
24
|
+
"Huawei AppGallery Connect Plugin"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.authors
|
28
|
+
["Shreejan Shrestha"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.return_value
|
32
|
+
# If your method provides a return value, you can describe here what it does
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.details
|
36
|
+
# Optional:
|
37
|
+
"Fastlane plugin to get Android app to Huawei AppGallery Connect information"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.available_options
|
41
|
+
[
|
42
|
+
FastlaneCore::ConfigItem.new(key: :client_id,
|
43
|
+
env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_ID",
|
44
|
+
description: "Huawei AppGallery Connect Client ID",
|
45
|
+
optional: false,
|
46
|
+
type: String),
|
47
|
+
|
48
|
+
FastlaneCore::ConfigItem.new(key: :client_secret,
|
49
|
+
env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET",
|
50
|
+
description: "Huawei AppGallery Connect Client Secret",
|
51
|
+
optional: false,
|
52
|
+
type: String),
|
53
|
+
|
54
|
+
FastlaneCore::ConfigItem.new(key: :app_id,
|
55
|
+
env_name: "HUAWEI_APPGALLERY_CONNECT_APP_ID",
|
56
|
+
description: "Huawei AppGallery Connect App ID",
|
57
|
+
optional: false,
|
58
|
+
type: String),
|
59
|
+
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.is_supported?(platform)
|
64
|
+
[:android].include?(platform)
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.example_code
|
69
|
+
[
|
70
|
+
'app_info = huawei_appgallery_connect_get_app_info'
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb
CHANGED
@@ -31,8 +31,19 @@ module Fastlane
|
|
31
31
|
request["client_id"] = client_id
|
32
32
|
request["Authorization"] = "Bearer #{token}"
|
33
33
|
response = http.request(request)
|
34
|
+
if !response.kind_of? Net::HTTPSuccess
|
35
|
+
UI.user_error!("Cannot obtain app info, please check API Token / Permissions (status code: #{response.code})")
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
result_json = JSON.parse(response.body)
|
39
|
+
|
40
|
+
if result_json['ret']['code'] == 0
|
41
|
+
UI.success("Successfully getting app info")
|
42
|
+
return result_json['appInfo']
|
43
|
+
else
|
44
|
+
UI.user_error!("Failed to get app info")
|
45
|
+
end
|
34
46
|
|
35
|
-
result_json = JSON.parse(res.body)
|
36
47
|
end
|
37
48
|
|
38
49
|
def self.update_appinfo(client_id, token, app_id, privacy_policy_url)
|
@@ -49,7 +60,10 @@ module Fastlane
|
|
49
60
|
request.body = {privacyPolicy: privacy_policy_url}.to_json
|
50
61
|
|
51
62
|
response = http.request(request)
|
52
|
-
|
63
|
+
if !response.kind_of? Net::HTTPSuccess
|
64
|
+
UI.user_error!("Cannot update app info, please check API Token / Permissions (status code: #{response.code})")
|
65
|
+
return false
|
66
|
+
end
|
53
67
|
result_json = JSON.parse(response.body)
|
54
68
|
|
55
69
|
if result_json['ret']['code'] == 0
|
@@ -60,7 +74,7 @@ module Fastlane
|
|
60
74
|
end
|
61
75
|
|
62
76
|
|
63
|
-
def self.upload_app(token, client_id, app_id, apk_path
|
77
|
+
def self.upload_app(token, client_id, app_id, apk_path)
|
64
78
|
UI.message("Fetching upload URL")
|
65
79
|
|
66
80
|
uri = URI.parse("https://connect-api.cloud.huawei.com/api/publish/v2/upload-url?appId=#{app_id}&suffix=apk")
|
@@ -73,6 +87,11 @@ module Fastlane
|
|
73
87
|
|
74
88
|
response = http.request(request)
|
75
89
|
|
90
|
+
if !response.kind_of? Net::HTTPSuccess
|
91
|
+
UI.user_error!("Cannot obtain upload url, please check API Token / Permissions (status code: #{response.code})")
|
92
|
+
return false
|
93
|
+
end
|
94
|
+
|
76
95
|
result_json = JSON.parse(response.body)
|
77
96
|
|
78
97
|
if result_json['uploadUrl'].nil?
|
@@ -87,26 +106,15 @@ module Fastlane
|
|
87
106
|
http = Net::HTTP.new(uri.host, uri.port)
|
88
107
|
http.use_ssl = true
|
89
108
|
request = Net::HTTP::Post.new(uri)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
# add the auth code
|
94
|
-
post_body << "--#{boundary}\r\n"
|
95
|
-
post_body << "Content-Disposition: form-data; name=\"authCode\"\r\n\r\n"
|
96
|
-
post_body << result_json['authCode']
|
97
|
-
# add the file count
|
98
|
-
post_body << "\r\n--#{boundary}\r\n"
|
99
|
-
post_body << "Content-Disposition: form-data; name=\"fileCount\"\r\n\r\n"
|
100
|
-
post_body << "1"
|
101
|
-
# add the apk
|
102
|
-
post_body << "\r\n--#{boundary}\r\n"
|
103
|
-
post_body << "Content-Disposition: form-data; name=\"file\"; filename=\"release.apk\"\r\n"
|
104
|
-
post_body << "Content-Type: multipart/form-data\r\n\r\n"
|
105
|
-
post_body << File.read(apk_path).encode('utf-8')
|
106
|
-
post_body << "\r\n--#{boundary}--\r\n"
|
107
|
-
request.body = post_body.join
|
109
|
+
|
110
|
+
form_data = [['file', File.open(apk_path.to_s)],['authCode', result_json['authCode']],['fileCount', '1']]
|
111
|
+
request.set_form form_data, 'multipart/form-data'
|
108
112
|
|
109
113
|
result = http.request(request)
|
114
|
+
if !result.kind_of? Net::HTTPSuccess
|
115
|
+
UI.user_error!("Cannot upload app, please check API Token / Permissions (status code: #{result.code})")
|
116
|
+
return false
|
117
|
+
end
|
110
118
|
result_json = JSON.parse(result.body)
|
111
119
|
|
112
120
|
if result_json['result']['result_code'].to_i == 0
|
@@ -121,7 +129,7 @@ module Fastlane
|
|
121
129
|
request["client_id"] = client_id
|
122
130
|
request["Authorization"] = "Bearer #{token}"
|
123
131
|
|
124
|
-
data = {fileType: 5,
|
132
|
+
data = {fileType: 5, files: [{
|
125
133
|
|
126
134
|
fileName: "release.apk",
|
127
135
|
fileDestUrl: result_json['result']['UploadFileRsp']['fileInfoList'][0]['fileDestUlr'],
|
@@ -131,13 +139,17 @@ module Fastlane
|
|
131
139
|
|
132
140
|
request.body = data
|
133
141
|
response = http.request(request)
|
134
|
-
|
142
|
+
if !response.kind_of? Net::HTTPSuccess
|
143
|
+
UI.user_error!("Cannot save app info, please check API Token / Permissions (status code: #{response.code})")
|
144
|
+
return false
|
145
|
+
end
|
135
146
|
result_json = JSON.parse(response.body)
|
136
147
|
|
137
148
|
if result_json['ret']['code'] == 0
|
138
149
|
UI.success("App information saved.")
|
139
150
|
return true
|
140
151
|
else
|
152
|
+
UI.user_error!(result_json)
|
141
153
|
UI.user_error!("Failed to save app information")
|
142
154
|
return false
|
143
155
|
end
|
@@ -203,6 +215,11 @@ module Fastlane
|
|
203
215
|
|
204
216
|
response = http.request(request)
|
205
217
|
|
218
|
+
if !response.kind_of? Net::HTTPSuccess
|
219
|
+
UI.user_error!("Cannot submit app for review (status code: #{response.code}, body: #{response.body})")
|
220
|
+
return false
|
221
|
+
end
|
222
|
+
|
206
223
|
result_json = JSON.parse(response.body)
|
207
224
|
|
208
225
|
if result_json['ret']['code'] == 0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-huawei_appgallery_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shreejan Shrestha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- README.md
|
147
147
|
- lib/fastlane/plugin/huawei_appgallery_connect.rb
|
148
148
|
- lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb
|
149
|
+
- lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_get_app_info.rb
|
149
150
|
- lib/fastlane/plugin/huawei_appgallery_connect/helper/huawei_appgallery_connect_helper.rb
|
150
151
|
- lib/fastlane/plugin/huawei_appgallery_connect/version.rb
|
151
152
|
homepage: https://github.com/shr3jn/fastlane-plugin-huawei_appgallery_connect
|