Class: GDK::Command::DebugInfo
Constant Summary
collapse
- NEW_ISSUE_LINK =
'https://gitlab.com/gitlab-org/gitlab-development-kit/-/issues/new'
- ENV_WILDCARDS =
%w[GDK_.* BUNDLE_.* GEM_.*].freeze
- ENV_VARS =
%w[
PATH LANG LANGUAGE LC_ALL LDFLAGS CPPFLAGS PKG_CONFIG_PATH
LIBPCREDIR RUBY_CONFIGURE_OPTS
].freeze
Instance Attribute Summary
Attributes inherited from BaseCommand
#stderr, #stdout
Instance Method Summary
collapse
Methods inherited from BaseCommand
#config, #display_help_message, #help, #initialize, #print_help, #print_ready_message, #ready_messages, validate_config?
Instance Method Details
#arch ⇒ Object
53
54
55
|
# File 'lib/gdk/command/debug_info.rb', line 53
def arch
shellout('arch')
end
|
#combined_env_regex ⇒ Object
79
80
81
|
# File 'lib/gdk/command/debug_info.rb', line 79
def combined_env_regex
@combined_env_regex ||= /^#{ENV_WILDCARDS.join('|')}$/
end
|
#gdk_version ⇒ Object
65
66
67
|
# File 'lib/gdk/command/debug_info.rb', line 65
def gdk_version
shellout('git rev-parse --short HEAD', chdir: GDK.root)
end
|
#gdk_yml ⇒ Object
83
84
85
|
# File 'lib/gdk/command/debug_info.rb', line 83
def gdk_yml
File.read(GDK::Config::FILE)
end
|
#gdk_yml_exists? ⇒ Boolean
87
88
89
|
# File 'lib/gdk/command/debug_info.rb', line 87
def gdk_yml_exists?
File.exist?(GDK::Config::FILE)
end
|
#matches_regex?(var) ⇒ Boolean
75
76
77
|
# File 'lib/gdk/command/debug_info.rb', line 75
def matches_regex?(var)
var.match?(combined_env_regex)
end
|
#node_version ⇒ Object
61
62
63
|
# File 'lib/gdk/command/debug_info.rb', line 61
def node_version
shellout('node --version')
end
|
#os_name ⇒ Object
49
50
51
|
# File 'lib/gdk/command/debug_info.rb', line 49
def os_name
shellout('uname -a')
end
|
#review_prompt ⇒ Object
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/gdk/command/debug_info.rb', line 91
def review_prompt
<<~MESSAGE
Please review the content below, ensuring any sensitive information such as
API keys, passwords etc are removed before submitting. To create an issue
in the GitLab Development Kit project, use the following link:
#{NEW_ISSUE_LINK}
MESSAGE
end
|
#ruby_version ⇒ Object
57
58
59
|
# File 'lib/gdk/command/debug_info.rb', line 57
def ruby_version
shellout('ruby --version')
end
|
#run(_ = []) ⇒ Object
15
16
17
18
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
|
# File 'lib/gdk/command/debug_info.rb', line 15
def run(_ = [])
stdout.puts separator
stdout.info review_prompt
stdout.puts separator
stdout.puts "Operating system: #{os_name}"
stdout.puts "Architecture: #{arch}"
stdout.puts "Ruby version: #{ruby_version}"
stdout.puts "GDK version: #{gdk_version}"
stdout.puts
stdout.puts 'Environment:'
ENV_VARS.each do |var|
stdout.puts "#{var}=#{ENV.fetch(var, nil)}"
end
ENV.each do |var, content|
next unless matches_regex?(var)
stdout.puts "#{var}=#{content}"
end
if gdk_yml_exists?
stdout.puts
stdout.puts 'GDK configuration:'
stdout.puts gdk_yml
end
stdout.puts separator
true
end
|
#separator ⇒ Object
102
103
104
|
# File 'lib/gdk/command/debug_info.rb', line 102
def separator
@separator ||= '-' * 80
end
|
#shellout(cmd, **args) ⇒ Object
69
70
71
72
73
|
# File 'lib/gdk/command/debug_info.rb', line 69
def shellout(cmd, **args)
Shellout.new(cmd, **args).run
rescue StandardError => e
"Unknown (#{e.message})"
end
|