26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/rage/cli/skills.rb', line 26
def update
skills_destinations = Dir.glob(".*/skills/#{SKILLS_DIR}")
debug { "Existing skills installations found: #{skills_destinations}" }
if skills_destinations.empty?
log "No existing installation found. Running fresh install...\n\n"
return install
end
skills_version = fetch_skills_version
updated_paths = []
skills_destinations.each do |destination|
version_file = File.join(destination, VERSION_FILE)
current_version = File.exist?(version_file) ? File.read(version_file).strip : nil
if current_version == skills_version
log "#{set_color(destination, :cyan)}: already up to date."
next
end
log "Updating #{set_color(destination, :cyan)}..."
install_skills(destination, skills_version)
updated_paths << destination
end
if updated_paths.any?
log "#{set_color("✓", :green)} Updated #{updated_paths.size} installation#{"s" if updated_paths.size > 1} to #{set_color(skills_version, :bold)}."
end
json_output(
status: updated_paths.any? ? "updated" : "up_to_date",
version: skills_version,
paths: skills_destinations
)
rescue => e
if options[:json]
json_output(status: "error", message: e.message)
exit 1
else
say_error(e)
end
end
|