fastlane-plugin-pgyer 0.2.2 → 0.2.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
  SHA256:
3
- metadata.gz: 9b3168d388cca58506137723c74a12cd472e84e6b5c5d01ae72a3dde55aa9cee
4
- data.tar.gz: f6f898ceb67bcc0491b0495743f7a86c9a7cafcdccc20be17a95e1f735c3501a
3
+ metadata.gz: 8d3c45e770d204ec7bc1f613a1b27dc11db4f25043a8975e9bd63b6bcb10abf8
4
+ data.tar.gz: 71e8f65496c95cf9168f09ae2c81880666d88ed59b2d2a9e21f2c034a98b53d0
5
5
  SHA512:
6
- metadata.gz: 6dd499a1f68dcddb5dccbd8199d7fe3c8b4a8f24b37143f77b0dae49442b9f084bab07e925a97650d7e45127578e39107c1e1c40210b3c0fcf0ffb3436b893da
7
- data.tar.gz: 82bb3f9e4281e6f285c5ede18c7c5f26bbebac39de87801c3da0a2b6c3817f2cffa60689f6291895a749678c2059ccb76698f09971297055143275b36f353d84
6
+ metadata.gz: 1382bcc6d2cf7b41c5fb0f2ac5a52a1fa451ebab5bddfcd43ac03cab5728a2f3f7459c0524c18f19c6887b54e2e327448190cfa30fb08e6c2dfa9d8eaa71fe16
7
+ data.tar.gz: 313861f4d385c8bb2c3964839ce6807a7ba9a6b3dc47aac75c262fe637ae197236e96fa0734b206821e6800cbcaa9367a1a02f52c2dfbc5302228e0af7540c4d
data/README.md CHANGED
@@ -18,12 +18,12 @@ This pluginin allow you distribute app automatically to [pgyer beta testing serv
18
18
 
19
19
  Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
20
20
 
21
- Just specify the `api_key` and `user_key` associated with your pgyer account.
21
+ Just specify the `api_key` associated with your pgyer account.
22
22
 
23
23
  ```
24
24
  lane :beta do
25
25
  gym
26
- pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e")
26
+ pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141")
27
27
  end
28
28
  ```
29
29
 
@@ -32,7 +32,7 @@ You can also set a password to protect the App from being downloaded publicly:
32
32
  ```
33
33
  lane :beta do
34
34
  gym
35
- pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", password: "123456", install_type: "2")
35
+ pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", password: "123456", install_type: "2")
36
36
  end
37
37
  ```
38
38
 
@@ -41,10 +41,29 @@ Set a version update description for App:
41
41
  ```
42
42
  lane :beta do
43
43
  gym
44
- pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", update_description: "update by fastlane")
44
+ pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", update_description: "update by fastlane")
45
45
  end
46
46
  ```
47
47
 
48
+ And more params
49
+
50
+ ```
51
+
52
+ password: Set password to protect app.
53
+
54
+ update_description: Set update description for app.
55
+
56
+ install_type: Set install type for app (1=public, 2=password, 3=invite), Please set as a string.
57
+
58
+ install_date: Set install type for app (1=Set valid time, 2=Long-term effective, other=Do not modify the last setting), Please set as a string.
59
+
60
+ install_start_date: The value is a string of characters, for example, 2018-01-01.
61
+
62
+ install_end_date: The value is a string of characters, such as 2018-12-31.
63
+
64
+ channel: Need to update the specified channel of the download short link, can specify only one channel, string type, such as: ABCD. Specifies channel uploads. If you do not have one, do not use this parameter.
65
+
66
+ ```
48
67
  ## Run tests for this plugin
49
68
 
50
69
  To run both the tests, and code style validation, run
@@ -1,5 +1,5 @@
1
- require 'faraday'
2
- require 'faraday_middleware'
1
+ require "faraday"
2
+ require "faraday_middleware"
3
3
 
4
4
  module Fastlane
5
5
  module Actions
@@ -7,44 +7,73 @@ module Fastlane
7
7
  def self.run(params)
8
8
  UI.message("The pgyer plugin is working.")
9
9
 
10
- api_host = "http://qiniu-storage.pgyer.com/apiv1/app/upload"
11
10
  api_key = params[:api_key]
12
- user_key = params[:user_key]
13
11
 
14
12
  build_file = [
15
13
  params[:ipa],
16
- params[:apk]
14
+ params[:apk],
17
15
  ].detect { |e| !e.to_s.empty? }
18
16
 
19
17
  if build_file.nil?
20
18
  UI.user_error!("You have to provide a build file")
21
19
  end
22
20
 
23
- UI.message "build_file: #{build_file}"
21
+ type = params[:ipa].nil? ? "android" : "ios"
22
+
23
+ UI.message "build_file: #{build_file}, type: #{type}"
24
+
25
+ install_type = params[:install_type]
26
+ if install_type.nil?
27
+ install_type = "1"
28
+ end
24
29
 
25
30
  password = params[:password]
26
31
  if password.nil?
27
32
  password = ""
28
33
  end
29
34
 
35
+ request_params = {
36
+ "_api_key" => api_key,
37
+ "buildType" => type,
38
+ "buildInstallType" => install_type,
39
+ "buildPassword" => password,
40
+ }
41
+
30
42
  update_description = params[:update_description]
31
- if update_description.nil?
32
- update_description = ""
43
+
44
+ if update_description != nil
45
+ request_params["buildUpdateDescription"] = update_description
33
46
  end
34
47
 
35
- install_type = params[:install_type]
36
- if install_type.nil?
37
- install_type = "1"
48
+ install_date = params[:install_date]
49
+
50
+ if install_date != nil
51
+ if install_date == "1"
52
+ request_params["buildInstallDate"] = install_date
53
+ install_start_date = params[:install_start_date]
54
+ request_params["buildInstallStartDate"] = install_start_date
55
+ install_end_date = params[:install_end_date]
56
+ request_params["buildInstallEndDate"] = install_end_date
57
+ elsif install_date == "2"
58
+ request_params["buildInstallDate"] = install_date
59
+ end
60
+ end
61
+
62
+ channel = params[:channel]
63
+ if channel != nil
64
+ request_params["buildChannelShortcut"] = channel
38
65
  end
39
66
 
40
67
  # start upload
41
68
  conn_options = {
42
69
  request: {
43
- timeout: 1000,
44
- open_timeout: 300
45
- }
70
+ timeout: 1000,
71
+ open_timeout: 300,
72
+ },
46
73
  }
