makit 0.0.111 → 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 (140) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -41
  3. data/exe/makit +5 -5
  4. data/lib/makit/apache.rb +28 -28
  5. data/lib/makit/cli/build_commands.rb +500 -500
  6. data/lib/makit/cli/generators/base_generator.rb +74 -74
  7. data/lib/makit/cli/generators/dotnet_generator.rb +50 -50
  8. data/lib/makit/cli/generators/generator_factory.rb +49 -49
  9. data/lib/makit/cli/generators/node_generator.rb +50 -50
  10. data/lib/makit/cli/generators/ruby_generator.rb +77 -77
  11. data/lib/makit/cli/generators/rust_generator.rb +50 -50
  12. data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -167
  13. data/lib/makit/cli/generators/templates/node_templates.rb +161 -161
  14. data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -26
  15. data/lib/makit/cli/generators/templates/ruby/gemspec.rb +40 -40
  16. data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -33
  17. data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -35
  18. data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -63
  19. data/lib/makit/cli/generators/templates/ruby/test.rb +39 -39
  20. data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -29
  21. data/lib/makit/cli/generators/templates/ruby/version.rb +29 -29
  22. data/lib/makit/cli/generators/templates/rust_templates.rb +128 -128
  23. data/lib/makit/cli/main.rb +62 -62
  24. data/lib/makit/cli/project_commands.rb +868 -868
  25. data/lib/makit/cli/repository_commands.rb +661 -661
  26. data/lib/makit/cli/utility_commands.rb +521 -521
  27. data/lib/makit/commands/factory.rb +359 -359
  28. data/lib/makit/commands/middleware/base.rb +73 -73
  29. data/lib/makit/commands/middleware/cache.rb +248 -248
  30. data/lib/makit/commands/middleware/command_logger.rb +320 -323
  31. data/lib/makit/commands/middleware/unified_logger.rb +243 -243
  32. data/lib/makit/commands/middleware/validator.rb +269 -269
  33. data/lib/makit/commands/request.rb +254 -254
  34. data/lib/makit/commands/result.rb +323 -323
  35. data/lib/makit/commands/runner.rb +337 -317
  36. data/lib/makit/commands/strategies/base.rb +160 -160
  37. data/lib/makit/commands/strategies/synchronous.rb +134 -134
  38. data/lib/makit/commands.rb +51 -42
  39. data/lib/makit/configuration/gitlab_helper.rb +60 -60
  40. data/lib/makit/configuration/project.rb +127 -127
  41. data/lib/makit/configuration/rakefile_helper.rb +43 -43
  42. data/lib/makit/configuration/step.rb +34 -34
  43. data/lib/makit/configuration.rb +14 -14
  44. data/lib/makit/content/default_gitignore.rb +7 -7
  45. data/lib/makit/content/default_rakefile.rb +13 -13
  46. data/lib/makit/content/gem_rakefile.rb +16 -16
  47. data/lib/makit/context.rb +1 -1
  48. data/lib/makit/data.rb +49 -49
  49. data/lib/makit/directories.rb +141 -141
  50. data/lib/makit/directory.rb +262 -262
  51. data/lib/makit/docs/files.rb +89 -89
  52. data/lib/makit/docs/rake.rb +102 -102
  53. data/lib/makit/dotnet/project.rb +153 -153
  54. data/lib/makit/dotnet/solution.rb +38 -38
  55. data/lib/makit/dotnet/solution_classlib.rb +239 -239
  56. data/lib/makit/dotnet/solution_console.rb +264 -264
  57. data/lib/makit/dotnet/solution_maui.rb +354 -354
  58. data/lib/makit/dotnet/solution_wasm.rb +275 -275
  59. data/lib/makit/dotnet/solution_wpf.rb +304 -304
  60. data/lib/makit/dotnet.rb +102 -102
  61. data/lib/makit/email.rb +90 -90
  62. data/lib/makit/environment.rb +142 -142
  63. data/lib/makit/examples/runner.rb +370 -370
  64. data/lib/makit/exceptions.rb +45 -45
  65. data/lib/makit/fileinfo.rb +24 -24
  66. data/lib/makit/files.rb +43 -43
  67. data/lib/makit/gems.rb +40 -40
  68. data/lib/makit/git/cli.rb +54 -54
  69. data/lib/makit/git/repository.rb +90 -90
  70. data/lib/makit/git.rb +98 -98
  71. data/lib/makit/gitlab_runner.rb +59 -59
  72. data/lib/makit/humanize.rb +137 -137
  73. data/lib/makit/indexer.rb +47 -47
  74. data/lib/makit/logging/configuration.rb +305 -305
  75. data/lib/makit/logging/formatters/base.rb +39 -39
  76. data/lib/makit/logging/formatters/console_formatter.rb +140 -127
  77. data/lib/makit/logging/formatters/json_formatter.rb +65 -65
  78. data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -71
  79. data/lib/makit/logging/formatters/text_formatter.rb +64 -64
  80. data/lib/makit/logging/log_request.rb +115 -115
  81. data/lib/makit/logging/logger.rb +163 -159
  82. data/lib/makit/logging/sinks/console.rb +72 -72
  83. data/lib/makit/logging/sinks/file_sink.rb +92 -92
  84. data/lib/makit/logging/sinks/unified_file_sink.rb +303 -303
  85. data/lib/makit/logging.rb +530 -521
  86. data/lib/makit/markdown.rb +75 -75
  87. data/lib/makit/mp/basic_object_mp.rb +17 -17
  88. data/lib/makit/mp/command_mp.rb +13 -13
  89. data/lib/makit/mp/command_request.mp.rb +17 -17
  90. data/lib/makit/mp/project_mp.rb +199 -199
  91. data/lib/makit/mp/string_mp.rb +193 -348
  92. data/lib/makit/nuget.rb +74 -74
  93. data/lib/makit/port.rb +32 -32
  94. data/lib/makit/process.rb +163 -163
  95. data/lib/makit/protoc.rb +107 -107
  96. data/lib/makit/rake/cli.rb +196 -196
  97. data/lib/makit/rake.rb +25 -25
  98. data/lib/makit/ruby/cli.rb +185 -185
  99. data/lib/makit/ruby.rb +25 -25
  100. data/lib/makit/secrets.rb +51 -51
  101. data/lib/makit/serializer.rb +130 -117
  102. data/lib/makit/services/builder.rb +186 -186
  103. data/lib/makit/services/error_handler.rb +226 -226
  104. data/lib/makit/services/repository_manager.rb +229 -229
  105. data/lib/makit/services/validator.rb +112 -112
  106. data/lib/makit/setup/classlib.rb +53 -53
  107. data/lib/makit/setup/gem.rb +30 -17
  108. data/lib/makit/setup/runner.rb +45 -40
  109. data/lib/makit/setup.rb +5 -0
  110. data/lib/makit/show.rb +110 -110
  111. data/lib/makit/storage.rb +126 -126
  112. data/lib/makit/symbols.rb +170 -161
  113. data/lib/makit/task_info.rb +128 -128
  114. data/lib/makit/tasks/at_exit.rb +13 -13
  115. data/lib/makit/tasks/build.rb +19 -18
  116. data/lib/makit/tasks/clean.rb +11 -11
  117. data/lib/makit/tasks/hook_manager.rb +393 -239
  118. data/lib/makit/tasks/init.rb +47 -47
  119. data/lib/makit/tasks/integrate.rb +17 -15
  120. data/lib/makit/tasks/pull_incoming.rb +11 -12
  121. data/lib/makit/tasks/setup.rb +6 -6
  122. data/lib/makit/tasks/sync.rb +12 -11
  123. data/lib/makit/tasks/tag.rb +15 -0
  124. data/lib/makit/tasks/task_monkey_patch.rb +79 -79
  125. data/lib/makit/tasks.rb +10 -0
  126. data/lib/makit/test_cache.rb +239 -239
  127. data/lib/makit/tree.rb +37 -37
  128. data/lib/makit/v1/makit.v1_pb.rb +34 -34
  129. data/lib/makit/v1/makit.v1_services_pb.rb +27 -27
  130. data/lib/makit/version.rb +5 -5
  131. data/lib/makit/version_util.rb +21 -0
  132. data/lib/makit/wix.rb +95 -95
  133. data/lib/makit/yaml.rb +29 -29
  134. data/lib/makit/zip.rb +17 -17
  135. data/lib/makit copy.rb +44 -0
  136. data/lib/makit.rb +40 -8
  137. metadata +50 -7
  138. data/lib/makit/command_runner.rb +0 -463
  139. data/lib/makit/commands/compatibility.rb +0 -365
  140. data/lib/makit/task_hooks.rb +0 -125
