pindo 5.5.8 → 5.6.0

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: d4c90bdffcd10aa827054b7aacc7107591c96d6f7c1079f2096592bc5bb0af77
4
- data.tar.gz: 48d4f04d336c484d76cf1a92fda827b7e9e53608d55786c588f43f85a8752f64
3
+ metadata.gz: 7d23d4410fab4ab64064d30c2de2d2d80497680f7ef7060dfbec66b8846590fd
4
+ data.tar.gz: b5cb4eac436803e526996758e177f7c65fb1b46fd61a4206a73b10186b36032d
5
5
  SHA512:
6
- metadata.gz: b280d9bcb83416db8499742ab9fc854460fd94125b268e864a7dec64837ceb220bb0d19986718816430ba82497ce980e0a1e515c4ba99c3c3a8562a473f616ef
7
- data.tar.gz: a6628594b11ef81be6d762bc00a6ae3a0fa21c126de0b87222d189afd40b61256742d22bd360b8a02d0afac9850b032d8a5e9aa4b084c144caa758d55237e95b
6
+ metadata.gz: 740540fd9b326e5d499f7e7b676114ee0d16d76cf7ceff46c542ef77f4f5d42919b9e53b137c1fdfd7381e7cd2aa1d530cfeda93abf25fbf12c5d5a6811b5d06
7
+ data.tar.gz: 68d4a36608e23b651a2acac424ecfb3f2bd8b9c026c435d908841ae064952d7ecdc1166f3b87f634c34a32e7bc2c734abe794e2e694c4e416eca68c09f053d76
@@ -306,13 +306,22 @@ module Pindo
306
306
  end
307
307
  puts "────────────────────────────────────────"
308
308
 
309
- # 询问用户是否使用缓存
310
- require 'highline/import'
311
- cli = HighLine.new
312
- confirm = cli.agree("\n是否使用以上缓存的选择? (y/n) ")
309
+ # 检查是否设置了强制编译环境变量
310
+ force_build = ENV['PINDO_FORCE_BUILD']
311
+
312
+ if force_build && !force_build.empty?
313
+ # 环境变量存在,自动使用缓存
314
+ puts "\n检测到 PINDO_FORCE_BUILD 环境变量,自动使用缓存的选择"
315
+ confirm = true
316
+ else
317
+ # 询问用户是否使用缓存
318
+ require 'highline/import'
319
+ cli = HighLine.new
320
+ confirm = cli.agree("\n是否使用以上缓存的选择? (y/n) ")
321
+ end
313
322
 
314
323
  if confirm
315
- puts "使用缓存的选择\n"
324
+ puts "使用缓存的选择\n" unless force_build
316
325
  # 恢复三级结构的文件缓存到内存缓存
317
326
  file_cache.each do |proj_path, commands|
318
327
  @memory_selections[proj_path] ||= {}
@@ -13,7 +13,7 @@ module Pindo
13
13
  include Appselect
14
14
  include Pindo::Githelper
15
15
 
16
- self.summary = '打包Android工程并发布到蒲公英'
16
+ self.summary = '打包Android工程并发布到测试平台'
17
17
 
18
18
  # 启用缓存机制
19
19
  def self.use_cache?
@@ -21,35 +21,31 @@ module Pindo
21
21
  end
22
22
 
23
23
  self.description = <<-DESC
24
- 编译Android包并支持上传到测试平台。
24
+ 编译Android工程生成APK/AAB并支持上传到测试平台。
25
25
 
26
- 支持功能:
26
+ 环境变量:
27
27
 
28
- * 编译Debug/Release包
28
+ PINDO_PROJECT_NAME - 指定项目名称,跳过选择确认
29
+ PINDO_TAG_DECISION - 指定Tag策略(new/retag/skip/exit)
30
+ PINDO_FORCE_BUILD - 存在时自动使用缓存选择
29
31
 
30
- * 上传到测试平台
32
+ 使用示例:
31
33
 
32
- * 发送测试通知
34
+ $ pindo android autobuild # 编译Debug包
35
+ $ pindo android autobuild --release # 编译Release包
36
+ $ pindo android autobuild --upload # 编译并上传
37
+ $ pindo android autobuild --send # 编译、上传并发送群组通知
33
38
 
34
- 使用示例:
35
-
36
- $ pindo android autobuild # 编译Debug包
37
-
38
- $ pindo android autobuild --release # 编译Release包
39
-
40
- $ pindo android autobuild --upload # 编译并上传
41
-
42
- $ pindo android autobuild --send # 编译上传并发送通知
43
-
44
- $ pindo android autobuild --proj=myapp # 指定项目名称
39
+ # CI/CD自动化构建
40
+ $ PINDO_FORCE_BUILD=1 PINDO_PROJECT_NAME="Test Demo" PINDO_TAG_DECISION=new pindo android autobuild --upload
45
41
  DESC
46
42
 
47
43
  def self.options
48
44
  [
49
- ['--release', '使用release模式构建'],
50
- ['--proj', '指定上传到测试平台的项目名称'],
51
- ['--upload', '上传编译后的apk到测试平台(上传成功后会自动发送消息给自己)'],
52
- ['--send', '发送消息到项目群(注意:不带此参数也会发送给自己)']
45
+ ['--release', '使用Release模式构建'],
46
+ ['--proj=NAME', '指定上传到测试平台的项目名称'],
47
+ ['--upload', '编译后上传到测试平台(自动发送给自己)'],
48
+ ['--send', '发送通知到测试群组(同时发送给自己)']
53
49
  ].concat(super)
