makit 0.0.112 → 0.0.128

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 (147) 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 +311 -320
  31. data/lib/makit/commands/middleware/validator.rb +269 -269
  32. data/lib/makit/commands/request.rb +316 -254
  33. data/lib/makit/commands/result.rb +323 -323
  34. data/lib/makit/commands/runner.rb +368 -337
  35. data/lib/makit/commands/strategies/base.rb +171 -160
  36. data/lib/makit/commands/strategies/synchronous.rb +139 -134
  37. data/lib/makit/commands.rb +50 -51
  38. data/lib/makit/configuration/gitlab_helper.rb +58 -60
  39. data/lib/makit/configuration/project.rb +167 -127
  40. data/lib/makit/configuration/rakefile_helper.rb +43 -43
  41. data/lib/makit/configuration/step.rb +34 -34
  42. data/lib/makit/configuration.rb +14 -14
  43. data/lib/makit/content/default_gitignore.rb +7 -7
  44. data/lib/makit/content/default_gitignore.txt +226 -0
  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 +140 -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/cli.rb +69 -65
  54. data/lib/makit/dotnet/project.rb +217 -153
  55. data/lib/makit/dotnet/solution.rb +38 -38
  56. data/lib/makit/dotnet/solution_classlib.rb +239 -239
  57. data/lib/makit/dotnet/solution_console.rb +264 -264
  58. data/lib/makit/dotnet/solution_maui.rb +354 -354
  59. data/lib/makit/dotnet/solution_wasm.rb +275 -275
  60. data/lib/makit/dotnet/solution_wpf.rb +304 -304
  61. data/lib/makit/dotnet.rb +102 -102
  62. data/lib/makit/email.rb +90 -90
  63. data/lib/makit/environment.rb +142 -142
  64. data/lib/makit/examples/runner.rb +370 -370
  65. data/lib/makit/exceptions.rb +45 -45
  66. data/lib/makit/fileinfo.rb +24 -24
  67. data/lib/makit/files.rb +43 -43
  68. data/lib/makit/gems.rb +40 -40
  69. data/lib/makit/git/cli.rb +54 -54
  70. data/lib/makit/git/repository.rb +90 -90
  71. data/lib/makit/git.rb +98 -98
  72. data/lib/makit/gitlab_runner.rb +59 -59
  73. data/lib/makit/humanize.rb +137 -137
  74. data/lib/makit/indexer.rb +47 -47
  75. data/lib/makit/logging/configuration.rb +308 -305
  76. data/lib/makit/logging/format_registry.rb +84 -84
  77. data/lib/makit/logging/formatters/base.rb +39 -39
  78. data/lib/makit/logging/formatters/console_formatter.rb +140 -140
  79. data/lib/makit/logging/formatters/json_formatter.rb +65 -65
  80. data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -71
  81. data/lib/makit/logging/formatters/text_formatter.rb +64 -64
  82. data/lib/makit/logging/log_request.rb +119 -115
  83. data/lib/makit/logging/logger.rb +199 -163
  84. data/lib/makit/logging/sinks/base.rb +91 -91
  85. data/lib/makit/logging/sinks/console.rb +72 -72
  86. data/lib/makit/logging/sinks/file_sink.rb +92 -92
  87. data/lib/makit/logging/sinks/structured.rb +123 -129
  88. data/lib/makit/logging/sinks/unified_file_sink.rb +296 -303
  89. data/lib/makit/logging.rb +565 -530
  90. data/lib/makit/markdown.rb +75 -75
  91. data/lib/makit/mp/basic_object_mp.rb +17 -17
  92. data/lib/makit/mp/command_mp.rb +13 -13
  93. data/lib/makit/mp/command_request.mp.rb +17 -17
  94. data/lib/makit/mp/project_mp.rb +199 -199
  95. data/lib/makit/mp/string_mp.rb +191 -193
  96. data/lib/makit/nuget.rb +74 -74
  97. data/lib/makit/port.rb +32 -32
  98. data/lib/makit/process.rb +163 -163
  99. data/lib/makit/protoc.rb +107 -107
  100. data/lib/makit/rake/cli.rb +196 -196
  101. data/lib/makit/rake.rb +25 -25
  102. data/lib/makit/ruby/cli.rb +185 -185
  103. data/lib/makit/ruby.rb +25 -25
  104. data/lib/makit/secrets.rb +51 -51
  105. data/lib/makit/serializer.rb +130 -130
  106. data/lib/makit/services/builder.rb +186 -186
  107. data/lib/makit/services/error_handler.rb +226 -226
  108. data/lib/makit/services/repository_manager.rb +231 -229
  109. data/lib/makit/services/validator.rb +112 -112
  110. data/lib/makit/setup/classlib.rb +94 -53
  111. data/lib/makit/setup/gem.rb +268 -263
  112. data/lib/makit/setup/razorclasslib.rb +91 -0
  113. data/lib/makit/setup/runner.rb +54 -45
  114. data/lib/makit/setup.rb +5 -5
  115. data/lib/makit/show.rb +110 -110
  116. data/lib/makit/storage.rb +126 -126
  117. data/lib/makit/symbols.rb +170 -170
  118. data/lib/makit/task_info.rb +128 -128
  119. data/lib/makit/tasks/at_exit.rb +15 -13
  120. data/lib/makit/tasks/build.rb +22 -19
  121. data/lib/makit/tasks/clean.rb +13 -11
  122. data/lib/makit/tasks/configure.rb +10 -0
  123. data/lib/makit/tasks/format.rb +10 -0
  124. data/lib/makit/tasks/hook_manager.rb +391 -393
  125. data/lib/makit/tasks/init.rb +49 -47
  126. data/lib/makit/tasks/integrate.rb +29 -17
  127. data/lib/makit/tasks/pull_incoming.rb +13 -11
  128. data/lib/makit/tasks/setup.rb +13 -6
  129. data/lib/makit/tasks/sync.rb +17 -12
  130. data/lib/makit/tasks/tag.rb +16 -15
  131. data/lib/makit/tasks/task_monkey_patch.rb +81 -79
  132. data/lib/makit/tasks/test.rb +22 -0
  133. data/lib/makit/tasks/update.rb +18 -0
  134. data/lib/makit/tasks.rb +20 -15
  135. data/lib/makit/test_cache.rb +239 -239
  136. data/lib/makit/tree.rb +37 -37
  137. data/lib/makit/v1/makit.v1_pb.rb +35 -34
  138. data/lib/makit/v1/makit.v1_services_pb.rb +27 -27
  139. data/lib/makit/version.rb +5 -5
  140. data/lib/makit/version_util.rb +21 -21
  141. data/lib/makit/wix.rb +95 -95
  142. data/lib/makit/yaml.rb +29 -29
  143. data/lib/makit/zip.rb +17 -17
  144. data/lib/makit copy.rb +44 -44
  145. data/lib/makit.rb +39 -40
  146. metadata +69 -7
  147. data/lib/makit/commands/middleware/unified_logger.rb +0 -243