@@ -1,365 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "ostruct"
4
- require "fileutils"
5
- require_relative "runner"
6
- require_relative "request"
7
- require_relative "result"
8
-
9
- module Makit
10
- module Commands
11
- # Compatibility layer that provides legacy interface methods for the new Commands::Runner
12
- #
13
- # This class bridges the gap between the old CommandRunner interface and the new
14
- # Commands::Runner architecture, allowing existing code to work without modification
15
- # while benefiting from the improved architecture.
16
- class Compatibility
17
- # @!attribute [r] runner
18
- # @return [Runner] the underlying Commands::Runner instance
19
- attr_reader :runner
20
-
21
- # Initialize compatibility layer
22
- #
23
- # @param runner [Runner] the Commands::Runner instance to wrap
24
- def initialize(runner = nil)
25
- @runner = runner || create_runner_with_caching
26
- end
27
-
28
- # Parse command request from various input types (legacy interface)
29
- #
30
- # @param source [String, Hash, Request] command source
31
- # @return [Request] normalized request
32
- def parse_command_request(source)
33
- case source
34
- when String
35
- Request.from_string(source)
36
- when Hash
37
- Request.from_hash(source)
38
- when Request
39
- source
40
- when Makit::V1::CommandRequest
41
- # Convert legacy CommandRequest to new Request
42
- Request.new(
43
- command: source.name,
44
- arguments: source.arguments.to_a,
45
- directory: source.directory,
46
- timeout: source.timeout,
47
- environment: {},
48
- metadata: { legacy: true },
49
- )
50
- else
51
- raise ArgumentError, "Invalid source type: #{source.class}"
52
- end
53
- end
54
-
55
- # Parse arguments (legacy interface)
56
- #
57
- # @param args [String, Array, Hash, Request] arguments to parse
58
- # @return [Request] parsed request
59
- def parse_args(args)
60
- parse_command_request(args)
61
- end
62
-
63
- # Execute command (legacy run interface)
64
- #
65
- # @param request_or_string [Request, String, Hash] command to run
66
- # @return [Result] execution result converted to legacy format
67
- def run(request_or_string)
68
- request = parse_command_request(request_or_string)
69
- result = @runner.execute(request)
70
- # Store directory in result metadata for legacy compatibility
71
- result.metadata[:directory] = request.directory
72
- convert_to_legacy_command(result)
73
- end
74
-
75
- # Execute command with caching (legacy cache_run interface)
76
- #
77
- # @param request_or_string [Request, String, Hash] command to run
78
- # @param timestamp [Time, nil] cache timestamp
79
- # @return [Result] execution result converted to legacy format
80
- def cache_run(request_or_string, timestamp = nil)
81
- request = parse_command_request(request_or_string)
82
-
83
- # Add cache metadata
84
- cache_key = generate_cache_key(request)
85
- request.metadata[:cache_key] = cache_key
86
- request.metadata[:cache_timestamp] = timestamp || default_timestamp
87
-
88
- # Execute with caching middleware
89
- result = @runner.execute(request)
90
- # Store directory in result metadata for legacy compatibility
91
- result.metadata[:directory] = request.directory
92
- convert_to_legacy_command(result)
93
- end
94
-
95
- # Execute command with caching without raising on error (legacy cache_try interface)
96
- #
97
- # @param request_or_string [Request, String, Hash] command to try
98
- # @param timestamp [Time, nil] cache timestamp
99
- # @return [Result] execution result converted to legacy format
100
- def cache_try(request_or_string, timestamp = nil)
101
- request = parse_command_request(request_or_string)
102
- request.metadata[:exit_on_error] = false
103
-
104
- # Add cache metadata
105
- cache_key = generate_cache_key(request)
106
- request.metadata[:cache_key] = cache_key
107
- request.metadata[:cache_timestamp] = timestamp || default_timestamp
108
-
109
- # Execute with caching middleware
110
- result = @runner.execute(request)
111
- # Store directory in result metadata for legacy compatibility
112
- result.metadata[:directory] = request.directory
113
- convert_to_legacy_command(result)
114
- end
115
-
116
- # Execute command without raising on error (legacy try interface)
117
- #
118
- # @param request_or_string [Request, String, Hash] command to try
119
- # @return [Result] execution result converted to legacy format
120
- def try(request_or_string)
121
- request = parse_command_request(request_or_string)
122
- request.metadata[:exit_on_error] = false
123
-
124
- result = @runner.execute(request)
125
- # Store directory in result metadata for legacy compatibility
126
- result.metadata[:directory] = request.directory
127
- convert_to_legacy_command(result)
128
- end
129
-
130
- # Show command information (legacy show interface)
131
- #
132
- # @param request_or_string [Request, String, Hash] command to show
133
- # @return [Result] execution result converted to legacy format
134
- def show(request_or_string)
135
- request = parse_command_request(request_or_string)
136
- request.metadata[:show_output] = true
137
-
138
- result = @runner.execute(request)
139
- # Store directory in result metadata for legacy compatibility
140
- result.metadata[:directory] = request.directory
141
- show_command(convert_to_legacy_command(result))
142
- convert_to_legacy_command(result)
143
- end
144
-
145
- # Search command history for matching commands (legacy interface)
146
- #
147
- # @param query [String] search query
148
- # @return [Array<Object>] matching command results
149
- def search(query)
150
- # For now, return empty array since we don't have command history in new architecture
151
- # This could be enhanced with a command history middleware
152
- []
153
- end
154
-
155
- # Get cache filename for a command (legacy interface)
156
- #
157
- # @param command [Object] command object
158
- # @return [String] cache filename
159
- def get_cache_filename(command)
160
- require "digest"
161
- if command.respond_to?(:name) && command.respond_to?(:arguments)
162
- content = "#{command.name} #{command.arguments.join(" ")}"
163
- else
164
- content = command.to_s
165
- end
166
- hash = Digest::SHA256.hexdigest(content)
167
- cache_dir = File.join(Makit::Directories::PROJECT_ARTIFACTS, "commands", "cache")
168
- FileUtils.mkdir_p(cache_dir)
169
- File.join(cache_dir, "#{hash}.pb")
170
- end
171
-
172
- # Log rake commands to file (legacy interface)
173
- #
174
- # @return [void]
175
- def log_rake_commands
176
- dir = File.join(Makit::Directories::PROJECT_ARTIFACTS, "commands")
177
- FileUtils.mkdir_p(dir)
178
-
179
- # For now, create empty file since we don't have command history
180
- # This could be enhanced with a command history middleware
181
- File.open(File.join(dir, "rake.commands.txt"), "w") do |file|
182
- file.puts "# No command history available in new architecture"
183
- file.puts "# This functionality will be restored with command history middleware"
184
- end
185
- end
186
-
187
- # Log slowest commands to file (legacy interface)
188
- #
189
- # @return [void]
190
- def log_slowest_commands
191
- dir = File.join(Makit::Directories::PROJECT_ARTIFACTS, "commands")
192
- FileUtils.mkdir_p(dir)
193
-
194
- # For now, create empty file since we don't have command history
195
- # This could be enhanced with a command history middleware
196
- File.open(File.join(dir, "slow.commands.txt"), "w") do |file|
197
- file.puts "# No command history available in new architecture"
198
- file.puts "# This functionality will be restored with command history middleware"
199
- end
200
- end
201
-
202
- # Display command summary (legacy show_command interface)
203
- #
204
- # @param command [Makit::V1::Command, Result] command result to display
205
- def show_command(command)
206
- # Convert new Result to legacy format if needed
207
- legacy_command = command.is_a?(Result) ? convert_to_legacy_command(command) : command
208
-
209
- if legacy_command.exit_code.zero?
210
- puts get_command_summary(legacy_command) + " (#{legacy_command.duration&.seconds || 0} seconds)".colorize(:cyan)
211
- puts indent_string(legacy_command.output, 2).colorize(:default) if should_show_output_on_success?
212
- else
213
- puts get_command_summary(legacy_command) + " (exit code #{legacy_command.exit_code})".colorize(:default)
214
- puts " directory: #{legacy_command.directory}\n"
215
- puts " duration: #{legacy_command.duration&.seconds || 0} seconds\n"
216
- puts indent_string(legacy_command.output, 2) if legacy_command.output&.length&.positive?
217
- puts indent_string(legacy_command.error, 2) if legacy_command.error&.length&.positive?
218
- end
219
- end
220
-
221
- private
222
-
223
- # Create a runner with caching middleware
224
- #
225
- # @return [Runner] runner with caching middleware
226
- def create_runner_with_caching
227
- require_relative "middleware/cache"
228
-
229
- Runner.new(
230
- middleware: [
231
- Middleware::Cache.new,
232
- Middleware::CommandLogger.new(
233
- log_stdout: true,
234
- log_stderr: true,
235
- log_performance: true,
236
- max_output_lines: 50,
237
- ),
238
- ],
239
- )
240
- end
241
-
242
- # Convert new Result to legacy Makit::V1::Command format
243
- #
244
- # @param result [Result] result to convert
245
- # @return [Makit::V1::Command] legacy command object
246
- def convert_to_legacy_command(result)
247
- # Create a legacy command object that duck-types with Makit::V1::Command
248
- legacy_command = OpenStruct.new
249
- legacy_command.name = result.command.split.first
250
- legacy_command.arguments = result.command.split[1..] || []
251
- # Get directory from metadata if available, otherwise use current directory
252
- legacy_command.directory = result.metadata[:directory] || Dir.pwd
253
- legacy_command.exit_code = result.exit_code
254
- legacy_command.output = result.stdout
255
- legacy_command.error = result.stderr
256
- legacy_command.started_at = convert_time_to_protobuf_timestamp(result.started_at)
257
- legacy_command.duration = convert_duration_to_protobuf(result.duration)
258
-
259
- # Add success? method for compatibility
260
- def legacy_command.success?
261
- exit_code.zero?
262
- end
263
-
264
- legacy_command
265
- end
266
-
267
- # Generate cache key for a request
268
- #
269
- # @param request [Request] request to generate key for
270
- # @return [String] cache key
271
- def generate_cache_key(request)
272
- require "digest"
273
- content = "#{request.command} #{request.arguments.join(" ")}"
274
- Digest::SHA256.hexdigest(content)
275
- end
276
-
277
- # Get default timestamp for caching
278
- #
279
- # @return [Time] default timestamp
280
- def default_timestamp
281
- if defined?(Makit::GIT_FILE_INFOS) && Makit::GIT_FILE_INFOS.any?
282
- Makit::GIT_FILE_INFOS.first.mtime
283
- else
284
- Time.now
285
- end
286
- end
287
-
288
- # Get command summary string (legacy interface)
289
- #
290
- # @param command [Object] command object
291
- # @return [String] command summary
292
- def get_command_summary(command)
293
- symbol = "⚠️" # warning by default
294
- symbol = "✓" if command.exit_code&.zero?
295
- symbol = "✗" if command.exit_code != 0
296
-
297
- summary = "#{symbol} #{command.name} #{command.arguments.join(" ")}"
298
-
299
- # Apply line wrapping if available
300
- if summary.respond_to?(:to_lines) && summary.length > 80
301
- summary.to_lines(80, command.name.length + 3)
302
- else
303
- summary
304
- end
305
- end
306
-
307
- # Indent string helper
308
- #
309
- # @param input_string [String] string to indent
310
- # @param indent_spaces [Integer] number of spaces to indent
311
- # @return [String] indented string
312
- def indent_string(input_string, indent_spaces)
313
- return "" unless input_string
314
-
315
- indentation = " " * indent_spaces
316
- input_string.lines.map { |line| indentation + line }.join
317
- end
318
-
319
- # Check if output should be shown on success
320
- #
321
- # @return [Boolean] true if output should be shown
322
- def should_show_output_on_success?
323
- # Check if the legacy runner has this setting
324
- if defined?(Makit::RUNNER) && Makit::RUNNER.respond_to?(:show_output_on_success)
325
- Makit::RUNNER.show_output_on_success
326
- else
327
- false
328
- end
329
- end
330
-
331
- # Convert Time to protobuf timestamp format
332
- #
333
- # @param time [Time] time to convert
334
- # @return [Google::Protobuf::Timestamp] protobuf timestamp
335
- def convert_time_to_protobuf_timestamp(time)
336
- return nil unless time
337
-
338
- if defined?(Google::Protobuf::Timestamp)
339
- Google::Protobuf::Timestamp.new(seconds: time.to_i, nanos: time.nsec)
340
- else
341
- # Fallback object with same interface
342
- OpenStruct.new(seconds: time.to_i, nanos: time.nsec)
343
- end
344
- end
345
-
346
- # Convert duration to protobuf duration format
347
- #
348
- # @param duration [Float] duration in seconds
349
- # @return [Google::Protobuf::Duration] protobuf duration
350
- def convert_duration_to_protobuf(duration)
351
- return nil unless duration
352
-
353
- seconds = duration.to_i
354
- nanos = ((duration - seconds) * 1_000_000_000).to_i
355
-
356
- if defined?(Google::Protobuf::Duration)
357
- Google::Protobuf::Duration.new(seconds: seconds, nanos: nanos)
358
- else
359
- # Fallback object with same interface
360
- OpenStruct.new(seconds: seconds, nanos: nanos)
361
- end
362
- end
363
- end
364
- end
365
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "fileutils"
4
- require "rake"
5
-
6
- module Makit
7
- # Task hooks for automatic timing, logging, and lifecycle management
8
- # This provides optional instrumentation for Rake tasks
9
- class TaskHooks
10
- class << self
11
- attr_reader :enabled, :task_stack, :performance_log
12
-
13
- def initialize!
14
- @enabled = false # Start disabled - must be explicitly enabled
15
- @task_stack = []
16
- @performance_log = "artifacts/task_performance.log"
17
- @hooks_installed = false
18
- end
19
-
20
- def setup!
21
- return if @hooks_installed
22
-
23
- initialize! unless defined?(@enabled)
24
-
25
- Rake::Task.class_eval do
26
- alias_method :makit_original_execute, :execute
27
-
28
- def execute(args = nil)
29
- if Makit::TaskHooks.enabled?
30
- Makit::TaskHooks.before_execute(name, args)
31
- result = makit_original_execute(args)
32
- Makit::TaskHooks.after_execute(name, args, result)
33
- result
34
- else
35
- makit_original_execute(args)
36
- end
37
- rescue StandardError => e
38
- Makit::TaskHooks.on_error(name, args, e) if Makit::TaskHooks.enabled?
39
- raise
40
- end
41
- end
42
-
43
- @hooks_installed = true
44
- end
45
-
46
- def enable!
47
- initialize! unless defined?(@enabled)
48
- @enabled = true
49
- puts "🔧 Task timing enabled".colorize(:grey) if defined?(String.instance_method(:colorize))
50
- end
51
-
52
- def disable!
53
- @enabled = false
54
- end
55
-
56
- def enabled?
57
- @enabled == true
58
- end
59
-
60
- def before_execute(name, _args)
61
- return unless enabled?
62
-
63
- @task_stack.push({
64
- name: name,
65
- start_time: Time.now,
66
- level: @task_stack.length,
67
- })
68
- end
69
-
70
- def after_execute(name, _args, _result)
71
- return unless enabled?
72
-
73
- task_info = @task_stack.pop
74
- return unless task_info && task_info[:name] == name
75
-
76
- duration = Time.now - task_info[:start_time]
77
- log_task_performance(name, duration, task_info[:level]) if duration > 0.1
78
- end
79
-
80
- def on_error(name, _args, error)
81
- return unless enabled?
82
-
83
- task_info = @task_stack.pop
84
- return unless task_info
85
-
86
- duration = Time.now - task_info[:start_time]
87
- log_task_failure(name, duration, error, task_info[:level])
88
- end
89
-
90
- def clear_performance_logs
91
- FileUtils.rm_f(@performance_log)
92
- FileUtils.rm_f("artifacts/task_failures.log")
93
- end
94
-
95
- private
96
-
97
- def log_task_performance(name, duration, level)
98
- return if ENV["CI"] == "true" && duration < 1.0
99
-
100
- FileUtils.mkdir_p("artifacts")
101
- File.open(@performance_log, "a") do |f|
102
- f.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")},#{name},#{duration.round(4)},#{level}"
103
- end
104
- rescue StandardError
105
- # Silently fail performance logging to not interrupt tasks
106
- end
107
-
108
- def log_task_failure(name, duration, error, _level)
109
- failure_log = "artifacts/task_failures.log"
110
- FileUtils.mkdir_p("artifacts")
111
-
112
- File.open(failure_log, "a") do |f|
113
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
114
- message = error.message.gsub(",", ";")
115
- f.puts "#{timestamp},#{name},#{duration.round(4)},#{error.class.name},#{message}"
116
- end
117
- rescue StandardError
118
- # Silently fail error logging
119
- end
120
- end
121
-
122
- # Initialize when loaded
123
- initialize!
124
- end
125
- end