makit 0.0.99 → 0.0.112

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 (152) 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 +28 -32
  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 +62 -33
  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/commands/factory.rb +359 -0
  28. data/lib/makit/commands/middleware/base.rb +73 -0
  29. data/lib/makit/commands/middleware/cache.rb +248 -0
  30. data/lib/makit/commands/middleware/command_logger.rb +320 -0
  31. data/lib/makit/commands/middleware/unified_logger.rb +243 -0
  32. data/lib/makit/commands/middleware/validator.rb +269 -0
  33. data/lib/makit/commands/request.rb +254 -0
  34. data/lib/makit/commands/result.rb +323 -0
  35. data/lib/makit/commands/runner.rb +337 -0
  36. data/lib/makit/commands/strategies/base.rb +160 -0
  37. data/lib/makit/commands/strategies/synchronous.rb +134 -0
  38. data/lib/makit/commands.rb +51 -21
  39. data/lib/makit/configuration/gitlab_helper.rb +60 -0
  40. data/lib/makit/configuration/project.rb +127 -0
  41. data/lib/makit/configuration/rakefile_helper.rb +43 -0
  42. data/lib/makit/configuration/step.rb +34 -0
  43. data/lib/makit/configuration.rb +14 -0
  44. data/lib/makit/content/default_gitignore.rb +7 -5
  45. data/lib/makit/content/default_rakefile.rb +13 -11
  46. data/lib/makit/content/gem_rakefile.rb +16 -14
  47. data/lib/makit/context.rb +1 -0
  48. data/lib/makit/data.rb +49 -50
  49. data/lib/makit/directories.rb +141 -145
  50. data/lib/makit/directory.rb +262 -276
  51. data/lib/makit/docs/files.rb +89 -94
  52. data/lib/makit/docs/rake.rb +102 -106
  53. data/lib/makit/dotnet/cli.rb +65 -0
  54. data/lib/makit/dotnet/project.rb +153 -0
  55. data/lib/makit/dotnet/solution.rb +38 -0
  56. data/lib/makit/dotnet/solution_classlib.rb +239 -0
  57. data/lib/makit/dotnet/solution_console.rb +264 -0
  58. data/lib/makit/dotnet/solution_maui.rb +354 -0
  59. data/lib/makit/dotnet/solution_wasm.rb +275 -0
  60. data/lib/makit/dotnet/solution_wpf.rb +304 -0
  61. data/lib/makit/dotnet.rb +102 -219
  62. data/lib/makit/email.rb +90 -61
  63. data/lib/makit/environment.rb +142 -139
  64. data/lib/makit/examples/runner.rb +370 -0
  65. data/lib/makit/exceptions.rb +45 -0
  66. data/lib/makit/fileinfo.rb +24 -26
  67. data/lib/makit/files.rb +43 -47
  68. data/lib/makit/gems.rb +29 -28
  69. data/lib/makit/git/cli.rb +54 -0
  70. data/lib/makit/git/repository.rb +90 -0
  71. data/lib/makit/git.rb +98 -145
  72. data/lib/makit/gitlab_runner.rb +59 -60
  73. data/lib/makit/humanize.rb +137 -129
  74. data/lib/makit/indexer.rb +47 -56
  75. data/lib/makit/logging/configuration.rb +305 -0
  76. data/lib/makit/logging/format_registry.rb +84 -0
  77. data/lib/makit/logging/formatters/base.rb +39 -0
  78. data/lib/makit/logging/formatters/console_formatter.rb +140 -0
  79. data/lib/makit/logging/formatters/json_formatter.rb +65 -0
  80. data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -0
  81. data/lib/makit/logging/formatters/text_formatter.rb +64 -0
  82. data/lib/makit/logging/log_request.rb +115 -0
  83. data/lib/makit/logging/logger.rb +163 -0
  84. data/lib/makit/logging/sinks/base.rb +91 -0
  85. data/lib/makit/logging/sinks/console.rb +72 -0
  86. data/lib/makit/logging/sinks/file_sink.rb +92 -0
  87. data/lib/makit/logging/sinks/structured.rb +129 -0
  88. data/lib/makit/logging/sinks/unified_file_sink.rb +303 -0
  89. data/lib/makit/logging.rb +530 -106
  90. data/lib/makit/markdown.rb +75 -75
  91. data/lib/makit/mp/basic_object_mp.rb +17 -16
  92. data/lib/makit/mp/command_mp.rb +13 -13
  93. data/lib/makit/mp/command_request.mp.rb +17 -16
  94. data/lib/makit/mp/project_mp.rb +199 -210
  95. data/lib/makit/mp/string_mp.rb +193 -176
  96. data/lib/makit/nuget.rb +74 -72
  97. data/lib/makit/port.rb +32 -34
  98. data/lib/makit/process.rb +163 -65
  99. data/lib/makit/protoc.rb +107 -104
  100. data/lib/makit/rake/cli.rb +196 -0
  101. data/lib/makit/rake.rb +25 -25
  102. data/lib/makit/ruby/cli.rb +185 -0
  103. data/lib/makit/ruby.rb +25 -0
  104. data/lib/makit/secrets.rb +51 -51
  105. data/lib/makit/serializer.rb +130 -115
  106. data/lib/makit/services/builder.rb +186 -0
  107. data/lib/makit/services/error_handler.rb +226 -0
  108. data/lib/makit/services/repository_manager.rb +229 -0
  109. data/lib/makit/services/validator.rb +112 -0
  110. data/lib/makit/setup/classlib.rb +53 -0
  111. data/lib/makit/setup/gem.rb +263 -0
  112. data/lib/makit/setup/runner.rb +45 -0
  113. data/lib/makit/setup.rb +5 -0
  114. data/lib/makit/show.rb +110 -110
  115. data/lib/makit/storage.rb +126 -131
  116. data/lib/makit/symbols.rb +170 -149
  117. data/lib/makit/task_info.rb +128 -86
  118. data/lib/makit/tasks/at_exit.rb +13 -0
  119. data/lib/makit/tasks/build.rb +19 -0
  120. data/lib/makit/tasks/clean.rb +11 -0
  121. data/lib/makit/tasks/hook_manager.rb +393 -0
  122. data/lib/makit/tasks/init.rb +47 -0
  123. data/lib/makit/tasks/integrate.rb +17 -0
  124. data/lib/makit/tasks/pull_incoming.rb +11 -0
  125. data/lib/makit/tasks/setup.rb +6 -0
  126. data/lib/makit/tasks/sync.rb +12 -0
  127. data/lib/makit/tasks/tag.rb +15 -0
  128. data/lib/makit/tasks/task_monkey_patch.rb +79 -0
  129. data/lib/makit/tasks.rb +15 -150
  130. data/lib/makit/test_cache.rb +239 -0
  131. data/lib/makit/tree.rb +37 -37
  132. data/lib/makit/v1/makit.v1_pb.rb +3 -4
  133. data/lib/makit/v1/makit.v1_services_pb.rb +27 -25
  134. data/lib/makit/version.rb +5 -61
  135. data/lib/makit/version_util.rb +21 -0
  136. data/lib/makit/wix.rb +95 -95
  137. data/lib/makit/yaml.rb +29 -17
  138. data/lib/makit/zip.rb +17 -17
  139. data/lib/makit copy.rb +44 -0
  140. data/lib/makit.rb +40 -267
  141. metadata +117 -110
  142. data/lib/makit/cli/clean.rb +0 -14
  143. data/lib/makit/cli/clone.rb +0 -59
  144. data/lib/makit/cli/init.rb +0 -38
  145. data/lib/makit/cli/make.rb +0 -54
  146. data/lib/makit/cli/new.rb +0 -37
  147. data/lib/makit/cli/nuget_cache.rb +0 -38
  148. data/lib/makit/cli/pull.rb +0 -31
  149. data/lib/makit/cli/setup.rb +0 -71
  150. data/lib/makit/cli/work.rb +0 -21
  151. data/lib/makit/command_runner.rb +0 -404
  152. data/lib/makit/content/default_gitignore.txt +0 -222
