pindo 5.18.17 → 5.18.20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c4f5555594146ac02e8057cc535c1233b2c81b5204e6807a021744e9eeafd8b
4
- data.tar.gz: 1ad745131de6737f27c1c419253bf4dabc2c704cb2440f70ca7ad660d902b989
3
+ metadata.gz: 004b03010300629da1e55b7c6b34eada7cd76e55247deb8f76865d7446ef3572
4
+ data.tar.gz: 44757caa7ef3e6ae5253bd17d4a0c35ebe0c4cb6120d7ee2840c1a010b6800d2
5
5
  SHA512:
6
- metadata.gz: 0c505ba3e2a3f0c7bb74e6f57e588eeca6ab50844104abb98c4f02e6e676e584069135841f0793c951a0cc47c218e0d4b791c116ac5bffb7cc76437df9947218
7
- data.tar.gz: f0635784ade7e61a8b623238da8d60b04d221ceafb5312fea289063a065596db37aba8e6a67fe0210b4ece19e98d713d22fffd202805b4c530002f395265011c
6
+ metadata.gz: 05bd2c5264163a1ec12aa545e165f2bee0d832e2c038cd30d506c932842c024f9664d6ecd51c7aa80a71f061ffcaf4747a56caac6223b2c34fe4887845681fc6
7
+ data.tar.gz: 03d477b345f080c1dfe28e5367786d2147029e86aac185c4aa698b8d17acc98064bee17958060be7d1f44ebb5a41e2790a228a9a4b4699d5d9e2bb6f99709a1d
@@ -229,39 +229,27 @@ module Pindo
229
229
  end
230
230
 
231
231
 
