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
data/lib/makit/symbols.rb CHANGED
@@ -1,161 +1,170 @@
1
- # frozen_string_literal: true
2
-
3
- require "rainbow"
4
-
5
- # https://symbl.cc/en/unicode/table/
6
- module Makit
7
- # Unicode symbol utilities with colorization
8
- #
9
- # This class provides a collection of Unicode symbols with appropriate
10
- # colors for use in terminal output. Symbols are provided for various
11
- # purposes including status indicators, directional arrows, and decorative elements.
12
- class Symbols
13
- def self.checkmark
14
- "\u2713"
15
- end
16
-
17
- def self.success
18
- "\u2713"
19
- end
20
-
21
- def self.error
22
- Rainbow("\u0058").red
23
- end
24
-
25
- def self.warning
26
- Rainbow("\u26A0").yellow
27
- end
28
-
29
- def self.debug
30
- Rainbow("\u24D8").blue # Circle with "i"
31
- end
32
-
33
- def self.info
34
- Rainbow("\u2139").blue # Information source
35
- end
36
-
37
- def self.fatal
38
- Rainbow("\u25A0").bright.red # Filled square, indicating stop/critical
39
- end
40
-
41
- def self.warn
42
- Rainbow("\u26A0").yellow # Warning sign
43
- end
44
-
45
- def self.star
46
- Rainbow("\u2605").yellow # Star
47
- end
48
-
49
- def self.coffee
50
- Rainbow("\u2615").yellow # Hot beverage
51
- end
52
-
53
- def self.heart
54
- Rainbow("\u2764").red # Heavy black heart
55
- end
56
-
57
- def self.bug
58
- Rainbow("\u1F41E").yellow # Bug
59
- end
60
-
61
- def self.gear
62
- Rainbow("\u2699").yellow # Gear
63
- end
64
-
65
- def self.magnifying_glass
66
- Rainbow("\u1F50D").yellow # Left-pointing magnifying glass
67
- end
68
-
69
- def self.question
70
- Rainbow("\u003F").yellow # Question mark
71
- end
72
-
73
- def self.arrow_right
74
- Rainbow("\u27A4").yellow # Arrow pointing rightwards then curving upwards
75
- end
76
-
77
- def self.arrow_left
78
- Rainbow("\u2B05").yellow # Left arrow
79
- end
80
-
81
- def self.arrow_up
82
- Rainbow("\u2B06").yellow # Up arrow
83
- end
84
-
85
- def self.arrow_down
86
- Rainbow("\u2B07").yellow # Down arrow
87
- end
88
-
89
- def self.arrow_up_down
90
- Rainbow("\u2195").yellow # Up/down arrow
91
- end
92
-
93
- def self.arrow_left_right
94
- Rainbow("\u2194").yellow # Left/right arrow
95
- end
96
-
97
- def self.arrow_upper_right
98
- Rainbow("\u2197").yellow # North east arrow
99
- end
100
-
101
- def self.arrow_lower_right
102
- Rainbow("\u2198").yellow # South east arrow
103
- end
104
-
105
- def self.arrow_lower_left
106
- Rainbow("\u2199").yellow # South west arrow
107
- end
108
-
109
- def self.arrow_upper_left
110
- Rainbow("\u2196").yellow # North west arrow
111
- end
112
-
113
- def self.arrow_up_small
114
- Rainbow("\u2B06").yellow # Up arrow
115
- end
116
-
117
- def self.arrow_down_small
118
- Rainbow("\u2B07").yellow # Down arrow
119
- end
120
-
121
- def self.arrow_right_small
122
- Rainbow("\u27A1").yellow # Black rightwards arrow
123
- end
124
-
125
- def self.arrow_left_small
126
- Rainbow("\u2B05").yellow # Left arrow
127
- end
128
-
129
- def self.arrow_up_down_small
130
- Rainbow("\u2195").yellow # Up/down arrow
131
- end
132
-
133
- def self.music
134
- Rainbow("\u266B").yellow # Beamed eighth notes
135
- end
136
-
137
- # Get appropriate symbol for log severity level
138
- #
139
- # Returns a colored Unicode symbol that matches the given log severity level.
140
- # Used primarily in log formatting to provide visual indicators.
141
- #
142
- # @param severity [String] The severity level (DEBUG, WARN, ERROR, FATAL)
143
- # @return [String] Colored Unicode symbol or space for unrecognized levels
144
- def self.get_severity_symbol(severity)
145
- case severity
146
- when "DEBUG"
147
- question
148
- # when "INFO"
149
- # info
150
- when "WARN"
151
- warning
152
- when "ERROR"
153
- error
154
- when "FATAL"
155
- fatal
156
- else
157
- " "
158
- end
159
- end
160
- end
161
- end
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "rainbow"
5
+ rescue LoadError
6
+ # rainbow gem not available, define a no-op rainbow method
7
+ class String
8
+ def rainbow
9
+ self
10
+ end
11
+ end
12
+ end
13
+
14
+ # https://symbl.cc/en/unicode/table/
15
+ module Makit
16
+ # Unicode symbol utilities with colorization
17
+ #
18
+ # This class provides a collection of Unicode symbols with appropriate
19
+ # colors for use in terminal output. Symbols are provided for various
20
+ # purposes including status indicators, directional arrows, and decorative elements.
21
+ class Symbols
22
+ def self.checkmark
23
+ "\u2713"
24
+ end
25
+
26
+ def self.success
27
+ "\u2713"
28
+ end
29
+
30
+ def self.error
31
+ Rainbow("\u0058").red
32
+ end
33
+
34
+ def self.warning
35
+ Rainbow("\u26A0").yellow
36
+ end
37
+
38
+ def self.debug
39
+ Rainbow("\u24D8").blue # Circle with "i"
40
+ end
41
+
42
+ def self.info
43
+ Rainbow("\u2139").blue # Information source
44
+ end
45
+
46
+ def self.fatal
47
+ Rainbow("\u25A0").bright.red # Filled square, indicating stop/critical
48
+ end
49
+
50
+ def self.warn
51
+ Rainbow("\u26A0").yellow # Warning sign
52
+ end
53
+
54
+ def self.star
55
+ Rainbow("\u2605").yellow # Star
56
+ end
57
+
58
+ def self.coffee
59
+ Rainbow("\u2615").yellow # Hot beverage
60
+ end
61
+
62
+ def self.heart
63
+ Rainbow("\u2764").red # Heavy black heart
64
+ end
65
+
66
+ def self.bug
67
+ Rainbow("\u1F41E").yellow # Bug
68
+ end
69
+
70
+ def self.gear
71
+ Rainbow("\u2699").yellow # Gear
72
+ end
73
+
74
+ def self.magnifying_glass
75
+ Rainbow("\u1F50D").yellow # Left-pointing magnifying glass
76
+ end
77
+
78
+ def self.question
79
+ Rainbow("\u003F").yellow # Question mark
80
+ end
81
+
82
+ def self.arrow_right
83
+ Rainbow("\u27A4").yellow # Arrow pointing rightwards then curving upwards
84
+ end
85
+
86
+ def self.arrow_left
87
+ Rainbow("\u2B05").yellow # Left arrow
88
+ end
89
+
90
+ def self.arrow_up
91
+ Rainbow("\u2B06").yellow # Up arrow
92
+ end
93
+
94
+ def self.arrow_down
95
+ Rainbow("\u2B07").yellow # Down arrow
96
+ end
97
+
98
+ def self.arrow_up_down
99
+ Rainbow("\u2195").yellow # Up/down arrow
100
+ end
101
+
102
+ def self.arrow_left_right
103
+ Rainbow("\u2194").yellow # Left/right arrow
104
+ end
105
+
106
+ def self.arrow_upper_right
107
+ Rainbow("\u2197").yellow # North east arrow
108
+ end
109
+
110
+ def self.arrow_lower_right
111
+ Rainbow("\u2198").yellow # South east arrow
112
+ end
113
+
114
+ def self.arrow_lower_left
115
+ Rainbow("\u2199").yellow # South west arrow
116
+ end
117
+
118
+ def self.arrow_upper_left
119
+ Rainbow("\u2196").yellow # North west arrow
120
+ end
121
+
122
+ def self.arrow_up_small
123
+ Rainbow("\u2B06").yellow # Up arrow
124
+ end
125
+
126
+ def self.arrow_down_small
127
+ Rainbow("\u2B07").yellow # Down arrow
128
+ end
129
+
130
+ def self.arrow_right_small
131
+ Rainbow("\u27A1").yellow # Black rightwards arrow
132
+ end
133
+
134
+ def self.arrow_left_small
135
+ Rainbow("\u2B05").yellow # Left arrow
136
+ end
137
+
138
+ def self.arrow_up_down_small
139
+ Rainbow("\u2195").yellow # Up/down arrow
140
+ end
141
+
142
+ def self.music
143
+ Rainbow("\u266B").yellow # Beamed eighth notes
144
+ end
145
+
146
+ # Get appropriate symbol for log severity level
147
+ #
148
+ # Returns a colored Unicode symbol that matches the given log severity level.
149
+ # Used primarily in log formatting to provide visual indicators.
150
+ #
151
+ # @param severity [String] The severity level (DEBUG, WARN, ERROR, FATAL)
152
+ # @return [String] Colored Unicode symbol or space for unrecognized levels
153
+ def self.get_severity_symbol(severity)
154
+ case severity
155
+ when "DEBUG"
156
+ question
157
+ # when "INFO"
158
+ # info
159
+ when "WARN"
160
+ warning
161
+ when "ERROR"
162
+ error
163
+ when "FATAL"
164
+ fatal
165
+ else
166
+ " "
167
+ end
168
+ end
169
+ end
170
+ end
@@ -1,128 +1,128 @@
1
- # frozen_string_literal: true
2
-
3
- # Task timing and performance tracking utilities
4
- module Makit
5
- # Task execution time tracking and reporting
6
- #
7
- # This class provides functionality to track the execution time of tasks,
8
- # store timing information, and generate performance reports. It's designed
9
- # to help identify performance bottlenecks in build processes.
10
- class TaskInfo
11
- #
12
- # Class variable to store completed task information
13
- #
14
- class << self
15
- attr_accessor :completed_tasks
16
- end
17
- @completed_tasks = {}
18
-
19
- # @return [String] Name of the task being tracked
20
- # @return [Time] Time when task execution started
21
- # @return [Time] Time when task execution ended
22
- # @return [String] Directory path for task artifacts
23
- attr_reader :task_name, :start_time, :end_time, :artifacts_dir
24
-
25
- # Get the name of the slowest completed task
26
- #
27
- # Analyzes all completed tasks and returns the name of the one
28
- # with the longest execution duration.
29
- #
30
- # @return [String] Name of the slowest task, or "unknown" if no tasks completed
31
- def self.slowest_task_name
32
- return "unknown" if @completed_tasks.empty?
33
-
34
- @completed_tasks.max_by { |_task_name, task_info| task_info[:duration] }[0]
35
- end
36
-
37
- # Track execution time of a task with a block
38
- #
39
- # Creates a new TaskInfo instance, displays the task name,
40
- # executes the provided block, and ensures timing is reported
41
- # even if an exception occurs.
42
- #
43
- # @param task_name [String, Symbol] Name of the task to track
44
- # @yield [TaskInfo] The task info instance for use within the block
45
- # @return [Object] Result of the yielded block
46
- #
47
- # @example
48
- # Makit::TaskInfo.track(:generate) do
49
- # # generate code
50
- # end
51
- def self.track(task_name)
52
- task = new(task_name)
53
- Makit::SHOW.task(task_name)
54
- yield(task)
55
- ensure
56
- task&.report_and_store_time_taken
57
- end
58
-
59
- # Track execution time with inferred task name
60
- #
61
- # Similar to track() but attempts to infer the task name automatically.
62
- # Currently returns nil as task name inference is not implemented.
63
- #
64
- # @yield [TaskInfo] The task info instance for use within the block
65
- # @return [Object] Result of the yielded block
66
- def self.track_inferred(&block)
67
- task_name = infer_task_name
68
- Makit::SHOW.task(task_name)
69
- track(task_name, &block)
70
- end
71
-
72
- # Initialize a new task tracking instance
73
- #
74
- # Sets up timing tracking for a named task, creates an artifacts
75
- # directory path, and records the start time.
76
- #
77
- # @param task_name [String, Symbol] Name of the task to track
78
- def initialize(task_name)
79
- @task_name = task_name
80
- @artifacts_dir = File.join("artifacts", task_name.to_s.gsub(":", "_"))
81
- @start_time = Time.now
82
- # at_exit { report_and_store_time_taken }
83
- end
84
-
85
- # Report and store the task execution time
86
- #
87
- # Calculates the duration, displays a human-readable completion message,
88
- # and stores the timing information in the class-level completed_tasks hash.
89
- #
90
- # @return [nil]
91
- def report_and_store_time_taken
92
- @end_time = Time.now
93
- duration = @end_time - @start_time
94
-
95
- # leverate the Makit::Humanize.get_humanized_duration method
96
- humanized_duration = Makit::Humanize.get_humanized_duration(duration)
97
- puts " #{@task_name} completed in #{humanized_duration}".colorize(:grey)
98
- # puts "[TaskGuard] Task '#{@task_name}' completed in #{duration}."
99
-
100
- # Add to class-level storage
101
- self.class.completed_tasks[@task_name] = {
102
- start_time: @start_time,
103
- end_time: @end_time,
104
- duration: duration,
105
- }
106
- end
107
-
108
- # def format_duration(seconds)
109
- # if seconds >= 60
110
- # mins = (seconds / 60).to_i
111
- # secs = (seconds % 60).round(2)
112
- # "#{mins}m #{secs}s"
113
- # else
114
- # "#{seconds.round(2)}s"
115
- # end
116
- # end
117
-
118
- # Attempt to infer the current task name
119
- #
120
- # This method would extract the current Rake task name from the
121
- # application context, but is currently not implemented.
122
- #
123
- # @return [String, nil] The inferred task name, or nil if unavailable
124
- def self.infer_task_name
125
- # Rake.application.current_scope.join(":") rescue "unknown"
126
- end
127
- end
128
- end
1
+ # frozen_string_literal: true
2
+
3
+ # Task timing and performance tracking utilities
4
+ module Makit
5
+ # Task execution time tracking and reporting
6
+ #
7
+ # This class provides functionality to track the execution time of tasks,
8
+ # store timing information, and generate performance reports. It's designed
9
+ # to help identify performance bottlenecks in build processes.
10
+ class TaskInfo
11
+ #
12
+ # Class variable to store completed task information
13
+ #
14
+ class << self
15
+ attr_accessor :completed_tasks
16
+ end
17
+ @completed_tasks = {}
18
+
19
+ # @return [String] Name of the task being tracked
20
+ # @return [Time] Time when task execution started
21
+ # @return [Time] Time when task execution ended
22
+ # @return [String] Directory path for task artifacts
23
+ attr_reader :task_name, :start_time, :end_time, :artifacts_dir
24
+
25
+ # Get the name of the slowest completed task
26
+ #
27
+ # Analyzes all completed tasks and returns the name of the one
28
+ # with the longest execution duration.
29
+ #
30
+ # @return [String] Name of the slowest task, or "unknown" if no tasks completed
31
+ def self.slowest_task_name
32
+ return "unknown" if @completed_tasks.empty?
33
+
34
+ @completed_tasks.max_by { |_task_name, task_info| task_info[:duration] }[0]
35
+ end
36
+
37
+ # Track execution time of a task with a block
38
+ #
39
+ # Creates a new TaskInfo instance, displays the task name,
40
+ # executes the provided block, and ensures timing is reported
41
+ # even if an exception occurs.
42
+ #
43
+ # @param task_name [String, Symbol] Name of the task to track
44
+ # @yield [TaskInfo] The task info instance for use within the block
45
+ # @return [Object] Result of the yielded block
46
+ #
47
+ # @example
48
+ # Makit::TaskInfo.track(:generate) do
49
+ # # generate code
50
+ # end
51
+ def self.track(task_name)
52
+ task = new(task_name)
53
+ Makit::SHOW.task(task_name)
54
+ yield(task)
55
+ ensure
56
+ task&.report_and_store_time_taken
57
+ end
58
+
59
+ # Track execution time with inferred task name
60
+ #
61
+ # Similar to track() but attempts to infer the task name automatically.
62
+ # Currently returns nil as task name inference is not implemented.
63
+ #
64
+ # @yield [TaskInfo] The task info instance for use within the block
65
+ # @return [Object] Result of the yielded block
66
+ def self.track_inferred(&block)
67
+ task_name = infer_task_name
68
+ Makit::SHOW.task(task_name)
69
+ track(task_name, &block)
70
+ end
71
+
72
+ # Initialize a new task tracking instance
73
+ #
74
+ # Sets up timing tracking for a named task, creates an artifacts
75
+ # directory path, and records the start time.
76
+ #
77
+ # @param task_name [String, Symbol] Name of the task to track
78
+ def initialize(task_name)
79
+ @task_name = task_name
80
+ @artifacts_dir = File.join("artifacts", task_name.to_s.gsub(":", "_"))
81
+ @start_time = Time.now
82
+ # at_exit { report_and_store_time_taken }
83
+ end
84
+
85
+ # Report and store the task execution time
86
+ #
87
+ # Calculates the duration, displays a human-readable completion message,
88
+ # and stores the timing information in the class-level completed_tasks hash.
89
+ #
90
+ # @return [nil]
91
+ def report_and_store_time_taken
92
+ @end_time = Time.now
93
+ duration = @end_time - @start_time
94
+
95
+ # leverate the Makit::Humanize.get_humanized_duration method
96
+ humanized_duration = Makit::Humanize.get_humanized_duration(duration)
97
+ puts " #{@task_name} completed in #{humanized_duration}".colorize(:grey)
98
+ # puts "[TaskGuard] Task '#{@task_name}' completed in #{duration}."
99
+
100
+ # Add to class-level storage
101
+ self.class.completed_tasks[@task_name] = {
102
+ start_time: @start_time,
103
+ end_time: @end_time,
104
+ duration: duration,
105
+ }
106
+ end
107
+
108
+ # def format_duration(seconds)
109
+ # if seconds >= 60
110
+ # mins = (seconds / 60).to_i
111
+ # secs = (seconds % 60).round(2)
112
+ # "#{mins}m #{secs}s"
113
+ # else
114
+ # "#{seconds.round(2)}s"
115
+ # end
116
+ # end
117
+
118
+ # Attempt to infer the current task name
119
+ #
120
+ # This method would extract the current Rake task name from the
121
+ # application context, but is currently not implemented.
122
+ #
123
+ # @return [String, nil] The inferred task name, or nil if unavailable
124
+ def self.infer_task_name
125
+ # Rake.application.current_scope.join(":") rescue "unknown"
126
+ end
127
+ end
128
+ end
@@ -1,13 +1,13 @@
1
- require "English"
2
-
3
- at_exit do
4
- command = "rake #{ARGV.join(" ")}"
5
- duration = Time.now - Makit::STARTTIME
6
- message = "#{command} (#{Makit::Humanize.get_humanized_duration(duration)})"
7
- # detect if the rake execution was successful
8
- if $ERROR_INFO.nil?
9
- Makit::Logging.default_logger.info(message)
10
- else
11
- Makit::Logging.default_logger.error(message)
12
- end # display the humanized duration of the rake execution
13
- end
1
+ require "English"
2
+
3
+ at_exit do
4
+ command = "rake #{ARGV.join(" ")}"
5
+ duration = Time.now - Makit::STARTTIME
6
+ message = "#{command} (#{Makit::Humanize.get_humanized_duration(duration)})"
7
+ # detect if the rake execution was successful
8
+ if $ERROR_INFO.nil?
9
+ Makit::Logging.default_logger.info(message)
10
+ else
11
+ Makit::Logging.default_logger.error(message)
12
+ end # display the humanized duration of the rake execution
13
+ end
@@ -1,18 +1,19 @@
1
- require_relative "../setup/runner"
2
-
3
- desc "Build project artifacts.."
4
- task :build do
5
- # load the default project configuration
6
- project = Makit::Configuration::Project.default
7
-
8
- # for each step in the project configuration, run the commands
9
- project.steps.each do |step|
10
- step.commands.each do |command|
11
- request = Makit::Commands::Request.from_string(command)
12
- result = Makit::Commands::Runner.default.execute(request)
13
- end
14
- end
15
-
16
- # Make sure the build commands are in the project configuration
17
-
18
- end
1
+ require_relative "../setup/runner"
2
+
3
+ desc "Build project artifacts.."
4
+ task :build do
5
+ # load the default project configuration
6
+ #puts "loading project configuration"
7
+ #project = Makit::Configuration::Project.default
8
+
9
+ # for each step in the project configuration, run the commands
10
+ #project.steps.each do |step|
11
+ # step.commands.each do |command|
12
+ # request = Makit::Commands::Request.from_string(command)
13
+ # result = Makit::Commands::Runner.default.execute(request)
14
+ # end
15
+ #end
16
+
17
+ # Make sure the build commands are in the project configuration
18
+
19
+ end