makit 0.0.48 → 0.0.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generated/makit/v1/makit.v1_pb.rb +34 -0
  3. data/lib/generated/makit/v1/web/link_pb.rb +20 -0
  4. data/lib/makit/apache.rb +32 -32
  5. data/lib/makit/cli/clean.rb +14 -14
  6. data/lib/makit/cli/clone.rb +59 -59
  7. data/lib/makit/cli/init.rb +38 -38
  8. data/lib/makit/cli/main.rb +33 -33
  9. data/lib/makit/cli/make.rb +54 -54
  10. data/lib/makit/cli/new.rb +37 -37
  11. data/lib/makit/cli/nuget_cache.rb +38 -38
  12. data/lib/makit/cli/pull.rb +31 -31
  13. data/lib/makit/cli/setup.rb +71 -71
  14. data/lib/makit/cli/work.rb +21 -21
  15. data/lib/makit/command_runner.rb +399 -391
  16. data/lib/makit/commands.rb +21 -21
  17. data/lib/makit/content/default_gitignore.rb +5 -5
  18. data/lib/makit/content/default_rakefile.rb +11 -11
  19. data/lib/makit/content/gem_rakefile.rb +14 -14
  20. data/lib/makit/data.rb +50 -50
  21. data/lib/makit/directories.rb +140 -140
  22. data/lib/makit/directory.rb +200 -200
  23. data/lib/makit/dotnet.rb +170 -162
  24. data/lib/makit/environment.rb +127 -127
  25. data/lib/makit/fileinfo.rb +16 -16
  26. data/lib/makit/files.rb +47 -47
  27. data/lib/makit/git.rb +87 -87
  28. data/lib/makit/gitlab_runner.rb +60 -60
  29. data/lib/makit/humanize.rb +129 -129
  30. data/lib/makit/indexer.rb +56 -56
  31. data/lib/makit/logging.rb +96 -96
  32. data/lib/makit/markdown.rb +75 -75
  33. data/lib/makit/mp/basic_object_mp.rb +16 -16
  34. data/lib/makit/mp/command_request.mp.rb +16 -16
  35. data/lib/makit/mp/project_mp.rb +210 -210
  36. data/lib/makit/mp/string_mp.rb +137 -122
  37. data/lib/makit/nuget.rb +57 -57
  38. data/lib/makit/protoc.rb +104 -104
  39. data/lib/makit/serializer.rb +115 -115
  40. data/lib/makit/show.rb +106 -108
  41. data/lib/makit/storage.rb +131 -131
  42. data/lib/makit/symbols.rb +149 -149
  43. data/lib/makit/tasks.rb +61 -60
  44. data/lib/makit/tree.rb +37 -37
  45. data/lib/makit/v1/makit.v1_pb.rb +33 -34
  46. data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
  47. data/lib/makit/version.rb +62 -52
  48. data/lib/makit/wix.rb +95 -95
  49. data/lib/makit/zip.rb +17 -17
  50. data/lib/makit.rb +267 -267
  51. metadata +5 -3
