pindo 4.6.9

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.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/bin/pindo +35 -0
  3. data/lib/pindo/base/aeshelper.rb +31 -0
  4. data/lib/pindo/base/deviceinfo.rb +90 -0
  5. data/lib/pindo/base/executable.rb +224 -0
  6. data/lib/pindo/base/githelper.rb +489 -0
  7. data/lib/pindo/base/hashhelper.rb +134 -0
  8. data/lib/pindo/base/plaininformative.rb +15 -0
  9. data/lib/pindo/base/plistbuddyexecutable.rb +121 -0
  10. data/lib/pindo/base/standarderror.rb +14 -0
  11. data/lib/pindo/client/applovinclient.rb +156 -0
  12. data/lib/pindo/client/aws3sclient.rb +183 -0
  13. data/lib/pindo/client/bossclient.rb +229 -0
  14. data/lib/pindo/client/bossconfigclient.rb +175 -0
  15. data/lib/pindo/client/giteeclient.rb +65 -0
  16. data/lib/pindo/client/httpclient.rb +40 -0
  17. data/lib/pindo/client/pgyerclient.rb +439 -0
  18. data/lib/pindo/client/tgateclient.rb +103 -0
  19. data/lib/pindo/command.rb +101 -0
  20. data/lib/pindo/config/pindoconfig.rb +439 -0
  21. data/lib/pindo/config/pindouserlocalconfig.rb +81 -0
  22. data/lib/pindo/deploy/Fastfile +233 -0
  23. data/lib/pindo/deploy/build.rb +167 -0
  24. data/lib/pindo/deploy/bundleid.rb +245 -0
  25. data/lib/pindo/deploy/cert.rb +508 -0
  26. data/lib/pindo/deploy/check.rb +79 -0
  27. data/lib/pindo/deploy/configproj.rb +89 -0
  28. data/lib/pindo/deploy/confusecode.rb +248 -0
  29. data/lib/pindo/deploy/confuseproj.rb +112 -0
  30. data/lib/pindo/deploy/fabric.rb +58 -0
  31. data/lib/pindo/deploy/getitcinfo.rb +248 -0
  32. data/lib/pindo/deploy/iap.rb +796 -0
  33. data/lib/pindo/deploy/initconfig.rb +128 -0
  34. data/lib/pindo/deploy/itcapp.rb +147 -0
  35. data/lib/pindo/deploy/itcinfo.rb +369 -0
  36. data/lib/pindo/deploy/pem.rb +55 -0
  37. data/lib/pindo/deploy/pullconfig.rb +46 -0
  38. data/lib/pindo/deploy/pushconfig.rb +83 -0
  39. data/lib/pindo/deploy/quswark.rb +146 -0
  40. data/lib/pindo/deploy/quswauth.rb +67 -0
  41. data/lib/pindo/deploy/reportbug.rb +135 -0
  42. data/lib/pindo/deploy/resign.rb +338 -0
  43. data/lib/pindo/deploy/tag.rb +108 -0
  44. data/lib/pindo/deploy/updateconfig.rb +129 -0
  45. data/lib/pindo/deploy/uploadipa.rb +63 -0
  46. data/lib/pindo/deploy.rb +44 -0
  47. data/lib/pindo/dev/autobuild.rb +204 -0
  48. data/lib/pindo/dev/autoresign.rb +186 -0
  49. data/lib/pindo/dev/confusecode.rb +127 -0
  50. data/lib/pindo/dev/confuseproj.rb +111 -0
  51. data/lib/pindo/dev/createbuild.rb +159 -0
  52. data/lib/pindo/dev/debug.rb +141 -0
  53. data/lib/pindo/dev/pub.rb +171 -0
  54. data/lib/pindo/dev/renewcert.rb +142 -0
  55. data/lib/pindo/dev.rb +23 -0
  56. data/lib/pindo/env/dreamstudio.rb +53 -0
  57. data/lib/pindo/env/flutter.rb +59 -0
  58. data/lib/pindo/env/flutter.sh +116 -0
  59. data/lib/pindo/env/quarkenv.rb +58 -0
  60. data/lib/pindo/env/swarkenv.rb +62 -0
  61. data/lib/pindo/env/workhard.rb +56 -0
  62. data/lib/pindo/env.rb +17 -0
  63. data/lib/pindo/ipa/autoresign.rb +188 -0
  64. data/lib/pindo/ipa/import.rb +261 -0
  65. data/lib/pindo/ipa/output.rb +396 -0
  66. data/lib/pindo/ipa.rb +22 -0
  67. data/lib/pindo/lib/forcepush.rb +159 -0
  68. data/lib/pindo/lib/lint.rb +115 -0
  69. data/lib/pindo/lib/push.rb +143 -0
  70. data/lib/pindo/lib/update.rb +75 -0
  71. data/lib/pindo/lib.rb +18 -0
  72. data/lib/pindo/module/appselect.rb +200 -0
  73. data/lib/pindo/module/appstore_in_app_purchase.rb +1803 -0
  74. data/lib/pindo/module/appstore_metadata_connect_api_helper.rb +12 -0
  75. data/lib/pindo/module/appstore_metadata_fastlane_helper.rb +922 -0
  76. data/lib/pindo/module/buildconfighelper.rb +13 -0
  77. data/lib/pindo/module/buildhelper.rb +76 -0
  78. data/lib/pindo/module/commonconfuseproj.rb +271 -0
  79. data/lib/pindo/module/config_project.sh +143 -0
  80. data/lib/pindo/module/configprojhelper.rb +631 -0
  81. data/lib/pindo/module/iap_tier.json +813 -0
  82. data/lib/pindo/module/icon_contents.json +116 -0
  83. data/lib/pindo/module/imessage_icon.json +91 -0
  84. data/lib/pindo/module/imgset_contents.json +21 -0
  85. data/lib/pindo/module/launchimg_contents.json +21 -0
  86. data/lib/pindo/module/pemcreate.rb +63 -0
  87. data/lib/pindo/module/pgyerhelper.rb +339 -0
  88. data/lib/pindo/module/xcodebuildpre.rb +258 -0
  89. data/lib/pindo/module/xcodehelper.rb +521 -0
  90. data/lib/pindo/options/appconfigoptions.rb +23 -0
  91. data/lib/pindo/options/deployoptions.rb +363 -0
  92. data/lib/pindo/pgyer/apptest.rb +104 -0
  93. data/lib/pindo/pgyer/comment.rb +95 -0
  94. data/lib/pindo/pgyer/download.rb +105 -0
  95. data/lib/pindo/pgyer/login.rb +61 -0
  96. data/lib/pindo/pgyer/upload.rb +234 -0
  97. data/lib/pindo/pgyer.rb +17 -0
  98. data/lib/pindo/repo/clone.rb +78 -0
  99. data/lib/pindo/repo/create.rb +55 -0
  100. data/lib/pindo/repo/login.rb +64 -0
  101. data/lib/pindo/repo/search.rb +60 -0
  102. data/lib/pindo/repo.rb +16 -0
  103. data/lib/pindo/setup.rb +60 -0
  104. data/lib/pindo/upgrade.rb +56 -0
  105. data/lib/pindo/utils/applovin.rb +213 -0
  106. data/lib/pindo/utils/boss.rb +209 -0
  107. data/lib/pindo/utils/clearcert.rb +60 -0
  108. data/lib/pindo/utils/device.rb +279 -0
  109. data/lib/pindo/utils/icon.rb +91 -0
  110. data/lib/pindo/utils/icon.sh +133 -0
  111. data/lib/pindo/utils/podindex.rb +56 -0
  112. data/lib/pindo/utils/podindex.sh +30 -0
  113. data/lib/pindo/utils/renewproj.rb +146 -0
  114. data/lib/pindo/utils/tgate.rb +159 -0
  115. data/lib/pindo/utils/xcassets.rb +46 -0
  116. data/lib/pindo/utils/xcassets.sh +88 -0
  117. data/lib/pindo/utils.rb +29 -0
  118. data/lib/pindo/version.rb +110 -0
  119. data/lib/pindo.rb +34 -0
  120. metadata +364 -0
