Class: EasyAI::Command::Update
Constant Summary
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
#args_help_flag
Class Method Summary
collapse
Instance Method Summary
collapse
run
Constructor Details
#initialize(argv) ⇒ Update
Returns a new instance of Update.
39
40
41
42
43
44
|
# File 'lib/easyai/command/update.rb', line 39
def initialize(argv)
@branch = argv.option('branch') || 'master'
@keep_source = argv.flag?('keep-source')
@verbose = argv.flag?('verbose')
super
end
|
Class Method Details
.options ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/easyai/command/update.rb', line 31
def self.options
[
['--branch=BRANCH', '指定要安装的分支(默认: master)'],
['--keep-source', '保留下载的源代码'],
['--verbose', '显示详细输出']
].concat(super)
end
|
Instance Method Details
#run ⇒ Object
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
|
# File 'lib/easyai/command/update.rb', line 51
def run
puts "\n╔#{'═' * 58}╗".cyan
puts "║#{'EasyAI 开发版本更新工具'.center(58)}║".cyan
puts "╚#{'═' * 58}╝\n".cyan
puts "⚠️ 注意:此命令仅用于测试开发版本".yellow
puts "📦 生产环境请使用: #{'gem update easyai'.green}\n\n"
unless confirm_update?
puts "❌ 更新已取消".red
return
end
temp_dir = Dir.mktmpdir('easyai-update-')
begin
clone_repository(temp_dir)
install_from_source(temp_dir)
show_success_message
rescue => e
puts "\n❌ 更新失败: #{e.message}".red
puts " 请检查网络连接或稍后重试".red
exit 1
ensure
cleanup_temp_files(temp_dir) unless @keep_source
end
end
|
#validate! ⇒ Object
46
47
48
49
|
# File 'lib/easyai/command/update.rb', line 46
def validate!
super
help! '未找到 git 命令。请先安装 git。' unless git_available?
end
|