data/lib/makit/indexer.rb CHANGED
@@ -1,56 +1,56 @@
1
- # frozen_string_literal: true
2
-
3
- # This module provides classes for the Makit gem.
4
- module Makit
5
- # This class provide methods for indexing objects.
6
- #
7
- class Indexer
8
- attr_accessor :keywords_index # Hash of string key to string[] of keyword
9
- attr_accessor :protoc_json_serializer
10
-
11
- def initialize
12
- @keywords_index = Hash.new
13
- @protoc_json_serializer = Makit::Serializer::new(Makit::Proto3Formats::JSON)
14
- end
15
-
16
- def index(key, item)
17
- # item must be serializable to json
18
- keywords = []
19
- hash = JSON.parse(item.to_json)
20
- hash.each do |key, value|
21
- value = value.to_s.downcase
22
- if (value.length >= 3 && !keywords.include?(value))
23
- keywords << value
24
- end
25
- end
26
- keywords.each do |keyword|
27
- if !@keywords_index.key?(keyword)
28
- @keywords_index[keyword] = []
29
- end
30
- @keywords_index[keyword] << key unless @keywords_index[keyword].include?(key)
31
- end
32
- end
33
-
34
- def search(query)
35
- keys = []
36
- # todo, remove terms less that length of 3
37
- terms = query.downcase.split(" ").reject { |term| term.length < 3 }
38
- keywords_index.each do |key, value| #{|kvp|
39
- if (get_match_count(terms, value) == terms.length)
40
- keys << key
41
- end
42
- end
43
- keys
44
- end
45
-
46
- def get_match_count(terms, keywords)
47
- match_count = 0
48
- terms.each { |term|
49
- if (keywords.include?(term))
50
- match_count += 1
51
- end
52
- }
53
- return match_count
54
- end
55
- end # class Indexer
56
- end # module Makit
1
+ # frozen_string_literal: true
2
+
3
+ # This module provides classes for the Makit gem.
4
+ module Makit
5
+ # This class provide methods for indexing objects.
6
+ #
7
+ class Indexer
8
+ attr_accessor :keywords_index # Hash of string key to string[] of keyword
9
+ attr_accessor :protoc_json_serializer
10
+
11
+ def initialize
12
+ @keywords_index = Hash.new
13
+ @protoc_json_serializer = Makit::Serializer::new(Makit::Proto3Formats::JSON)
14
+ end
15
+
16
+ def index(key, item)
17
+ # item must be serializable to json
18
+ keywords = []
19
+ hash = JSON.parse(item.to_json)
20
+ hash.each do |key, value|
21
+ value = value.to_s.downcase
22
+ if (value.length >= 3 && !keywords.include?(value))
23
+ keywords << value
24
+ end
25
+ end
26
+ keywords.each do |keyword|
27
+ if !@keywords_index.key?(keyword)
28
+ @keywords_index[keyword] = []
29
+ end
30
+ @keywords_index[keyword] << key unless @keywords_index[keyword].include?(key)
31
+ end
32
+ end
33
+
34
+ def search(query)
35
+ keys = []
36
+ # todo, remove terms less that length of 3
37
+ terms = query.downcase.split(" ").reject { |term| term.length < 3 }
38
+ keywords_index.each do |key, value| #{|kvp|
39
+ if (get_match_count(terms, value) == terms.length)
40
+ keys << key
41
+ end
42
+ end
43
+ keys
44
+ end
45
+
46
+ def get_match_count(terms, keywords)
47
+ match_count = 0
48
+ terms.each { |term|
49
+ if (keywords.include?(term))
50
+ match_count += 1
51
+ end
52
+ }
53
+ return match_count
54
+ end
55
+ end # class Indexer
56
+ end # module Makit
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
@@ -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
@@ -1,16 +1,16 @@
1
- # frozen_string_literal: true
2
- require "json"
3
- require "yaml"
4
-
5
- # monkey patch String class with a run method
6
-
7
- class BasicObject
8
- def to_json
9
- self.to_json
10
- end
11
-
12
- def to_pretty_json
13
- json = self.to_json
14
- ::JSON.pretty_generate(::JSON.parse(json))
15
- end
16
- end # class BasicObject
1
+ # frozen_string_literal: true
2
+ require "json"
3
+ require "yaml"
4
+
5
+ # monkey patch String class with a run method
6
+
7
+ class BasicObject
8
+ def to_json
9
+ self.to_json
10
+ end
11
+
12
+ def to_pretty_json
13
+ json = self.to_json
14
+ ::JSON.pretty_generate(::JSON.parse(json))
15
+ end
16
+ end # class BasicObject
@@ -1,16 +1,16 @@
1
- # frozen_string_literal: true
2
- require "digest"
3
-
4
- module Makit
5
- module V1
6
- #class CommandRequest
7
- # def to_hash
8
- # int_hash = Digest::SHA256.hexdigest("{self.name}.#{self.arguments.join(" ")}")
9
- # int_hash
10
- # end
11
- # def to_hash_string
12
- # hash_string = "#{int_hash}"
13
- # end
14
- # end
15
- end
16
- end # module Makit
1
+ # frozen_string_literal: true
2
+ require "digest"
3
+
4
+ module Makit
5
+ module V1
6
+ #class CommandRequest
7
+ # def to_hash
8
+ # int_hash = Digest::SHA256.hexdigest("{self.name}.#{self.arguments.join(" ")}")
9
+ # int_hash
10
+ # end
11
+ # def to_hash_string
12
+ # hash_string = "#{int_hash}"
13
+ # end
14
+ # end
15
+ end
16
+ end # module Makit