19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/legion/cli/doctor/config_check.rb', line 19
def run
found_dirs = CONFIG_PATHS.select { |p| Dir.exist?(p) }
if found_dirs.empty?
return Result.new(
name: name,
status: :warn,
message: "No config directory found (checked: #{CONFIG_PATHS.join(', ')})",
prescription: 'Run `legion config scaffold` to generate starter config',
auto_fixable: true
)
end
invalid_files = find_invalid_json_files(found_dirs)
if invalid_files.any?
messages = invalid_files.map { |f, err| "#{f}: #{err}" }
return Result.new(
name: name,
status: :fail,
message: "Invalid JSON in config files: #{messages.join('; ')}",
prescription: messages.map { |m| "Fix JSON syntax error in #{m}" }.join('; ')
)
end
Result.new(
name: name,
status: :pass,
message: "Config found in: #{found_dirs.join(', ')}"
)
end
|