47
74
 
75
+ api_host = "https://www.pgyer.com/apiv2/app"
76
+
48
77
  pgyer_client = Faraday.new(nil, conn_options) do |c|
49
78
  c.request :multipart
50
79
  c.request :url_encoded
@@ -52,25 +81,35 @@ module Fastlane
52
81
  c.adapter :net_http
53
82
  end
54
83
 
55
- params = {
56
- '_api_key' => api_key,
57
- 'uKey' => user_key,
58
- 'password' => password,
59
- 'updateDescription' => update_description,
60
- 'installType' => install_type,
61
- 'file' => Faraday::UploadIO.new(build_file, 'application/octet-stream')
62
- }
84
+ response = pgyer_client.post "#{api_host}/getCOSToken", request_params
85
+
86
+ info = response.body
87
+
88
+ if info["code"] != 0
89
+ UI.user_error!("Get token is failed, info: #{info}")
90
+ end
91
+
92
+ key = info["data"]["key"]
93
+
94
+ endpoint = info["data"]["endpoint"]
95
+
96
+ request_params = info["data"]["params"]
97
+
98
+ if key.nil? || endpoint.nil? || request_params.nil?
99
+ UI.user_error!("Get token is failed")
100
+ end
101
+ content_type = type == 'android' ? 'application/vnd.android.package-archive' : 'application/octet-stream'
102
+ request_params["file"] = Faraday::UploadIO.new(build_file, content_type)
63
103
 
