makit 0.0.99 → 0.0.111

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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -0
  3. data/exe/makit +5 -0
  4. data/lib/makit/apache.rb +7 -11
  5. data/lib/makit/cli/build_commands.rb +500 -0
  6. data/lib/makit/cli/generators/base_generator.rb +74 -0
  7. data/lib/makit/cli/generators/dotnet_generator.rb +50 -0
  8. data/lib/makit/cli/generators/generator_factory.rb +49 -0
  9. data/lib/makit/cli/generators/node_generator.rb +50 -0
  10. data/lib/makit/cli/generators/ruby_generator.rb +77 -0
  11. data/lib/makit/cli/generators/rust_generator.rb +50 -0
  12. data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -0
  13. data/lib/makit/cli/generators/templates/node_templates.rb +161 -0
  14. data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -0
  15. data/lib/makit/cli/generators/templates/ruby/gemspec.rb +40 -0
  16. data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -0
  17. data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -0
  18. data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -0
  19. data/lib/makit/cli/generators/templates/ruby/test.rb +39 -0
  20. data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -0
  21. data/lib/makit/cli/generators/templates/ruby/version.rb +29 -0
  22. data/lib/makit/cli/generators/templates/rust_templates.rb +128 -0
  23. data/lib/makit/cli/main.rb +48 -19
  24. data/lib/makit/cli/project_commands.rb +868 -0
  25. data/lib/makit/cli/repository_commands.rb +661 -0
  26. data/lib/makit/cli/utility_commands.rb +521 -0
  27. data/lib/makit/command_runner.rb +187 -128
  28. data/lib/makit/commands/compatibility.rb +365 -0
  29. data/lib/makit/commands/factory.rb +359 -0
  30. data/lib/makit/commands/middleware/base.rb +73 -0
  31. data/lib/makit/commands/middleware/cache.rb +248 -0
  32. data/lib/makit/commands/middleware/command_logger.rb +323 -0
  33. data/lib/makit/commands/middleware/unified_logger.rb +243 -0
  34. data/lib/makit/commands/middleware/validator.rb +269 -0
  35. data/lib/makit/commands/request.rb +254 -0
  36. data/lib/makit/commands/result.rb +323 -0
  37. data/lib/makit/commands/runner.rb +317 -0
  38. data/lib/makit/commands/strategies/base.rb +160 -0
  39. data/lib/makit/commands/strategies/synchronous.rb +134 -0
  40. data/lib/makit/commands.rb +24 -3
  41. data/lib/makit/configuration/gitlab_helper.rb +60 -0
  42. data/lib/makit/configuration/project.rb +127 -0
  43. data/lib/makit/configuration/rakefile_helper.rb +43 -0
  44. data/lib/makit/configuration/step.rb +34 -0
  45. data/lib/makit/configuration.rb +14 -0
  46. data/lib/makit/content/default_gitignore.rb +4 -2
  47. data/lib/makit/content/default_rakefile.rb +4 -2
  48. data/lib/makit/content/gem_rakefile.rb +4 -2
  49. data/lib/makit/context.rb +1 -0
  50. data/lib/makit/data.rb +9 -10
  51. data/lib/makit/directories.rb +48 -52
  52. data/lib/makit/directory.rb +38 -52
  53. data/lib/makit/docs/files.rb +5 -10
  54. data/lib/makit/docs/rake.rb +16 -20
  55. data/lib/makit/dotnet/cli.rb +65 -0
  56. data/lib/makit/dotnet/project.rb +153 -0
  57. data/lib/makit/dotnet/solution.rb +38 -0
  58. data/lib/makit/dotnet/solution_classlib.rb +239 -0
  59. data/lib/makit/dotnet/solution_console.rb +264 -0
  60. data/lib/makit/dotnet/solution_maui.rb +354 -0
  61. data/lib/makit/dotnet/solution_wasm.rb +275 -0
  62. data/lib/makit/dotnet/solution_wpf.rb +304 -0
  63. data/lib/makit/dotnet.rb +54 -171
  64. data/lib/makit/email.rb +46 -17
  65. data/lib/makit/environment.rb +22 -19
  66. data/lib/makit/examples/runner.rb +370 -0
  67. data/lib/makit/exceptions.rb +45 -0
  68. data/lib/makit/fileinfo.rb +3 -5
  69. data/lib/makit/files.rb +12 -16
  70. data/lib/makit/gems.rb +40 -39
  71. data/lib/makit/git/cli.rb +54 -0
  72. data/lib/makit/git/repository.rb +90 -0
  73. data/lib/makit/git.rb +44 -91
  74. data/lib/makit/gitlab_runner.rb +0 -1
  75. data/lib/makit/humanize.rb +31 -23
  76. data/lib/makit/indexer.rb +15 -24
  77. data/lib/makit/logging/configuration.rb +305 -0
  78. data/lib/makit/logging/format_registry.rb +84 -0
  79. data/lib/makit/logging/formatters/base.rb +39 -0
  80. data/lib/makit/logging/formatters/console_formatter.rb +127 -0
  81. data/lib/makit/logging/formatters/json_formatter.rb +65 -0
  82. data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -0
  83. data/lib/makit/logging/formatters/text_formatter.rb +64 -0
  84. data/lib/makit/logging/log_request.rb +115 -0
  85. data/lib/makit/logging/logger.rb +159 -0
  86. data/lib/makit/logging/sinks/base.rb +91 -0
  87. data/lib/makit/logging/sinks/console.rb +72 -0
  88. data/lib/makit/logging/sinks/file_sink.rb +92 -0
  89. data/lib/makit/logging/sinks/structured.rb +129 -0
  90. data/lib/makit/logging/sinks/unified_file_sink.rb +303 -0
  91. data/lib/makit/logging.rb +452 -37
  92. data/lib/makit/markdown.rb +18 -18
  93. data/lib/makit/mp/basic_object_mp.rb +5 -4
  94. data/lib/makit/mp/command_mp.rb +5 -5
  95. data/lib/makit/mp/command_request.mp.rb +3 -2
  96. data/lib/makit/mp/project_mp.rb +85 -96
  97. data/lib/makit/mp/string_mp.rb +245 -73
  98. data/lib/makit/nuget.rb +27 -25
  99. data/lib/makit/port.rb +25 -27
  100. data/lib/makit/process.rb +127 -29
  101. data/lib/makit/protoc.rb +27 -24
  102. data/lib/makit/rake/cli.rb +196 -0
  103. data/lib/makit/rake.rb +6 -6
  104. data/lib/makit/ruby/cli.rb +185 -0
  105. data/lib/makit/ruby.rb +25 -0
  106. data/lib/makit/secrets.rb +18 -18
  107. data/lib/makit/serializer.rb +29 -27
  108. data/lib/makit/services/builder.rb +186 -0
  109. data/lib/makit/services/error_handler.rb +226 -0
  110. data/lib/makit/services/repository_manager.rb +229 -0
  111. data/lib/makit/services/validator.rb +112 -0
  112. data/lib/makit/setup/classlib.rb +53 -0
  113. data/lib/makit/setup/gem.rb +250 -0
  114. data/lib/makit/setup/runner.rb +40 -0
  115. data/lib/makit/show.rb +16 -16
  116. data/lib/makit/storage.rb +32 -37
  117. data/lib/makit/symbols.rb +12 -0
  118. data/lib/makit/task_hooks.rb +125 -0
  119. data/lib/makit/task_info.rb +63 -21
  120. data/lib/makit/tasks/at_exit.rb +13 -0
  121. data/lib/makit/tasks/build.rb +18 -0
  122. data/lib/makit/tasks/clean.rb +11 -0
  123. data/lib/makit/tasks/hook_manager.rb +239 -0
  124. data/lib/makit/tasks/init.rb +47 -0
  125. data/lib/makit/tasks/integrate.rb +15 -0
  126. data/lib/makit/tasks/pull_incoming.rb +12 -0
  127. data/lib/makit/tasks/setup.rb +6 -0
  128. data/lib/makit/tasks/sync.rb +11 -0
  129. data/lib/makit/tasks/task_monkey_patch.rb +79 -0
  130. data/lib/makit/tasks.rb +5 -150
  131. data/lib/makit/test_cache.rb +239 -0
  132. data/lib/makit/v1/makit.v1_pb.rb +34 -35
  133. data/lib/makit/v1/makit.v1_services_pb.rb +2 -0
  134. data/lib/makit/version.rb +1 -57
  135. data/lib/makit/wix.rb +23 -23
  136. data/lib/makit/yaml.rb +18 -6
  137. data/lib/makit.rb +2 -261
  138. metadata +109 -145
  139. data/lib/makit/cli/clean.rb +0 -14
  140. data/lib/makit/cli/clone.rb +0 -59
  141. data/lib/makit/cli/init.rb +0 -38
  142. data/lib/makit/cli/make.rb +0 -54
  143. data/lib/makit/cli/new.rb +0 -37
  144. data/lib/makit/cli/nuget_cache.rb +0 -38
  145. data/lib/makit/cli/pull.rb +0 -31
  146. data/lib/makit/cli/setup.rb +0 -71
  147. data/lib/makit/cli/work.rb +0 -21
  148. data/lib/makit/content/default_gitignore.txt +0 -222
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "sorted_set"
4
3
  require_relative "directory"
