pindo 4.8.9 → 4.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
-
2
1
  require 'fileutils'
3
2
  require 'json'
4
3
 
@@ -115,5 +114,22 @@ module Pindo
115
114
  end
116
115
  end
117
116
 
117
+ def save
118
+ @pindo_user_local_config_json = @pindo_user_local_config_json || {}
119
+ File.open(@pindo_user_local_config_file, "w") do |file|
120
+ file.write(JSON.pretty_generate(@pindo_user_local_config_json))
121
+ file.close
122
+ end
123
+ end
124
+
125
+ def unity_version
126
+ @pindo_user_local_config_json['unity_version'] if @pindo_user_local_config_json
127
+ end
128
+
129
+ def unity_version=(version)
130
+ @pindo_user_local_config_json = @pindo_user_local_config_json || {}
131
+ @pindo_user_local_config_json['unity_version'] = version
132
+ end
133
+
118
134
  end
119
135
  end
@@ -0,0 +1,143 @@
1
+ require 'singleton'
2
+ require 'fileutils'
3
+ require 'xcodeproj' # 用于iOS项目检查
4
+
5
+ module Pindo
6
+ module Module
7
+ module Build
8
+ class BuildHelper
9
+ include Singleton
10
+
11
+ class << self
12
+ def share_instance
13
+ instance
14
+ end
15
+ end
16
+
17
+ def unity_project?(project_path)
18
+ # 检查Unity工程的关键文件和目录
19
+ project_settings_path = File.join(project_path, "ProjectSettings")
20
+ assets_path = File.join(project_path, "Assets")
21
+ packages_path = File.join(project_path, "Packages")
22
+
23
+ # Unity工程必须包含这些目录和文件
24
+ File.directory?(project_settings_path) &&
25
+ File.directory?(assets_path) &&
26
+ File.directory?(packages_path) &&
27
+ File.exist?(File.join(project_settings_path, "ProjectSettings.asset"))
28
+ end
29
+
30
+ def ios_project?(project_path)
31
+ # 检查iOS工程的关键文件
32
+ xcodeproj_files = Dir.glob(File.join(project_path, "*.xcodeproj"))
33
+ workspace_files = Dir.glob(File.join(project_path, "*.xcworkspace"))
34
+
35
+ # 至少要有.xcodeproj文件或.xcworkspace文件
36
+ return false if xcodeproj_files.empty? && workspace_files.empty?
37
+
38
+ if !xcodeproj_files.empty?
39
+ # 检查.xcodeproj内部结构
40
+ project_file = File.join(xcodeproj_files.first, "project.pbxproj")
41
+ return true if File.exist?(project_file)
42
+ end
43
+
44
+ if !workspace_files.empty?
45
+ # 检查.xcworkspace内部结构
46
+ contents_file = File.join(workspace_files.first, "contents.xcworkspacedata")
47
+ return true if File.exist?(contents_file)
48
+ end
49
+
50
+ false
51
+ end
52
+
53
+ def android_project?(project_path)
54
+ # 检查Android工程的关键文件和目录
55
+ gradle_file = File.exist?(File.join(project_path, "build.gradle"))
56
+ settings_gradle = File.exist?(File.join(project_path, "settings.gradle"))
57
+ app_dir = File.directory?(File.join(project_path, "app"))
58
+
59
+ # Android Studio项目结构
60
+ if gradle_file && settings_gradle && app_dir
61
+ app_gradle = File.exist?(File.join(project_path, "app", "build.gradle"))
62
+ app_manifest = File.exist?(File.join(project_path, "app", "src", "main", "AndroidManifest.xml"))
63
+ return true if app_gradle && app_manifest
64
+ end
65
+
66
+ # 传统Eclipse项目结构
67
+ if File.directory?(File.join(project_path, "src"))
68
+ manifest = File.join(project_path, "AndroidManifest.xml")
69
+ return true if File.exist?(manifest)
70
+ end
71
+
72
+ false
73
+ end
74
+
75
+ def project_type(project_path)
76
+ raise ArgumentError, "项目路径不能为空" if project_path.nil? || project_path.empty?
77
+ raise ArgumentError, "项目路径不存在: #{project_path}" unless File.directory?(project_path)
78
+
79
+ return :unity if unity_project?(project_path)
80
+ return :ios if ios_project?(project_path)
81
+ return :android if android_project?(project_path)
82
+ :unknown
83
+ end
84
+
85
+ def project_type_name(project_path)
86
+ case project_type(project_path)
87
+ when :unity
88
+ "Unity"
89
+ when :ios
90
+ "iOS"
91
+ when :android
92
+ "Android"
93
+ else
94
+ "Unknown"
95
+ end
96
+ end
97
+
98
+ def get_project_name(project_path)
99
+ case project_type(project_path)
100
+ when :unity
101
+ File.basename(project_path)
102
+ when :ios
103
+ xcodeproj = Dir.glob(File.join(project_path, "*.xcodeproj")).first
104
+ File.basename(xcodeproj, ".xcodeproj") if xcodeproj
105
+ when :android
106
+ settings_gradle = File.join(project_path, "settings.gradle")
107
+ if File.exist?(settings_gradle)
108
+ content = File.read(settings_gradle)
109
+ if content =~ /rootProject\.name\s*=\s*['"](.+)['"]/
110
+ $1
111
+ else
112
+ File.basename(project_path)
113
+ end
114
+ else
115
+ File.basename(project_path)
116
+ end
117
+ else
118
+ File.basename(project_path)
119
+ end
120
+ end
121
+
122
+ def get_project_version(project_path)
123
+ case project_type(project_path)
124
+ when :unity
125
+ version_file = File.join(project_path, "ProjectSettings", "ProjectVersion.txt")
126
+ if File.exist?(version_file)
127
+ content = File.read(version_file)
128
+ if content =~ /m_EditorVersion: (.*)/
129
+ $1.strip
130
+ end
131
+ end
132
+ when :ios
133
+ # 从Info.plist获取版本号
134
+ nil
135
+ when :android
136
+ # 从build.gradle获取版本号
137
+ nil
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
@@ -17,7 +17,7 @@ module Pindo
17
17
  "C:/Program Files/Unity/Hub/Editor/*/Unity.exe"
18
18
  ]
