pindo 4.9.2 → 4.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
 
2
- require 'pindo/command/ios/cert'
3
- require 'pindo/command/ios/build'
4
2
  require 'pindo/command/ios/debug'
3
+ require 'pindo/command/ios/build'
4
+ require 'pindo/command/ios/autobuild'
5
5
  require 'pindo/command/ios/adhoc'
6
6
  require 'pindo/command/ios/autoresign'
7
7
  require 'pindo/command/ios/applovin'
@@ -4,6 +4,7 @@ require 'find'
4
4
  require 'fileutils'
5
5
  require 'pindo/base/executable'
6
6
  require 'pindo/module/build/unityhelper'
7
+ require 'pindo/module/build/buildhelper'
7
8
 
8
9
  module Pindo
9
10
  class Command
@@ -11,7 +12,8 @@ module Pindo
11
12
  class Ipa < Unity
12
13
 
13
14
  include Appselect
14
-
15
+
16
+ include Pindo::Githelper
15
17
  # Unity IPA包编译和上传命令
16
18
  self.summary = '编译Unity工程生成iOS IPA并支持上传到测试平台'
17
19
 
@@ -71,61 +73,34 @@ module Pindo
71
73
 
72
74
  super
73
75
  end
74
-
75
- def export_ios_project(project_path, pindo_ios_project_dir, additional_args)
76
-
77
- # 获取 UnityHelper 实例
78
- unity_helper = Pindo::Client::UnityHelper.share_instance
79
- # 获取 Unity 版本
80
- unity_version = unity_helper.find_unity_path
81
- puts "Unity 版本: #{unity_version}"
82
-
83
- begin
84
-
85
- # 执行Unity命令
86
- result = unity_helper.execute_unity_command(
87
- project_path,
88
- 'GoodUnityBuild.BuildManager.BatchBuild',
89
- additional_args
90
- )
91
-
92
- if result[:success]
93
- puts "Unity iOS library build completed successfully"
94
- puts "Unity version: #{result[:unity_version]}"
95
- puts "Output: #{pindo_ios_project_dir}"
96
- puts result[:stdout]
97
- return true
98
- else
99
- puts "Unity iOS library build failed"
100
- puts "Unity version: #{result[:unity_version]}"
101
- puts "Error:"
102
- puts result[:stderr]
103
- raise "Build failed with status: #{result[:exit_status]}"
104
- end
105
-
106
- rescue => e
107
- puts "Error during Unity build: #{e.message}"
108
- puts e.backtrace
109
- return false
110
- end
111
- end
112
76
 
113
77
 
114
78
  def run
79
+
115
80
  pindo_unity_project_dir = Dir.pwd
116
-
81
+
117
82
  # 检查是否是Unity工程
118
83
  unity_helper = Pindo::Client::UnityHelper.share_instance
119
-
120
- if @force_select_unity
121
- puts "强制选择Unity版本"
122
- unity_helper.find_unity_path(change_unity_version:true)
123
- end
124
-
125
84
  unless unity_helper.unity_project?(pindo_unity_project_dir)
126
85
  raise Informative, "当前目录不是Unity工程,请在Unity工程根目录下执行此命令"
127
86
  end
128
-
87
+
88
+ if @args_upload_flag
89
+ build_helper = Pindo::BuildHelper.share_instance
90
+ is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_unity_project_dir)
91
+ if is_need_add_tag
92
+ Pindo::Command::Dev::Tag::run(tag_action_parms)
93
+ end
94
+ end
95
+
96
+ project_unity_version = unity_helper.get_unity_version(pindo_unity_project_dir)
97
+ project_unity_major_version = project_unity_version.split('.')[0..1].join('.')
98
+ puts
99
+ puts "工程的Unity版本: #{project_unity_version}"
100
+ unity_exe_path = unity_helper.find_unity_path(unity_major_version:project_unity_major_version, force_change_version: @force_select_unity)
101
+ puts "选择的Unity路径: #{unity_exe_path}"
102
+ puts
103
+
129
104
  app_info_obj = nil
130
105
  if @args_upload_flag
131
106
  proj_name = @args_proj_name
@@ -140,21 +115,19 @@ module Pindo
140
115
  mainapp_bundleid = get_selected_dev_bundleid()
141
116
  end
142
117
 