64
104
  UI.message "Start upload #{build_file} to pgyer..."
65
105
 
66
- response = pgyer_client.post api_host, params
67
- info = response.body
106
+ response = pgyer_client.post endpoint, request_params
68
107
 
69
- if info['code'] != 0
70
- UI.user_error!("PGYER Plugin Error: #{info['message']}")
108
+ if response.status != 204
109
+ UI.user_error!("PGYER Plugin Upload Error: #{response.body}")
71
110
  end
72
111
 
73
- UI.success "Upload success. Visit this URL to see: https://www.pgyer.com/#{info['data']['appShortcutUrl']}"
112
+ self.checkPublishStatus(pgyer_client, api_host, api_key, key)
74
113
  end
75
114
 
76
115
  def self.description
@@ -93,15 +132,10 @@ module Fastlane
93
132
  def self.available_options
94
133
  [
95
134
  FastlaneCore::ConfigItem.new(key: :api_key,
96
- env_name: "PGYER_API_KEY",
97
- description: "api_key in your pgyer account",
98
- optional: false,
99
- type: String),
100
- FastlaneCore::ConfigItem.new(key: :user_key,
101
- env_name: "PGYER_USER_KEY",
102
- description: "user_key in your pgyer account",
103
- optional: false,
104
- type: String),
135
+ env_name: "PGYER_API_KEY",
136
+ description: "api_key in your pgyer account",
137
+ optional: false,
138
+ type: String),
105
139
  FastlaneCore::ConfigItem.new(key: :apk,
106
140
  env_name: "PGYER_APK",
107
141
  description: "Path to your APK file",
@@ -127,20 +161,40 @@ module Fastlane
127
161
  UI.user_error!("You can't use 'ipa' and '#{value.key}' options in one run")
128
162
  end),
129
163
  FastlaneCore::ConfigItem.new(key: :password,
130
- env_name: "PGYER_PASSWORD",
131
- description: "set password to protect app",
132
- optional: true,
133
- type: String),
164
+ env_name: "PGYER_PASSWORD",
165
+ description: "Set password to protect app",
166
+ optional: true,
167
+ type: String),
134
168
  FastlaneCore::ConfigItem.new(key: :update_description,
135
- env_name: "PGYER_UPDATE_DESCRIPTION",
136
- description: "set update description for app",
137
- optional: true,
138
- type: String),
169
+ env_name: "PGYER_UPDATE_DESCRIPTION",
170
+ description: "Set update description for app",
171
+ optional: true,
172
+ type: String),
139
173
  FastlaneCore::ConfigItem.new(key: :install_type,
140
- env_name: "PGYER_INSTALL_TYPE",
141
- description: "set install type for app (1=public, 2=password, 3=invite). Please set as a string",
142
- optional: true,
143
- type: String)
174
+ env_name: "PGYER_INSTALL_TYPE",
175
+ description: "Set install type for app (1=public, 2=password, 3=invite). Please set as a string",
176
+ optional: true,
177
+ type: String),
178
+ FastlaneCore::ConfigItem.new(key: :install_date,
179
+ env_name: "PGYER_INSTALL_DATE",
180
+ description: "Set install type for app (1=Set valid time, 2=Long-term effective, other=Do not modify the last setting). Please set as a string",
181
+ optional: true,
182
+ type: String),
183
+ FastlaneCore::ConfigItem.new(key: :install_start_date,
184
+ env_name: "PGYER_INSTALL_START_DATE",
185
+ description: "The value is a string of characters, for example, 2018-01-01",
186
+ optional: true,
187
+ type: String),
188
+ FastlaneCore::ConfigItem.new(key: :install_end_date,
189
+ env_name: "PGYER_INSTALL_END_DATE",
190
+ description: "The value is a string of characters, such as 2018-12-31",
191
+ optional: true,
192
+ type: String),
193
+ FastlaneCore::ConfigItem.new(key: :channel,
194
+ env_name: "PGYER_INSTALL_TYPE",
195
+ description: "Need to update the specified channel of the download short link, can specify only one channel, string type, such as: ABCD",
196
+ optional: true,
197
+ type: String),
144
198
  ]
