48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/pindo/command/unity/initpack.rb', line 48
def run
package_dir = Dir.pwd
puts "=" * 60
puts "🔧 Unity Package 初始化"
puts "=" * 60
puts
status = Pindo::Unity::NugetHelper.detect_files(package_dir)
puts "文件检测:"
puts " package.json: #{status[:has_package_json] ? '✅' : '❌'}"
puts " .nuspec: #{status[:has_nuspec] ? '✅' : '❌'}"
if status[:nuspec_file]
puts " 路径: #{File.basename(status[:nuspec_file])}"
end
puts
case [status[:has_package_json], status[:has_nuspec]]
when [true, false]
puts "📝 情况A:只有 package.json"
puts " → 创建 .nuspec(ID 使用驼峰格式)"
puts
Pindo::Unity::NugetHelper.handle_case_a(package_dir)
when [false, true]
puts "📝 情况B:只有 .nuspec"
puts " → 创建 package.json(name 使用全小写)"
puts
Pindo::Unity::NugetHelper.handle_case_b(package_dir, status[:nuspec_file])
when [true, true]
puts "📝 情况C:同时存在两个文件"
puts " → 以 .nuspec 为准同步到 package.json"
puts
Pindo::Unity::NugetHelper.handle_case_c(package_dir, status[:nuspec_file])
when [false, false]
puts "❌ 情况D:都不存在"
Pindo::Unity::NugetHelper.handle_case_d(package_dir)
end
puts
puts "=" * 60
puts "✅ 初始化完成!"
puts "=" * 60
puts
puts "下一步:"
puts " 运行 pindo unity pack 进行打包"
end
|