@@ -0,0 +1,248 @@
1
+ require 'highline/import'
2
+ require 'xcodeproj'
3
+ require 'find'
4
+ require 'fileutils'
5
+
6
+ module Pindo
7
+ class Command
8
+ class Deploy < Command
9
+ class Confusecode < Deploy
10
+
11
+ include Command::DeployOptions
12
+
13
+ include CommonConfuseProj
14
+
15
+ self.summary = '替换混淆名称'
16
+
17
+ self.description = <<-DESC
18
+ 替换混淆名称.
19
+ DESC
20
+
21
+ self.arguments = [
22
+ CLAide::Argument.new('path/to/config.json', true),
23
+ ]
24
+
25
+ def self.options
26
+ [
27
+ ['--pull', '拉取混淆配置'],
28
+ ['--push', '上传混淆配置'],
29
+ ].concat(super)
30
+ end
31
+
32
+ def initialize(argv)
33
+
34
+ @pull_mode = argv.flag?('pull', false)
35
+ @push_mode = argv.flag?('push', false)
36
+
37
+ if @push_mode
38
+ puts "Push Mode ============================================ true"
39
+ else
40
+ puts "Push Mode ============================================ false"
41
+ end
42
+ if @pull_mode
43
+ puts "Pull Mode ============================================ true"
44
+ else
45
+ puts "Pull Mode ============================================ false"
46
+ end
47
+ super
48
+ end
49
+
50
+ def run
51
+
52
+ current_project_dir = Dir.pwd
53
+ puts "+++++ #{current_project_dir}"
54
+ app_config_dir = clong_buildconfig_repo(repo_name: @deploy_repo_name)
55
+ if !File.exist?(app_config_dir)
56
+ puts "App Config is nil !!!"
57
+ return
58
+ end
59
+
60
+ clang_repo_dir = clone_clang_repo
61
+ # if !File.exist?(clang_repo_dir)
62
+ puts "#{clang_repo_dir}"
63
+ puts "There is no clang tool !!! deploy confusecode"
64
+ # return
65
+ # end
66
+
67
+ default_symash = "symash2"
68
+ if @newconfuse_flag
69
+ default_symash = "symash2"
70
+ end
71
+
72
+ symash_type = confuse_version_type(path:current_project_dir, default_type:default_symash)
73
+ confuse_tool_path = File.join(clang_repo_dir, symash_type)
74
+ puts "Confuse Tool Path: #{confuse_tool_path}"
75
+
76
+ meaning_tool = File.join(clang_repo_dir, "MeaningfulTools/MeaningfulName")
77
+ if symash_type == "symash1"
78
+ base_db = File.join(clang_repo_dir, "MeaningfulTools/confuse.db")
79
+ meaning_db = File.join(app_config_dir, "app_confuse.db")
80
+ origin_json_dir = File.join(current_project_dir, "SymashCache/Original")
81
+ output_dir = File.join(current_project_dir, "SymashCache")
82
+
83
+ confuse_type= @confuse_type
84
+
85
+ if File.exist?(File.join(current_project_dir, "Symash.json"))
86
+ proj_confuse_json=JSON.parse(File.read(File.join(current_project_dir, "Symash.json")))
87
+ confuse_type = "pods"
88
+ if !proj_confuse_json["IGNORE_SYMASH_INTERFACE"]
89
+ confuse_type = confuse_type + "_class"
90
+ end
91
+
92
+ if !proj_confuse_json["IGNORE_SYMASH_METHOD"]
93
+ confuse_type = confuse_type + "_method"
94
+ end
95
+
96
+ if !proj_confuse_json["IGNORE_SYMASH_PROTOCOL"]
97
+ confuse_type = confuse_type + "_protocol"
98
+ end
99
+
100
+ if !proj_confuse_json["IGNORE_SYMASH_PROPERTY"]
101
+ confuse_type = confuse_type + "_property"
102
+ end
103
+
104
+ if !proj_confuse_json["IGNORE_SYMASH_CATEGORY"]
105
+ confuse_type = confuse_type + "_category"
106
+ end
107
+
108
+ if !proj_confuse_json["IGNORE_SYMASH_IVAR"]
109
+ confuse_type = confuse_type + "_variable"
110
+ end
111
+
112
+ end
113
+
114
+ if File.exist?(File.join(output_dir, "Replaced.json"))
115
+ FileUtils.rm_rf(File.join(output_dir, "Replaced.json"))
116
+ end
117
+
118
+ puts "Tool: #{meaning_tool}"
119
+ puts "DB: #{meaning_db}"
120
+ puts "Origin Dir: #{origin_json_dir}"
121
+ puts "Output Dir: #{output_dir}"
122
+ puts "Project Dir: #{current_project_dir}"
123
+ puts "Confuse Type: #{confuse_type}"
124
+
125
+ if File.exist?(origin_json_dir)
126
+ command = meaning_tool + " -r -p 100 -i 100 -b " + @deploy_identifier + " -d " + origin_json_dir + " -o " + base_db + " -m " + meaning_db + " -t " + output_dir + " -f " + current_project_dir + " -z " + confuse_type
127
+ puts "Command: #{command}"
128
+ system command
129
+ end
130
+
131
+ text = File.read(File.join(current_project_dir, "Symash.json"))
132
+ new_contents = text.gsub(/\"IMPORT\".*/, "\"IMPORT\":true,")
133
+ File.open(File.join(current_project_dir, "Symash.json"), "w") {|file| file.puts new_contents }
134
+
135
+ else
136
+
137
+ output_dir = File.join(current_project_dir, "SymashData")
138
+ puts "Tool: #{meaning_tool}"
139
+
140
+ puts "+++++++"
141
+ puts "+++++++"
142
+ puts "+++++++"
143
+ service_path = File.join(confuse_tool_path, "/Applications/SymashX.app/Contents/MacOS/symashctl")
144
+ command1 = "cd #{current_project_dir} && " + service_path + " stop >> /dev/null "
145
+ puts "Command: #{command1}"
146
+ system command1
147
+
148
+ if File.exist?(File.join(current_project_dir, "SymashData/export-sympkg.plist"))
149
+ command = meaning_tool + " -q -f " + current_project_dir + " -d " + app_config_dir
150
+ puts "Command: #{command}"
151
+ system command
152
+ end
153
+ puts "+++++++"
154
+ puts "+++++++"
155
+ puts "+++++++"
156
+
157
+ end
158
+
159
+
160
+ if @pull_mode
161
+ if File.exist?(File.join(app_config_dir, "Replaced.json"))
162
+ FileUtils.cp_r(File.join(app_config_dir, "Replaced.json"), File.join(output_dir, "Replaced.json"))
163
+ end
164
+
165
+ if File.exist?(File.join(app_config_dir, "import-sympkg.plist"))
166
+ FileUtils.cp_r(File.join(app_config_dir, "import-sympkg.plist"), File.join(output_dir, "import-sympkg.plist"))
167
+ end
168
+
169
+ if File.exist?(File.join(app_config_dir, "ReplaceAllNames.json"))
170
+ FileUtils.cp_r(File.join(app_config_dir, "ReplaceAllNames.json"), File.join(output_dir, "ReplaceAllNames.json"))
171
+ end
172
+
173
+ if File.exist?(File.join(app_config_dir, "Replaced.json"))
174
+ FileUtils.cp_r(File.join(app_config_dir, "Replaced.json"), File.join(output_dir, "Replaced.json"))
175
+ end
176
+
177
+
178
+ if File.exist?(File.join(output_dir, "MergeClassFiles"))
179
+ FileUtils.rm_rf(File.join(output_dir, "MergeClassFiles"))
180
+ end
181
+
182
+ if File.exist?(File.join(app_config_dir, "MergeClassFiles"))
183
+ FileUtils.cp_r(File.join(app_config_dir, "MergeClassFiles"), output_dir)
184
+ end
185
+
186
+
187
+ repo_backup_json = File.join(app_config_dir, "Backup_MapBundleName.json")
188
+ project_json = File.join(current_project_dir, "allbundles", "Backup_MapBundleName.json")
189
+ if File.exist?(repo_backup_json)
190
+ if !File.exist?(File.join(current_project_dir, "allbundles"))
191
+ FileUtils.mkdir(File.join(current_project_dir, "allbundles"))
192
+ end
193
+ FileUtils.cp_r(repo_backup_json, File.join(project_json))
194
+ end
195
+ end
196
+
197
+ if symash_type == "symash2"
198
+ service_path = File.join(confuse_tool_path, "/Applications/SymashX.app/Contents/MacOS/symashctl")
199
+ command2 = "cd #{current_project_dir} && " + service_path + " start -backend"
200
+ puts "Command: #{command2}"
201
+ system command2
202
+ puts "Done !"
203
+ end
204
+
205
+
206
+
207
+ if @push_mode
208
+
209
+ if File.exist?(File.join(current_project_dir, "Symash.json"))
210
+ FileUtils.cp_r(File.join(current_project_dir, "Symash.json"), File.join(app_config_dir, "Symash.json"))
211
+ end
212
+
213
+ if File.exist?(File.join(output_dir, "Replaced.json"))
214
+ FileUtils.cp_r(File.join(output_dir, "Replaced.json"), File.join(app_config_dir, "Replaced.json"))
215
+ end
216
+
217
+
218
+ if File.exist?(File.join(output_dir, "import-sympkg.plist"))
219
+ FileUtils.cp_r(File.join(output_dir, "import-sympkg.plist"), File.join(app_config_dir, "import-sympkg.plist"))
220
+ end
221
+
222
+ if File.exist?(File.join(app_config_dir, "MergeClassFiles"))
223
+ FileUtils.rm_rf(File.join(app_config_dir, "MergeClassFiles"))
224
+ end
225
+
226
+ if File.exist?(File.join(output_dir, "MergeClassFiles"))
227
+ FileUtils.cp_r(File.join(output_dir, "MergeClassFiles"), app_config_dir)
228
+ end
229
+
230
+ new_backup_json = File.join(current_project_dir, "allbundles", "Backup_MapBundleName.json")
231
+ repo_backup_json = File.join(app_config_dir, "Backup_MapBundleName.json")
232
+ if File.exist?(new_backup_json)
233
+ FileUtils.cp_r(new_backup_json, repo_backup_json)
234
+ end
235
+
236
+ end
237
+
238
+ message = @config_json["app_info"]["app_build_version"]
239
+ message = message || ""
240
+ message = message + "confuse code commit replace.json"
241
+
242
+ git_addpush_repo(path:app_config_dir, message:message)
243
+
244
+ end
245
+ end
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,112 @@
1
+ require 'highline/import'
2
+ require 'xcodeproj'
3
+ require 'find'
4
+ require 'fileutils'
5
+ require 'json'
6
+
7
+ module Pindo
8
+ class Command
9
+ class Deploy < Command
10
+ class Confuseproj < Deploy
11
+
12
+
13
+
14
+ include Command::DeployOptions
15
+
16
+ include CommonConfuseProj
17
+
18
+ self.summary = '给Xcode添加混淆设置'
19
+
20
+ self.description = <<-DESC
21
+ 给Xcode添加混淆设置
22
+ DESC
23
+
24
+ self.arguments = [
25
+
26
+ ]
27
+ def self.options
28
+ [
29
+
30
+ ].concat(super)
31
+ end
32
+
33
+ def initialize(argv)
34
+ super
35
+ end
36
+
37
+ def validate!
38
+ super
39
+ @XCODE_CLANG_RESOURCE_DIR = `clang -print-resource-dir`
40
+ puts "#{@XCODE_CLANG_RESOURCE_DIR}"
41
+ end
42
+
43
+
44
+ def run
45
+ current_dir = Dir.pwd
46
+ current_project_dir = current_dir
47
+ puts "+++++ #{current_project_dir}"
48
+
49
+ clang_repo_dir = clone_clang_repo
50
+ if !File.exist?(clang_repo_dir)
51
+ puts "Error !!!"
52
+ return
53
+ end
54
+
55
+ app_config_dir = clong_buildconfig_repo(repo_name: @deploy_repo_name)
56
+
57
+ default_symash = "symash2"
58
+ if @newconfuse_flag
59
+ default_symash = "symash2"
60
+ end
61
+
62
+ symash_type = confuse_version_type(path:app_config_dir, default_type:default_symash)
63
+ confuse_tool_path = File.join(clang_repo_dir, symash_type)
64
+ # puts "Confuse Tool Path: #{confuse_tool_path}"
65
+
66
+ puts "Clang Path: #{confuse_tool_path}"
67
+ install_symash(clang_path:confuse_tool_path)
68
+
69
+ current_project_fullname = ""
70
+ Dir.foreach(current_dir) do |file|
71
+ if file =~ /(.*).xcodeproj/
72
+ current_project_fullname = file
73
+ break;
74
+ end
75
+ end
76
+
77
+ old_proj_name = File.basename(current_project_fullname, ".xcodeproj")
78
+ config_confuse_project(clang_path:confuse_tool_path, project_name:old_proj_name, project_path:current_project_dir, default_type:symash_type)
79
+
80
+ config_symash(clang_path:confuse_tool_path, project_path:current_project_dir, confuse_type:@confuse_type, default_type:symash_type)
81
+
82
+
83
+ force_config = nil
84
+ force_config = {}
85
+ # force_config['BACKEND_SYMASH_DISABLE_SPL'] = true
86
+ force_config['BACKEND_SYMASH_DISABLE_BCF_PROB'] = 50
87
+
88
+
89
+ update_symash_config(app_config_dir:app_config_dir, project_path:current_project_dir, confuse_type:@confuse_type, force_config:force_config)
90
+
91
+
92
+ if symash_type == "symash2"
93
+ Dir.chdir(current_project_dir)
94
+ puts "+++++ #{current_project_dir}"
95
+ service_path = File.join(confuse_tool_path, "/Applications/SymashX.app/Contents/MacOS/symashctl")
96
+ command1 = "cd #{current_project_dir} && " + service_path + " stop"
97
+ command2 = "cd #{current_project_dir} && " + service_path + " start -export"
98
+ puts "Command: #{command1}"
99
+ system command1
100
+ puts "Command: #{command2}"
101
+ system command2
102
+ Dir.chdir(current_project_dir)
103
+ puts "Done !"
104
+ end
105
+
106
+ puts "Done !"
107
+ end
108
+
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,58 @@
1
+ require 'highline/import'
2
+ require 'xcodeproj'
3
+ require 'find'
4
+ require 'fileutils'
5
+ require 'sigh'
6
+
7
+ module Pindo
8
+ class Command
9
+ class Deploy < Command
10
+ class Fabric < Deploy
11
+
12
+
13
+ self.summary = '上传dsym文件到Firebase'
14
+
15
+ self.description = <<-DESC
16
+ 上传dsym文件到Firebase. 用法:工程目录下执行 pindo deploy fabric
17
+ DESC
18
+
19
+ self.arguments = [
20
+
21
+ ]
22
+
23
+ def run
24
+
25
+
26
+ current_project_dir = Dir.pwd
27
+
28
+ dsyms_file = nil
29
+ Find.find(File.join(current_project_dir, "build")) do |path|
30
+ if path.to_s.end_with?(".app.dSYM.zip") then
31
+ dsyms_file = path
32
+ puts "DSYMS ++++++++++ #{dsyms_file}"
33
+ puts
34
+ end
35
+ end
36
+
37
+
38
+ if !dsyms_file.nil? && File.exist?(dsyms_file)
39
+
40
+ upload_tool_path = File.join(current_project_dir, "Pods/FirebaseCrashlytics/upload-symbols")
41
+ google_plist_path = File.join(current_project_dir, "AppEntry/GoogleService-Info.plist")
42
+
43
+ command = upload_tool_path + " -gsp " + google_plist_path + " -p ios " + dsyms_file
44
+ puts
45
+ puts command
46
+ puts
47
+ system command
48
+
49
+ end
50
+
51
+
52
+ end
53
+
54
+
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,248 @@
1
+ require 'highline/import'
2
+ require 'xcodeproj'
3
+ require 'find'
4
+ require 'fileutils'
5
+ require "fastimage"
6
+
7
+
8
+ module Pindo
9
+ class Command
10
+ class Deploy < Command
11
+ class Getitcinfo < Deploy
12
+
13
+ include Command::DeployOptions
14
+
15
+ include Xcodebuildpre
16
+ include AppstoreMetadataConnectApiHelper
17
+
18
+
19
+ self.summary = '从AppStore中获取app详细信息'
20
+
21
+ self.description = <<-DESC
22
+ 从AppStore中获取app详细信息
23
+ DESC
24
+
25
+ self.arguments = [
26
+ CLAide::Argument.new('path/to/config.json', true),
27
+ ]
28
+
29
+ def self.options
30
+ [
31
+ ['--metadata', '获取metadata信息.'],
32
+ ['--screenshots', '下载商店截屏.'],
33
+ ].concat(super)
34
+ end
35
+
36
+ def initialize(argv)
37
+
38
+ @upload_metadata_flag = argv.flag?('metadata', false)
39
+ @upload_screenshots_flag = argv.flag?('screenshots', false)
40
+
41
+ @over_write = argv.flag?('overwrite', false)
42
+
43
+ super
44
+ end
45
+
46
+
47
+ def run
48
+ current_project_dir = Dir.pwd
49
+ pindo_dir = File::expand_path(pindo_single_config.pindo_dir)
50
+ @app_config_dir = File.join(pindo_dir, @deploy_repo_name)
51
+ app_itunes_dir = File.join(@app_config_dir, "fastlane")
52
+ begin
53
+ FileUtils.mkdir_p(File.join(app_itunes_dir))
54
+ rescue
55
+ # if it's already there
56
+ end
57
+
58
+ fastlane_login(apple_id:@apple_id)
59
+
60
+ if @upload_metadata_flag
61
+ fastlane_download_metadata(temp_bundle_id:@bundle_id)
62
+ end
63
+
64
+
65
+ if @upload_screenshots_flag
66
+ fastlane_download_screenshots(temp_bundle_id:@bundle_id)
67
+ valid_screenshots_html
68
+ end
69
+
70
+ puts "Done !!!"
71
+ end
72
+
73
+ def fastlane_download_metadata(temp_bundle_id:nil)
74
+
75
+ app_itunes_dir = File.join(@app_config_dir, "fastlane")
76
+ app_itunes_file = File.join(app_itunes_dir, "app_itunes.json")
77
+
78
+ app_itunes_json = {}
79
+ # if File.exist?(app_itunes_file)
80
+ # app_itunes_json = JSON.parse(File.read(app_itunes_file))
81
+ # else
82
+ # app_itunes_json = {}
83
+ # end
84
+
85
+
86
+ app = Spaceship::ConnectAPI::App.find(temp_bundle_id)
87
+
88
+ # app_itunes_json["prices"] = app.prices
89
+ app_itunes_json["primary_locale"] = app.primary_locale
90
+ # app_itunes_json["is_opted_in_to_distribute_ios_app_on_mac_app_store"] = app.is_opted_in_to_distribute_ios_app_on_mac_app_store
91
+ app_itunes_json["content_rights_declaration"] = app.content_rights_declaration
92
+
93
+
94
+
95
+ all_usages = Spaceship::ConnectAPI::AppDataUsage.all(app_id: app.id, includes: "category,grouping,purpose,dataProtection", limit: 500)
96
+ if !all_usages.nil? && all_usages.size > 0
97
+ app_itunes_json["privacy_data"] = []
98
+
99
+ all_usages_config = {}
100
+
101
+ all_usages.each do |privacy_usage|
102
+
103
+ if !privacy_usage.category.nil?
104
+ category= privacy_usage.category.id
105
+ all_usages_config[category] = all_usages_config[category] || {}
106
+ all_usages_config[category]["category"] = category
107
+
108
+ if !privacy_usage.purpose.nil?
109
+ all_usages_config[category]["purposes"] = all_usages_config[category]["purposes"] || []
110
+ all_usages_config[category]["purposes"] << privacy_usage.purpose.id
111
+
112
+ end
113
+
114
+ if !privacy_usage.data_protection.nil?
115
+ all_usages_config[category]["data_protections"] = all_usages_config[category]["data_protections"] || []
116
+ all_usages_config[category]["data_protections"] << privacy_usage.data_protection.id
117
+ end
118
+
119
+ else
120
+ usages_config = {}
121
+ usages_config["data_protections"] = usages_config["data_protections"] || []
122
+ if !privacy_usage.data_protection.nil?
123
+ usages_config["data_protections"] = usages_config["data_protections"] || []
124
+ usages_config["data_protections"] << privacy_usage.data_protection.id
125
+ end
126
+ app_itunes_json["privacy_data"] << usages_config
127
+ end
128
+ end
129
+
130
+ all_usages_config.each do |k, item|
131
+ app_itunes_json["privacy_data"] << item
132
+ end
133
+
134
+ end
135
+
136
+
137
+
138
+
139
+ app_itunes_json["app_info"] = app_itunes_json["app_info"] || {}
140
+
141
+ platforms = ["IOS", "MAC_OS", "TV_OS", "XR_OS"]
142
+
143
+ platforms.each do |platform|
144
+
145
+ app_itunes_json["app_edit_version_info"] = app_itunes_json["app_edit_version_info"] || {}
146
+
147
+ app_edit_version_info = app.get_edit_app_store_version(platform: platform, includes: 'appStoreVersionSubmission,build,appStoreVersionPhasedRelease,appStoreVersionLocalizations')
148
+
149
+
150
+ if app_edit_version_info.nil?
151
+
152
+ if File.exist?(File.join(app_itunes_dir, platform.downcase))
153
+ FileUtils.rm_rf(File.join(app_itunes_dir, platform.downcase))
154
+ end
155
+
156
+
157
+ app_itunes_json["app_edit_version_info"].delete(platform)
158
+ app_itunes_json["app_edit_version_info"].delete(platform.downcase)
159
+
160
+ else
161
+
162
+ fastlane_download_app_version_info(app_version_info: app_edit_version_info, platform:platform, app_itunes_json:app_itunes_json, app_itunes_dir:app_itunes_dir)
163
+
164
+ end
165
+
166
+
167
+ end
168
+
169
+ app_itunes_json["app_info"]["app_info_localization"] = {}
170
+ fastlane_download_app_info(app: app, app_itunes_json:app_itunes_json, app_itunes_dir:app_itunes_dir)
171
+
172
+
173
+
174
+ File.open(app_itunes_file, "w") do |file|
175
+ file.write(JSON.pretty_generate(app_itunes_json))
176
+ file.close
177
+ end
178
+
179
+ end
180
+
181
+
182
+
183
+ def fastlane_download_screenshots(temp_bundle_id:nil)
184
+
185
+ app_screenshots_dir = File.join(@app_config_dir, "fastlane/screenshots")
186
+ app = Spaceship::ConnectAPI::App.find(temp_bundle_id)
187
+ platforms = ["IOS", "MAC_OS", "TV_OS", "XR_OS"]
188
+
189
+ if !File.exist?(app_screenshots_dir)
190
+ FileUtils.rm_rf(app_screenshots_dir)
191
+ end
192
+ platforms.each do |platform|
193
+
194
+ app_edit_version_info = app.get_edit_app_store_version(platform: platform)
195
+
196
+ if app_edit_version_info.nil?
197
+
198
+ if File.exist?(File.join(app_screenshots_dir, platform.downcase))
199
+ FileUtils.rm_rf(File.join(app_screenshots_dir, platform.platform.downcase))
200
+ end
201
+ else
202
+ fastlane_download_app_screenshots(app_version_info: app_edit_version_info, platform:platform, app_screenshots_dir:app_screenshots_dir, over_write:@over_write)
203
+ end
204
+
205
+ end
206
+
207
+ end
208
+
209
+
210
+ def valid_screenshots_html()
211
+
212
+ app_screenshots_dir = File.join(@app_config_dir, "fastlane/screenshots")
213
+ screenshots_path = File.join(app_screenshots_dir, "ios")
214
+ screenshots = Deliver::Loader.load_app_screenshots(screenshots_path, true)
215
+
216
+
217
+ app_itunes_dir = File.join(@app_config_dir, "fastlane")
218
+ app_itunes_file = File.join(app_itunes_dir, "app_itunes.json")
219
+ app_itunes_json = JSON.parse(File.read(app_itunes_file))
220
+
221
+
222
+
223
+ # Validate
224
+ options = {}
225
+ options[:name] = {}
226
+ options[:name]["en-US"] = app_itunes_json["app_info"]["app_info_localization"]["en-US"]["name"]
227
+ options[:description] = {}
228
+
229
+ app_itunes_json["app_info"]["app_info_localization"].each do |lang , data|
230
+ options[:description][lang] = ""
231
+ end
232
+
233
+ html_path = Deliver::HtmlGenerator.new.render(options, screenshots, app_itunes_dir)
234
+ system("open '#{html_path}'")
235
+ end
236
+
237
+
238
+
239
+
240
+ def download_iap_info(temp_bundle_id:nil)
241
+
242
+ end
243
+
244
+
245
+ end
246
+ end
247
+ end
248
+ end