145
199
  end
146
200
 
@@ -151,6 +205,27 @@ module Fastlane
151
205
  [:ios, :mac, :android].include?(platform)
152
206
  true
153
207
  end
208
+
209
+ private
210
+
211
+ def self.checkPublishStatus(client, api_host, api_key, buildKey)
212
+ response = client.post "#{api_host}/buildInfo", { :_api_key => api_key, :buildKey => buildKey }
213
+ info = response.body
214
+ code = info["code"]
215
+ if code == 0
216
+ UI.success "Upload success. BuildInfo is #{info["data"]}."
217
+ shortUrl = info["data"]["buildShortcutUrl"]
218
+ if shortUrl.nil? || shortUrl == ""
219
+ shortUrl = info["data"]["buildKey"]
220
+ end
221
+ UI.success "Upload success. Visit this URL to see: https://www.pgyer.com/#{shortUrl}"
222
+ elsif code == 1246 || code == 1247
223
+ sleep 3
224
+ self.checkPublishStatus(client, api_host, api_key, buildKey)
225
+ else
226
+ UI.user_error!("PGYER Plugin Published Error: #{info} buildKey: #{buildKey}")
227
+ end
228
+ end
154
229
  end
155
230
  end
156
231
  end
@@ -1,4 +1,8 @@
1
+ require "fastlane_core/ui/ui"
2
+
1
3
  module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
2
6
  module Helper
3
7
  class PgyerHelper
4
8
  # class methods that you define here become available in your action
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Pgyer
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-pgyer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - rexshi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2022-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fastlane
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.208.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.208.0
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: pry
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -25,7 +53,7 @@ dependencies:
25
53
  - !ruby/object:Gem::Version
26
54
  version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
- name: bundler
56
+ name: rake
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - ">="
@@ -53,7 +81,7 @@ dependencies:
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: rake
84
+ name: rspec_junit_formatter
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - ">="
@@ -68,6 +96,20 @@ dependencies:
68
96
  version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.12.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - ">="
@@ -81,20 +123,34 @@ dependencies:
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
- name: fastlane
126
+ name: rubocop-require_tools
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
129
  - - ">="
88
130
  - !ruby/object:Gem::Version
89
- version: 2.9.0
131
+ version: '0'
90
132
  type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
136
  - - ">="
95
137
  - !ruby/object:Gem::Version
96
- version: 2.9.0
97
- description:
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description:
98
154
  email: rexshi@pgyer.com
99
155
  executables: []
100
156
  extensions: []
@@ -110,7 +166,7 @@ homepage: https://github.com/shishirui/fastlane-plugin-pgyer
110
166
  licenses:
111
167
  - MIT
112
168
  metadata: {}
113
- post_install_message:
169
+ post_install_message:
114
170
  rdoc_options: []
115
171
  require_paths:
116
172
  - lib
@@ -118,16 +174,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
174
  requirements:
119
175
  - - ">="
120
176
  - !ruby/object:Gem::Version
121
- version: '0'
177
+ version: '2.6'
122
178
  required_rubygems_version: !ruby/object:Gem::Requirement
123
179
  requirements:
124
180
  - - ">="
125
181
  - !ruby/object:Gem::Version
126
182
  version: '0'
127
183
  requirements: []
128
- rubyforge_project:
129
- rubygems_version: 2.7.7
130
- signing_key:
184
+ rubygems_version: 3.1.6
185
+ signing_key:
131
186
  specification_version: 4
132
187
  summary: distribute app to pgyer beta testing service
133
188
  test_files: []