54
50
  end
55
51
 
@@ -23,13 +23,13 @@ module Pindo
23
23
 
24
24
  使用示例:
25
25
 
26
- $ pindo android build # 仅编译
26
+ $ pindo and build # 仅编译
27
27
 
28
- $ pindo android build --upload # 编译并上传
28
+ $ pindo and build --upload # 编译并上传
29
29
 
30
- $ pindo android build --send # 编译并发送通知
30
+ $ pindo and build --send # 编译并发送通知
31
31
 
32
- $ pindo android build --proj=myapp # 指定项目名称
32
+ $ pindo and build --proj=myapp # 指定项目名称
33
33
  DESC
34
34
 
35
35
  def self.options
@@ -22,19 +22,19 @@ module Pindo
22
22
 
23
23
  使用示例:
24
24
 
25
- $ pindo android debug # 编译Debug包
25
+ $ pindo and debug # 编译Debug包
26
26
 
27
- $ pindo android debug --upload # 编译并上传
27
+ $ pindo and debug --upload # 编译并上传
28
28
 
29
- $ pindo android debug --send # 编译上传并发送通知
29
+ $ pindo and debug --send # 编译上传并发送通知
30
30
 
31
- $ pindo android debug --proj=myapp # 指定项目名称
31
+ $ pindo and debug --proj=myapp # 指定项目名称
32
32
 
33
- $ pindo android debug --release # 编译Release包
33
+ $ pindo and debug --release # 编译Release包
34
34
 
35
- $ pindo android debug --dsign # 测试获取签名文件
35
+ $ pindo and debug --dsign # 测试获取签名文件
36
36
 
37
- $ pindo android debug --direct # 直接打包而不编译 unity 子 Lib
37
+ $ pindo and debug --direct # 直接打包而不编译 unity 子 Lib
38
38
  DESC
39
39
 
40
40
  # 命令参数
@@ -102,7 +102,7 @@ module Pindo
102
102
  puts "iOS工程, 请使用 pindo ios autobuild"
103
103
  Pindo::Command::Ios::Autobuild::run(args_temp)
104
104
  when :android
105
- puts "Android工程, 请使用 pindo android autobuild"
105
+ puts "Android工程, 请使用 pindo and autobuild"
106
106
  when :unity
107
107
  raise Informative, "Unity工程, 请使用 pindo unity ipa 或者pindo unity apk"
108
108
  else
@@ -79,7 +79,7 @@ module Pindo
79
79
  puts "iOS 工程, 请使用 pindo ios build"
80
80
  Pindo::Command::Ios::Build::run(args_temp)
81
81
  when :android
82
- puts "Android 工程, 请使用 pindo android build"
82
+ puts "Android 工程, 请使用 pindo and build"
83
83
  Pindo::Command::Android::Build::run(args_temp)
84
84
  when :unity
85
85
  raise Informative, "Unity 工程, 请使用 pindo unity ipa 或者pindo unity apk"
@@ -16,7 +16,7 @@ module Pindo
16
16
  include Appselect
17
17
  include Pindo::Githelper
18
18
  # 命令的简要说明 - 打包iOS工程并发布到蒲公英
19
- self.summary = '打包iOS工程并发布到蒲公英'
19
+ self.summary = '打包iOS工程并发布到测试平台'
20
20
 
21
21
  # 启用缓存机制
22
22
  def self.use_cache?
@@ -27,25 +27,23 @@ module Pindo
27
27
 
28
28
  # 命令的详细说明,包含用法示例
29
29
  self.description = <<-DESC
30
- 编译iOS Debug包并支持上传到测试平台。
31
-
32
- 支持功能:
33
-
34
- * 编译Debug包
35
-
36
- * 上传到测试平台
37
-
38
- * 发送测试通知
30
+ 编译iOS工程生成IPA并支持上传到测试平台。
39
31
 
40
- 使用示例:
32
+ 环境变量:
41
33
 
42
- $ pindo ios autobuild # 编译Debug包
34
+ PINDO_BUNDLE_ID - 指定Bundle ID(如: com.heroneverdie101)
35
+ PINDO_PROJECT_NAME - 指定项目名称(如: Test Demo)
36
+ PINDO_TAG_DECISION - 指定Tag策略(new/retag/skip/exit)
37
+ PINDO_FORCE_BUILD - 自动使用缓存选择,跳过确认
43
38
 
44
- $ pindo ios autobuild --upload # 编译并上传
39
+ 使用示例:
45
40
 
46
- $ pindo ios autobuild --send # 编译上传并发送通知
41
+ $ pindo ios autobuild # 编译Debug包
42
+ $ pindo ios autobuild --upload # 编译并上传
43
+ $ pindo ios autobuild --send # 编译、上传并发送群组通知
47
44
 
48
- $ pindo ios autobuild --proj=myapp # 指定项目名称
45
+ # CI/CD自动化构建
46
+ $ PINDO_FORCE_BUILD=1 PINDO_BUNDLE_ID=com.heroneverdie101 PINDO_PROJECT_NAME="Test Demo" PINDO_TAG_DECISION=new pindo ios autobuild --upload
49
47
  DESC