data/lib/makit/symbols.rb CHANGED
@@ -1,170 +1,170 @@
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
+ # 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,15 @@
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
+ # frozen_string_literal: true
2
+
3
+ require "English"
4
+
5
+ at_exit do
6
+ command = "rake #{ARGV.join(" ")}"
7
+ duration = Time.now - Makit::STARTTIME
8
+ message = "#{command} (#{Makit::Humanize.get_humanized_duration(duration)})"
9
+ # detect if the rake execution was successful
10
+ if $ERROR_INFO.nil?
11
+ Makit::Logging.default_logger.info(message)
12
+ else
13
+ Makit::Logging.default_logger.error(message)
14
+ end
15
+ end
@@ -1,19 +1,22 @@
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
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../setup/runner"
4
+
5
+ if File.exist?(".makit.json")
6
+ desc "Build project artifacts.."
7
+ task :build do
8
+ Makit::Logging.default_logger.task_start("build")
9
+ # load the default project configuration
10
+ # puts "loading project configuration"
11
+ project = Makit::Configuration::Project.default
12
+
13
+ # if the project has a build step, run the commands
14
+ build_step = project.steps.find { |step| step.name == "build" }
15
+ build_step&.commands&.each do |command|
16
+ request = Makit::Commands::Request.from_string(command).exit_on_failure(true).show_stderr(true)
17
+ Makit::Commands::Runner.default.execute(request)
18
+ end
19
+ end
20
+ else
21
+ Makit::Logging.default_logger.debug("Project not configured, skipping setup task definition")
22
+ end