19
19
 
20
- TARGET_UNITY_VERSION = "2021.3"
20
+ PINDO_UNITY_VERSION = "2021.3"
21
21
 
22
22
  class << self
23
23
  def share_instance
@@ -25,7 +25,7 @@ module Pindo
25
25
  end
26
26
  end
27
27
 
28
- def find_unity_path
28
+ def find_unity_path(change_unity_version:false)
29
29
  paths = case RUBY_PLATFORM
30
30
  when /darwin/
31
31
  UNITY_MAC_PATHS
@@ -40,9 +40,8 @@ module Pindo
40
40
  paths.each do |path|
41
41
  if path.include?("*")
42
42
  Dir.glob(path).each do |expanded_path|
43
- # 从路径中提取版本号
44
43
  version = extract_version_from_path(expanded_path)
45
- if version && version.start_with?(TARGET_UNITY_VERSION)
44
+ if version
46
45
  unity_versions << {
47
46
  path: expanded_path,
48
47
  version: version
@@ -51,7 +50,7 @@ module Pindo
51
50
  end
52
51
  elsif File.exist?(path)
53
52
  version = extract_version_from_path(path)
54
- if version && version.start_with?(TARGET_UNITY_VERSION)
53
+ if version
55
54
  unity_versions << {
56
55
  path: path,
57
56
  version: version
@@ -61,12 +60,82 @@ module Pindo
61
60
  end
62
61
 
63
62
  if unity_versions.empty?
64
- raise "No Unity #{TARGET_UNITY_VERSION} found in standard locations"
63
+ raise Informative, "未找到任何Unity版本"
64
+ end
65
+
66
+ if unity_versions.length == 1
67
+ selected_unity = unity_versions.first
68
+ return selected_unity[:path]
69
+ end
70
+
71
+ # 获取所有可用的主版本号
72
+ major_versions = unity_versions.map { |v|
73
+ v[:version].split('.')[0..1].join('.')
74
+ }.uniq.sort_by { |v| Gem::Version.new(v) }
75
+
76
+ if change_unity_version
77
+ # 让用户选择主版本号
78
+ puts "\n可用的Unity主版本:"
79
+ major_versions.each_with_index do |v, i|
80
+ puts "#{i + 1}. #{v}"
81
+ end
82
+
83
+ print "\n请选择Unity主版本 (1-#{major_versions.length}): "
84
+ choice = gets.chomp.to_i
85
+
86
+ if choice < 1 || choice > major_versions.length
87
+ raise Informative, "无效的选择"
88
+ end
89
+
90
+ selected_major_version = major_versions[choice - 1]
91
+
92
+ # 保存选择的主版本号
93
+ config = Pindo::Config::PindoUserLocalConfig.instance
94
+ config.unity_version = selected_major_version
95
+ config.save
96
+
97
+ # 在选定主版本下选择最新的版本
98
+ matching_versions = unity_versions.select { |v| v[:version].start_with?(selected_major_version) }
99
+ selected_unity = matching_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
100
+
101
+ return selected_unity[:path]
102
+ end
103
+
104
+ # 使用已保存的版本
105
+ config = Pindo::Config::PindoUserLocalConfig.instance
106
+ saved_version = config.unity_version
107
+
108
+ if saved_version
109
+ matching_versions = unity_versions.select { |v| v[:version].start_with?(saved_version) }
110
+ if matching_versions.any?
111
+ selected_unity = matching_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
112
+ return selected_unity[:path]
113
+ end
114
+ end
115
+
116
+ # 如果没有保存的版本或找不到匹配版本,让用户选择
117
+ puts "\n可用的Unity主版本:"
118
+ major_versions.each_with_index do |v, i|
119
+ puts "#{i + 1}. #{v}"
120
+ end
121
+
122
+ print "\n请选择Unity主版本 (1-#{major_versions.length}): "
123
+ choice = gets.chomp.to_i
124
+
125
+ if choice < 1 || choice > major_versions.length
126
+ raise Informative, "无效的选择"
65
127
  end
66
128
 
67
- # 按版本号排序,取最新的2021.3.x版本
68
- selected_unity = unity_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
69
- puts "Selected Unity version: #{selected_unity[:version]}"
129
+ selected_major_version = major_versions[choice - 1]
130
+
131
+ # 保存选择的主版本号
132
+ config.unity_version = selected_major_version
133
+ config.save
134
+
135
+ # 在选定主版本下选择最新的版本
136
+ matching_versions = unity_versions.select { |v| v[:version].start_with?(selected_major_version) }
137
+ selected_unity = matching_versions.sort_by { |v| Gem::Version.new(v[:version]) }.last
138
+
70
139
  selected_unity[:path]
71
140
  end
72
141
 
@@ -103,7 +172,7 @@ module Pindo
103
172
  cmd_args << value.to_s if value
104
173
  end
105
174
 
106
- puts "Executing Unity command: #{cmd_args.join(' ')}"
175
+ puts "Unity command: #{cmd_args.join(' ')}"
107
176
  stdout, stderr, status = Open3.capture3(*cmd_args)
108
177
 
109
178
  {
@@ -151,8 +220,8 @@ module Pindo
151
220
  content = File.read(version_path)
152
221
  if content =~ /m_EditorVersion: (.*)/
153
222
  version = $1.strip
154
- unless version.start_with?(TARGET_UNITY_VERSION)
155
- raise "Project Unity version (#{version}) does not match required version (#{TARGET_UNITY_VERSION}.x)"
223
+ unless version.start_with?(PINDO_UNITY_VERSION)
224
+ raise "Project Unity version (#{version}) does not match required version (#{PINDO_UNITY_VERSION}.x)"
156
225
  end
157
226
  version
158
227
  else
@@ -174,6 +243,18 @@ module Pindo
174
243
 
175
244
  true
176
245
  end
246
+
247
+ def unity_project?(project_path)
248
+ # 检查关键Unity工程文件和目录是否存在
249
+ project_settings_path = File.join(project_path, "ProjectSettings")
250
+ assets_path = File.join(project_path, "Assets")
251
+ packages_path = File.join(project_path, "Packages")
252
+
253
+ File.directory?(project_settings_path) &&
254
+ File.directory?(assets_path) &&
255
+ File.directory?(packages_path) &&
256
+ File.exist?(File.join(project_settings_path, "ProjectSettings.asset"))
257
+ end
177
258
  end
178
259
  end
179
260
  end
@@ -145,6 +145,7 @@ module Pindo
145
145
  end
146
146
 
147
147
  def start_upload(app_info_obj:nil, ipa_file_upload:nil, description:nil)
148
+
148
149
  if !ipa_file_upload.nil? && File.extname(ipa_file_upload).eql?(".app")
149
150
  mac_app_path = ipa_file_upload
150
151
  ipa_base_dir = File.dirname(ipa_file_upload)
@@ -165,6 +166,7 @@ module Pindo
165
166
  end
166
167
  end
167
168
 
169
+
168
170
  unless !ipa_file_upload.nil? && File.exist?(ipa_file_upload)
169
171
  return
170
172
  end
@@ -172,49 +174,9 @@ module Pindo
172
174
  args_ipa_file_dir = File.expand_path(File::dirname(ipa_file_upload))
173
175
  ipa_file_upload=File.join(args_ipa_file_dir, File.basename(ipa_file_upload))
174
176
  current_project_dir = Dir.pwd
175
- puts "+++++1 current_project_dir = #{current_project_dir}"
176
-
177
- if description.nil? && is_git_directory?(local_repo_dir: current_project_dir)
178
- puts "+++++2 current_project_dir = #{current_project_dir}"
179
-
180
- current_git_root_path = git_root_directory(local_repo_dir: current_project_dir)
181
- puts "+++++3 current_git_root_path = #{current_git_root_path}"
182
-
183
- xcodeproj_file_name = Dir.glob(File.join(current_project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
184
- if !xcodeproj_file_name.nil? && !xcodeproj_file_name.empty? && File.exist?(xcodeproj_file_name)
185
- puts "+++++4 xcodeproj_file_name = #{xcodeproj_file_name}"
186
-
187
- project_obj = Xcodeproj::Project.open(xcodeproj_file_name)
188
- main_target = project_obj.targets.select { |target| target.product_type.include?(Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]) }.first
189
- provisioning_profile_name = main_target.build_configurations.first.build_settings['PROVISIONING_PROFILE_SPECIFIER'].downcase.split(" ")
190
- if provisioning_profile_name.include?("adhoc")
191
- description = git!(%W(-C #{current_project_dir} show -s --format=commit::%H)).strip
192
- elsif provisioning_profile_name.include?("development")
193
- cliff_toml_path = File.join(current_git_root_path, "cliff.toml")
194
- if File.exist?(cliff_toml_path)
195
- begin
196
- `git-cliff --version`
197
- git_cliff_installed = $?.success?
198
- if git_cliff_installed
199
- temp_dir = Dir.pwd
200
- Dir.chdir(current_git_root_path)
201
- description = `git-cliff -c #{cliff_toml_path} --latest -o -`.strip
202
- description = " " if description.empty?
203
- Dir.chdir(temp_dir)
204
- else
205
- description = " "
206
- end
207
- rescue StandardError => e
208
- description = " "
209
- end
210
- else
211
- description = " "
212
- end
213
- elsif provisioning_profile_name.include?("appstore")
214
- description = "提交包重签名"
215
- end
216
- end
217
- end
177
+ description = get_description_from_git(current_project_dir:current_project_dir)
178
+ description = " " if description.empty?
179
+
218
180
 
219
181
  addtach_file = nil
220
182
  if ipa_file_upload.include?(File.join(current_project_dir, "build")) && File.exist?(File.join(current_project_dir, "VMData"))
@@ -558,50 +520,50 @@ module Pindo
558
520
  end
559
521
 
560
522
 
561
- def get_description()
562
- comment_array = []
563
- puts "请输入备注信息(按Esc结束):"
564
- loop do
565
-
566
- line = STDIN.gets.chomp
567
- comment_array << line
568
-
569
- key = STDIN.getch
570
- break if key == "\e" # Break the loop if Esc key is pressed
523
+ def get_description_from_git(current_project_dir:nil)
524
+ description = nil
525
+ if !current_project_dir.nil? && is_git_directory?(local_repo_dir: current_project_dir)
526
+ current_git_root_path = git_root_directory(local_repo_dir: current_project_dir)
527
+
528
+ # dev 打包情况的备注
529
+ cliff_toml_path = File.join(current_git_root_path, "cliff.toml")
530
+ if File.exist?(cliff_toml_path)
531
+ begin
532
+ `git-cliff --version`
533
+ git_cliff_installed = $?.success?
534
+ if git_cliff_installed
535
+ temp_dir = Dir.pwd
536
+ Dir.chdir(current_git_root_path)
537
+ description = `git-cliff -c #{cliff_toml_path} --latest -o -`.strip
538
+ Dir.chdir(temp_dir)
539
+ end
540
+ rescue StandardError => e
541
+ end
542
+ end
571
543
  end
572
- puts "================================="
573
- puts "输入结束,输入内容为:"
574
- puts "================================="
575
- comment_str = comment_array.join("\n")
576
- puts comment_array
577
- puts "================================="
578
- return comment_str
544
+ return description
579
545
  end
580
546
 
581
547
  def modify_coment(app_info_obj:nil, version_item_obj:nil)
582
548
 
583
- comment_str = get_description()
584
- puts
585
- puts "确修改信息:"
549
+ current_project_dir = Dir.pwd
550
+ comment_str = get_description_from_git(current_project_dir:current_project_dir)
551
+ puts "=========================================="
586
552
  puts
587
- puts "================================="
588
- puts "App: #{app_info_obj["appName"]}"
589
- puts "版本: #{version_item_obj["appVersion"]} (build #{version_item_obj["build"]})"
590
- puts "Build号: #{version_item_obj["incId"]}"
591
- puts "bundleId: #{version_item_obj["bundleId"]}"
592
- puts "上传时间: #{version_item_obj["updateTime"]}"
553
+ puts "#{comment_str}"
593
554
  puts
594
- puts "旧备注: \n#{version_item_obj["description"]}"
555
+ puts "=========================================="
595
556
  puts
596
- puts "修改备注: \n#{comment_str.strip}"
597
- puts "================================="
598
- puts
599
- answer = agree("确认修改备注信息(Y/n)?:")
600
- unless answer
601
- raise Informative, "暂停修改!!"
557
+
558
+ if comment_str.nil? || comment_str.empty?
559
+ Funlog.instance.fancyinfo_error("没有找到git备注信息,无法修改pgyer备注!")
560
+ else
561
+ Funlog.instance.fancyinfo_start("开始修复pgyer备注...")
562
+ @pgyer_client.post_update_upload_comment(appId:app_info_obj["appId"], id:version_item_obj["id"], comment:comment_str.strip)
563
+ Funlog.instance.fancyinfo_start("pgyer备注已经修改!")
602
564
  end
603
565
 
604
- @pgyer_client.post_update_upload_comment(appId:app_info_obj["appId"], id:version_item_obj["id"], comment:comment_str.strip)
566
+
605
567
 
606
568
  puts "备注信息修改成功!!"
607
569
 
data/lib/pindo/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pindo
2
2
 
3
- VERSION = "4.8.9"
3
+ VERSION = "4.9.1"
4
4
 
5
5
  class VersionCheck
6
6
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.9
4
+ version: 4.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-19 00:00:00.000000000 Z
10
+ date: 2025-02-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: claide
@@ -240,7 +240,6 @@ files:
240
240
  - lib/pindo/client/pgyerclient.rb
241
241
  - lib/pindo/client/pgyeruploadclient.rb
242
242
  - lib/pindo/client/tgateclient.rb
243
- - lib/pindo/client/unityhelper.rb
244
243
  - lib/pindo/command.rb
245
244
  - lib/pindo/command/android.rb
246
245
  - lib/pindo/command/android/debug.rb
@@ -284,7 +283,7 @@ files:
284
283
  - lib/pindo/command/dev/createbuild.rb
285
284
  - lib/pindo/command/dev/debug.rb
286
285
  - lib/pindo/command/dev/pgyercert.rb
287
- - lib/pindo/command/dev/pub.rb
286
+ - lib/pindo/command/dev/tag.rb
288
287
  - lib/pindo/command/env.rb
289
288
  - lib/pindo/command/env/dreamstudio.rb
290
289
  - lib/pindo/command/env/quarkenv.rb
@@ -346,8 +345,10 @@ files:
346
345
  - lib/pindo/module/appstore/appstore_metadata_connect_api_helper.rb
347
346
  - lib/pindo/module/appstore/appstore_metadata_fastlane_helper.rb
348
347
  - lib/pindo/module/appstore/iap_tier.json
348
+ - lib/pindo/module/build/buildhelper.rb
349
349
  - lib/pindo/module/build/commonconfuseproj.rb
350
350
  - lib/pindo/module/build/swarkhelper.rb
351
+ - lib/pindo/module/build/unityhelper.rb
351
352
  - lib/pindo/module/cert/certhelper.rb
352
353
  - lib/pindo/module/cert/keychainhelper.rb
353
354
  - lib/pindo/module/cert/pemhelper.rb