5
4
  # This module provides classes for the Makit gem.
6
5
  module Makit
@@ -9,10 +8,8 @@ module Makit
9
8
  class Environment
10
9
  def self.current_user
11
10
  if Makit::Environment.is_windows?
12
- `whoami`
13
- else
14
- `whoami`
15
11
  end
12
+ `whoami`
16
13
  end
17
14
 
18
15
  def self.which(name)
@@ -33,8 +30,11 @@ module Makit
33
30
  def self.constants_hash
34
31
  constants = {}
35
32
  # collect all constants that are all uppercase
36
- Object.constants.each { |c| constants[c] = Object.const_get(c) if c == c.upcase } # puts "#{c} = #{Object.const_get(c)}" }
37
- #Object.constants.each { |c| constants[c] = Object.const_get(c)}# puts "#{c} = #{Object.const_get(c)}" }
33
+ Object.constants.each do |c|
34
+ # puts "#{c} = #{Object.const_get(c)}" }
35
+ constants[c] = Object.const_get(c) if c == c.upcase
36
+ end
37
+ # Object.constants.each { |c| constants[c] = Object.const_get(c)}# puts "#{c} = #{Object.const_get(c)}" }
38
38
  constants
39
39
  end
40
40
 
@@ -46,36 +46,39 @@ module Makit
46
46
  end