143
-
144
- pindo_ios_project_dir = File.join(pindo_unity_project_dir, "GoodPlatform/iOS")
145
- # 准备额外的参数
146
- additional_args = {
147
- 'platform' => 'iOS'
148
- }
149
- if @args_base_flag
150
- pindo_ios_project_dir = File.join(pindo_unity_project_dir, "GoodPlatform/BaseiOS")
151
- additional_args = {
152
- 'platform' => 'iOS',
153
- 'buildtype' => 'library'
154
- }
118
+ isLibrary = @args_base_flag
119
+
120
+ ios_export_lib_dir = File.join(pindo_unity_project_dir, "GoodPlatform/BaseiOS")
121
+ if File.directory?(ios_export_lib_dir)
122
+ isLibrary = true
155
123
  end
156
124
 
157
- export_ios_project(pindo_unity_project_dir, pindo_ios_project_dir, additional_args)
125
+ pindo_ios_project_dir = File.join(pindo_unity_project_dir, "GoodPlatform/iOS")
126
+ if isLibrary
127
+ pindo_ios_project_dir = ios_export_lib_dir
128
+ end
129
+ unity_helper.build_project(unity_exe_full_path:unity_exe_path, project_path:pindo_unity_project_dir, platform:'iOS', isLibrary:isLibrary)
130
+
158
131
 
159
132
  args_temp = []
160
133
  args_temp << "--bundleid=#{mainapp_bundleid}"
@@ -168,14 +141,8 @@ module Pindo
168
141
  end
169
142
 
170
143
  Dir.chdir(pindo_ios_project_dir)
171
- if @args_base_flag
172
- `chmod 777 #{pindo_ios_project_dir}`
173
- else
174
- `chmod 777 #{pindo_ios_project_dir}/Unity`
175
- end
176
144
 
177
-
178
- Pindo::Command::Ios::Debug::run(args_temp)
145
+ Pindo::Command::Ios::Autobuild::run(args_temp)
179
146
 
180
147
 
181
148
  end
data/lib/pindo/command.rb CHANGED
@@ -44,7 +44,6 @@ module Pindo
44
44
  require 'pindo/command/pgyer'
45
45
  require 'pindo/command/setup'
46
46
  require 'pindo/command/repo'
47
- require 'pindo/command/upgrade'
48
47
  require 'pindo/command/ipa'
49
48
  require 'pindo/command/appstore'
50
49
  require 'pindo/command/unity'
@@ -3,10 +3,10 @@ require 'fileutils'
3
3
  require 'xcodeproj' # 用于iOS项目检查
4
4
 
5
5
  module Pindo
6
- module Module
7
- module Build
6
+
8
7
  class BuildHelper
9
8
  include Singleton
9
+ include Pindo::Githelper
10
10
 
11
11
  class << self
12
12
  def share_instance
@@ -14,6 +14,51 @@ module Pindo
14
14
  end
15
15
  end
16
16
 
17
+ def check_is_need_add_tag?(project_path)
18
+ tag_action_parms = nil
19
+ is_need_add_tag = false
20
+
21
+ if is_git_directory?(local_repo_dir: project_path)
22
+ current_git_root_path = git_root_directory(local_repo_dir: project_path)
23
+ latest_tag = get_latest_version_tag(project_dir: current_git_root_path)
24
+
25
+ unless is_tag_at_head?(git_root_dir: current_git_root_path, tag_name: latest_tag)
26
+ cli = HighLine.new
27
+ menu_options = {
28
+ "新增版本号,打新Tag" => -> {
29
+ tag_action_parms = []
30
+ :new_tag
31
+ },
32
+ "将上次的Tag删除重新打Tag" => -> {
33
+ tag_action_parms = []
34
+ tag_action_parms << "--retag"
35
+ :recreate_tag
36
+ },
37
+ "不需要Tag继续编译且上传,手动修改上传备注" => -> {
38
+ puts ""
39
+ :continue_without_tag
40
+ },
41
+ "终止退出编译" => -> {
42
+ raise Informative, "终止退出编译!"
43
+ :exit
44
+ }
45
+ }
46
+
47
+ result = cli.choose do |menu|
48
+ menu.header = "当前代码并没有打Tag,上传的Changelog需要Tag"
49
+ menu.prompt = "请选中打Tag的方式, 请输入选项(1/2/3...):"
50
+ menu_options.each do |option, action|
51
+ menu.choice(option) { action.call }
52
+ end
53
+ end
54
+
55
+ is_need_add_tag = !tag_action_parms.nil?
56
+ end
57
+ end
58
+
59
+ return [is_need_add_tag, tag_action_parms]
60
+ end
61
+
17
62
  def unity_project?(project_path)
