fastlane-plugin-schindler 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 016b39bfe8f3c4baa2539ac31fca66de42f6dc9185e3cefe87ef9673a7084146
4
+ data.tar.gz: 5a7693adb3c46632c26c34714750592923f0adb4b3d811af63f1a107fdc3dc69
5
+ SHA512:
6
+ metadata.gz: 6a3cee2a5eaaf58b3217d302e50062c08739fd2123a821a25d80ff3e88bfc5776735e8859668a5c6b0e3300d241c37bbeeebeec61f6c2c660f3b3988032a1e23
7
+ data.tar.gz: 2b47919e6b1013f93737c16de3cf8ab29c3335eca6f9b1b788fac85e8523ce672a80f727e9f58c7b03be2c817b136bf06d05b8c92d89c38680404e531ec0fb84
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 泊涛 <hongtao.ht@alibaba-inc.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # schindler plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-schindler)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-schindler`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin schindler
11
+ ```
12
+
13
+ ## About schindler
14
+
15
+ Schindler is a TestFlight automatic processing tool, which is used to maintain the number of TestFlight quota, eliminate useless testers, and improve the external gray effect of iOS.
16
+
17
+ **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
18
+
19
+ ## Example
20
+
21
+ 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`.
22
+
23
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
24
+
25
+ ## Run tests for this plugin
26
+
27
+ To run both the tests, and code style validation, run
28
+
29
+ ```
30
+ rake
31
+ ```
32
+
33
+ To automatically fix many of the styling issues, use
34
+ ```
35
+ rubocop -a
36
+ ```
37
+
38
+ ## Issues and Feedback
39
+
40
+ For any other issues and feedback about this plugin, please submit it to this repository.
41
+
42
+ ## Troubleshooting
43
+
44
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
45
+
46
+ ## Using _fastlane_ Plugins
47
+
48
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
49
+
50
+ ## About _fastlane_
51
+
52
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,235 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/schindler_helper'
3
+ require 'spaceship'
4
+ require 'json'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class SchindlerAction < Action
9
+ Filter_Uninstall = 1 << 0
10
+ Filter_Expire = 1 << 1
11
+ Filter_UnUse = 1 << 2
12
+
13
+ def self.run(params)
14
+ UI.message("The schindler plugin is working!")
15
+
16
+ ARGV.clear
17
+
18
+ filter_type = params[:filter_type].to_i
19
+ auto_confirm = params[:auto_confirm].to_s == 'auto'
20
+ user_id = params[:user_id].to_s
21
+ user_password = params[:user_password].to_s
22
+ ios_app_id = params[:ios_app_id].to_s
23
+ puts "================================\n新建名单,初始化参数信息:\n筛选类型(位运算):#{filter_type} (#{Filter_Uninstall}-未安装,#{Filter_Expire}-已过期,#{Filter_UnUse}-未使用)\n跳过二次确认:#{auto_confirm}\n账号:#{user_id}\n密码:******\n应用ID:#{ios_app_id}\n================================"
24
+
25
+ # 先扫描未安装、已过期
26
+ if ((filter_type & Filter_Uninstall > 0) || (filter_type & Filter_Expire > 0))
27
+ add_process_uninstall_expired(filter_type: filter_type, auto_confirm: auto_confirm, ios_app_id: ios_app_id, user_id: user_id, user_password: user_password)
28
+ end
29
+ # 再扫描未使用,因为未使用需要全量查询,耗时1小时起步,容易超时
30
+ if (filter_type & Filter_UnUse > 0)
31
+ add_process_unused(auto_confirm: auto_confirm, ios_app_id: ios_app_id, user_id: user_id, user_password: user_password)
32
+ end
33
+ end
34
+
35
+ def self.exec_process (testers, filter_type, auto_confirm)
36
+ return [] if testers.nil?
37
+
38
+ ids = Array.new();
39
+ # 90天前的安装
40
+ currentDate = DateTime.now.to_time
41
+ expiredtime =(currentDate - 60*60*24*90).to_i
42
+ # 7天内更新的,不统计打开次数
43
+ sevendaytime = (currentDate - 60*60*24*7).to_i
44
+
45
+ testers.each do |tester|
46
+ # puts "测试员信息:#{tester.to_json}"
47
+
48
+ if (!tester.respond_to?(:beta_tester_metrics))
49
+ puts "\n\n~~~~~~~~~~ 异常跳过:不合法的BetaTester数据 ~~~~~~~~~~"
50
+ next
51
+ end
52
+
53
+ id = tester.id.to_s;
54
+ metric = (tester.beta_tester_metrics || []).first
55
+ tester_state = metric.beta_tester_state
56
+ puts "测试员:#{tester.id.to_s} 状态-#{tester_state}"
57
+
58
+ if metric.installed?
59
+ # 在removeAfterDate支持前,暂时用lastModifiedDate. "last_modified_date":"2022-09-02T07:05:44.414-07:00"
60
+ modified_date_string = metric.last_modified_date
61
+ modified_date = nil
62
+ # 兼容没有毫秒的数据,苹果也不标准啊!
63
+ if modified_date_string.length == 29
64
+ modified_date = DateTime.strptime(modified_date_string, '%Y-%m-%dT%H:%M:%S.%L%z').to_time
65
+ elsif modified_date_string.length == 25
66
+ modified_date = DateTime.strptime(modified_date_string, '%Y-%m-%dT%H:%M:%S%z').to_time
67
+ else
68
+ puts "不合法的lastModifiedDate: #{modified_date_string}"
69
+ next
70
+ end
71
+
72
+ last_date = modified_date.getlocal.to_i
73
+ puts "最后更新时间:#{modified_date}"
74
+ # 在sevenDaySessionCount支持前,暂时用session_count + lastModifiedDate
75
+ count = metric.session_count.to_i
76
+
77
+ if ((filter_type & Filter_Expire) > 0 && last_date < expiredtime)
78
+ # 过期
79
+ ids << id;
80
+
81
+ puts "===== 已过期 +1 ====="
82
+ elsif ((filter_type & Filter_UnUse) > 0 && count < 1 && last_date < sevendaytime)
83
+ # 超过7天未使用
84
+ ids << id;
85
+
86
+ puts "===== 未使用 +1 ====="
87
+ end
88
+ elsif (filter_type & Filter_Uninstall > 0)
89
+ ids << id;
90
+
91
+ puts "===== 未安装 +1 ====="
92
+ end
93
+ end
94
+
95
+ puts "\n测试员筛选完成\n================================"
96
+ if ids.size < 1
97
+ puts "当前规则下,测试员已经删完干净了\n================================"
98
+ return []
99
+ end
100
+
101
+ if !auto_confirm
102
+ puts "删除TestFlight测试员:#{ids.size}个? (Y/n)"
103
+ if (gets.chomp != 'Y')
104
+ puts "Cancel,任务取消,此次任务结束\n================================"
105
+ return []
106
+ end
107
+ end
108
+
109
+ return ids
110
+ end
111
+
112
+ def self.add_process_unused (auto_confirm: false, ios_app_id: nil, user_id: nil, user_password: nil)
113
+ # 查询全量数据,但容易超时,未使用的用户只能全量查询
114
+ puts "#{DateTime.now.to_time} 开始获取App数据……"
115
+ app = Spaceship::ConnectAPI::App.get(app_id: ios_app_id)
116
+
117
+ puts "#{DateTime.now.to_time} 开始获取测试人员列表,带薪喝茶时间……"
118
+ testers = nil
119
+ if app
120
+ puts "App get_beta_testers"
121
+ testers = app.get_beta_testers(filter: {apps: ios_app_id, isDeleted: false}, includes: "betaTesterMetrics", sort: "betaTesterMetrics.betaTesterState", limit:20)
122
+ else
123
+ puts "Spaceship::ConnectAPI::BetaTester"
124
+ testers = Spaceship::ConnectAPI::BetaTester.all(filter: {apps: ios_app_id, isDeleted: false}, includes: "betaTesterMetrics", sort: "betaTesterMetrics.betaTesterState", limit:20)
125
+ end
126
+ puts "#{DateTime.now.to_time} 获取测试人员列表成功,共#{testers.count}个"
127
+
128
+ ids = exec_process(testers, Filter_UnUse, auto_confirm)
129
+ if (ids.size < 1)
130
+ return
131
+ end
132
+
133
+ client = Spaceship::ConnectAPI::Client.login(user_id, user_password)
134
+ puts "登录成功"
135
+ client.delete_beta_testers_from_app(beta_tester_ids: ids, app_id: ios_app_id)
136
+ puts "Success,删除#{ids.size}个测试人员成功\n================================"
137
+ end
138
+
139
+ def self.add_process_uninstall_expired (filter_type: (Filter_Uninstall | Filter_Expire), auto_confirm: false, ios_app_id: nil, user_id: nil, user_password: nil)
140
+ # 每次查询Top 50,直到没有符合的记录,适合按状态排序后的扫描
141
+ client = Spaceship::ConnectAPI::Client.login(user_id, user_password)
142
+ puts "登录成功"
143
+
144
+ while true do
145
+ puts "#{DateTime.now.to_time} 开始获取测试人员列表,带薪喝茶时间……"
146
+ testers = client.get_beta_testers(filter: {apps: ios_app_id, isDeleted: false}, includes: "betaTesterMetrics", sort: "betaTesterMetrics.betaTesterState")
147
+
148
+ puts "#{DateTime.now.to_time} 获取测试人员列表成功,共#{testers.count}个"
149
+
150
+ ids = exec_process(testers, filter_type, auto_confirm)
151
+ if ids.size < 1
152
+ puts "未安装 or 已过期 测试员清除完毕\n================================"
153
+ return
154
+ end
155
+
156
+ client.delete_beta_testers_from_app(beta_tester_ids: ids, app_id: ios_app_id)
157
+ puts "Success,删除#{ids.size}个测试人员成功\n================================"
158
+ end
159
+ end
160
+
161
+ #####################################################
162
+ # @!group Documentation
163
+ #####################################################
164
+
165
+ def self.description
166
+ "Schindler is a TestFlight tool for release useless quota."
167
+ end
168
+
169
+ def self.authors
170
+ ["xjk_001@163.com"]
171
+ end
172
+
173
+ def self.return_value
174
+ # If your method provides a return value, you can describe here what it does
175
+ end
176
+
177
+ def self.details
178
+ # Optional:
179
+ "Schindler is a TestFlight automatic processing tool, which is used to maintain the number of TestFlight quota, eliminate useless testers, and improve the external gray effect of iOS."
180
+ end
181
+
182
+ def self.available_options
183
+ [
184
+ FastlaneCore::ConfigItem.new(key: :filter_type,
185
+ env_name: "SCHINDLER_FILTER_TYPE",
186
+ description: "'1'-Not installed, '2'-Expired, '4'-Unused, '7'-All(1 | 2 | 4), default 7",
187
+ optional: true,
188
+ default_value: "7",
189
+ type: String),
190
+ FastlaneCore::ConfigItem.new(key: :auto_confirm,
191
+ env_name: "SCHINDLER_AUTO_CONFIRM",
192
+ description: "'auto'-skip, default no. Skip the second confirmation, or wait for user confirmation before deleting after scanning",
193
+ optional: true,
194
+ default_value: "none",
195
+ type: String),
196
+ FastlaneCore::ConfigItem.new(key: :user_id,
197
+ env_name: "SCHINDLER_USER_ID",
198
+ description: "Your AppID for login Connect",
199
+ optional: false,
200
+ type: String),
201
+ FastlaneCore::ConfigItem.new(key: :user_password,
202
+ env_name: "SCHINDLER_PASSWORD",
203
+ description: "AppID password, support App private password",
204
+ optional: false,
205
+ type: String),
206
+ FastlaneCore::ConfigItem.new(key: :ios_app_id,
207
+ env_name: "SCHINDLER_APP_ID",
208
+ description: "The ID of the app in the Apple Store",
209
+ optional: false,
210
+ type: String)
211
+ ]
212
+ end
213
+
214
+ def self.is_supported?(platform)
215
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
216
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
217
+ #
218
+ [:ios, :mac].include?(platform)
219
+ # true
220
+ end
221
+
222
+ def self.example_code
223
+ [
224
+ 'schindler(
225
+ filter_type: "7", # Optional, eliminate useless testers
226
+ auto_confirm: "auto", # Optional, Skip the second confirmation
227
+ user_id: "my_username", # My AppID
228
+ user_password: "my_password", # My password
229
+ ios_app_id: "my_ios_app" # The App which to be eliminated
230
+ )'
231
+ ]
232
+ end
233
+ end
234
+ end
235
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class SchindlerHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::SchindlerHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the schindler plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Schindler
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/schindler/version'
2
+
3
+ module Fastlane
4
+ module Schindler
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Schindler.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-schindler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - xjkstar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-09-29 00:00:00.000000000 Z
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.209.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.209.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
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
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-require_tools
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
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:
154
+ email: xjk_001@163.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/schindler.rb
162
+ - lib/fastlane/plugin/schindler/actions/schindler_action.rb
163
+ - lib/fastlane/plugin/schindler/helper/schindler_helper.rb
164
+ - lib/fastlane/plugin/schindler/version.rb
165
+ homepage: https://github.com/Xjkstar/fastlane-plugin-schindler
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '2.6'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubygems_version: 3.1.6
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Schindler is a TestFlight automatic processing tool, which is used to maintain
188
+ the number of TestFlight quota, eliminate useless testers, and improve the external
189
+ gray effect of iOS.
190
+ test_files: []