Class: Pindo::Command::Unity::Packpush
Constant Summary
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
#args_help_flag
Class Method Summary
collapse
Instance Method Summary
collapse
command_name, #initialize_options, run, use_cache?, #validate!
#pindo_log_instance
#pindo_single_config
Constructor Details
#initialize(argv) ⇒ Packpush
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/pindo/command/unity/packpush.rb', line 50
def initialize(argv)
@args_nupkg_file = argv.shift_argument
@nupkg_file = argv.option('nupkg')
if !@nupkg_file.nil?
@args_nupkg_file = @nupkg_file
end
if @args_nupkg_file && !@args_nupkg_file.empty?
@args_nupkg_file = @args_nupkg_file.strip.gsub(/\"/, '')
end
super(argv)
@additional_args = argv.remainder!
end
|
Class Method Details
.arguments ⇒ Object
38
39
40
41
42
|
# File 'lib/pindo/command/unity/packpush.rb', line 38
def self.arguments
[
CLAide::Argument.new('path/to/package.nupkg', false),
]
end
|
.options ⇒ Object
44
45
46
47
48
|
# File 'lib/pindo/command/unity/packpush.rb', line 44
def self.options
[
['--nupkg', '指定要上传的 .nupkg 文件路径'],
].concat(super)
end
|
Instance Method Details
#run ⇒ Object
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/pindo/command/unity/packpush.rb', line 65
def run
package_dir = Dir.pwd
puts ""
puts "🚀 上传 Unity Package 到 JPS"
puts ""
if @args_nupkg_file.nil? || !File.exist?(@args_nupkg_file)
@args_nupkg_file = Pindo::Unity::NugetHelper.find_nupkg_file(package_dir)
if @args_nupkg_file.nil? || !File.exist?(@args_nupkg_file)
@args_nupkg_file = ask('需要上传的文件:') || nil
if @args_nupkg_file
@args_nupkg_file = @args_nupkg_file.strip.gsub(/\\ /, ' ')
end
end
end
if @args_nupkg_file.nil? || !File.exist?(@args_nupkg_file)
raise Informative, "未找到 .nupkg 文件"
end
package_info = get_package_info_for_upload(package_dir) rescue nil
if package_info && !package_info.empty?
puts "📦 包信息:"
puts ""
puts " 名称: #{package_info['displayName']}"
puts " ID: #{package_info['name']}"
puts " 版本: #{package_info['version']}"
puts " 文件: #{@args_nupkg_file}"
puts " 大小: #{sprintf('%.2f', File.size(@args_nupkg_file) / 1024.0 / 1024.0)} MB"
else
puts "📦 上传文件:"
puts ""
puts " 文件: #{@args_nupkg_file}"
puts " 大小: #{sprintf('%.2f', File.size(@args_nupkg_file) / 1024.0 / 1024.0)} MB"
end
puts ""
force_upload = ENV['NUGET_UPLOAD_FORCE']
if force_upload && !force_upload.empty?
puts "🚀 检测到 NUGET_UPLOAD_FORCE 环境变量,跳过确认直接上传..."
else
answer = agree("确认上传?(Y/n)")
unless answer
puts "已取消上传"
return
end
end
puts ""
upload_task = Pindo::TaskSystem::NugetUploadTask.new(
project_path: package_dir,
nupkg_file: @args_nupkg_file
)
task_manager = Pindo::TaskSystem::TaskManager.instance
task_manager.clear_all
task_manager.add_task(upload_task)
task_manager.start
puts ""
Funlog.instance.fancyinfo_success("上传完成!")
puts ""
end
|