47
47
 
48
48
  def self.gem_data_directory
49
- gem_data_directory = File.join(Dir.home, ".makit")
49
+ File.join(Dir.home, ".makit")
50
50
  end
51
51
 
52
52
  def self.project_root_directory
53
- if !Makit::Environment.rake_file_name.nil?
54
- File.dirname(Makit::Environment.rake_file_name)
55
- else
53
+ if Makit::Environment.rake_file_name.nil?
56
54
  Makit::Directory.find_directory_with_pattern(File.dirname(__FILE__), "Rakefile")
57
55
  # lass Directory
58
56
  # def self.find_directory_with_pattern(starting_directory, pattern)
59
57
  # nil
58
+ else
59
+ File.dirname(Makit::Environment.rake_file_name)
60
60
  end
61
61
  end
62
62
 
63
63
  def self.get_relative_directory(url)
64
64
  url = url.gsub("https://", "").gsub("http://", "")
65
- url = url.gsub("gitlab.com", "gitlab")
66
- url
65
+ url.gsub("gitlab.com", "gitlab")
67
66
  end
68
67
 
69
68
  def self.get_code_root
70
69
  # user home directory + "code"
71
- code_root = File.join(Dir.home, "code")
70
+ File.join(Dir.home, "code")
72
71
  end
73
72
 
74
73
  def self.get_work_directory(url)
75
- raise "invalid url" if !url.include? "https://"
76
- url = url.gsub("https://", "").gsub("http://", "")
77
- #url = url.gsub("gitlab.com","gitlab")
78
- url
74
+ raise "invalid url" unless url.include? "https://"
75
+
76
+ url.gsub("https://", "").gsub("http://", "")
77
+ # url = url.gsub("gitlab.com","gitlab")
78
+ end
79
+
80
+ def self.get_work_base_directory
81
+ File.join(Dir.home, ".makit", "work")
79
82
  end
