pindo 5.11.4 → 5.12.2

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pindo/base/githelper.rb +16 -0
  3. data/lib/pindo/base/pindocontext.rb +13 -4
  4. data/lib/pindo/command/android/autobuild.rb +108 -185
  5. data/lib/pindo/command/android/build.rb +10 -2
  6. data/lib/pindo/command/ios/autobuild.rb +116 -213
  7. data/lib/pindo/command/ios/build.rb +12 -3
  8. data/lib/pindo/command/jps/upload.rb +253 -118
  9. data/lib/pindo/command/unity/autobuild.rb +297 -227
  10. data/lib/pindo/command/unity.rb +0 -3
  11. data/lib/pindo/command/utils/boss.rb +18 -15
  12. data/lib/pindo/command/utils/clearcert.rb +26 -18
  13. data/lib/pindo/command/utils/device.rb +28 -19
  14. data/lib/pindo/command/utils/feishu.rb +11 -4
  15. data/lib/pindo/command/utils/icon.rb +26 -20
  16. data/lib/pindo/command/utils/renewcert.rb +35 -29
  17. data/lib/pindo/command/utils/renewproj.rb +32 -25
  18. data/lib/pindo/command/utils/repoinit.rb +1 -1
  19. data/lib/pindo/command/utils/tag.rb +6 -180
  20. data/lib/pindo/command/utils/tgate.rb +34 -28
  21. data/lib/pindo/command/utils/xcassets.rb +30 -20
  22. data/lib/pindo/command/web/autobuild.rb +148 -128
  23. data/lib/pindo/module/android/android_build_helper.rb +0 -6
  24. data/lib/pindo/module/android/android_config_helper.rb +4 -26
  25. data/lib/pindo/module/build/build_helper.rb +18 -294
  26. data/lib/pindo/module/build/git_repo_helper.rb +530 -0
  27. data/lib/pindo/module/build/icon_downloader.rb +85 -0
  28. data/lib/pindo/module/pgyer/pgyerhelper.rb +16 -11
  29. data/lib/pindo/module/task/model/build/android_dev_build_task.rb +209 -0
  30. data/lib/pindo/module/task/model/build/android_release_build_task.rb +29 -0
  31. data/lib/pindo/module/task/model/build/ios_adhoc_build_task.rb +53 -0
  32. data/lib/pindo/module/task/model/build/ios_dev_build_task.rb +251 -0
  33. data/lib/pindo/module/task/model/build/ios_release_build_task.rb +53 -0
  34. data/lib/pindo/module/task/model/build/web_dev_build_task.rb +43 -0
  35. data/lib/pindo/module/task/model/build_task.rb +125 -301
  36. data/lib/pindo/module/task/model/git_tag_task.rb +80 -0
  37. data/lib/pindo/module/task/model/unity_export_task.rb +53 -41
  38. data/lib/pindo/module/task/model/upload_task.rb +149 -208
  39. data/lib/pindo/module/task/pindo_task.rb +135 -95
  40. data/lib/pindo/module/task/task_manager.rb +202 -352
  41. data/lib/pindo/module/unity/unity_helper.rb +7 -3
  42. data/lib/pindo/module/xcode/xcode_build_config.rb +4 -10
  43. data/lib/pindo/module/xcode/xcode_build_helper.rb +19 -0
  44. data/lib/pindo/version.rb +1 -1
  45. metadata +10 -4
  46. data/lib/pindo/command/unity/apk.rb +0 -185
  47. data/lib/pindo/command/unity/ipa.rb +0 -198
  48. data/lib/pindo/command/unity/web.rb +0 -163
@@ -6,7 +6,13 @@ require 'pindo/base/executable'
6
6
  require 'pindo/module/build/build_helper'
7
7
  require 'pindo/module/build/version_helper'
8
8
  require 'pindo/module/xcode/xcode_build_config'
9
+ require 'pindo/module/xcode/xcode_build_helper'
9
10
  require 'pindo/base/pindocontext'
11
+ require 'pindo/module/task/task_manager'
12
+ require 'pindo/module/task/model/git_tag_task'
13
+ require 'pindo/module/task/model/unity_export_task'
14
+ require 'pindo/module/task/model/build_task'
15
+ require 'pindo/module/task/model/upload_task'
10
16
 
