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?
#pindo_log_instance
#pindo_single_config
#validate!
Constructor Details
#initialize(argv) ⇒ Packpush
Returns a new instance of Packpush.
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/pindo/command/unity/packpush.rb', line 62
def initialize(argv)
@args_nupkg_file = argv.shift_argument
@options = initialize_options(argv)
@force_flag = @options[:force] || false
nupkg_option = @options[:nupkg]
if !nupkg_option.nil?
@args_nupkg_file = nupkg_option
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
45
46
47
48
49
|
# File 'lib/pindo/command/unity/packpush.rb', line 45
def self.arguments
[
CLAide::Argument.new('path/to/package.nupkg', false),
]
end
|
.options ⇒ Object
58
59
60
|
# File 'lib/pindo/command/unity/packpush.rb', line 58
def self.options
option_items.map(&:to_claide_option).concat(super)
end
|
Instance Method Details
#run ⇒ Object
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/pindo/command/unity/packpush.rb', line 80
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 = @force_flag || (ENV['NUGET_UPLOAD_FORCE'] && !ENV['NUGET_UPLOAD_FORCE'].empty?)
if force_upload
if @force_flag
puts "🚀 检测到 --force 参数,跳过确认直接上传..."
else
puts "🚀 检测到 NUGET_UPLOAD_FORCE 环境变量,跳过确认直接上传..."
end
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
|