50
48
 
51
49
  # 命令的参数列表
@@ -56,13 +54,12 @@ module Pindo
56
54
  # 命令的选项列表
57
55
  def self.options
58
56
  [
59
- ['--bundleid', '指定打包的bundleID'],
60
- # 指定上传到蒲公英的项目
61
- ['--proj', '指定上传到测试平台的项目名称'],
62
- # 上传编译包
63
- ['--upload', '上传编译后的ipa到测试平台(上传成功后会自动发送消息给自己)'],
64
- # 发送通知
65
- ['--send', '发送消息到项目群(注意:不带此参数也会发送给自己)']
57
+ ['--bundleid=ID', '指定打包的Bundle ID'],
58
+ ['--proj=NAME', '指定上传到测试平台的项目名称'],
59
+ ['--upload', '编译后上传到测试平台(上传成功后自动发送给自己)'],
60
+ ['--send', '发送通知到测试群组(同时也会发送给自己)'],
61
+ ['--adhoc', '使用AdHoc证书打包(默认使用Dev证书)'],
62
+ ['--deploy', '使用发布证书打包']
66
63
  ].concat(super)
67
64
  end
68
65
 
@@ -103,7 +100,7 @@ module Pindo
103
100
  when :ios
104
101
  ios_autobuild
105
102
  when :android
106
- puts "Android 工程, 请使用 pindo android build"
103
+ puts "Android 工程, 请使用 pindo and build"
107
104
 
108
105
  when :unity
109
106
  Pindo::Command::Unity::Ipa::run(args_temp)
@@ -84,7 +84,7 @@ module Pindo
84
84
  when :ios
85
85
  ios_build
86
86
  when :android
87
- raise Informative, "Android 工程, 请使用 pindo android build"
87
+ raise Informative, "Android 工程, 请使用 pindo and build"
88
88
  when :unity
89
89
  raise Informative, "Unity 工程, 请使用 pindo unity ipa"
90
90
  else
@@ -12,7 +12,7 @@ module Pindo
12
12
  class Apk < Unity
13
13
 
14
14
  # 命令的简要说明 - 编译Unity工程生成Android APK
15
- self.summary = '编译Unity工程生成Android APK'
15
+ self.summary = '编译Unity工程生成Android APK并支持上传到测试平台'
16
16
 
17
17
  # 启用缓存机制
18
18
  def self.use_cache?
@@ -21,25 +21,26 @@ module Pindo
21
21
 
22
22
  # 命令的详细说明,包含用法示例
23
23
  self.description = <<-DESC
24
- 编译Unity工程生成Android APK
24
+ 编译Unity工程生成Android APK并支持上传到测试平台。
25
25
 
26
- 支持功能:
26
+ 环境变量:
27
27
 
28
- * 编译生成APK
28
+ PINDO_PROJECT_NAME - 指定项目名称,跳过选择确认
29
+ PINDO_TAG_DECISION - 指定Tag策略(new/retag/skip/exit)
30
+ PINDO_FORCE_BUILD - 存在时自动使用缓存选择
29
31
 
30
- * 上传到测试平台
32
+ 使用示例:
31
33
 
32
- * 发送测试通知
34
+ $ pindo unity apk # 编译APK
35
+ $ pindo unity apk --upload # 编译并上传
36
+ $ pindo unity apk --send # 编译、上传并发送群组通知
33
37
 
34
- 使用示例:
38
+ # CI/CD自动化构建
39
+ $ PINDO_FORCE_BUILD=1 PINDO_PROJECT_NAME="Test Demo" PINDO_TAG_DECISION=new pindo unity apk --upload
35
40
 
36
- $ pindo unity apk # 编译APK
37
-
38
- $ pindo unity apk --upload # 编译并上传
39
-
40
- $ pindo unity apk --send # 编译并上传并发送通知
41
-
42
- $ pindo unity apk --proj=myapp # 指定项目名称
41
+ 注意事项:
42
+ • 需要在Unity工程根目录下执行
43
+ Unity版本会自动检测
43
44
  DESC
44
45
 
45
46
  # 命令的参数列表
@@ -50,13 +51,9 @@ DESC
50
51
  # 命令的选项列表
51
52
  def self.options
52
53
  [
53
- # 指定上传到蒲公英的项目
54
- ['--proj', '指定上传到测试平台的项目名称'],
55
- # 上传编译包
56
- ['--upload', '上传编译后的APK到测试平台(上传成功后会自动发送消息给自己)'],
57
- # 发送通知
58
- ['--send', '发送消息到项目群(注意:不带此参数也会发送给自己)']
59
-
54
+ ['--proj=NAME', '指定上传到测试平台的项目名称'],
55
+ ['--upload', '编译后上传到测试平台(自动发送给自己)'],
56
+ ['--send', '发送通知到测试群组(同时发送给自己)']
60
57
  ].concat(super)
61
58
  end
62
59
 
@@ -29,23 +29,27 @@ module Pindo
29
29
  self.description = <<-DESC
30
30
  编译Unity工程生成iOS IPA并支持上传到测试平台。
31
31
 
32
- 支持功能:
32
+ 环境变量:
33
33
 