11
17
  module Pindo
12
18
  class Command
@@ -102,239 +108,136 @@ module Pindo
102
108
  # 确认并应用缓存(如果有)
103
109
  context.confirm_and_apply_cache
104
110
 
111
+ # 准备配置
112
+ config = prepare_ios_config(pindo_project_dir)
105
113
 
106
- @mainapp_bundleid= nil
107
- if @args_bundle_id
108
- @mainapp_bundleid = @args_bundle_id
109
- else
110
- if @args_deploy_flag
111
- @mainapp_bundleid = get_selected_deploy_bundleid()
112
- else
113
- @mainapp_bundleid = get_selected_dev_bundleid()
114
- end
115
- end
116
-
117
-
118
- build_helper = Pindo::BuildHelper.share_instance
119
- project_type = build_helper.project_type(pindo_project_dir)
120
-
121
- args_temp = []
122
- args_temp << "--proj=#{@args_proj_name}" if @args_proj_name
123
- args_temp << "--upload" if @args_upload_flag
124
- args_temp << "--send" if @args_send_flag
125
- args_temp << "--bundleid=#{@mainapp_bundleid}" if @mainapp_bundleid
126
- case project_type
127
- when :ios
128
- ios_autobuild
129
- when :android
130
- puts "Android 工程, 请使用 pindo and build"
114
+ # 创建并执行任务
115
+ tasks = make_build_task(config)
131
116
 
132
- when :unity
133
- Pindo::Command::Unity::Ipa::run(args_temp)
134
- else
135
- raise Informative, "当前目录不是工程目录,不能编译"
136
- end
117
+ # 添加到任务管理器并执行
118
+ task_manager = Pindo::TaskSystem::TaskManager.instance
119
+ task_manager.clear_all
120
+ tasks.each { |task| task_manager.add_task(task) }
121
+ task_manager.start
137
122
 
123
+ system "open #{pindo_project_dir}"
138
124
  end
139
125
 
140
- def ios_autobuild
141
- # 记录构建开始时间
142
- build_start_time = Time.now
126
+ private
143
127
 
144
- pindo_project_dir = Dir.pwd
128
+ # 创建构建任务
129
+ def make_build_task(config)
130
+ # 检测项目类型
145
131
  build_helper = Pindo::BuildHelper.share_instance