80
83
 
81
84
  def self.is_windows?
@@ -103,7 +106,7 @@ module Makit
103
106
  end
104
107
  end
105
108
 
106
- def self.get_runtime_identifier()
109
+ def self.get_runtime_identifier
107
110
  os = RbConfig::CONFIG["host_os"]
108
111
  cpu = RbConfig::CONFIG["host_cpu"]
109
112
 
@@ -125,7 +128,7 @@ module Makit
125
128
  arch_rid = "x64"
126
129
  when /i686|i386/
127
130
  arch_rid = "x86"
128
- #when /arm/
131
+ # when /arm/
129
132
  # arch_rid = "arm"
130
133
  when /aarch64|arm64/
131
134
  arch_rid = "arm64"
@@ -0,0 +1,370 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "parallel"
5
+
6
+ module Makit
7
+ module Examples
8
+ # Centralized management of example discovery, execution, and verification
9
+ #
10
+ # This class provides a clean interface for running all examples in the
11
+ # examples directory, with support for different execution strategies,
12
+ # artifact verification, and comprehensive reporting.
13
+ #
14
+ # @example Basic usage
15
+ # runner = Makit::Examples::Runner.new
16
+ # runner.run_all
17
+ #
18
+ # @example Custom configuration
19
+ # runner = Makit::Examples::Runner.new(
20
+ # strategy: :parallel,
21
+ # verify_artifacts: true,
22
+ # cleanup_after: false
23
+ # )
24
+ # runner.run_all
25
+ class Runner
26
+ # Configuration options
27
+ attr_reader :examples_dir, :execution_strategy, :verify_artifacts, :cleanup_after, :filter, :timeout, :verbose
28
+
29
+ # Execution results
30
+ attr_reader :results, :failed_examples, :passed_examples, :examples
31
+
32
+ # Initialize the examples runner
33
+ #
34
+ # @param options [Hash] configuration options
35
+ # @option options [String] :examples_dir directory containing examples (default: "examples")
36
+ # @option options [Symbol] :strategy execution strategy (:sequential, :parallel, :filtered)
37
+ # @option options [Boolean] :verify_artifacts whether to verify expected artifacts (default: true)
38
+ # @option options [Boolean] :cleanup_after whether to clean up artifacts after testing (default: true)
39
+ # @option options [Regexp] :filter pattern to filter examples (default: nil)
40
+ # @option options [Integer] :timeout timeout per example in seconds (default: 30)
41
+ # @option options [Boolean] :verbose whether to show detailed output (default: false)
42
+ def initialize(options = {})
43
+ @examples_dir = options[:examples_dir] || "examples"
44
+ @execution_strategy = options[:strategy] || :sequential
45
+ @verify_artifacts = options[:verify_artifacts] || true
46
+ @cleanup_after = options[:cleanup_after] || true
47
+ @filter = options[:filter]
48
+ @timeout = options[:timeout] || 30
49
+ @verbose = options[:verbose] || false
50
+
51
+ @results = []
52
+ @failed_examples = []
53
+ @passed_examples = []
54
+ @examples = []
55
+ end
56
+
57
+ # Run all discovered examples
58
+ #
59
+ # @return [Boolean] true if all examples passed, false otherwise
60
+ def run_all
61
+ discover_examples
62
+ execute_examples
63
+ verify_results
64
+ report_results
65
+ cleanup_if_needed
66
+
67
+ @failed_examples.empty?
68
+ end
69
+
70
+ # Run a specific example
71
+ #
72
+ # @param example_path [String] path to the example directory
73
+ # @return [Hash] result hash with success status and details
74
+ def run_example(example_path)
75
+ discover_examples if @examples.empty?
76
+ example = @examples.find { |ex| ex[:name] == example_path }
77
+ return { success: false, error: "Example not found: #{example_path}" } unless example
78
+
79
+ execute_single_example(example)
80
+ end
81
+
82
+ # Discover all examples in the examples directory
83
+ def discover_examples
84
+ @examples = Dir.glob("#{@examples_dir}/**/Rakefile").map do |rakefile|
85
+ example_dir = File.dirname(rakefile)
86
+ example_name = example_dir.gsub("#{@examples_dir}/", "")
87
+
88
+ {
89
+ path: example_dir,
90
+ name: example_name,
91
+ rakefile: rakefile,
92
+ expected_artifacts: determine_expected_artifacts(example_name),
93
+ }
94
+ end
95
+
96
+ # Apply filter if specified
97
+ @examples = @examples.select { |ex| ex[:name].match?(@filter) } if @filter
98
+
99
+ log "Discovered #{@examples.count} examples" if @verbose
100
+ end
101
+
102
+ private
103
+
104
+ # Execute all examples based on the configured strategy
105
+ def execute_examples
106
+ case @execution_strategy
107
+ when :sequential
108
+ execute_sequential
109
+ when :parallel
110
+ execute_parallel
111
+ when :filtered
112
+ execute_filtered
113
+ else
114
+ execute_sequential
115
+ end
116
+ end
117
+
118
+ # Execute examples sequentially
119
+ def execute_sequential
120
+ @examples.each do |example|
121
+ result = execute_single_example(example)
122
+
123
+ # Verify artifacts immediately after execution if enabled
124
+ verify_example_artifacts(example, result) if @verify_artifacts && result[:success]
125
+
126
+ @results << result
127
+
128
+ if result[:success]
129
+ @passed_examples << example
130
+ log " ✅ #{example[:name]} passed".colorize(:green) if @verbose
131
+ else
132
+ @failed_examples << example
133
+ log " ❌ #{example[:name]} failed: #{result[:error]}".colorize(:red) if @verbose
134
+ end
135
+ end
136
+ end
137
+
138
+ # Execute examples in parallel
139
+ def execute_parallel
140
+ results = Parallel.map(@examples, in_threads: 4) do |example|
141
+ result = execute_single_example(example)
142
+
143
+ # Verify artifacts immediately after execution if enabled
144
+ verify_example_artifacts(example, result) if @verify_artifacts && result[:success]
145
+
146
+ result
147
+ end
148
+
149
+ results.each_with_index do |result, index|
150
+ @results << result
151
+ example = @examples[index]
152
+
153
+ if result[:success]
154
+ @passed_examples << example
155
+ log " ✅ #{example[:name]} passed".colorize(:green) if @verbose
156
+ else
157
+ @failed_examples << example
158
+ log " ❌ #{example[:name]} failed: #{result[:error]}".colorize(:red) if @verbose
159
+ end
160
+ end
161
+ end
162
+
163
+ # Execute examples with filtering (same as sequential for now)
164
+ def execute_filtered
165
+ execute_sequential
166
+ end
167
+
168
+ # Execute a single example
169
+ #
170
+ # @param example [Hash] example configuration
171
+ # @return [Hash] result hash
172
+ def execute_single_example(example)
173
+ # Display separator and example path
174
+ puts "=" * 80
175
+ #puts example[:name]
176
+ puts example[:rakefile]
177
+
178
+ log " Testing example: #{example[:name]}" if @verbose
179
+
180
+ # Store current directory
181
+ original_dir = Dir.pwd
182
+
183
+ begin
184
+ Dir.chdir(example[:path]) do
185
+ # Use the default runner with middleware for consistent behavior
186
+ runner = Makit::DEFAULT_COMMANDS_RUNNER
187
+ custom_logger = Makit::Logging::Logger.new(
188
+ Makit::Logging::Sinks::Console.new,
189
+ Makit::Logging::Sinks::FileSink.new(log_file: "artifacts/command_examples.log")
190
+ )
191
+
192
+ begin
193
+ request = Makit::Commands::Request.from_string("rake default")
194
+ result = runner.execute(request)
195
+
196
+ # Log success or error for each example
197
+ if result.success?
198
+ Makit::Logging.success(example[:name])
199
+ else
200
+ Makit::Logging.error(example[:name])
201
+ end
202
+
203
+ {
204
+ example: example,
205
+ success: result.success?,
206
+ exit_code: result.exit_code,
207
+ output: result.stdout,
208
+ error: result.stderr,
209
+ duration: result.duration,
210
+ }
211
+ rescue StandardError => e
212
+ # Log error for exceptions
213
+ Makit::Logging.error(example[:name])
214
+
215
+ {
216
+ example: example,
217
+ success: false,
218
+ exit_code: -1,
219
+ output: "",
220
+ error: e.message,
221
+ duration: 0,
222
+ }
223
+ end
224
+ end
225
+ rescue StandardError => e
226
+ # Log error for directory change failures
227
+ Makit::Logging.error(example[:name])
228
+
229
+ {
230
+ example: example,
231
+ success: false,
232
+ exit_code: -1,
233
+ output: "",
234
+ error: "Failed to change directory: #{e.message}",
235
+ duration: 0,
236
+ }
237
+ ensure
238
+ # Always return to original directory
239
+ begin
240
+ Dir.chdir(original_dir)
241
+ rescue StandardError
242
+ nil
243
+ end
244
+ end
245
+ end
246
+
247
+ # Determine expected artifacts for an example
248
+ #
249
+ # @param example_name [String] name of the example
250
+ # @return [Array<String>] list of expected artifact paths
251
+ def determine_expected_artifacts(example_name)
252
+ case example_name
253
+ when %r{commands/(default_runner|runner)}
254
+ ["artifacts/commands/git_version.log", "artifacts/commands/git_version.txt"]
255
+ when "protoc"
256
+ ["artifacts/makit.v1_pb.rb"]
257
+ when "rake_default"
258
+ [".makit.project.json"]
259
+ when "run_mp"
260
+ [] # No expected artifacts
261
+ when "tasks/simple"
262
+ [] # No expected artifacts
263
+ when "rubygem-foo"
264
+ [] # No expected artifacts
265
+ else
266
+ [] # Default to no expected artifacts
267
+ end
268
+ end
269
+
270
+ # Verify artifacts for a single example immediately after execution
271
+ #
272
+ # @param example [Hash] example configuration
273
+ # @param result [Hash] execution result
274
+ def verify_example_artifacts(example, result)
275
+ return unless @verify_artifacts
276
+
277
+ # Check artifacts in the example directory context
278
+ missing_artifacts = example[:expected_artifacts].reject do |artifact|
279
+ artifact_path = File.join(example[:path], artifact)
280
+ File.exist?(artifact_path)
281
+ end
282
+
283
+ return unless missing_artifacts.any?
284
+
285
+ result[:success] = false
286
+ result[:error] = "Missing expected artifacts: #{missing_artifacts.join(", ")}"
287
+ end
288
+
289
+ # Verify that all results meet expectations
290
+ def verify_results
291
+ return unless @verify_artifacts
292
+
293
+ @results.each do |result|
294
+ next unless result[:success]
295
+
296
+ example = result[:example]
297
+
298
+ # Check artifacts in the example directory context
299
+ missing_artifacts = example[:expected_artifacts].reject do |artifact|
300
+ artifact_path = File.join(example[:path], artifact)
301
+ File.exist?(artifact_path)
302
+ end
303
+
304
+ next unless missing_artifacts.any?
305
+
306
+ result[:success] = false
307
+ result[:error] = "Missing expected artifacts: #{missing_artifacts.join(", ")}"
308
+
309
+ # Move from passed to failed
310
+ @passed_examples.delete(example)
311
+ @failed_examples << example
312
+ end
313
+ end
314
+
315
+ # Clean up artifacts if configured
316
+ def cleanup_if_needed
317
+ return unless @cleanup_after
318
+
319
+ @examples.each do |example|
320
+ cleanup_example(example)
321
+ end
322
+ end
323
+
324
+ # Clean up artifacts for a specific example
325
+ #
326
+ # @param example [Hash] example configuration
327
+ def cleanup_example(example)
328
+ Dir.chdir(example[:path]) do
329
+ # Remove artifacts directory if it exists
330
+ FileUtils.rm_rf("artifacts")
331
+
332
+ # Remove project file if it exists
333
+ FileUtils.rm_f(".makit.project.json")
334
+ end
335
+ rescue StandardError => e
336
+ log " Warning: Failed to cleanup #{example[:name]}: #{e.message}" if @verbose
337
+ end
338
+
339
+ # Report the results of example execution
340
+ def report_results
341
+ puts "📊 Example Test Results:".colorize(:blue)
342
+ puts " ✅ Passed: #{@passed_examples.count}".colorize(:green)
343
+ puts " ❌ Failed: #{@failed_examples.count}".colorize(:red)
344
+
345
+ if @failed_examples.any?
346
+ puts " Failed examples:".colorize(:red)
347
+ @failed_examples.each do |example|
348
+ result = @results.find { |r| r[:example] == example }
349
+ error_msg = result ? result[:error] : "Unknown error"
350
+ puts " - #{example[:name]}: #{error_msg}".colorize(:red)
351
+ end
352
+ end
353
+
354
+ return unless @passed_examples.any? && @verbose
355
+
356
+ puts " Passed examples:".colorize(:green)
357
+ @passed_examples.each do |example|
358
+ puts " - #{example[:name]}".colorize(:green)
359
+ end
360
+ end
361
+
362
+ # Log a message if verbose mode is enabled
363
+ #
364
+ # @param message [String] message to log
365
+ def log(message)
366
+ puts message if @verbose
367
+ end
368
+ end
369
+ end
370
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Makit
4
+ # Base exception class for all Makit errors
5
+ class Error < StandardError; end
6
+
7
+ # Raised when a directory operation fails
8
+ class DirectoryError < Error; end
9
+
10
+ # Raised when a git operation fails
11
+ class GitError < Error; end
12
+
13
+ # Raised when a clone operation fails
14
+ class CloneError < GitError; end
15
+
16
+ # Raised when a pull operation fails
17
+ class PullError < GitError; end
18
+
19
+ # Raised when a commit is invalid
20
+ class InvalidCommitError < GitError; end
21
+
22
+ # Raised when a build operation fails
23
+ class BuildError < Error; end
24
+
25
+ # Raised when a configuration is invalid
26
+ class ConfigurationError < Error; end
27
+
28
+ # Raised when a file operation fails
29
+ class FileError < Error; end
30
+
31
+ # Raised when a network operation fails
32
+ class NetworkError < Error; end
33
+
34
+ # Raised when a timeout occurs
35
+ class TimeoutError < Error; end
36
+
37
+ # Raised when a dependency is missing
38
+ class DependencyError < Error; end
39
+
40
+ # Raised when a command execution fails
41
+ class CommandError < Error; end
42
+
43
+ # Raised when a validation fails
44
+ class ValidationError < Error; end
45
+ end
@@ -15,11 +15,9 @@ module Makit
15
15
 