34
- * 编译生成IPA
35
-
36
- * 上传到测试平台
37
-
38
- * 发送测试通知
34
+ PINDO_BUNDLE_ID - 指定Bundle ID(如: com.heroneverdie101)
35
+ PINDO_PROJECT_NAME - 指定项目名称(如: Test Demo)
36
+ PINDO_TAG_DECISION - 指定Tag策略(new/retag/skip/exit)
37
+ PINDO_FORCE_BUILD - 自动使用缓存选择,跳过确认
39
38
 
40
39
  使用示例:
41
40
 
42
- $ pindo unity ipa # 编译IPA
41
+ $ pindo unity ipa # 编译IPA
42
+ $ pindo unity ipa --upload # 编译并上传
43
+ $ pindo unity ipa --send # 编译、上传并发送群组通知
44
+
45
+ # CI/CD自动化构建
46
+ $ PINDO_FORCE_BUILD=1 PINDO_BUNDLE_ID=com.heroneverdie101 PINDO_PROJECT_NAME="Test Demo" PINDO_TAG_DECISION=new pindo unity ipa --upload
43
47
 
44
- $ pindo unity ipa --upload # 编译并上传
48
+ 注意事项:
45
49
 
46
- $ pindo unity ipa --send # 编译上传并发送通知
47
50
 
48
- $ pindo unity ipa --proj=myapp # 指定项目名称
51
+ 需要在Unity工程根目录下执行
52
+ • Unity版本会自动检测
49
53
  DESC
50
54
 
51
55
  # 命令参数
@@ -56,12 +60,13 @@ DESC
56
60
  # 命令选项
57
61
  def self.options
58
62
  [
59
- ['--bundleid', '指定打包的bundleID'],
60
- ['--proj', '指定上传到测试平台的项目名称'],
61
- ['--upload', '上传编译后的IPA到测试平台(上传成功后会自动发送消息给自己)'],
62
- ['--send', '发送消息到项目群(注意:不带此参数也会发送给自己)'],
63
- ['--base', 'Unity工程编译lib模式'],
64
- ['--unity-version', '切换Unity版本']
63
+ ['--bundleid=ID', '指定打包的Bundle ID'],
64
+ ['--proj=NAME', '指定上传到测试平台的项目名称'],
65
+ ['--upload', '编译后上传到测试平台(上传成功后自动发送给自己)'],
66
+ ['--send', '发送通知到测试群组(同时也会发送给自己)'],
67
+ ['--base', 'Unity工程编译lib模式'],
68
+ ['--unity-version', '强制选择Unity版本'],
69
+ ['--deploy', '使用发布证书打包']
65
70
  ].concat(super)
66
71
  end
67
72
 
@@ -101,7 +101,7 @@ module Pindo
101
101
  when :ios
102
102
  puts "iOS 工程, 请使用 pindo ios autobuild"
103
103
  when :android
104
- puts "Android 工程, 请使用 pindo android build"
104
+ puts "Android 工程, 请使用 pindo and build"
105
105
 
106
106
  when :unity
107
107
  web_autobuild
data/lib/pindo/command.rb CHANGED
@@ -108,11 +108,19 @@ module Pindo
108
108
  @args_help_flag = argv.flag?('help', false)
109
109
  @args_verbose_flag = argv.flag?('verbose', false)
110
110
 
111
+ # 检查是否是 help 请求(检查原始命令行参数)
112
+ original_args = ARGV.join(' ')
113
+ is_help_request = @args_help_flag ||
114
+ original_args.include?('--help') ||
115
+ original_args.include?('-h') ||
116
+ argv.remainder.include?('--help') ||
117
+ argv.remainder.include?('-h')
118
+
111
119
  # 设置全局 verbose 标志
112
120
  ENV['PINDO_VERBOSE'] = '1' if @args_verbose_flag
113
121
 
114
- # 在非抽象命令初始化时设置上下文
115
- if !self.class.abstract_command? && !@args_help_flag
122
+ # 在非抽象命令初始化时设置上下文(但不在显示帮助时)
123
+ if !self.class.abstract_command? && !is_help_request
116
124
  context = Pindo::PindoContext.instance
117
125
 
118
126
  # 只在上下文未设置时才设置(避免重复设置)
@@ -55,6 +55,12 @@ module Pindo
55
55
  puts "\e[31m\e[1m✗ AAB 包不符合 Google Play 提交标准,需要修复合规问题才能提交!!!\e[0m"
56
56
  end
57
57
 
58
+ # 添加合规检测说明
59
+ puts "\e[36m\e[1m📋 合规检测说明:\e[0m"
60
+ puts "\e[33m • 仅供测试用的包可以忽略合规检测问题\e[0m"
61
+ puts "\e[33m • 提交至 Google Play 的正式用包必须处理所有合规检测问题\e[0m"
62
+ puts "\e[33m • 建议在正式发布前解决所有合规问题以确保顺利上架\e[0m"
63
+
58
64
  rescue => e
59
65
  puts "\e[31mGoogle Play 合规检测失败: #{e.message}\e[0m"
60
66
  puts "\e[33m建议手动检查包体积、Target SDK 版本和共享库对齐情况\e[0m"
@@ -264,31 +264,39 @@ module Pindo
264
264
  end
265
265
  end
266
266
 