146
- if @args_upload_flag
147
- is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
148
- if is_need_add_tag
149
- Pindo::Command::Utils::Tag::run(tag_action_parms)
150
- end
151
- end
152
- new_project_fullname = Dir.glob(File.join(pindo_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
153
- if !new_project_fullname.nil? && File.exist?(new_project_fullname)
154
- build_helper.delete_libtarget_firebase_shell(pindo_project_dir)
155
- end
156
-
157
-
158
- app_info_obj = nil
159
- workflow_info = nil
160
- proj_name = @args_proj_name
161
- # 传入 package_type 获取 workflow_info
162
- app_info_obj, workflow_info = PgyerHelper.share_instace.prepare_upload(
163
- working_directory: Dir.pwd,
164
- proj_name: proj_name,
165
- package_type: 'ipa'
166
- )
167
-
168
- # ===== 使用 workflow 配置更新项目 =====
169
- if workflow_info && workflow_info[:package_name]
170
- workflow_packname = workflow_info[:package_name]
171
- project_id = app_info_obj ? app_info_obj["id"] : nil
172
-
173
- puts "\n使用工作流配置更新 iOS 项目:"
174
- puts " Workflow Package Name: #{workflow_packname}"
175
-
176
- # 一次性更新 Display Name、Bundle ID、URL Schemes 和 JPS 快捷操作
177
- Pindo::XcodeBuildConfig.update_project_with_workflow(
178
- project_dir: pindo_project_dir,
179
- workflow_packname: workflow_packname,
180
- project_id: project_id
181
- )
182
- else
183
- raise Informative, "未获取到工作流信息"
184
- end
185
-
186
- # ===== 从 JPS 下载并替换项目 Icon =====
187
- if app_info_obj && app_info_obj["projectIcon"] && !app_info_obj["projectIcon"].empty?
188
- icon_replace_success = Pindo::XcodeBuildConfig.download_and_replace_icon_from_url(
189
- project_dir: pindo_project_dir,
190
- icon_url: app_info_obj["projectIcon"]
191
- )
192
-
193
- # 如果 projectIcon 不为空且下载失败,抛出异常终止执行
194
- unless icon_replace_success
195
- raise Informative, "Icon 下载或替换失败,请检查 Icon URL 是否有效: #{app_info_obj["projectIcon"]}"
196
- end
197
- else
198
- Funlog.warning("未配置 Icon URL,跳过 Icon 替换")
199
- end
132
+ project_type = build_helper.project_type(config[:project_path])
200
133
 
201
- # ===== 更新版本号和Build号(仅在Git仓库中)=====
202
- version_helper = Pindo::VersionHelper.share_instance
203
- version_info = version_helper.get_version_info(project_dir: pindo_project_dir)
134
+ case project_type
135
+ when :android
136
+ raise Informative, "Android 工程, 请使用 pindo and build"
137
+ when :ios, :unity
138
+ # 判断是否是 Unity 工程
139
+ is_unity = (project_type == :unity)
140
+
141
+ tasks = []
142
+
143
+ # 1. Git 标签任务(所有编译场景都需要打 Tag)
144
+ git_tag_task = Pindo::TaskSystem::GitTagTask.new(config[:project_path])
145
+ tasks << git_tag_task
146
+
147
+ # 2. Unity 导出任务(仅 Unity 工程)
148
+ if is_unity
149
+ # 确定 iOS 导出路径
150
+ base_ios_path = File.join(config[:project_path], "GoodPlatform", "BaseiOS")
151
+ ios_path = File.join(config[:project_path], "GoodPlatform", "iOS")
152
+ ios_export_path = File.exist?(base_ios_path) ? base_ios_path : ios_path
153
+
154
+ unity_context = {}
155
+ unity_context[:project_name] = @args_proj_name if @args_proj_name
156
+
157
+ unity_task = Pindo::TaskSystem::UnityExportTask.new(
158
+ 'ios',
159
+ project_path: config[:project_path],
160
+ export_path: ios_export_path,
161
+ context: unity_context
162
+ )
163
+ unity_task.dependencies << git_tag_task.id
164
+ tasks << unity_task
165
+ end
204
166
 
205
- if version_info[:is_git_repo]
206
- # 更新iOS工程版本
207
- Pindo::XcodeBuildConfig.update_ios_project_version(
208
- project_dir: pindo_project_dir,
209
- version: version_info[:version],
210
- build_number: version_info[:build_number]
211
- )
212
- else
213
- Funlog.warning("非Git仓库,保持工程原有版本号")
214
- end
167
+ # 3. 构建任务
168
+ build_mode = @args_deploy_flag ? :release : (@args_adhoc_flag ? :adhoc : :dev)
215
169
 
216
- args_temp = []
217
- args_temp << @mainapp_bundleid
218
- Pindo::Command::Deploy::Pullconfig::run(args_temp)
219
-
220
- Dir.chdir(pindo_project_dir)
221
- config_json_file = File.join(pindo_project_dir,"config.json")
222
-
223
- # 处理entitlements配置
224
- Pindo::XcodeBuildConfig.update_entitlements_config(project_dir: pindo_project_dir, config_file: config_json_file)
225
-
226
- if File.exist?(File.join(pindo_project_dir, "Podfile"))
227
-
228
- args_temp = []
229
- args_temp << config_json_file
230
- Pindo::Command::Ios::Podupdate::run([])
231
-
232
- begin
233
- if File.exist?(File.join(pindo_project_dir, "Podfile.lock"))
234
- FileUtils.rm_rf(File.join(pindo_project_dir, "Podfile.lock"))
235
- end
236
- if File.exist?(File.join(pindo_project_dir,"Pods"))
237
- FileUtils.rm_rf(File.join(pindo_project_dir, "Pods"))
238
- end
239
- puts "正在执行pod deintegrate..."
240
- system 'pod deintegrate'
241
- puts "正在执行pod install..."
242
- system 'pod install'
243
- rescue => error
244
- puts(error.to_s)
245
- raise Informative, "pod install失败!!先pod install 完成后成编译 !"
170
+ # 确定 iOS 项目路径
171
+ if is_unity
172
+ ios_project_path = ios_export_path
173
+ else
174
+ ios_project_path = config[:project_path]
246
175
  end
247
176
 
248
- Dir.chdir(pindo_project_dir)
249
- pod_lock_file = File.join(pindo_project_dir, "Podfile.lock")
250
- if !File.exist?(pod_lock_file)
251
- raise Informative, "pod install失败!!先pod install 完成后成编译 !"
177
+ build_options = {
178
+ project_path: ios_project_path,
179
+ bundle_id: config[:bundle_id],
180
+ proj_name: @args_proj_name,
181
+ upload: @args_upload_flag,
182
+ send: @args_send_flag,
183
+ app_info_obj: config[:app_info_obj],
184
+ workflow_info: config[:workflow_info]
185
+ }
186
+ build_options[:unity_root_path] = config[:project_path] if is_unity
187
+
188
+ build_task = Pindo::TaskSystem::BuildTask.create_task(
189
+ platform: :ios,
190
+ mode: build_mode,
191
+ options: build_options
192
+ )
193
+ build_task.dependencies << tasks.last.id if tasks.any?
194
+ tasks << build_task
195
+
196
+ # 4. 上传任务(如果需要)
197
+ if @args_upload_flag
198
+ upload_task = Pindo::TaskSystem::UploadTask.new(
199
+ 'ipa',
200
+ File.join(ios_project_path, 'build'),
201
+ nil,
202
+ app_info_obj: config[:app_info_obj],
203
+ workflow_info: config[:workflow_info],
204
+ project_name: @args_proj_name,
205
+ context: {
206
+ send_to_chat: @args_send_flag
207
+ },
208
+ dependencies: [build_task.id]
209
+ )
210
+ tasks << upload_task
252
211
  end
253
212
 
254
- end
255
-
256
-
257
- args_temp = []
258
- if @args_adhoc_flag
259
- args_temp << "--adhoc"
213
+ tasks
260
214
  else
261
- args_temp << "--dev"
262
- end
263
-
264
- project_fullname = Dir.glob(File.join(pindo_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
265
- if !project_fullname.nil?
266
- project_obj = Xcodeproj::Project.open(project_fullname)
267
- project_build_platform = project_obj.root_object.build_configuration_list.get_setting("SDKROOT")["Release"]
268
- if !project_build_platform.nil? && project_build_platform.eql?("macosx")
269
- @args_macos_flag = true
270
- end
271
- end
272
-
273
- if @args_macos_flag
274
- args_temp << "--macos"
215
+ raise Informative, "当前目录不是工程目录,不能编译"
275
216
  end
217
+ end
276
218
 
277
- Pindo::Command::Deploy::Cert::run(args_temp)
219
+ # 准备 iOS 配置
220
+ def prepare_ios_config(pindo_project_dir)
221
+ # 获取 Bundle ID
222
+ bundle_id = if @args_bundle_id
223
+ @args_bundle_id
224
+ else
225
+ @args_deploy_flag ? get_selected_deploy_bundleid() : get_selected_dev_bundleid()
226
+ end
278
227
 
279
- # 根据证书配置后的实际 Bundle ID 重新更新 URL Schemes
280
- # 因为 Cert::run 可能会修改 PRODUCT_BUNDLE_IDENTIFIER
281
- Pindo::XcodeBuildConfig.update_url_schemes_with_bundleid(
282
- project_dir: pindo_project_dir,
283
- package_name: workflow_packname
228
+ # 获取 JPS 配置
229
+ app_info_obj, workflow_info = PgyerHelper.share_instace.prepare_upload(
230
+ working_directory: pindo_project_dir,
231
+ proj_name: @args_proj_name,
232
+ package_type: 'ipa'
284
233
  )
285
234
 
286
- Dir.chdir(pindo_project_dir)
287
- Pindo::Command::Deploy::Build::run(args_temp)
288
-
289
- build_path = File.join(pindo_project_dir, "build", "*.{ipa,app}")
290
- ipa_file_upload = Dir.glob(build_path).max_by {|f| File.mtime(f)}
291
-
292
- if !ipa_file_upload.nil? && !app_info_obj.nil? && @args_upload_flag
293
- description = nil
294
- result_data = PgyerHelper.share_instace.start_upload(
295
- app_info_obj: app_info_obj,
296
- ipa_file_upload: ipa_file_upload,
297
- description: description,
298
- workflow_info: workflow_info
299
- )
300
- if !result_data.nil? && !result_data["data"].nil? && !result_data["data"]["id"].nil?
301
- PgyerHelper.share_instace.print_app_version_info(
302
- app_info_obj: app_info_obj,
303
- app_version_info_obj: result_data["data"]
304
- )
305
- # 始终发送给自己
306
- PgyerHelper.share_instace.send_apptest_msg(
307
- app_info_obj: app_info_obj,
308
- app_version_info_obj: result_data["data"],
309
- receiveType: "self"
310
- )
311
-
312
- # 如果有 --send 参数,额外发送到测试群
313
- if @args_send_flag
314
- PgyerHelper.share_instace.send_apptest_msg(
315
- app_info_obj: app_info_obj,
316
- app_version_info_obj: result_data["data"],
317
- chatEnv: "DevTest",
318
- receiveType: "chat"
319
- )
320
- end
321
- end
322
- end
323
-
324
- # 计算并显示总耗时
325
- total_time = Time.now - build_start_time
326
- minutes = (total_time / 60).to_i
327
- seconds = (total_time % 60).to_i
328
-
329
- if minutes > 0
330
- puts "\e[32m构建完成!总耗时: #{minutes}分#{seconds}秒\e[0m"
331
- else
332
- puts "\e[32m构建完成!总耗时: #{seconds}秒\e[0m"
333
- end
334
-
335
- puts "\e[32m正在打开目标文件夹...\e[0m"
336
- system "open #{pindo_project_dir}"
337
-
235
+ {
236
+ project_path: pindo_project_dir,
237
+ bundle_id: bundle_id,
238
+ app_info_obj: app_info_obj,
239
+ workflow_info: workflow_info
240
+ }
338
241
  end
339
242
 
340
243
  end
@@ -4,7 +4,9 @@ require 'json'
4
4
  require 'xcodeproj'
5
5
  require 'gym'
6
6
  require 'pindo/module/build/build_helper'
7
+ require 'pindo/module/build/git_repo_helper'
7
8
  require 'pindo/module/xcode/xcode_build_config'
9
+ require 'pindo/module/xcode/xcode_build_helper'
8
10
 
9
11
  module Pindo
10
12
  class Command
@@ -101,16 +103,23 @@ module Pindo
101
103
  pindo_project_dir = Dir.pwd
102
104
  build_helper = Pindo::BuildHelper.share_instance
103
105
  if @args_upload_flag
104
- is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
106
+ git_repo_helper = Pindo::GitRepoHelper.share_instance
107
+ is_need_add_tag, tag_action_parms = git_repo_helper.check_is_need_add_tag?(pindo_project_dir)
105
108
  if is_need_add_tag
106
- Pindo::Command::Utils::Tag::run(tag_action_parms)
109
+ git_repo_helper.create_and_push_tag(
110
+ project_dir: pindo_project_dir,
111
+ mode: 'minor',
112
+ force_retag: tag_action_parms&.include?('--retag') || false,
113
+ custom_tag: nil,
114
+ release_branch: 'master'
115
+ )
107
116
  end
108
117
  end
109
118
 
110
119
  new_project_fullname = Dir.glob(File.join(pindo_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
111
120
  puts "new_project_fullname: #{new_project_fullname}"
112
121
  if !new_project_fullname.nil? && File.exist?(new_project_fullname)
113
- build_helper.delete_libtarget_firebase_shell(pindo_project_dir)
122
+ Pindo::XcodeBuildHelper.delete_libtarget_firebase_shell(pindo_project_dir)
114
123
  end
115
124
 
116
125
  app_info_obj = nil