232
- def remote_tag_exists?(local_repo_dir: nil, tag_name: nil)
233
-
234
- result = false
235
- current=Dir.pwd
236
-
237
- if File.exist?(local_repo_dir)
238
- Dir.chdir(local_repo_dir)
239
- tag_ref = "refs/tags/#{tag_name}"
240
- res_data = git_remote!(local_repo_dir, %W(-C #{local_repo_dir} ls-remote --tags origin #{tag_ref}))
241
- result = !res_data.nil? && !res_data.empty?
242
- else
243
- result = false
244
- end
245
- Dir.chdir(current)
246
- return result
247
-
232
+ # 获取远程 tag 指向的 commit SHA,不存在返回 nil
233
+ # 命令已带 -C,无需 Dir.chdir(并发模式下 chdir 会污染全局 cwd)
234
+ def remote_tag_commit(local_repo_dir: nil, tag_name: nil)
235
+ return nil if local_repo_dir.nil? || !File.exist?(local_repo_dir)
236
+ tag_ref = "refs/tags/#{tag_name}"
237
+ res_data = git_remote!(local_repo_dir, %W(-C #{local_repo_dir} ls-remote --tags origin #{tag_ref}))
238
+ lines = res_data.to_s.lines.map(&:strip).reject(&:empty?)
239
+ return nil if lines.empty?
240
+ # annotated tag ^{} 解引用行才是真实 commit,优先取它
241
+ deref = lines.find { |l| l.include?("^{}") }
242
+ (deref || lines.first).split(/\s+/).first
243
+ end
248
244
 
245
+ def remote_tag_exists?(local_repo_dir: nil, tag_name: nil)
246
+ !remote_tag_commit(local_repo_dir: local_repo_dir, tag_name: tag_name).nil?
249
247
  end
250
248
 
251
249
  def local_tag_exists?(local_repo_dir: nil, tag_name: nil)
252
- # tag_ref = "refs/tags/#{tag_name}"
253
- result = false
254
- current=Dir.pwd
255
-
256
- if File.exist? (local_repo_dir)
257
- Dir.chdir(local_repo_dir)
258
- res_data = git!(%W(-C #{local_repo_dir} tag --list #{tag_name}))
259
- result = !res_data.nil? && !res_data.empty?
260
- else
261
- result = false
262
- end
263
- Dir.chdir(current)
264
- return result
250
+ return false if local_repo_dir.nil? || !File.exist?(local_repo_dir)
251
+ res_data = git!(%W(-C #{local_repo_dir} tag --list #{tag_name}))
252
+ !res_data.nil? && !res_data.empty?
265
253
  end
266
254
 
267
255
  def git_latest_commit_id(local_repo_dir:nil)
@@ -7,6 +7,7 @@ require 'pindo/module/build/build_helper'
7
7
  require 'pindo/module/utils/git_repo_helper'
8
8
  require 'pindo/module/xcode/xcode_build_config'
9
9
  require 'pindo/module/xcode/xcode_build_helper'
10
+ require 'pindo/base/git_handler'
10
11
  require 'pindo/config/ios_config_parser'
11
12
  require 'pindo/config/build_info_manager'
12
13
  require 'pindo/module/task/task_manager'
@@ -132,6 +133,10 @@ module Pindo
132
133
  pindo_project_dir = Dir.pwd
133
134
 
134
135
  begin
136
+ # 克隆公共/环境配置仓库(AdHoc 合并依赖 deploy_build_setting.json)
137
+ Pindo::GitHandler.clone_pindo_common_config_repo(force_delete: false)
138
+ Pindo::GitHandler.clone_pindo_env_config_repo(force_delete: false)
139
+
135
140
  # 加载 JPS 配置(如果存在)
136
141
  Pindo::BuildHelper.share_instance.load_jps_build_config(pindo_project_dir, conf: @args_conf)
137
142
 
@@ -196,6 +201,11 @@ module Pindo
196
201
  " 方式2: pindo appstore adhocbuild --bundleid=com.example.app"
197
202
  end
198
203
  end
204
+
205
+ # 在导出前合并 AdHoc 配置,确保 Unity AppConfig 等使用 AdHoc 值
206
+ # 失败 fail-fast:合并失败会抛 Informative 直接中断,
207
+ # 避免用原始 Bundle ID / Apple ID 产出错误身份的 AdHoc 包
208
+ Pindo::BuildInfoManager.share_instance.merge_adhoc_config_into_parser
199
209
  end
200
210
 
201
211
  # 创建构建任务
@@ -226,7 +236,7 @@ module Pindo
226
236
  # 1.1 Unity 配置编译模式任务(可选)
227
237
  unless @args_skip_config
228
238
  unity_config_task = Pindo::TaskSystem::UnityConfigTask.new(
229
- 'release', # AdHoc 也使用 release 模式
239
+ 'adhoc', # AdHoc 使用 adhoc 模式
230
240
  project_path: config[:project_path]
231
241
  )
232
242
  tasks << unity_config_task
@@ -263,7 +273,8 @@ module Pindo
263
273
  project_path: config[:project_path],
264
274
  export_path: ios_export_path,
265
275
  deploy_mode: 'adhoc', # AdHoc 使用 adhoc 模式
266
- context: unity_context
276
+ context: unity_context,
277
+ app_config: Pindo::IosConfigParser.instance.unity_appconfig_values # 导出前改写工程 AppConfig
267
278
  )
268
279
  unity_export_task.dependencies << last_task.id if last_task
269
280
  tasks << unity_export_task
@@ -253,7 +253,8 @@ module Pindo
253
253
  'ios',
254
254
  project_path: project_path,
255
255
  export_path: ios_export_path,
256
- deploy_mode: 'release' # AppStore 使用 release 模式
256
+ deploy_mode: 'release', # AppStore 使用 release 模式
257
+ app_config: Pindo::IosConfigParser.instance.unity_appconfig_values # 导出前改写工程 AppConfig
257
258
  )
258
259
  unity_export_task.dependencies << last_task.id
259
260
  tasks << unity_export_task
@@ -42,6 +42,28 @@ module Pindo
42
42
  def validate!
43
43
  super
44
44
 
45
+ # 加载配置
46
+ project_dir = Dir.pwd
47
+ config_file = File.join(project_dir, "config.json")
48
+
49
+ config_parser = Pindo::IosConfigParser.instance
50
+ config_parser.load_config(config_file: config_file)
51
+ @config_json = config_parser.config_json
52
+ @bundle_id = config_parser.bundle_id
53
+ @apple_id = config_parser.apple_id
54
+
55
+ if @config_json.nil? || @config_json.empty?
56
+ raise Informative, "配置未加载,请检查配置文件: #{config_file}"
57
+ end
58
+
59
+ if @bundle_id.nil? || @bundle_id.empty?
60
+ raise Informative, "无法从配置文件中获取 Bundle ID"
61
+ end
62
+
63
+ if @apple_id.nil? || @apple_id.empty?
64
+ raise Informative, "无法从配置文件中获取 Apple ID"
65
+ end
66
+
45
67
  pindo_dir = File.expand_path(pindo_single_config.pindo_dir)
46
68
  config_repo_dir = File.join(pindo_dir, @bundle_id)
47
69
  @iapconfig_dir = File.join(config_repo_dir, "fastlane/iap")
@@ -63,29 +85,6 @@ module Pindo
63
85
 
64
86
  def run
65
87
 
66
-
67
- # 加载配置
68
- project_dir = Dir.pwd
69
- config_file = File.join(project_dir, "config.json")
70
-
71
- config_parser = Pindo::IosConfigParser.instance
72
- config_parser.load_config(config_file: config_file)
73
- @config_json = config_parser.config_json
74
- @bundle_id = config_parser.bundle_id
75
- @apple_id = config_parser.apple_id
76
-
77
- if @config_json.nil? || @config_json.empty?
78
- raise Informative, "配置未加载,请检查配置文件: #{config_file}"
79
- end
80
-
81
- if @bundle_id.nil? || @bundle_id.empty?
82
- raise Informative, "无法从配置文件中获取 Bundle ID"
83
- end
84
-
85
- if @apple_id.nil? || @apple_id.empty?
86
- raise Informative, "无法从配置文件中获取 Apple ID"
87
- end
88
-
89
88
  if @download_flag
90
89
 
91
90
  login_api_key(apple_id: @apple_id)
@@ -121,18 +120,7 @@ module Pindo
121
120
  def download_appstore_iap(appstore_iap_file: nil)
122
121
  puts "正在下载appstore iap 信息 ..."
123
122
 
124
- app_list_response = @app_store_connect.list_apps(filter: {
125
- bundle_id: @bundle_id
126
- })
127
-
128
- current_app = nil
129
- app_list_response[:data].each do |app_info|
130
- if app_info[:attributes][:bundle_id].to_s.eql?(@bundle_id)
131
- current_app = app_info
132
- end
133
- end
134
-
135
- app_id = current_app[:id]
123
+ app_id = find_appstore_app_id
136
124
 
137
125
  puts " "
138
126
  puts "app_id : #{app_id} +++++++++"
@@ -162,7 +150,7 @@ module Pindo
162
150
 
163
151
  pindo_dir = File.expand_path(pindo_single_config.pindo_dir)
164
152
  config_repo_dir = File.join(pindo_dir, @bundle_id)
165
- git_addpush_repo(path: config_repo_dir, message: "download app iap", commit_file_params: ["fastlane/iap/iap_appstore_download.json"])
153
+ Pindo::GitHandler.git_addpush_repo(path: config_repo_dir, message: "download app iap", commit_file_params: ["fastlane/iap/iap_appstore_download.json"])
166
154
 
167
155
  update_app_share_secrets(app_id: app_id, need_create: false)
168
156
  end
@@ -307,39 +295,51 @@ module Pindo
307
295
  file.close
308
296
  end
309
297
 
310
- git_addpush_repo(path: config_repo_dir, message: "update app shared secret", commit_file_params: ["config.json"])
298
+ Pindo::GitHandler.git_addpush_repo(path: config_repo_dir, message: "update app shared secret", commit_file_params: ["config.json"])
311
299
 
312
300
  end
313
301
 
314
302
 
315
303
  end
316
304
 
317
- def create_appstore_iap(appstore_iap_file: nil)
305
+ def find_appstore_app_id
318
306
 
319
- temp_iap_json = JSON.parse(File.read(appstore_iap_file))
307
+ app_list_response = @app_store_connect.list_apps(filter: {
308
+ bundle_id: @bundle_id
309
+ })
320
310
 
321
- if @check_flag
322
- check_purchase_items_right(in_app_purchase_json: temp_iap_json, config_json: @config_json)
311
+ if app_list_response.nil? || app_list_response[:data].nil?
312
+ error_detail = if !app_list_response.nil? && !app_list_response[:errors].nil?
313
+ JSON.pretty_generate(app_list_response[:errors])
314
+ else
315
+ app_list_response.inspect
316
+ end
317
+ raise Informative, "获取 App 列表失败,App Store Connect 返回:\n#{error_detail}"
323
318
  end
324
319
 
325
- in_app_purchase_json = process_purchase_items(in_app_purchase_json: temp_iap_json, iap_tester: @iaptester)
320
+ current_app = app_list_response[:data].find do |app_info|
321
+ app_info[:attributes][:bundle_id].to_s.eql?(@bundle_id)
322
+ end
326
323
 
324
+ if current_app.nil?
325
+ raise Informative, "在 App Store Connect 中未找到 Bundle ID 为 #{@bundle_id} 的 App"
326
+ end
327
327
 
328
- app_list_response = @app_store_connect.list_apps(filter: {
329
- bundle_id: @bundle_id
330
- })
328
+ current_app[:id]
329
+ end
331
330
 
331
+ def create_appstore_iap(appstore_iap_file: nil)
332
332
 
333
- # puts app_list_response
334
- current_app = nil
333
+ temp_iap_json = JSON.parse(File.read(appstore_iap_file))
335
334
 
336
- app_list_response[:data].each do |app_info|
337
- if app_info[:attributes][:bundle_id].to_s.eql?(@bundle_id)
338
- current_app = app_info
339
- end
335
+ if @check_flag
336
+ check_purchase_items_right(in_app_purchase_json: temp_iap_json, config_json: @config_json)
340
337
  end
341
338
 
342
- app_id = current_app[:id]
339
+ in_app_purchase_json = process_purchase_items(in_app_purchase_json: temp_iap_json, iap_tester: @iaptester)
340
+
341
+
342
+ app_id = find_appstore_app_id
343
343
 
344
344
  puts " "
345
345
  puts "app_id : #{app_id} +++++++++"
@@ -789,7 +789,11 @@ module Pindo
789
789
  @iaptester = sandbox_tester_json["iaptester"]
790
790
  end
791
791
 
792
- if !@iaptester.nil? && @iaptester["need_create"]
792
+ if @iaptester.nil?
793
+ raise Informative, "没有Sandbox Tester !!!"
794
+ end
795
+
796
+ if @iaptester["need_create"]
793
797
  puts
794
798
  puts
795
799
  if itc_has_sandbox_tester(email: @iaptester["email"])
@@ -806,7 +810,7 @@ module Pindo
806
810
  end
807
811
  end
808
812
  else
809
- raise Informative, "没有Sandbox Tester !!!"
813
+ puts "沙盒账号:#{@iaptester["email"]} 配置 need_create=false,跳过创建。"
810
814
  end
811
815
 
812
816
  end
@@ -2,6 +2,7 @@ require 'singleton'
2
2
  require 'fileutils'
3
3
  require 'pindo/base/git_handler'
4
4
  require 'pindo/config/pindoconfig'
5
+ require 'pindo/config/ios_config_parser'
5
6
 
6
7
  module Pindo
7
8
 
@@ -174,6 +175,36 @@ module Pindo
174
175
  end
175
176
  end
176
177
 
178
+ # 解析并克隆 AdHoc 配置仓库,将 AdHoc 配置合并进 IosConfigParser 单例
179
+ # 供命令层(导出前)与 AdHoc 构建任务复用;幂等,可重复调用
180
+ # @return [String, nil] AdHoc 配置仓库目录;无 app_type 时返回 nil
181
+ def merge_adhoc_config_into_parser
182
+ config_parser = Pindo::IosConfigParser.instance
183
+
184
+ # 幂等短路:已合并则直接复用缓存目录,避免重复克隆与重复改写
185
+ return config_parser.adhoc_config_dir if config_parser.adhoc_merged?
186
+
187
+ config_json = config_parser.config_json
188
+ unless config_json && config_json.dig('project_info', 'app_type')
189
+ puts "配置中缺少 app_type,跳过 AdHoc 配置合并"
190
+ return nil
191
+ end
192
+
193
+ adhoc_repo_name = get_deploy_repo_with_modul_name(
194
+ module_name: config_json['project_info']['app_type']
195
+ )
196
+ if adhoc_repo_name.nil? || adhoc_repo_name.empty?
197
+ raise Informative, "config.json app_type is error!!!"
198
+ end
199
+
200
+ adhoc_config_dir = Pindo::GitHandler.clong_buildconfig_repo(repo_name: adhoc_repo_name)
201
+
202
+ # 合并失败采用 fail-fast:modify_config_with_adhoc 会抛 Informative,
203
+ # 直接冒泡给调用方,避免静默退化为原始配置产出错误身份的包
204
+ config_parser.modify_config_with_adhoc(adhoc_config_dir: adhoc_config_dir)
205
+ adhoc_config_dir
206
+ end
207
+
177
208
  # 将仓库注册到 git_base_url.json,指定其所属 org
178
209
  def modify_repo_setting(repo_name:, owner_org:)
179
210
  pindo_setting_dir = pindo_single_config.pindo_env_configdir