267
- # 生成gradle-wrapper.jar(使用gradle wrapper命令)
267
+ # 改进的生成gradle-wrapper.jar逻辑(带缓存和内置文件回退)
268
268
  def download_gradle_wrapper_jar(wrapper_dir, gradle_version)
269
269
  wrapper_jar_path = File.join(wrapper_dir, "gradle-wrapper.jar")
270
270
 
271
- # 如果已存在且版本匹配,跳过生成
272
- if File.exist?(wrapper_jar_path) && verify_gradle_wrapper_jar(wrapper_jar_path, gradle_version)
273
- puts "\e[32m✓ gradle-wrapper.jar已存在且版本匹配\e[0m"
271
+ # 1. 检查现有文件是否有效
272
+ if File.exist?(wrapper_jar_path) && verify_gradle_wrapper_jar_complete(wrapper_jar_path, gradle_version)
273
+ puts "\e[32m✓ gradle-wrapper.jar已存在且验证通过\e[0m"
274
274
  return true
275
275
  end
276
276
 
277
277
  puts "正在生成gradle-wrapper.jar (版本: #{gradle_version})..."
278
278
 
279
- # 获取项目根目录
280
- project_path = File.dirname(File.dirname(wrapper_dir))
279
+ # 2. 尝试使用缓存
280
+ cached_jar = get_cached_gradle_wrapper_jar(gradle_version)
281
+ if cached_jar
282
+ FileUtils.cp(cached_jar, wrapper_jar_path)
283
+ puts "\e[32m✓ 从缓存复制 gradle-wrapper.jar 成功\e[0m"
284
+ return true
285
+ end
281
286
 
282
- # 检查是否有gradlew脚本
283
- gradlew_path = File.join(project_path, "gradlew")
287
+ # 3. 尝试下载
288
+ if download_standard_wrapper_jar(wrapper_jar_path, gradle_version)
289
+ return true
290
+ end
284
291
 
285
- if File.exist?(gradlew_path)
286
- puts "发现gradlew脚本,使用gradle wrapper命令生成..."
287
- return generate_wrapper_with_gradlew(project_path, gradle_version)
288
- else
289
- puts "未发现gradlew脚本,使用gradle命令生成..."
290
- return generate_wrapper_with_gradle(project_path, gradle_version)
292
+ # 4. 最后回退:使用内置文件
293
+ puts "\e[33m⚠ 所有下载源失败,使用内置 gradle-wrapper.jar\e[0m"
294
+ if use_builtin_gradle_wrapper_jar(wrapper_jar_path, gradle_version)
295
+ return true
291
296
  end
297
+
298
+ puts "\e[31m✗ 无法获取有效的 gradle-wrapper.jar\e[0m"
299
+ false
292
300
  end
293
301
 
294
302
  # 使用gradlew脚本生成wrapper
@@ -345,7 +353,7 @@ module Pindo
345
353
  false
346
354
  end
347
355
 
348
- # 手动生成wrapper(不使用临时目录)
356
+ # 改进的手动生成wrapper逻辑(带内置文件回退)
349
357
  def generate_wrapper_manually(project_path, gradle_version)
350
358
  puts "手动生成gradle wrapper..."
351
359
 
@@ -353,20 +361,24 @@ module Pindo
353
361
  wrapper_dir = File.join(project_path, "gradle/wrapper")
354
362
  FileUtils.mkdir_p(wrapper_dir)
355
363
 
356
- # 生成gradlew脚本
364
+ # 1. 生成gradlew脚本(带内置文件回退)
357
365
  gradlew_path = File.join(project_path, "gradlew")
358
366
  unless File.exist?(gradlew_path)
359
367
  puts "生成gradlew脚本..."
360
- generate_gradlew_script(project_path)
368
+ unless generate_gradlew_script(project_path)
369
+ puts "\e[31m✗ 生成gradlew脚本失败\e[0m"
370
+ return false
371
+ end
361
372
  end
362
373
 
363
- # 生成gradle-wrapper.jar(使用预定义的jar文件)
374
+ # 2. 生成gradle-wrapper.jar(带缓存和内置文件回退)
364
375
  wrapper_jar_path = File.join(wrapper_dir, "gradle-wrapper.jar")
365
376
  unless File.exist?(wrapper_jar_path)
366
377
  puts "生成gradle-wrapper.jar..."
367
- # 这里可以使用一个通用的gradle-wrapper.jar文件
368
- # 或者从网络下载一个标准的jar文件
369
- return download_standard_wrapper_jar(wrapper_jar_path, gradle_version)
378
+ unless download_gradle_wrapper_jar(wrapper_dir, gradle_version)
379
+ puts "\e[31m✗ 生成gradle-wrapper.jar失败\e[0m"
380
+ return false
381
+ end
370
382
  end
371
383
 
372
384
  puts "\e[32m✓ gradle wrapper手动生成成功\e[0m"
@@ -376,27 +388,144 @@ module Pindo
376
388
  false
377
389
  end
378
390
 