18
63
  # 检查Unity工程的关键文件和目录
19
64
  project_settings_path = File.join(project_path, "ProjectSettings")
@@ -138,6 +183,5 @@ module Pindo
138
183
  end
139
184
  end
140
185
  end
141
- end
142
- end
186
+
143
187
  end
@@ -25,7 +25,8 @@ module Pindo
25
25
  end
26
26
  end
27
27
 
28
- def find_unity_path(change_unity_version:false)
28
+ def find_unity_path(unity_major_version:nil, force_change_version:false)
29
+
29
30
  paths = case RUBY_PLATFORM
30
31
  when /darwin/
31
32
  UNITY_MAC_PATHS
@@ -42,101 +43,44 @@ module Pindo
42
43
  Dir.glob(path).each do |expanded_path|
43
44
  version = extract_version_from_path(expanded_path)
44
45
  if version
46
+ major_version = version.split('.')[0..1].join('.')
45
47
  unity_versions << {
46
48
  path: expanded_path,
47
- version: version
49
+ version: version,
50
+ major_version: major_version
48
51
  }
49
52
  end
50
53
  end
51
54
  elsif File.exist?(path)
52
55
  version = extract_version_from_path(path)
56
+ major_version = version.split('.')[0..1].join('.')
53
57
  if version
54
58
  unity_versions << {
55
59
  path: path,
56
- version: version
60
+ version: version,
61
+ major_version: major_version
57
62
  }
58
63
  end
59
64
  end
60
65
  end
61
-
66
+
62
67
  if unity_versions.empty?
63
68
  raise Informative, "未找到任何Unity版本"
64
69
  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::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
70
 
104
- # 使用已保存的版本
105
- config = Pindo::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]
71
+ unity_versions.sort_by! { |v| v[:major_version] }
72
+ select_unity_versions = unity_versions.select! { |v| v[:major_version] == unity_major_version } if unity_major_version
73
+ if select_unity_versions.empty?
74
+ if force_change_version
75
+ return unity_versions.last[:path]
76
+ else
77
+ raise Informative, "未找到匹配的Unity版本"
78
+ return nil
113
79
  end
80
+ else
81
+ return select_unity_versions.first[:path]
114
82
  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, "无效的选择"
127
- end
128
-
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
-
139
- selected_unity[:path]
83
+
140
84
  end
141
85
 
142
86
  private
@@ -153,17 +97,19 @@ module Pindo
153
97
 
154
98
  public
155
99
 
156
- def execute_unity_command(project_path, method_name, additional_args = {})
157
- unity_path = find_unity_path
100
+ def execute_unity_command(unity_exe_full_path, project_path, additional_args = {})
101
+ if unity_exe_full_path.nil?
102
+ raise Informative, "Unity path not found!"
103
+ end
158
104
 
159
105
  cmd_args = [
160
- unity_path,
106
+ unity_exe_full_path,
161
107
  "-batchmode",
162
108
  "-quit",
163
109
  "-projectPath",
164
110
  project_path.to_s,
165
111
  "-executeMethod",
166
- method_name
112
+ "GoodUnityBuild.BuildManager.BatchBuild"
167
113
  ]
168
114
 
169
115
  # Add any additional arguments
@@ -179,17 +125,17 @@ module Pindo
179
125
  success: status.success?,
180
126
  stdout: stdout,
181
127
  stderr: stderr,
182
- exit_status: status.exitstatus,
183
- unity_version: extract_version_from_path(unity_path)
128
+ exit_status: status.exitstatus
184
129
  }
185
130
  end
186
131
 
187
- def build_project(project_path, build_method, platform: nil, output_path: nil)
188
- additional_args = {}
189
- additional_args[:buildTarget] = platform if platform
190
- additional_args[:outputPath] = output_path if output_path
132
+
133
+ def build_project(unity_exe_full_path:nil, project_path:nil, platform: nil, isLibrary: false)
191
134
 