@@ -0,0 +1,393 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "set"
4
+ require "colorize"
5
+ require "fileutils"
6
+
7
+ # Task hooks system for Makit
8
+ #
9
+ # This module provides a comprehensive hook system for Rake tasks, allowing
10
+ # developers to add pre and post execution hooks globally or for specific tasks.
11
+ # It uses monkey patching to intercept all task invocations and execute hooks
12
+ # at the appropriate times.
13
+ #
14
+ # @example Global hooks
15
+ # Makit::Tasks::HookManager.add_pre_hook do |task_name|
16
+ # Makit::Logging.info("Starting task: #{task_name}")
17
+ # end
18
+ #
19
+ # Makit::Tasks::HookManager.add_post_hook do |task_name, duration, result, error|
20
+ # if error
21
+ # Makit::Logging.error("Task failed: #{task_name}")
22
+ # else
23
+ # Makit::Logging.success("Task completed: #{task_name}")
24
+ # end
25
+ # end
26
+ #
27
+ # @example Task-specific hooks
28
+ # Makit::Tasks::HookManager.add_pre_hook_for(:build) do |task_name|
29
+ # Makit::Logging.info("Building project...")
30
+ # end
31
+ #
32
+ # Makit::Tasks::HookManager.add_post_hook_for(:test) do |task_name, duration, result, error|
33
+ # Makit::Logging.info("Test execution took #{duration.round(2)}s")
34
+ # end
35
+ module Makit
36
+ module Tasks
37
+ class HookManager
38
+ @pre_hooks = []
39
+ @post_hooks = []
40
+ @task_specific_pre_hooks = {}
41
+ @task_specific_post_hooks = {}
42
+ @excluded_tasks = Set.new
43
+ @logged_tasks = Set.new
44
+
45
+ # Timing functionality
46
+ @timing_enabled = false
47
+ @task_stack = []
48
+ @performance_log = "artifacts/task_performance.log"
49
+ @hooks_installed = false
50
+
51
+ class << self
52
+ # @return [Array<Proc>] Global pre-task hooks
53
+ attr_reader :pre_hooks
54
+
55
+ # @return [Array<Proc>] Global post-task hooks
56
+ attr_reader :post_hooks
57
+
58
+ # @return [Hash<String, Array<Proc>>] Task-specific pre-task hooks
59
+ attr_reader :task_specific_pre_hooks
60
+
61
+ # @return [Hash<String, Array<Proc>>] Task-specific post-task hooks
62
+ attr_reader :task_specific_post_hooks
63
+
64
+ # @return [Set<String>] Tasks excluded from hook execution
65
+ attr_reader :excluded_tasks
66
+
67
+ # @return [Boolean] Whether timing is enabled
68
+ attr_reader :timing_enabled
69
+
70
+ # @return [Array<Hash>] Stack of currently executing tasks
71
+ attr_reader :task_stack
72
+
73
+ # @return [String] Path to performance log file
74
+ attr_reader :performance_log
75
+
76
+ # Add a global pre-task hook
77
+ #
78
+ # The hook will be executed before every task runs.
79
+ #
80
+ # @yield [task_name] the name of the task being executed
81
+ # @yieldparam task_name [String] the name of the task
82
+ # @return [void]
83
+ def add_pre_hook(&block)
84
+ @pre_hooks << block
85
+ end
86
+
87
+ # Add a global post-task hook
88
+ #
89
+ # The hook will be executed after every task completes (success or failure).
90
+ #
91
+ # @yield [task_name, duration, result, error] hook parameters
92
+ # @yieldparam task_name [String] the name of the task
93
+ # @yieldparam duration [Float] execution duration in seconds
94
+ # @yieldparam result [Object, nil] the result of the task execution
95
+ # @yieldparam error [Exception, nil] any error that occurred during execution
96
+ # @return [void]
97
+ def add_post_hook(&block)
98
+ @post_hooks << block
99
+ end
100
+
101
+ # Add a pre-task hook for a specific task
102
+ #
103
+ # The hook will only be executed before the specified task runs.
104
+ #
105
+ # @param task_name [String, Symbol] the name of the task
106
+ # @yield [task_name] the name of the task being executed
107
+ # @yieldparam task_name [String] the name of the task
108
+ # @return [void]
109
+ def add_pre_hook_for(task_name, &block)
110
+ @task_specific_pre_hooks[task_name.to_s] ||= []
111
+ @task_specific_pre_hooks[task_name.to_s] << block
112
+ end
113
+
114
+ # Add a post-task hook for a specific task
115
+ #
116
+ # The hook will only be executed after the specified task completes.
117
+ #
118
+ # @param task_name [String, Symbol] the name of the task
119
+ # @yield [task_name, duration, result, error] hook parameters
120
+ # @yieldparam task_name [String] the name of the task
121
+ # @yieldparam duration [Float] execution duration in seconds
122
+ # @yieldparam result [Object, nil] the result of the task execution
123
+ # @yieldparam error [Exception, nil] any error that occurred during execution
124
+ # @return [void]
125
+ def add_post_hook_for(task_name, &block)
126
+ @task_specific_post_hooks[task_name.to_s] ||= []
127
+ @task_specific_post_hooks[task_name.to_s] << block
128
+ end
129
+
130
+ # Execute all pre-task hooks for a given task
131
+ #
132
+ # @param task_name [String] the name of the task
133
+ # @return [void]
134
+ def execute_pre_hooks(task_name)
135
+ return if excluded?(task_name)
136
+
137
+ # Track timing if enabled
138
+ if timing_enabled?
139
+ @task_stack.push({
140
+ name: task_name,
141
+ start_time: Time.now,
142
+ level: @task_stack.length,
143
+ })
144
+ end
145
+
146
+ # Execute global pre-hooks
147
+ @pre_hooks.each { |hook| hook.call(task_name) }
148
+
149
+ # Execute task-specific pre-hooks
150
+ task_hooks = @task_specific_pre_hooks[task_name.to_s] || []
151
+ task_hooks.each { |hook| hook.call(task_name) }
152
+ end
153
+
154
+ # Execute all post-task hooks for a given task
155
+ #
156
+ # @param task_name [String] the name of the task
157
+ # @param duration [Float] execution duration in seconds
158
+ # @param result [Object, nil] the result of the task execution
159
+ # @param error [Exception, nil] any error that occurred during execution
160
+ # @return [void]
161
+ def execute_post_hooks(task_name, duration, result, error)
162
+ return if excluded?(task_name)
163
+
164
+ # Handle timing if enabled
165
+ if timing_enabled?
166
+ task_info = @task_stack.pop
167
+ if task_info && task_info[:name] == task_name
168
+ # Log performance for tasks that took longer than 0.1 seconds
169
+ log_task_performance(task_name, duration, task_info[:level]) if duration > 0.1
170
+ end
171
+
172
+ # Log task failure if there was an error
173
+ if error
174
+ log_task_failure(task_name, duration, error, task_info&.dig(:level) || 0)
175
+ end
176
+ end
177
+
178
+ # Execute global post-hooks
179
+ @post_hooks.each { |hook| hook.call(task_name, duration, result, error) }
180
+
181
+ # Execute task-specific post-hooks
182
+ task_hooks = @task_specific_post_hooks[task_name.to_s] || []
183
+ task_hooks.each { |hook| hook.call(task_name, duration, result, error) }
184
+ end
185
+
186
+ # Clear all hooks
187
+ #
188
+ # @return [void]
189
+ def clear_all_hooks
190
+ @pre_hooks.clear
191
+ @post_hooks.clear
192
+ @task_specific_pre_hooks.clear
193
+ @task_specific_post_hooks.clear
194
+ end
195
+
196
+ # Exclude a task from hook execution
197
+ #
198
+ # @param task_name [String, Symbol] the name of the task to exclude
199
+ # @return [void]
200
+ def exclude_task(task_name)
201
+ @excluded_tasks.add(task_name.to_s)
202
+ end
203
+
204
+ # Include a task in hook execution (remove from exclusions)
205
+ #
206
+ # @param task_name [String, Symbol] the name of the task to include
207
+ # @return [void]
208
+ def include_task(task_name)
209
+ @excluded_tasks.delete(task_name.to_s)
210
+ end
211
+
212
+ # Check if a task is excluded from hook execution
213
+ #
214
+ # @param task_name [String, Symbol] the name of the task to check
215
+ # @return [Boolean] true if the task is excluded
216
+ def excluded?(task_name)
217
+ @excluded_tasks.include?(task_name.to_s)
218
+ end
219
+
220
+ # Get statistics about registered hooks
221
+ #
222
+ # @return [Hash] hook statistics
223
+ def stats
224
+ {
225
+ global_pre_hooks: @pre_hooks.size,
226
+ global_post_hooks: @post_hooks.size,
227
+ task_specific_pre_hooks: @task_specific_pre_hooks.values.flatten.size,
228
+ task_specific_post_hooks: @task_specific_post_hooks.values.flatten.size,
229
+ tasks_with_pre_hooks: @task_specific_pre_hooks.keys,
230
+ tasks_with_post_hooks: @task_specific_post_hooks.keys,
231
+ timing_enabled: @timing_enabled,
232
+ task_stack_depth: @task_stack.size,
233
+ }
234
+ end
235
+
236
+ # Enable task timing and performance logging
237
+ #
238
+ # @return [void]
239
+ def enable_timing!
240
+ @timing_enabled = true
241
+ puts "🔧 Task timing enabled".colorize(:grey) if defined?(String.instance_method(:colorize))
242
+ end
243
+
244
+ # Disable task timing and performance logging
245
+ #
246
+ # @return [void]
247
+ def disable_timing!
248
+ @timing_enabled = false
249
+ end
250
+
251
+ # Check if timing is enabled
252
+ #
253
+ # @return [Boolean] true if timing is enabled
254
+ def timing_enabled?
255
+ @timing_enabled == true
256
+ end
257
+
258
+ # Clear performance logs
259
+ #
260
+ # @return [void]
261
+ def clear_performance_logs
262
+ FileUtils.rm_f(@performance_log)
263
+ FileUtils.rm_f("artifacts/task_failures.log")
264
+ end
265
+
266
+ # Setup task hooks by monkey patching Rake::Task
267
+ #
268
+ # This method patches the Rake::Task#execute method to automatically
269
+ # call pre and post hooks for all task executions.
270
+ #
271
+ # @return [void]
272
+ def setup!
273
+ return if @hooks_installed
274
+
275
+ Rake::Task.class_eval do
276
+ alias_method :makit_original_execute, :execute
277
+
278
+ def execute(args = nil)
279
+ start_time = Time.now
280
+ error = nil
281
+ result = nil
282
+
283
+ begin
284
+ # Execute pre-hooks
285
+ Makit::Tasks::HookManager.execute_pre_hooks(name)
286
+
287
+ # Execute the original task
288
+ result = makit_original_execute(args)
289
+ rescue StandardError => e
290
+ error = e
291
+ raise
292
+ ensure
293
+ # Calculate duration
294
+ duration = Time.now - start_time
295
+
296
+ # Execute post-hooks
297
+ Makit::Tasks::HookManager.execute_post_hooks(name, duration, result, error)
298
+ end
299
+
300
+ result
301
+ end
302
+ end
303
+
304
+ @hooks_installed = true
305
+ end
306
+
307
+ # Setup default task hooks
308
+ #
309
+ # This method sets up the default task hooks that provide basic
310
+ # task execution feedback. It should be called during initialization.
311
+ #
312
+ # @return [void]
313
+ def setup_default_hooks
314
+ # Setup the monkey patching first
315
+ setup!
316
+
317
+ # Only setup default hooks if no hooks are already registered
318
+ return unless @pre_hooks.empty? && @post_hooks.empty?
319
+
320
+ # Exclude the init task from hooks to prevent duplication
321
+ exclude_task(:init)
322
+ exclude_task(:default)
323
+
324
+ # Default pre-task hook: log task start to default logger
325
+ add_pre_hook do |task_name|
326
+ log_task_start(task_name)
327
+ end
328
+
329
+ # Default post-task hook: log task completion
330
+ add_post_hook do |task_name, duration, result, error|
331
+ log_task_completion(task_name, duration, result, error)
332
+ end
333
+ end
334
+
335
+ def log_task_start(task_name)
336
+ #return if @logged_tasks.include?(task_name)
337
+ #@logged_tasks.add(task_name)
338
+ #Makit::Logging.info("#{task_name}".colorize(:white).bold)
339
+ end
340
+
341
+ def log_task_completion(task_name, duration, result, error)
342
+ #Makit::Logging.info("#{task_name}".colorize(:white).bold)
343
+ #Makit::Logging.info("Task completed".colorize(:green).bold)
344
+ #Makit::Logging.info("Duration: #{duration.round(2)}s".colorize(:green).bold)
345
+ # Makit::Logging.info("Result: #{result}".colorize(:green).bold)
346
+ #Makit::Logging.info("Error: #{error}".colorize(:red).bold)
347
+ end
348
+
349
+ private
350
+
351
+ # Log task performance to file
352
+ #
353
+ # @param name [String] task name
354
+ # @param duration [Float] execution duration
355
+ # @param level [Integer] nesting level
356
+ # @return [void]
357
+ def log_task_performance(name, duration, level)
358
+ return if ENV["CI"] == "true" && duration < 1.0
359
+
360
+ FileUtils.mkdir_p("artifacts")
361
+ File.open(@performance_log, "a") do |f|
362
+ f.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")},#{name},#{duration.round(4)},#{level}"
363
+ end
364
+ rescue StandardError
365
+ # Silently fail performance logging to not interrupt tasks
366
+ end
367
+
368
+ # Log task failure to file
369
+ #
370
+ # @param name [String] task name
371
+ # @param duration [Float] execution duration
372
+ # @param error [Exception] the error that occurred
373
+ # @param level [Integer] nesting level
374
+ # @return [void]
375
+ def log_task_failure(name, duration, error, level)
376
+ failure_log = "artifacts/task_failures.log"
377
+ FileUtils.mkdir_p("artifacts")
378
+
379
+ File.open(failure_log, "a") do |f|
380
+ timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
381
+ message = error.message.gsub(",", ";")
382
+ f.puts "#{timestamp},#{name},#{duration.round(4)},#{error.class.name},#{message}"
383
+ end
384
+ rescue StandardError
385
+ # Silently fail error logging
386
+ end
387
+ end
388
+ end
389
+ end
390
+ end
391
+
392
+ # Setup default hooks when the module is loaded
393
+ Makit::Tasks::HookManager.setup_default_hooks
@@ -0,0 +1,47 @@
1
+ Rake.application.top_level_tasks.unshift("init")
2
+
3
+ task :init do
4
+ puts "-" * 80
5
+ humanized_timestamp = Makit::Humanize.get_humanized_timestamp(Time.now)
6
+ # log the rake + arguments, as it would be invoke at the console.
7
+ # for instance: rake -T
8
+ # or: rake
9
+ # or: rake clean
10
+ # or: rake LOG_LEVEL=debug
11
+ command = "rake #{ARGV.join(" ")}"
12
+ message = "#{command} (#{humanized_timestamp})"
13
+
14
+ # Create filename-friendly version of rake command
15
+ rake_name = command.gsub(/[^a-zA-Z0-9\-_]/, "_").gsub(/_+/, "_").gsub(/^_|_$/, "")
16
+
17
+ # Get the default logger and add custom file logging sinks
18
+ log = Makit::Logging.default_logger
19
+
20
+ # Add structured JSON and simple text logging sinks to the default logger
21
+ additional_sinks = [
22
+ Makit::Logging::Sinks::UnifiedFileSink.new(
23
+ configurations: [
24
+ # Structured JSON logging
25
+ {
26
+ file: "artifacts/#{rake_name}.json",
27
+ format: :json,
28
+ append: true,
29
+ include_metadata: true,
30
+ },
31
+ # Simple text logging with rendered context
32
+ {
33
+ file: "artifacts/#{rake_name}.txt",
34
+ format: :plain,
35
+ append: true,
36
+ include_context: true,
37
+ },
38
+ ],
39
+ ),
40
+ ]
41
+
42
+ # Add the additional sinks to the default logger
43
+ log.sinks.concat(additional_sinks)
44
+
45
+ # Log with the enhanced default logger
46
+ log.info(message)
47
+ end
@@ -0,0 +1,17 @@
1
+ require_relative "../git/repository"
2
+
3
+ if Dir.exist?(".git")
4
+ desc "Integrate changes into the git repository."
5
+ task :integrate do
6
+ unstaged_files = Makit::Git::Repository.unstaged_files
7
+ untracked_files = Makit::Git::Repository.untracked_files
8
+ if unstaged_files.length.positive? || untracked_files.length.positive?
9
+ Makit::Git::CLI.integrate
10
+ else
11
+ Makit::Logging.default_logger.info("No unstaged or untracked files found")
12
+ #puts " No unstaged or untracked files found".colorize(:grey)
13
+ end
14
+ end
15
+ else
16
+ Makit::Logging.default_logger.info("Not a git repository, skipping integrate")
17
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "../git/repository"
2
+
3
+ if Makit::Git::Repository.git_repo?
4
+ desc "pull changes from the remote branch, preferring incoming changes for conflicts"
5
+ task :pull_incoming do
6
+ # Makit::SHOW.task(:pull_incoming)
7
+ puts " git branch is ".colorize(:grey) + Makit::Git::Repository.branch.to_s.colorize(:green)
8
+ "git pull origin #{Makit::Git::Repository.branch} -X theirs".try
9
+ end
10
+
11
+ end
@@ -0,0 +1,6 @@
1
+ require_relative "../setup/runner"
2
+
3
+ desc "Setup project files.."
4
+ task :setup do
5
+ Makit::Setup::Runner.run
6
+ end
@@ -0,0 +1,12 @@
1
+ require_relative "../git/repository"
2
+
3
+ if Dir.exist?(".git")
4
+ desc "Sync changes with the git repository."
5
+ task :sync do
6
+ # Makit::SHOW.task(:sync)
7
+ #Makit::Git::CLI.sync
8
+ end
9
+
10
+ else
11
+ Makit::Logging.default_logger.info("Not a git repository, skipping sync")
12
+ end
@@ -0,0 +1,15 @@
1
+ if Dir.exist?(".git")
2
+ desc "tag the current version"
3
+ task :tag do
4
+
5
+ # check if the variable VERSION is defined
6
+ unless defined?(VERSION)
7
+ puts " VERSION is not defined".colorize(:red)
8
+ return
9
+ end
10
+
11
+ Makit::Git::CLI.tag(VERSION)
12
+ end
13
+ else
14
+ Makit::Logging.default_logger.info("Not a git repository, skipping tag")
15
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Monkey patch for Rake::Task to add hook support
4
+ #
5
+ # This module patches Rake::Task to automatically execute pre and post hooks
6
+ # for all task invocations. It preserves the original behavior while adding
7
+ # the hook functionality.
8
+ #
9
+ # @note This file should be required after the HookManager class is defined
10
+ require_relative "hook_manager"
11
+
12
+ # Monkey patch Rake::Task to add hook support
13
+ class Rake::Task
14
+ # Store original methods before patching
15
+ alias_method :original_invoke, :invoke
16
+ alias_method :original_execute, :execute
17
+
18
+ # Enhanced invoke method with hook support
19
+ #
20
+ # This method wraps the original invoke method to execute pre and post hooks
21
+ # around task execution. It handles errors gracefully and ensures hooks are
22
+ # always executed even if the task fails.
23
+ #
24
+ # @param args [Array] arguments passed to the task
25
+ # @return [Object] the result of the task execution
26
+ def invoke(*args)
27
+ start_time = Time.now
28
+ result = nil
29
+ error = nil
30
+
31
+ begin
32
+ # Execute pre-task hooks
33
+ Makit::Tasks::HookManager.execute_pre_hooks(name)
34
+
35
+ # Execute the original task
36
+ result = original_invoke(*args)
37
+ rescue => e
38
+ error = e
39
+ raise
40
+ ensure
41
+ # Execute post-task hooks (always runs, even on error)
42
+ duration = Time.now - start_time
43
+ Makit::Tasks::HookManager.execute_post_hooks(name, duration, result, error)
44
+ end
45
+
46
+ result
47
+ end
48
+
49
+ # Enhanced execute method with hook support
50
+ #
51
+ # This method wraps the original execute method to execute pre and post hooks
52
+ # around task execution. It handles errors gracefully and ensures hooks are
53
+ # always executed even if the task fails.
54
+ #
55
+ # @param args [Array] arguments passed to the task
56
+ # @return [Object] the result of the task execution
57
+ def execute(*args)
58
+ start_time = Time.now
59
+ result = nil
60
+ error = nil
61
+
62
+ begin
63
+ # Execute pre-task hooks
64
+ Makit::Tasks::HookManager.execute_pre_hooks(name)
65
+
66
+ # Execute the original task
67
+ result = original_execute(*args)
68
+ rescue => e
69
+ error = e
70
+ raise
71
+ ensure
72
+ # Execute post-task hooks (always runs, even on error)
73
+ duration = Time.now - start_time
74
+ Makit::Tasks::HookManager.execute_post_hooks(name, duration, result, error)
75
+ end
76
+
77
+ result
78
+ end
79
+ end