379
- # 下载标准的gradle-wrapper.jar
391
+ # 获取缓存目录路径
392
+ def get_gradle_wrapper_cache_dir
393
+ File.expand_path("~/.pindo/pindo_common_config/android_tools/gradle-wrapper-cache")
394
+ end
395
+
396
+ # 获取内置文件路径
397
+ def get_builtin_gradle_wrapper_jar_path
398
+ File.expand_path("~/.pindo/pindo_common_config/android_tools/gradle-wrapper.jar")
399
+ end
400
+
401
+ def get_builtin_gradlew_path
402
+ File.expand_path("~/.pindo/pindo_common_config/android_tools/gradlew")
403
+ end
404
+
405
+ # 检查并获取缓存的 gradle-wrapper.jar
406
+ def get_cached_gradle_wrapper_jar(gradle_version)
407
+ cache_dir = get_gradle_wrapper_cache_dir
408
+ FileUtils.mkdir_p(cache_dir)
409
+
410
+ cached_jar = File.join(cache_dir, "gradle-wrapper-#{gradle_version}.jar")
411
+
412
+ if File.exist?(cached_jar) && verify_gradle_wrapper_jar_complete(cached_jar, gradle_version)
413
+ puts "\e[32m✓ 使用缓存的 gradle-wrapper.jar (版本: #{gradle_version})\e[0m"
414
+ return cached_jar
415
+ end
416
+
417
+ nil
418
+ end
419
+
420
+ # 增强的 gradle-wrapper.jar 验证
421
+ def verify_gradle_wrapper_jar_complete(jar_path, expected_version)
422
+ return false unless File.exist?(jar_path)
423
+
424
+ # 检查文件大小(正常应该在 50KB-200KB 之间)
425
+ file_size = File.size(jar_path)
426
+ unless file_size.between?(50000, 200000)
427
+ puts "\e[33m⚠ gradle-wrapper.jar 大小异常: #{file_size} 字节\e[0m"
428
+ return false
429
+ end
430
+
431
+ # 检查 jar 文件是否包含 GradleWrapperMain 类
432
+ unless verify_jar_contains_class(jar_path, "org.gradle.wrapper.GradleWrapperMain")
433
+ puts "\e[33m⚠ gradle-wrapper.jar 缺少 GradleWrapperMain 类\e[0m"
434
+ return false
435
+ end
436
+
437
+ puts "\e[32m✓ gradle-wrapper.jar 验证通过\e[0m"
438
+ true
439
+ end
440
+
441
+ # 检查 jar 文件是否包含指定类
442
+ def verify_jar_contains_class(jar_path, class_name)
443
+ class_file = class_name.gsub('.', '/') + '.class'
444
+ system("jar -tf #{jar_path} | grep -q '#{class_file}'")
445
+ end
446
+
447
+ # 使用内置的 gradle-wrapper.jar
448
+ def use_builtin_gradle_wrapper_jar(wrapper_jar_path, gradle_version)
449
+ builtin_jar = get_builtin_gradle_wrapper_jar_path
450
+
451
+ unless File.exist?(builtin_jar)
452
+ puts "\e[31m✗ 内置 gradle-wrapper.jar 不存在: #{builtin_jar}\e[0m"
453
+ return false
454
+ end
455
+
456
+ # 复制内置文件
457
+ FileUtils.cp(builtin_jar, wrapper_jar_path)
458
+ puts "\e[33m⚠ 使用内置的 gradle-wrapper.jar\e[0m"
459
+
460
+ # 验证复制后的文件
461
+ if verify_gradle_wrapper_jar_complete(wrapper_jar_path, gradle_version)
462
+ puts "\e[32m✓ 内置 gradle-wrapper.jar 验证通过\e[0m"
463
+ return true
464
+ else
465
+ puts "\e[31m✗ 内置 gradle-wrapper.jar 验证失败\e[0m"
466
+ return false
467
+ end
468
+ end
469
+
470
+ # 使用内置的 gradlew 脚本
471
+ def use_builtin_gradlew_script(project_path)
472
+ builtin_gradlew = get_builtin_gradlew_path
473
+ gradlew_path = File.join(project_path, "gradlew")
474
+
475
+ unless File.exist?(builtin_gradlew)
476
+ puts "\e[31m✗ 内置 gradlew 脚本不存在: #{builtin_gradlew}\e[0m"
477
+ return false
478
+ end
479
+
480
+ # 复制内置脚本
481
+ FileUtils.cp(builtin_gradlew, gradlew_path)
482
+ system("chmod", "+x", gradlew_path)
483
+ puts "\e[33m⚠ 使用内置的 gradlew 脚本\e[0m"
484
+ puts "\e[32m✓ 内置 gradlew 脚本复制完成\e[0m"
485
+ true
486
+ end
487
+
488
+ # 保存到缓存的 gradle-wrapper.jar
489
+ def save_to_cache(wrapper_jar_path, gradle_version)
490
+ cache_dir = get_gradle_wrapper_cache_dir
491
+ FileUtils.mkdir_p(cache_dir)
492
+
493
+ cached_jar = File.join(cache_dir, "gradle-wrapper-#{gradle_version}.jar")
494
+ FileUtils.cp(wrapper_jar_path, cached_jar)
495
+ puts "\e[32m✓ gradle-wrapper.jar 已保存到缓存: #{cached_jar}\e[0m"
496
+ end
497
+
498
+ # 改进的下载标准 gradle-wrapper.jar
380
499
  def download_standard_wrapper_jar(wrapper_jar_path, gradle_version)
381
500
  puts "下载标准的gradle-wrapper.jar..."
382
501
 