16
16
  def self.get_file_infos(filenames)
17
17
  filenames.map do |filename|
18
- begin
19
- FileInfo.new(name: filename, mtime: File.mtime(filename), size: File.size(filename))
20
- rescue
21
- next
22
- end
18
+ FileInfo.new(name: filename, mtime: File.mtime(filename), size: File.size(filename))
19
+ rescue StandardError
20
+ next
23
21
  end
24
22
  end
25
23
  end
data/lib/makit/files.rb CHANGED
@@ -12,12 +12,12 @@ module Makit
12
12
  # This class provide methods for working with the system Environment.
13
13
  #
14
14
  module Files
15
- if (Makit::Directories::PROJECT_ROOT != nil)
15
+ if Makit::Directories::PROJECT_ROOT.nil?
16
+ CSPROJ = [].freeze
17
+ else
16
18
  Dir.chdir(Makit::Directories::PROJECT_ROOT) do
17
19
  CSPROJ = Dir.glob("**/*.csproj")
18
20
  end
19
- else
20
- CSPROJ = Array.new
21
21
  end
22
22
 
23
23
  # show all the files constants in a nicely formatted table format with the name of the constant and the value
@@ -30,18 +30,14 @@ module Makit
30
30
 
31
31
  # Iterate through each constant name
32
32
  constant_names.each do |constant_name|