192
- result = execute_unity_command(project_path, build_method, additional_args)
135
+ additional_args = {}
136
+ additional_args[:platform] = platform if platform
137
+ additional_args[:buildtype] = 'library' if isLibrary
138
+ result = execute_unity_command(unity_exe_full_path, project_path, additional_args)
193
139
 
194
140
  if result[:success]
195
141
  puts "Unity build completed successfully"
@@ -205,14 +151,6 @@ module Pindo
205
151
  result
206
152
  end
207
153
 
208
- def get_project_settings(project_path)
209
- settings_path = File.join(project_path, "ProjectSettings", "ProjectSettings.asset")
210
- if File.exist?(settings_path)
211
- File.read(settings_path)
212
- else
213
- raise "Project settings file not found at #{settings_path}"
214
- end
215
- end
216
154
 
217
155
  def get_unity_version(project_path)
218
156
  version_path = File.join(project_path, "ProjectSettings", "ProjectVersion.txt")
@@ -232,17 +170,6 @@ module Pindo
232
170
  end
233
171
  end
234
172
 
235
- def verify_unity_version(project_path)
236
- project_version = get_unity_version(project_path)
237
- unity_path = find_unity_path
238
- editor_version = extract_version_from_path(unity_path)
239
-
240
- if project_version != editor_version
241
- raise "Project Unity version (#{project_version}) does not match Editor version (#{editor_version})"
242
- end
243
-
244
- true
245
- end
246
173
 
247
174
  def unity_project?(project_path)
248
175
  # 检查关键Unity工程文件和目录是否存在
data/lib/pindo/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pindo
2
2
 
3
- VERSION = "4.9.2"
3
+ VERSION = "4.9.3"
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.9.2
4
+ version: 4.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-21 00:00:00.000000000 Z
10
+ date: 2025-02-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: claide
@@ -298,9 +298,9 @@ files:
298
298
  - lib/pindo/command/ios.rb
299
299
  - lib/pindo/command/ios/adhoc.rb
300
300
  - lib/pindo/command/ios/applovin.rb
301
+ - lib/pindo/command/ios/autobuild.rb
301
302
  - lib/pindo/command/ios/autoresign.rb
302
303
  - lib/pindo/command/ios/build.rb
303
- - lib/pindo/command/ios/cert.rb
304
304
  - lib/pindo/command/ios/debug.rb
305
305
  - lib/pindo/command/ipa.rb
306
306
  - lib/pindo/command/ipa/autoresign.rb
@@ -327,7 +327,6 @@ files:
327
327
  - lib/pindo/command/unity.rb
328
328
  - lib/pindo/command/unity/apk.rb
329
329
  - lib/pindo/command/unity/ipa.rb
330
- - lib/pindo/command/upgrade.rb
331
330
  - lib/pindo/command/utils.rb
332
331
  - lib/pindo/command/utils/boss.rb
333
332
  - lib/pindo/command/utils/clearcert.rb