383
- # 使用gradle官方提供的wrapper jar下载URL
502
+ # 使用更可靠的下载源
384
503
  wrapper_jar_urls = [
385
- "https://github.com/gradle/gradle/raw/v#{gradle_version}/gradle/wrapper/gradle-wrapper.jar",
386
- "https://raw.githubusercontent.com/gradle/gradle/v#{gradle_version}/gradle/wrapper/gradle-wrapper.jar"
504
+ # 官方 Gradle 分发服务(最可靠)
505
+ "https://services.gradle.org/distributions/gradle-#{gradle_version}-wrapper.jar",
506
+ # Maven Central(备用)
507
+ "https://repo1.maven.org/maven2/org/gradle/gradle-wrapper/#{gradle_version}/gradle-wrapper-#{gradle_version}.jar",
508
+ # GitHub releases(最后备用)
509
+ "https://github.com/gradle/gradle/releases/download/v#{gradle_version}/gradle-#{gradle_version}-wrapper.jar"
387
510
  ]
388
511
 
389
512
  wrapper_jar_urls.each do |url|
390
513
  puts "尝试下载: #{url}"
391
514
  if download_with_curl(url, wrapper_jar_path)
392
- if File.exist?(wrapper_jar_path) && File.size(wrapper_jar_path) > 1000
393
- puts "\e[32m✓ gradle-wrapper.jar下载成功\e[0m"
515
+ # 增强验证:检查文件完整性和类存在性
516
+ if verify_gradle_wrapper_jar_complete(wrapper_jar_path, gradle_version)
517
+ puts "\e[32m✓ gradle-wrapper.jar下载并验证成功\e[0m"
518
+ # 保存到缓存
519
+ save_to_cache(wrapper_jar_path, gradle_version)
394
520
  return true
521
+ else
522
+ puts "\e[33m⚠ 下载的文件验证失败,尝试下一个源\e[0m"
523
+ File.delete(wrapper_jar_path) if File.exist?(wrapper_jar_path)
395
524
  end
396
525
  end
397
526
  end
398
527
 
399
- puts "\e[31m✗ 下载gradle-wrapper.jar失败\e[0m"
528
+ puts "\e[31m✗ 所有下载源都失败\e[0m"
400
529
  false
401
530
  end
402
531
 
@@ -561,7 +690,7 @@ module Pindo
561
690
  false
562
691
  end
563
692
 
564
- # 生成gradlew脚本
693
+ # 改进的生成gradlew脚本逻辑(带内置文件回退)
565
694
  def generate_gradlew_script(project_path)
566
695
  gradlew_path = File.join(project_path, "gradlew")
567
696
 
@@ -573,6 +702,14 @@ module Pindo
573
702
 
574
703
  puts "正在生成gradlew脚本..."
575
704
 
705
+ # 1. 尝试使用内置脚本
706
+ if use_builtin_gradlew_script(project_path)
707
+ return true
708
+ end
709
+
710
+ # 2. 回退到生成新脚本
711
+ puts "\e[33m⚠ 内置脚本不可用,生成新的 gradlew 脚本\e[0m"
712
+
576
713
  # 生成gradlew脚本内容(通用脚本,不依赖版本)
577
714
  gradlew_content = generate_gradlew_content()
578
715
 
@@ -107,6 +107,18 @@ module Pindo
107
107
  end
108
108
 
109
109
  def get_selected_dev_bundleid()
110
+ # 检查环境变量
111
+ env_bundleid = ENV['PINDO_BUNDLE_ID']
112
+ if env_bundleid && !env_bundleid.empty?
113
+ puts "\n使用环境变量指定的Bundle ID: #{env_bundleid}"
114
+ puts
115
+ # 保存到缓存
116
+ require_relative '../base/pindocontext'
117
+ context = Pindo::PindoContext.instance
118
+ context.set_selection(Pindo::PindoContext::SelectionKey::BUNDLE_ID, env_bundleid)
119
+ return env_bundleid
120
+ end
121
+
110
122
  # 检查缓存
111
123
  require_relative '../base/pindocontext'
112
124
  context = Pindo::PindoContext.instance
@@ -138,6 +138,60 @@ module Pindo
138
138
  latest_tag = get_latest_version_tag(project_dir: current_git_root_path)
139
139
 
140
140
  unless is_tag_at_head?(git_root_dir: current_git_root_path, tag_name: latest_tag)
