makit 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/makit/apache.rb +32 -32
- data/lib/makit/cli/clean.rb +14 -14
- data/lib/makit/cli/clone.rb +59 -59
- data/lib/makit/cli/init.rb +38 -38
- data/lib/makit/cli/main.rb +33 -33
- data/lib/makit/cli/make.rb +54 -54
- data/lib/makit/cli/new.rb +37 -37
- data/lib/makit/cli/nuget_cache.rb +38 -38
- data/lib/makit/cli/pull.rb +31 -31
- data/lib/makit/cli/setup.rb +71 -71
- data/lib/makit/cli/work.rb +21 -21
- data/lib/makit/command_runner.rb +274 -237
- data/lib/makit/commands.rb +21 -21
- data/lib/makit/content/default_gitignore.rb +5 -5
- data/lib/makit/content/default_rakefile.rb +11 -11
- data/lib/makit/content/gem_rakefile.rb +14 -14
- data/lib/makit/data.rb +50 -50
- data/lib/makit/directories.rb +140 -140
- data/lib/makit/directory.rb +151 -120
- data/lib/makit/dotnet.rb +83 -75
- data/lib/makit/environment.rb +123 -123
- data/lib/makit/files.rb +47 -47
- data/lib/makit/git.rb +66 -66
- data/lib/makit/gitlab_runner.rb +60 -60
- data/lib/makit/humanize.rb +89 -89
- data/lib/makit/logging.rb +96 -96
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +16 -16
- data/lib/makit/mp/command_request.mp.rb +13 -0
- data/lib/makit/mp/project_mp.rb +156 -149
- data/lib/makit/mp/string_mp.rb +101 -101
- data/lib/makit/nuget.rb +57 -57
- data/lib/makit/protoc.rb +61 -61
- data/lib/makit/serializer.rb +115 -70
- data/lib/makit/storage.rb +131 -131
- data/lib/makit/symbols.rb +149 -149
- data/lib/makit/tasks.rb +67 -67
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/makit.v1_pb.rb +5 -5
- data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
- data/lib/makit/version.rb +12 -12
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/zip.rb +17 -17
- data/lib/makit.rb +243 -243
- metadata +4 -39
- data/.makit.project.json +0 -4
- data/.makit.project.yml +0 -2
- data/.rubocop.yml +0 -22
- data/.ruby-version +0 -1
- data/CHANGELOG.md +0 -8
- data/CODE_OF_CONDUCT.md +0 -84
- data/LICENSE +0 -21
- data/README.md +0 -119
- data/Rakefile +0 -200
- data/docs/Commands.md +0 -50
- data/docs_/Commands.md +0 -166
- data/docs_/Minitest.Timeouts.md +0 -332
- data/examples/protoc/Rakefile +0 -31
- data/examples/rake_default/Rakefile +0 -6
- data/examples/rubygem-foo/.gitkeep +0 -0
- data/examples/rubygem-foo/Rakefile +0 -3
- data/examples/run_mp/Rakefile +0 -8
- data/exe/makit +0 -5
- data/lib/makit/content/default_gitignore.txt +0 -222
- data/lib/makit/content/ruby_gitlab-ci.yml +0 -15
- data/lib/makit/v1/makit.v1.proto +0 -103
- data/makit.generated.sln +0 -30
- data/makit.sln +0 -69
- data/pages/.gitignore +0 -5
- data/pages/404.html +0 -25
- data/pages/Gemfile +0 -33
- data/pages/Gemfile.lock +0 -88
- data/pages/_config.yml +0 -55
- data/pages/_layouts/default.html +0 -1
- data/pages/_posts/2024-10-05-welcome-to-jekyll.markdown +0 -29
- data/pages/about.markdown +0 -18
- data/pages/index.markdown +0 -6
- data/sig/makit.rbs +0 -4
- data/src/ClassLib/Class1.cs +0 -6
- data/src/ClassLib/ClassLib.csproj +0 -13
data/lib/makit/gitlab_runner.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "yaml"
|
4
|
-
require "fileutils"
|
5
|
-
|
6
|
-
# This module provides classes for the Makit gem.
|
7
|
-
module Makit
|
8
|
-
# This class provide methods for working with Directories/
|
9
|
-
#
|
10
|
-
# Example:
|
11
|
-
#
|
12
|
-
# Makit::Directory.find_directory_with_pattern("/home/user", "*.rb")
|
13
|
-
#
|
14
|
-
class GitLabRunner
|
15
|
-
|
16
|
-
# Parse the .gitlab-ci.yml file
|
17
|
-
def parse_gitlab_ci_file(file_path)
|
18
|
-
YAML.load_file(file_path)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Extract the script for a specified job
|
22
|
-
def extract_script(ci_config, job_name)
|
23
|
-
job = ci_config[job_name]
|
24
|
-
job ? job["script"] : nil
|
25
|
-
end
|
26
|
-
|
27
|
-
# Write the script to a temporary file
|
28
|
-
def write_script_to_file(script, file_path)
|
29
|
-
File.open(file_path, "w") do |file|
|
30
|
-
script.each { |line| file.puts(line) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Run the script in a Docker container
|
35
|
-
def run_script_in_docker(image, script_file)
|
36
|
-
system("docker run --rm -v #{Dir.pwd}:/workspace -w /workspace #{image} /bin/sh #{script_file}")
|
37
|
-
end
|
38
|
-
|
39
|
-
# Main function to execute the process
|
40
|
-
def run_job(ci_file_path, job_name, docker_image)
|
41
|
-
ci_config = parse_gitlab_ci_file(ci_file_path)
|
42
|
-
script = extract_script(ci_config, job_name)
|
43
|
-
|
44
|
-
unless script
|
45
|
-
puts "Job '#{job_name}' not found in #{ci_file_path}"
|
46
|
-
return
|
47
|
-
end
|
48
|
-
|
49
|
-
script_file = "temp_script.sh"
|
50
|
-
write_script_to_file(script, script_file)
|
51
|
-
FileUtils.chmod("+x", script_file)
|
52
|
-
|
53
|
-
puts "Running script in Docker container..."
|
54
|
-
run_script_in_docker(docker_image, script_file)
|
55
|
-
|
56
|
-
# Clean up the temporary script file
|
57
|
-
FileUtils.rm(script_file)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
# This module provides classes for the Makit gem.
|
7
|
+
module Makit
|
8
|
+
# This class provide methods for working with Directories/
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
#
|
12
|
+
# Makit::Directory.find_directory_with_pattern("/home/user", "*.rb")
|
13
|
+
#
|
14
|
+
class GitLabRunner
|
15
|
+
|
16
|
+
# Parse the .gitlab-ci.yml file
|
17
|
+
def parse_gitlab_ci_file(file_path)
|
18
|
+
YAML.load_file(file_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Extract the script for a specified job
|
22
|
+
def extract_script(ci_config, job_name)
|
23
|
+
job = ci_config[job_name]
|
24
|
+
job ? job["script"] : nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# Write the script to a temporary file
|
28
|
+
def write_script_to_file(script, file_path)
|
29
|
+
File.open(file_path, "w") do |file|
|
30
|
+
script.each { |line| file.puts(line) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Run the script in a Docker container
|
35
|
+
def run_script_in_docker(image, script_file)
|
36
|
+
system("docker run --rm -v #{Dir.pwd}:/workspace -w /workspace #{image} /bin/sh #{script_file}")
|
37
|
+
end
|
38
|
+
|
39
|
+
# Main function to execute the process
|
40
|
+
def run_job(ci_file_path, job_name, docker_image)
|
41
|
+
ci_config = parse_gitlab_ci_file(ci_file_path)
|
42
|
+
script = extract_script(ci_config, job_name)
|
43
|
+
|
44
|
+
unless script
|
45
|
+
puts "Job '#{job_name}' not found in #{ci_file_path}"
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
script_file = "temp_script.sh"
|
50
|
+
write_script_to_file(script, script_file)
|
51
|
+
FileUtils.chmod("+x", script_file)
|
52
|
+
|
53
|
+
puts "Running script in Docker container..."
|
54
|
+
run_script_in_docker(docker_image, script_file)
|
55
|
+
|
56
|
+
# Clean up the temporary script file
|
57
|
+
FileUtils.rm(script_file)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/makit/humanize.rb
CHANGED
@@ -1,89 +1,89 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# This module provides classes for the Makit gem.
|
4
|
-
module Makit
|
5
|
-
class Humanize
|
6
|
-
def self.get_humanized_size(bytes, precision = 2)
|
7
|
-
units = ["B", "KB", "MB", "GB", "TB", "PB"]
|
8
|
-
return "0 B" if bytes == 0
|
9
|
-
|
10
|
-
exp = (Math.log(bytes) / Math.log(1024)).to_i
|
11
|
-
exp = units.size - 1 if exp >= units.size
|
12
|
-
|
13
|
-
size = bytes.to_f / (1024 ** exp)
|
14
|
-
format("%.#{precision}f %s", size, units[exp])
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.get_make_result_summary(make_result)
|
18
|
-
summary = "Make Result\n"
|
19
|
-
summary += " Repository: #{make_result.repository}\n"
|
20
|
-
summary += " Commit: #{make_result.commit}\n"
|
21
|
-
summary += " Branch: #{make_result.branch}\n"
|
22
|
-
summary += " Tag: #{make_result.tag}\n"
|
23
|
-
summary += " Device: #{make_result.device}\n"
|
24
|
-
summary += " Runtime Identifier: #{make_result.runtime_identifier}\n"
|
25
|
-
summary += " Initial Size: #{get_humanized_size(make_result.initial_size)}\n"
|
26
|
-
summary += " Final Size: #{get_humanized_size(make_result.final_size)}\n"
|
27
|
-
summary += " Delta Size: #{get_humanized_size(make_result.final_size - make_result.initial_size)}\n"
|
28
|
-
summary += " Commands: (#{make_result.commands.length})\n"
|
29
|
-
make_result.commands.each do |command|
|
30
|
-
details = get_command_details(command)
|
31
|
-
summary += "\n"
|
32
|
-
summary += indent_string(details, 4)
|
33
|
-
summary += "\n"
|
34
|
-
end
|
35
|
-
|
36
|
-
summary
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.get_commands(commands)
|
40
|
-
message = ""
|
41
|
-
commands.each do |command|
|
42
|
-
message += Makit::Humanize::get_command_details(command)
|
43
|
-
end
|
44
|
-
message
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.get_command_summary(command)
|
48
|
-
symbol = Makit::Symbols.warning
|
49
|
-
symbol = Makit::Symbols.checkmark if !command.exit_code.nil? && command.exit_code.zero?
|
50
|
-
symbol = Makit::Symbols.error if command.exit_code != 0
|
51
|
-
"#{symbol} #{command.name} #{command.arguments.join(" ")}"
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.get_command_details(command)
|
55
|
-
summary = "#{get_command_summary(command)}\n"
|
56
|
-
summary += " Name: #{command.name}\n"
|
57
|
-
summary += " Arguments: #{command.arguments.join(" ")}\n"
|
58
|
-
summary += " Directory: #{command.directory}\n"
|
59
|
-
summary += " Exit Code: #{command.exit_code}\n"
|
60
|
-
if command.output.length > 0
|
61
|
-
summary += " Output:\n"
|
62
|
-
summary += indent_string(command.output, 4)
|
63
|
-
summary += "\n"
|
64
|
-
end
|
65
|
-
if command.error.length > 0
|
66
|
-
summary += " Error:\n"
|
67
|
-
summary += indent_string(command.error, 4)
|
68
|
-
summary += "\n"
|
69
|
-
end
|
70
|
-
summary
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.indent_string(string, spaces)
|
74
|
-
string.split("\n").map { |line| " " * spaces + line }.join("\n")
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.get_protobuf_timestamp(timestamp)
|
78
|
-
Time.at(timestamp.seconds, timestamp.nanos / 1000.0).strftime("%Y-%m-%d %H:%M:%S")
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.get_protobuf_duration(duration)
|
82
|
-
total_seconds = duration.seconds + (duration.nanos / 1_000_000_000.0)
|
83
|
-
hours = (total_seconds / 3600).to_i
|
84
|
-
minutes = ((total_seconds % 3600) / 60).to_i
|
85
|
-
seconds = (total_seconds % 60).round(2)
|
86
|
-
"#{hours}h #{minutes}m #{seconds}s"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module provides classes for the Makit gem.
|
4
|
+
module Makit
|
5
|
+
class Humanize
|
6
|
+
def self.get_humanized_size(bytes, precision = 2)
|
7
|
+
units = ["B", "KB", "MB", "GB", "TB", "PB"]
|
8
|
+
return "0 B" if bytes == 0
|
9
|
+
|
10
|
+
exp = (Math.log(bytes) / Math.log(1024)).to_i
|
11
|
+
exp = units.size - 1 if exp >= units.size
|
12
|
+
|
13
|
+
size = bytes.to_f / (1024 ** exp)
|
14
|
+
format("%.#{precision}f %s", size, units[exp])
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_make_result_summary(make_result)
|
18
|
+
summary = "Make Result\n"
|
19
|
+
summary += " Repository: #{make_result.repository}\n"
|
20
|
+
summary += " Commit: #{make_result.commit}\n"
|
21
|
+
summary += " Branch: #{make_result.branch}\n"
|
22
|
+
summary += " Tag: #{make_result.tag}\n"
|
23
|
+
summary += " Device: #{make_result.device}\n"
|
24
|
+
summary += " Runtime Identifier: #{make_result.runtime_identifier}\n"
|
25
|
+
summary += " Initial Size: #{get_humanized_size(make_result.initial_size)}\n"
|
26
|
+
summary += " Final Size: #{get_humanized_size(make_result.final_size)}\n"
|
27
|
+
summary += " Delta Size: #{get_humanized_size(make_result.final_size - make_result.initial_size)}\n"
|
28
|
+
summary += " Commands: (#{make_result.commands.length})\n"
|
29
|
+
make_result.commands.each do |command|
|
30
|
+
details = get_command_details(command)
|
31
|
+
summary += "\n"
|
32
|
+
summary += indent_string(details, 4)
|
33
|
+
summary += "\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
summary
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.get_commands(commands)
|
40
|
+
message = ""
|
41
|
+
commands.each do |command|
|
42
|
+
message += Makit::Humanize::get_command_details(command)
|
43
|
+
end
|
44
|
+
message
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.get_command_summary(command)
|
48
|
+
symbol = Makit::Symbols.warning
|
49
|
+
symbol = Makit::Symbols.checkmark if !command.exit_code.nil? && command.exit_code.zero?
|
50
|
+
symbol = Makit::Symbols.error if command.exit_code != 0
|
51
|
+
"#{symbol} #{command.name} #{command.arguments.join(" ")}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.get_command_details(command)
|
55
|
+
summary = "#{get_command_summary(command)}\n"
|
56
|
+
summary += " Name: #{command.name}\n"
|
57
|
+
summary += " Arguments: #{command.arguments.join(" ")}\n"
|
58
|
+
summary += " Directory: #{command.directory}\n"
|
59
|
+
summary += " Exit Code: #{command.exit_code}\n"
|
60
|
+
if command.output.length > 0
|
61
|
+
summary += " Output:\n"
|
62
|
+
summary += indent_string(command.output, 4)
|
63
|
+
summary += "\n"
|
64
|
+
end
|
65
|
+
if command.error.length > 0
|
66
|
+
summary += " Error:\n"
|
67
|
+
summary += indent_string(command.error, 4)
|
68
|
+
summary += "\n"
|
69
|
+
end
|
70
|
+
summary
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.indent_string(string, spaces)
|
74
|
+
string.split("\n").map { |line| " " * spaces + line }.join("\n")
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.get_protobuf_timestamp(timestamp)
|
78
|
+
Time.at(timestamp.seconds, timestamp.nanos / 1000.0).strftime("%Y-%m-%d %H:%M:%S")
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.get_protobuf_duration(duration)
|
82
|
+
total_seconds = duration.seconds + (duration.nanos / 1_000_000_000.0)
|
83
|
+
hours = (total_seconds / 3600).to_i
|
84
|
+
minutes = ((total_seconds % 3600) / 60).to_i
|
85
|
+
seconds = (total_seconds % 60).round(2)
|
86
|
+
"#{hours}h #{minutes}m #{seconds}s"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/makit/logging.rb
CHANGED
@@ -1,96 +1,96 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "logger"
|
4
|
-
require "colorize"
|
5
|
-
require_relative "symbols"
|
6
|
-
|
7
|
-
# This module provides classes for the Makit gem.
|
8
|
-
module Makit
|
9
|
-
module Logging
|
10
|
-
ANSI_COLOR_REGEX = /\e\[[0-9;]*m/
|
11
|
-
|
12
|
-
class PlainFormatter < Logger::Formatter
|
13
|
-
def call(_severity, _time, _progname, msg)
|
14
|
-
stripped_msg = msg.gsub(ANSI_COLOR_REGEX, "") # Remove ANSI color codes
|
15
|
-
"#{stripped_msg}\n"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class ColorFormatter < Logger::Formatter
|
20
|
-
def call(_severity, _time, _progname, msg)
|
21
|
-
"#{msg}\n"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# This class provide methods for working with Directories/
|
26
|
-
#
|
27
|
-
# Example:
|
28
|
-
#
|
29
|
-
# Makit::Directory.find_directory_with_pattern("/home/user", "*.rb")
|
30
|
-
#
|
31
|
-
class MultiLogger
|
32
|
-
def initialize(*targets)
|
33
|
-
@targets = targets
|
34
|
-
end
|
35
|
-
|
36
|
-
def add(severity, message = nil, progname = nil, &block)
|
37
|
-
@targets.each do |logger|
|
38
|
-
logger.add(severity, message, progname, &block)
|
39
|
-
logger.flush if logger.respond_to?(:flush)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def <<(message)
|
44
|
-
@targets.each do |logger|
|
45
|
-
logger << message
|
46
|
-
logger.flush if logger.respond_to?(:flush)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def close
|
51
|
-
@targets.each(&:close)
|
52
|
-
end
|
53
|
-
|
54
|
-
def method_missing(method, *args, &block)
|
55
|
-
@targets.each { |logger| logger.send(method, *args, &block) }
|
56
|
-
end
|
57
|
-
|
58
|
-
def respond_to_missing?(method, include_private = false)
|
59
|
-
@targets.all? { |logger| logger.respond_to?(method, include_private) }
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.create_logger
|
63
|
-
stdout_logger = Logger.new($stdout) # ColoredLogger.new(STDOUT)
|
64
|
-
stdout_logger.level = Logger::DEBUG
|
65
|
-
# Assign the custom formatter to the file_logger
|
66
|
-
stdout_logger.formatter = ColorFormatter.new
|
67
|
-
|
68
|
-
# if clean or clobber commands are used, then log ONLY to stdout
|
69
|
-
if ARGV.include?("clean") || ARGV.include?("clobber")
|
70
|
-
return stdout_logger
|
71
|
-
end
|
72
|
-
if Makit::Environment.project_root_directory.nil?
|
73
|
-
logger = stdout_logger
|
74
|
-
else
|
75
|
-
#log_filename = if ARGV.empty?
|
76
|
-
# "#{Makit::Environment.project_root_directory}/artifacts/rake.log"
|
77
|
-
# else
|
78
|
-
# "#{Makit::Environment.project_root_directory}/artifacts/rake_#{ARGV.join("_").gsub(":",
|
79
|
-
# "_")}.log"
|
80
|
-
# end
|
81
|
-
# FileUtils.remove_file(log_file) if File.exist?(log_file)
|
82
|
-
#FileUtils.mkdir_p(File.dirname(log_filename)) unless Dir.exist?(File.dirname(log_filename))
|
83
|
-
#File.open(log_filename, "w")
|
84
|
-
#file_logger = Logger.new(log_filename)
|
85
|
-
#file_logger.level = Logger::DEBUG
|
86
|
-
# Assign the custom formatter to the file_logger
|
87
|
-
#file_logger.formatter = PlainFormatter.new
|
88
|
-
#logger = MultiLogger.new(file_logger, stdout_logger)
|
89
|
-
logger = stdout_logger
|
90
|
-
end
|
91
|
-
|
92
|
-
logger
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "logger"
|
4
|
+
require "colorize"
|
5
|
+
require_relative "symbols"
|
6
|
+
|
7
|
+
# This module provides classes for the Makit gem.
|
8
|
+
module Makit
|
9
|
+
module Logging
|
10
|
+
ANSI_COLOR_REGEX = /\e\[[0-9;]*m/
|
11
|
+
|
12
|
+
class PlainFormatter < Logger::Formatter
|
13
|
+
def call(_severity, _time, _progname, msg)
|
14
|
+
stripped_msg = msg.gsub(ANSI_COLOR_REGEX, "") # Remove ANSI color codes
|
15
|
+
"#{stripped_msg}\n"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class ColorFormatter < Logger::Formatter
|
20
|
+
def call(_severity, _time, _progname, msg)
|
21
|
+
"#{msg}\n"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# This class provide methods for working with Directories/
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
#
|
29
|
+
# Makit::Directory.find_directory_with_pattern("/home/user", "*.rb")
|
30
|
+
#
|
31
|
+
class MultiLogger
|
32
|
+
def initialize(*targets)
|
33
|
+
@targets = targets
|
34
|
+
end
|
35
|
+
|
36
|
+
def add(severity, message = nil, progname = nil, &block)
|
37
|
+
@targets.each do |logger|
|
38
|
+
logger.add(severity, message, progname, &block)
|
39
|
+
logger.flush if logger.respond_to?(:flush)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def <<(message)
|
44
|
+
@targets.each do |logger|
|
45
|
+
logger << message
|
46
|
+
logger.flush if logger.respond_to?(:flush)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def close
|
51
|
+
@targets.each(&:close)
|
52
|
+
end
|
53
|
+
|
54
|
+
def method_missing(method, *args, &block)
|
55
|
+
@targets.each { |logger| logger.send(method, *args, &block) }
|
56
|
+
end
|
57
|
+
|
58
|
+
def respond_to_missing?(method, include_private = false)
|
59
|
+
@targets.all? { |logger| logger.respond_to?(method, include_private) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.create_logger
|
63
|
+
stdout_logger = Logger.new($stdout) # ColoredLogger.new(STDOUT)
|
64
|
+
stdout_logger.level = Logger::DEBUG
|
65
|
+
# Assign the custom formatter to the file_logger
|
66
|
+
stdout_logger.formatter = ColorFormatter.new
|
67
|
+
|
68
|
+
# if clean or clobber commands are used, then log ONLY to stdout
|
69
|
+
if ARGV.include?("clean") || ARGV.include?("clobber")
|
70
|
+
return stdout_logger
|
71
|
+
end
|
72
|
+
if Makit::Environment.project_root_directory.nil?
|
73
|
+
logger = stdout_logger
|
74
|
+
else
|
75
|
+
#log_filename = if ARGV.empty?
|
76
|
+
# "#{Makit::Environment.project_root_directory}/artifacts/rake.log"
|
77
|
+
# else
|
78
|
+
# "#{Makit::Environment.project_root_directory}/artifacts/rake_#{ARGV.join("_").gsub(":",
|
79
|
+
# "_")}.log"
|
80
|
+
# end
|
81
|
+
# FileUtils.remove_file(log_file) if File.exist?(log_file)
|
82
|
+
#FileUtils.mkdir_p(File.dirname(log_filename)) unless Dir.exist?(File.dirname(log_filename))
|
83
|
+
#File.open(log_filename, "w")
|
84
|
+
#file_logger = Logger.new(log_filename)
|
85
|
+
#file_logger.level = Logger::DEBUG
|
86
|
+
# Assign the custom formatter to the file_logger
|
87
|
+
#file_logger.formatter = PlainFormatter.new
|
88
|
+
#logger = MultiLogger.new(file_logger, stdout_logger)
|
89
|
+
logger = stdout_logger
|
90
|
+
end
|
91
|
+
|
92
|
+
logger
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/makit/markdown.rb
CHANGED
@@ -1,75 +1,75 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "humanize"
|
4
|
-
|
5
|
-
# This module provides classes for the Makit gem.
|
6
|
-
module Makit
|
7
|
-
class Markdown
|
8
|
-
def self.get_commands_markdown(commands)
|
9
|
-
summary = ""
|
10
|
-
commands.each do |command|
|
11
|
-
md = Makit::Markdown.get_command_markdown(command)
|
12
|
-
summary += md
|
13
|
-
end
|
14
|
-
summary
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.get_command_markdown(command)
|
18
|
-
md = "<details>\n"
|
19
|
-
md += "<summary>#{Makit::Humanize::get_command_summary(command)}</summary>\n\n"
|
20
|
-
|
21
|
-
if command.output.length > 0
|
22
|
-
md += "<table><tr><th>output</th></tr><tr><td>\n\n" #<pre>\n"
|
23
|
-
md += "```shell\n"
|
24
|
-
md += "#{command.output}\n"
|
25
|
-
md += "```\n\n"
|
26
|
-
md += "</td></tr></table>\n\n"
|
27
|
-
#md += "output:\n"
|
28
|
-
#md += "```shell\n"
|
29
|
-
#md += "#{command.output}\n"
|
30
|
-
#md += "```\n\n"
|
31
|
-
end
|
32
|
-
if command.error.length > 0
|
33
|
-
md += "error:\n"
|
34
|
-
md += "```shell\n"
|
35
|
-
md += "#{command.error}\n"
|
36
|
-
md += "```\n\n"
|
37
|
-
end
|
38
|
-
md += "| exit code | started at | duration | user | device | os | directory |\n"
|
39
|
-
md += "| --- | --- | --- | --- | --- | --- | --- |\n"
|
40
|
-
md += "| #{command.exit_code} | #{Makit::Humanize::get_protobuf_timestamp(command.started_at)} | #{Makit::Humanize::get_protobuf_duration(command.duration)} | #{command.user} | #{command.device} | #{command.os} | #{command.directory} |\n"
|
41
|
-
|
42
|
-
#md += "| Name | Value |\n"
|
43
|
-
#md += "| --- | --- |\n"
|
44
|
-
#md += "| exit code | #{command.exit_code} |\n"
|
45
|
-
#md += "| started at | #{Makit::Humanize::get_protobuf_timestamp(command.started_at)} |\n"
|
46
|
-
#md += "| duration | #{Makit::Humanize::get_protobuf_duration(command.duration)} |\n"
|
47
|
-
#md += "| user | #{command.user} |\n"
|
48
|
-
#md += "| device | #{command.device} |\n"
|
49
|
-
#md += "| os | #{command.os} |\n"
|
50
|
-
#md += "| directory | #{command.directory} |\n"
|
51
|
-
md += "</details>\n"
|
52
|
-
md
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.get_make_result_markdown(make_result)
|
56
|
-
md = "# Make Result\n"
|
57
|
-
# display allow of the fields of the MakeResult message
|
58
|
-
md += "| Name | Value |\n"
|
59
|
-
md += "| --- | --- |\n"
|
60
|
-
md += "| repository | #{make_result.repository} |\n"
|
61
|
-
md += "| commit | #{make_result.commit} |\n"
|
62
|
-
md += "| branch | #{make_result.branch} |\n"
|
63
|
-
md += "| tag | #{make_result.tag} |\n"
|
64
|
-
md += "| device | #{make_result.device} |\n"
|
65
|
-
md += "| runtime identifier | #{make_result.runtime_identifier} |\n"
|
66
|
-
md += "| initial size | #{make_result.initial_size} |\n"
|
67
|
-
md += "| final size | #{make_result.final_size} |\n"
|
68
|
-
md += "\n"
|
69
|
-
md += "## Commands\n"
|
70
|
-
make_result.commands.each do |command|
|
71
|
-
md += Makit::Markdown.get_command_markdown(command)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "humanize"
|
4
|
+
|
5
|
+
# This module provides classes for the Makit gem.
|
6
|
+
module Makit
|
7
|
+
class Markdown
|
8
|
+
def self.get_commands_markdown(commands)
|
9
|
+
summary = ""
|
10
|
+
commands.each do |command|
|
11
|
+
md = Makit::Markdown.get_command_markdown(command)
|
12
|
+
summary += md
|
13
|
+
end
|
14
|
+
summary
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_command_markdown(command)
|
18
|
+
md = "<details>\n"
|
19
|
+
md += "<summary>#{Makit::Humanize::get_command_summary(command)}</summary>\n\n"
|
20
|
+
|
21
|
+
if command.output.length > 0
|
22
|
+
md += "<table><tr><th>output</th></tr><tr><td>\n\n" #<pre>\n"
|
23
|
+
md += "```shell\n"
|
24
|
+
md += "#{command.output}\n"
|
25
|
+
md += "```\n\n"
|
26
|
+
md += "</td></tr></table>\n\n"
|
27
|
+
#md += "output:\n"
|
28
|
+
#md += "```shell\n"
|
29
|
+
#md += "#{command.output}\n"
|
30
|
+
#md += "```\n\n"
|
31
|
+
end
|
32
|
+
if command.error.length > 0
|
33
|
+
md += "error:\n"
|
34
|
+
md += "```shell\n"
|
35
|
+
md += "#{command.error}\n"
|
36
|
+
md += "```\n\n"
|
37
|
+
end
|
38
|
+
md += "| exit code | started at | duration | user | device | os | directory |\n"
|
39
|
+
md += "| --- | --- | --- | --- | --- | --- | --- |\n"
|
40
|
+
md += "| #{command.exit_code} | #{Makit::Humanize::get_protobuf_timestamp(command.started_at)} | #{Makit::Humanize::get_protobuf_duration(command.duration)} | #{command.user} | #{command.device} | #{command.os} | #{command.directory} |\n"
|
41
|
+
|
42
|
+
#md += "| Name | Value |\n"
|
43
|
+
#md += "| --- | --- |\n"
|
44
|
+
#md += "| exit code | #{command.exit_code} |\n"
|
45
|
+
#md += "| started at | #{Makit::Humanize::get_protobuf_timestamp(command.started_at)} |\n"
|
46
|
+
#md += "| duration | #{Makit::Humanize::get_protobuf_duration(command.duration)} |\n"
|
47
|
+
#md += "| user | #{command.user} |\n"
|
48
|
+
#md += "| device | #{command.device} |\n"
|
49
|
+
#md += "| os | #{command.os} |\n"
|
50
|
+
#md += "| directory | #{command.directory} |\n"
|
51
|
+
md += "</details>\n"
|
52
|
+
md
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.get_make_result_markdown(make_result)
|
56
|
+
md = "# Make Result\n"
|
57
|
+
# display allow of the fields of the MakeResult message
|
58
|
+
md += "| Name | Value |\n"
|
59
|
+
md += "| --- | --- |\n"
|
60
|
+
md += "| repository | #{make_result.repository} |\n"
|
61
|
+
md += "| commit | #{make_result.commit} |\n"
|
62
|
+
md += "| branch | #{make_result.branch} |\n"
|
63
|
+
md += "| tag | #{make_result.tag} |\n"
|
64
|
+
md += "| device | #{make_result.device} |\n"
|
65
|
+
md += "| runtime identifier | #{make_result.runtime_identifier} |\n"
|
66
|
+
md += "| initial size | #{make_result.initial_size} |\n"
|
67
|
+
md += "| final size | #{make_result.final_size} |\n"
|
68
|
+
md += "\n"
|
69
|
+
md += "## Commands\n"
|
70
|
+
make_result.commands.each do |command|
|
71
|
+
md += Makit::Markdown.get_command_markdown(command)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|