33
- begin
34
- constant_value = const_get(constant_name) # Fetch the value of the constant
35
- if (constant_value != nil && File.exist?(constant_value))
36
- constant_value = constant_value.colorize(:green)
37
- end
38
- # Print the constant name right justified to the max_length
39
- puts "#{constant_name.to_s.rjust(max_length)} = #{constant_value}"
40
- rescue NameError
41
- # Handle the case where the constant is not defined
42
- puts "#{constant_name.to_s.rjust(max_length)} = [Constant not defined]"
43
- end
33
+ constant_value = const_get(constant_name) # Fetch the value of the constant
34
+ constant_value = constant_value.colorize(:green) if !constant_value.nil? && File.exist?(constant_value)
35
+ # Print the constant name right justified to the max_length
36
+ puts "#{constant_name.to_s.rjust(max_length)} = #{constant_value}"
37
+ rescue NameError
38
+ # Handle the case where the constant is not defined
39
+ puts "#{constant_name.to_s.rjust(max_length)} = [Constant not defined]"
44
40
  end
45
41
  end
46
- end # module Files
47
- end # module Makit
42
+ end
43
+ end
data/lib/makit/gems.rb CHANGED
@@ -1,39 +1,40 @@
1
- # frozen_string_literal: true
2
-
3
- # This module provides classes for the Makit gem.
4
- module Makit
5
- # This class provide methods for working with the system Environment.
6
- #
7
- module Gems
8
- def self.install_latest_gem(gem_name)
9
- if(!is_gem_installed(gem_name))
10
- "gem install #{gem_name}".run
11
- puts " #{gem_name} gem installed".colorize(:green)
12
- else
13
- latest_version = get_latest_gem_version(gem_name)
14
- installed_version = get_installed_gem_version(gem_name)
15
- if(installed_version != latest_version)
16
- "gem install #{gem_name}".run
17
- puts " #{gem_name} gem updated to #{latest_version}".colorize(:green)
18
- else
19
- puts " #{gem_name} gem is up to date".colorize(:green)
20
- end
21
- end
22
- end
23
-
24
- def self.is_gem_installed(gem_name)
25
- `gem list #{gem_name}`
26
- $?.success?
27
- end
28
-
29
-
30
- def self.get_installed_gem_version(gem_name)
31
- versions = `gem list #{gem_name}`.split("(")[1].split(")")[0].split(",")
32
- versions.first.strip
33
- end
34
-
35
- def self.get_latest_gem_version(gem_name)
36
- `gem search #{gem_name} --remote --exact`.split("(")[1].split(")")[0]
37
- end
38
- end # class Gem
39
- end # module Makit
1
+ # frozen_string_literal: true
2
+
3
+ # This module provides classes for the Makit gem.
4
+ require "English"
5
+
6
+ module Makit
7
+ # This class provide methods for working with the system Environment.
8
+ #
9
+ module Gems
10
+ def self.install_latest_gem(gem_name)
11
+ if is_gem_installed(gem_name)
12
+ latest_version = get_latest_gem_version(gem_name)
13
+ installed_version = get_installed_gem_version(gem_name)
14
+ if installed_version == latest_version
15
+ puts " #{gem_name} gem is up to date".colorize(:green)
16
+ else
17
+ "gem install #{gem_name}".run
18
+ puts " #{gem_name} gem updated to #{latest_version}".colorize(:green)
19
+ end
20
+ else
21
+ "gem install #{gem_name}".run
22
+ puts " #{gem_name} gem installed".colorize(:green)
23
+ end
24
+ end
25
+
26
+ def self.is_gem_installed(gem_name)
27
+ `gem list #{gem_name}`
28
+ $CHILD_STATUS.success?
29
+ end
30
+
31
+ def self.get_installed_gem_version(gem_name)
32
+ versions = `gem list #{gem_name}`.split("(")[1].split(")")[0].split(",")
33
+ versions.first.strip
34
+ end
35
+
36
+ def self.get_latest_gem_version(gem_name)
37
+ `gem search #{gem_name} --remote --exact`.split("(")[1].split(")")[0]
38
+ end
39
+ end
40
+ end