141
+ # 检查环境变量
142
+ env_tag_decision = ENV['PINDO_TAG_DECISION']
143
+ if env_tag_decision && !env_tag_decision.empty?
144
+ case env_tag_decision.downcase
145
+ when 'new', 'new_tag', '1'
146
+ puts "\n环境变量指定:新增版本号,打新Tag"
147
+ puts
148
+ tag_action_parms = []
149
+ is_need_add_tag = true
150
+ # 保存到缓存
151
+ context = PindoContext.instance
152
+ decision = {
153
+ tag_action_parms: tag_action_parms,
154
+ is_need_add_tag: is_need_add_tag,
155
+ action: :new_tag,
156
+ description: "新增版本号,打新Tag"
157
+ }
158
+ context.set_selection(PindoContext::SelectionKey::TAG_DECISION, decision)
159
+ return is_need_add_tag, tag_action_parms
160
+ when 'retag', 'recreate', '2'
161
+ puts "\n环境变量指定:将上次的Tag删除重新打Tag"
162
+ puts
163
+ tag_action_parms = ['--retag']
164
+ is_need_add_tag = true
165
+ # 保存到缓存
166
+ context = PindoContext.instance
167
+ decision = {
168
+ tag_action_parms: tag_action_parms,
169
+ is_need_add_tag: is_need_add_tag,
170
+ action: :recreate_tag,
171
+ description: "将上次的Tag删除重新打Tag"
172
+ }
173
+ context.set_selection(PindoContext::SelectionKey::TAG_DECISION, decision)
174
+ return is_need_add_tag, tag_action_parms
175
+ when 'skip', 'no', 'none', '3'
176
+ puts "\n环境变量指定:不需要Tag继续编译"
177
+ puts
178
+ tag_action_parms = nil
179
+ is_need_add_tag = false
180
+ # 保存到缓存
181
+ context = PindoContext.instance
182
+ decision = {
183
+ tag_action_parms: tag_action_parms,
184
+ is_need_add_tag: is_need_add_tag,
185
+ action: :continue_without_tag,
186
+ description: "不需要Tag继续编译且上传"
187
+ }
188
+ context.set_selection(PindoContext::SelectionKey::TAG_DECISION, decision)
189
+ return is_need_add_tag, tag_action_parms
190
+ when 'exit', 'quit', '4'
191
+ raise Informative, "环境变量指定:终止退出编译!"
192
+ end
193
+ end
194
+
141
195
  if auto_mode
142
196
  # 在自动化模式或没有交互式终端时,默认选择新增版本号打新Tag
143
197
  puts "检测到当前代码没有打Tag,在自动模式下将自动新增版本号并打新Tag"
@@ -56,6 +56,14 @@ module Pindo
56
56
  upload_proj_name = @proj_name
57
57
  end
58
58
 
59
+ # 检查环境变量
60
+ env_project_name = ENV['PINDO_PROJECT_NAME']
61
+ if env_project_name && !env_project_name.empty?
62
+ upload_proj_name = env_project_name
63
+ puts "\n使用环境变量指定的项目名称: #{upload_proj_name}"
64
+ puts
65
+ end
66
+
59
67
  app_info_obj = nil
60
68
  if login
61
69
 
@@ -64,6 +72,12 @@ module Pindo
64
72
  end
65
73
 
66
74
  if !app_info_obj.nil?
75
+ # 如果使用环境变量找到了项目,保存到缓存
76
+ if env_project_name && !env_project_name.empty?
77
+ require_relative '../../base/pindocontext'
78
+ context = Pindo::PindoContext.instance
79
+ context.set_selection(Pindo::PindoContext::SelectionKey::PROJECT_NAME, upload_proj_name)
80
+ end
67
81
  return app_info_obj
68
82
  end
69
83
 
@@ -110,18 +124,21 @@ module Pindo
110
124
  proj_name_array.uniq
111
125
  proj_name_array << "自定义输入Pyger上的App代号"
112
126
 
113
- # 检查缓存的 App Key
114
- require_relative '../../base/pindocontext'
115
- context = Pindo::PindoContext.instance
116
- cached_app_key = context.get_selection(Pindo::PindoContext::SelectionKey::PROJECT_NAME)
117
-
118
- if cached_app_key && proj_name_array.include?(cached_app_key)
119
- puts "\n使用之前选择的App代号: #{cached_app_key}"
120
- upload_proj_name = cached_app_key
121
- # 直接使用缓存的选择,跳过后续选择逻辑
127
+ # 如果环境变量已经设置了项目名,跳过选择逻辑
128
+ if !(env_project_name && !env_project_name.empty?)
129
+ # 检查缓存的 App Key
130
+ require_relative '../../base/pindocontext'
131
+ context = Pindo::PindoContext.instance
132
+ cached_app_key = context.get_selection(Pindo::PindoContext::SelectionKey::PROJECT_NAME)
133
+
134
+ if cached_app_key && proj_name_array.include?(cached_app_key)
135
+ puts "\n使用之前选择的App代号: #{cached_app_key}"
136
+ upload_proj_name = cached_app_key
137
+ # 直接使用缓存的选择,跳过后续选择逻辑
138
+ end
122
139
  end
123
140
 
124
- # 只有在没有缓存或缓存无效时才显示选择菜单
141
+ # 只有在没有缓存或缓存无效,且没有环境变量时才显示选择菜单
125
142
  if upload_proj_name.nil? || upload_proj_name.empty?
126
143
  if proj_name_array.size > 1
127
144
  cli = HighLine.new
data/lib/pindo/version.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
 
7
7
  module Pindo
8
8
 
9
- VERSION = "5.5.8"
9
+ VERSION = "5.6.0"
10
10
 
11
11
  class VersionCheck
12
12
  RUBYGEMS_API = 'https://rubygems.org/api/v1/gems/pindo.json'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.8
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - wade
@@ -115,20 +115,20 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 1.0.0
118
+ version: 1.1.0
119
119
  - - ">="
120
120
  - !ruby/object:Gem::Version
121
- version: 1.0.0
121
+ version: 1.1.0
122
122
  type: :runtime
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: 1.0.0
128
+ version: 1.1.0
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 1.0.0
131
+ version: 1.1.0
132
132
  - !ruby/object:Gem::Dependency
133
133
  name: rqrcode
134
134
  requirement: !ruby/object:Gem::Requirement