@@ -1,164 +0,0 @@
1
- require 'fileutils'
2
-
3
- module Pindo
4
- class Command
5
- class Ios < Command
6
- class Cert < Ios
7
-
8
- include Appselect
9
-
10
- include XcodeCertHelper
11
- self.summary = '更新iOS证书并使用新证书设置Xcode工程'
12
- self.description = <<-DESC
13
- 更新iOS证书并使用新证书设置Xcode工程。
14
-
15
- 支持功能:
16
-
17
- * 更新iOS证书
18
-
19
- * 设置Xcode工程证书
20
-
21
- * 支持开发和发布证书
22
-
23
- 使用示例:
24
-
25
- $ pindo ios cert # 更新开发证书
26
-
27
- $ pindo ios cert --deploy # 更新发布bundle id
28
-
29
- $ pindo ios cert --adhoc # 更新adhoc证书
30
-
31
- $ pindo ios cert --macos # 更新macos平台证书
32
-
33
- DESC
34
-
35
- self.arguments = [
36
-
37
- ]
38
-
39
- # 命令选项
40
- def self.options
41
- [
42
- ['--deploy', '默认使用开发环境的bundle id,使用此选项切换为发布环境的bundle id'],
43
- ['--adhoc', '默认使用开发证书,使用此选项切换为adhoc证书'],
44
- ['--macos', '指定为macOS平台的证书'],
45
- ['--upload', '生成用于上传到蒲公英平台的证书'],
46
- ].concat(super)
47
- end
48
-
49
- def initialize(argv)
50
- @args_adhoc_flag = argv.flag?('adhoc', false)
51
- @args_deploy_flag = argv.flag?('deploy', false)
52
- @args_macos_flag = argv.flag?('macos', false)
53
- @upload_flag = argv.flag?('upload', false)
54
- super
55
- end
56
-
57
-
58
- def run
59
-
60
- mainapp_bundleid= nil
61
- if @args_deploy_flag
62
- mainapp_bundleid = get_selected_deploy_bundleid()
63
- else
64
- mainapp_bundleid = get_selected_dev_bundleid()
65
- end
66
-
67
- args_temp = []
68
- args_temp << mainapp_bundleid
69
- Pindo::Command::Deploy::Pullconfig::run(args_temp)
70
-
71
-
72
- project_dir = Dir.pwd
73
- Dir.chdir(project_dir)
74
- config_json_file = File.join(project_dir,"config.json")
75
- Cert::modify_cert_with_project(project_dir:project_dir, config_file:config_json_file)
76
-
77
- args_temp = []
78
- if @args_adhoc_flag
79
- args_temp << "--adhoc"
80
- else
81
- args_temp << "--dev"
82
- end
83
-
84
-
85
-
86
- project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
87
- if !project_fullname.nil?
88
- project_obj = Xcodeproj::Project.open(project_fullname)
89
- project_build_platform = project_obj.root_object.build_configuration_list.get_setting("SDKROOT")["Release"]
90
- if !project_build_platform.nil? && project_build_platform.eql?("macosx")
91
- @args_macos_flag = true
92
- end
93
- end
94
-
95
- if @args_macos_flag
96
- args_temp << "--macos"
97
- end
98
-
99
- if @upload_flag
100
- args_temp << "--upload"
101
- end
102
-
103
- Pindo::Command::Deploy::Cert::run(args_temp)
104
-
105
- end
106
-
107
- def self.modify_cert_with_project(project_dir:nil, config_file:nil)
108
-
109
- project_fullname = Dir.glob(File.join(project_dir, "/*.xcodeproj")).max_by {|f| File.mtime(f)}
110
- if !project_fullname.nil?
111
-
112
- entitlements_plist_path = nil
113
- project_obj = Xcodeproj::Project.open(project_fullname)
114
- project_obj.targets.each do |target|
115
- if target.product_type.to_s.eql?("com.apple.product-type.application") then
116
- temp_entitlements_file = target.build_configurations.first.build_settings['CODE_SIGN_ENTITLEMENTS']
117
- if !temp_entitlements_file.nil? && !temp_entitlements_file.empty?
118
- entitlements_plist_path = File.join(project_dir, temp_entitlements_file)
119
- end
120
- end
121
- end
122
-
123
- # puts entitlements_plist_path
124
- if !entitlements_plist_path.nil? && File.exist?(entitlements_plist_path)
125
- config_json = nil
126
- if File.exist?(config_file)
127
- config_json = JSON.parse(File.read(config_file))
128
- end
129
-
130
- entitlements_plist_dict = Xcodeproj::Plist.read_from_path(entitlements_plist_path)
131
-
132
- if entitlements_plist_dict["com.apple.developer.icloud-container-identifiers"].nil?
133
- if !config_json.nil? && !config_json["app_info"]['app_icloud_id'].nil?
134
- config_json["app_info"].delete('app_icloud_id')
135
- end
136
- end
137
-
138
- if entitlements_plist_dict["com.apple.security.application-groups"].nil?
139
- if !config_json.nil? && !config_json["app_info"]['app_group_id'].nil?
140
- config_json["app_info"].delete('app_group_id')
141
- end
142
- end
143
-
144
- # puts JSON.pretty_generate(config_json)
145
- if !config_json.nil?
146
- File.open(config_file, "w") do |f|
147
- f.write(JSON.pretty_generate(config_json))
148
- end
149
-
150
- end
151
-
152
- end
153
-
154
- end
155
-
156
-
157
- end
158
-
159
-
160
- end
161
- end
162
- end
163
- end
164
-