makit 0.0.111 → 0.0.126
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.
- checksums.yaml +4 -4
- data/lib/makit/cli/repository_commands.rb +1 -1
- data/lib/makit/commands/middleware/cache.rb +3 -3
- data/lib/makit/commands/middleware/command_logger.rb +33 -45
- data/lib/makit/commands/request.rb +63 -1
- data/lib/makit/commands/runner.rb +56 -5
- data/lib/makit/commands/strategies/base.rb +13 -2
- data/lib/makit/commands/strategies/synchronous.rb +11 -6
- data/lib/makit/commands.rb +8 -0
- data/lib/makit/configuration/gitlab_helper.rb +0 -2
- data/lib/makit/configuration/project.rb +48 -8
- data/lib/makit/configuration/step.rb +3 -3
- data/lib/makit/content/default_gitignore.txt +226 -0
- data/lib/makit/directories.rb +3 -4
- data/lib/makit/docs/files.rb +1 -1
- data/lib/makit/docs/rake.rb +1 -1
- data/lib/makit/dotnet/cli.rb +69 -65
- data/lib/makit/dotnet/project.rb +71 -7
- data/lib/makit/examples/runner.rb +2 -2
- data/lib/makit/logging/configuration.rb +9 -6
- data/lib/makit/logging/format_registry.rb +84 -84
- data/lib/makit/logging/formatters/console_formatter.rb +22 -9
- data/lib/makit/logging/log_request.rb +6 -2
- data/lib/makit/logging/logger.rb +45 -5
- data/lib/makit/logging/sinks/base.rb +91 -91
- data/lib/makit/logging/sinks/structured.rb +123 -129
- data/lib/makit/logging/sinks/unified_file_sink.rb +39 -46
- data/lib/makit/logging.rb +45 -1
- data/lib/makit/mp/project_mp.rb +6 -6
- data/lib/makit/mp/string_mp.rb +108 -265
- data/lib/makit/serializer.rb +14 -1
- data/lib/makit/services/builder.rb +5 -5
- data/lib/makit/services/repository_manager.rb +8 -6
- data/lib/makit/setup/classlib.rb +44 -7
- data/lib/makit/setup/gem.rb +268 -250
- data/lib/makit/setup/razorclasslib.rb +91 -0
- data/lib/makit/setup/runner.rb +36 -22
- data/lib/makit/setup.rb +5 -0
- data/lib/makit/symbols.rb +10 -1
- data/lib/makit/tasks/at_exit.rb +3 -1
- data/lib/makit/tasks/build.rb +16 -12
- data/lib/makit/tasks/clean.rb +2 -0
- data/lib/makit/tasks/configure.rb +10 -0
- data/lib/makit/tasks/format.rb +10 -0
- data/lib/makit/tasks/hook_manager.rb +160 -8
- data/lib/makit/tasks/init.rb +2 -0
- data/lib/makit/tasks/integrate.rb +17 -3
- data/lib/makit/tasks/pull_incoming.rb +6 -5
- data/lib/makit/tasks/setup.rb +10 -3
- data/lib/makit/tasks/sync.rb +13 -7
- data/lib/makit/tasks/tag.rb +16 -0
- data/lib/makit/tasks/task_monkey_patch.rb +58 -56
- data/lib/makit/tasks/test.rb +22 -0
- data/lib/makit/tasks/update.rb +18 -0
- data/lib/makit/tasks.rb +20 -5
- data/lib/makit/v1/makit.v1_pb.rb +1 -0
- data/lib/makit/version.rb +1 -1
- data/lib/makit/version_util.rb +21 -0
- data/lib/makit copy.rb +44 -0
- data/lib/makit.rb +31 -0
- metadata +118 -13
- data/lib/makit/command_runner.rb +0 -463
- data/lib/makit/commands/compatibility.rb +0 -365
- data/lib/makit/commands/middleware/unified_logger.rb +0 -243
- data/lib/makit/task_hooks.rb +0 -125
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a002343e64c5e7dd72227c9a46010c8189e2413fac4a4175c50dd1da7afdc2a
|
4
|
+
data.tar.gz: bd27c52620a9df3198ac6be328294bb1935c9fbd6b6b33a270a45c562e52d19a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34d51c894957bfca45e42968b8eb74e2fe32f710b0687ea30c33a878ca0b125b2a641b961e38a0ef7a9a027142221e2b9bc5bdd125ff035dd7f9d49db834d33b
|
7
|
+
data.tar.gz: 9942166a1f8be21948d029a5b1058942a8637fb1e565d7ee28ec2d58dd5c40f9cf10cbff18cee4ec712e4ebbe54c4873065eef8b29cc4131fa3f2bbc51b57ec2
|
@@ -62,7 +62,7 @@ module Makit
|
|
62
62
|
%r{^https?://\w+[\w.-]*\w+/[\w.-]+/[\w.-]+(?:\.git)?/?$}, # HTTPS
|
63
63
|
%r{^git@[\w.-]+:[\w.-]+/[\w.-]+(?:\.git)?$}, # SSH
|
64
64
|
%r{^ssh://git@[\w.-]+/[\w.-]+/[\w.-]+(?:\.git)?$}, # SSH with ssh://
|
65
|
-
%r{^[\w.-]+@[\w.-]+:[\w.-]+/[\w.-]+(?:\.git)?$},
|
65
|
+
%r{^[\w.-]+@[\w.-]+:[\w.-]+/[\w.-]+(?:\.git)?$}, # Generic SSH
|
66
66
|
]
|
67
67
|
|
68
68
|
unless valid_patterns.any? { |pattern| url.match?(pattern) }
|
@@ -8,7 +8,7 @@ module Makit
|
|
8
8
|
module Middleware
|
9
9
|
# Caching middleware for command execution results
|
10
10
|
#
|
11
|
-
# This middleware provides caching functionality
|
11
|
+
# This middleware provides caching functionality for command execution,
|
12
12
|
# allowing commands to be cached based on their content and timestamp.
|
13
13
|
#
|
14
14
|
# @example Basic usage
|
@@ -123,7 +123,7 @@ module Makit
|
|
123
123
|
|
124
124
|
# Convert to new Result format
|
125
125
|
convert_cached_command_to_result(cached_command)
|
126
|
-
rescue => e
|
126
|
+
rescue StandardError => e
|
127
127
|
Makit::Logging.debug("Failed to load cached result", {
|
128
128
|
cache_file: cache_file,
|
129
129
|
error: e.message,
|
@@ -151,7 +151,7 @@ module Makit
|
|
151
151
|
command: result.command,
|
152
152
|
success: result.success?,
|
153
153
|
})
|
154
|
-
rescue => e
|
154
|
+
rescue StandardError => e
|
155
155
|
Makit::Logging.warn("Failed to cache result", {
|
156
156
|
cache_file: cache_file,
|
157
157
|
error: e.message,
|
@@ -32,31 +32,23 @@ module Makit
|
|
32
32
|
|
33
33
|
# Initialize command logging middleware.
|
34
34
|
#
|
35
|
-
# @param logger [Makit::Logging::Logger, nil] custom logger instance
|
36
35
|
# @param log_stdout [Boolean] whether to log stdout output
|
37
36
|
# @param log_stderr [Boolean] whether to log stderr output
|
38
37
|
# @param log_performance [Boolean] whether to log performance metrics
|
39
38
|
# @param max_output_lines [Integer] maximum lines of output to log
|
40
|
-
# @param log_level [Symbol] log level for command events
|
41
39
|
def initialize(
|
42
|
-
logger: nil,
|
43
40
|
log_stdout: false,
|
44
41
|
log_stderr: true,
|
45
42
|
log_performance: true,
|
46
|
-
max_output_lines: 100
|
47
|
-
log_level: nil
|
43
|
+
max_output_lines: 100
|
48
44
|
)
|
49
45
|
@log_stdout = log_stdout
|
50
46
|
@log_stderr = log_stderr
|
51
47
|
@log_performance = log_performance
|
52
48
|
@max_output_lines = max_output_lines
|
53
|
-
@log_level = log_level || Makit::Logging.current_log_level
|
54
49
|
|
55
|
-
# Use the
|
56
|
-
@logger =
|
57
|
-
level: @log_level,
|
58
|
-
sinks: Makit::Logging.default_logger.sinks,
|
59
|
-
)
|
50
|
+
# Use the default logger for all logging
|
51
|
+
@logger = Makit::Logging.default_logger
|
60
52
|
end
|
61
53
|
|
62
54
|
# Execute command with enhanced logging.
|
@@ -83,11 +75,11 @@ module Makit
|
|
83
75
|
log_command_output(request, result, command_id)
|
84
76
|
|
85
77
|
result
|
86
|
-
rescue =>
|
78
|
+
rescue StandardError => e
|
87
79
|
duration = Time.now - start_time
|
88
80
|
|
89
81
|
# Log command error with full context
|
90
|
-
log_command_error(request,
|
82
|
+
log_command_error(request, e, duration, command_id)
|
91
83
|
|
92
84
|
raise
|
93
85
|
end
|
@@ -97,7 +89,7 @@ module Makit
|
|
97
89
|
#
|
98
90
|
# @param request [Request] command request
|
99
91
|
# @return [Boolean] true if middleware applies
|
100
|
-
def applicable?(
|
92
|
+
def applicable?(_request)
|
101
93
|
# Apply to all requests
|
102
94
|
true
|
103
95
|
end
|
@@ -108,12 +100,11 @@ module Makit
|
|
108
100
|
def config
|
109
101
|
{
|
110
102
|
name: "CommandLogger",
|
111
|
-
description: "
|
103
|
+
description: "Command execution logging with performance tracking and output handling",
|
112
104
|
log_stdout: @log_stdout,
|
113
105
|
log_stderr: @log_stderr,
|
114
106
|
log_performance: @log_performance,
|
115
107
|
max_output_lines: @max_output_lines,
|
116
|
-
log_level: @log_level,
|
117
108
|
logger_class: @logger.class.name,
|
118
109
|
}
|
119
110
|
end
|
@@ -135,7 +126,7 @@ module Makit
|
|
135
126
|
timestamp: Time.now.iso8601,
|
136
127
|
}
|
137
128
|
|
138
|
-
@logger.
|
129
|
+
@logger.debug("Command execution started", log_data)
|
139
130
|
end
|
140
131
|
|
141
132
|
# Log command execution completion with performance data.
|
@@ -162,12 +153,9 @@ module Makit
|
|
162
153
|
)
|
163
154
|
end
|
164
155
|
|
165
|
-
# Log at
|
166
|
-
if result.success?
|
167
|
-
|
168
|
-
else
|
169
|
-
@logger.warn("Command completed with errors", log_data)
|
170
|
-
end
|
156
|
+
# Log detailed information at debug level
|
157
|
+
@logger.debug("Command completed successfully", log_data) if result.success?
|
158
|
+
@logger.debug("Command completed with errors", log_data) unless result.success?
|
171
159
|
|
172
160
|
# Log performance warnings
|
173
161
|
log_performance_warnings(request, result, duration, command_id) if @log_performance
|
@@ -196,20 +184,20 @@ module Makit
|
|
196
184
|
end
|
197
185
|
|
198
186
|
# Log stderr if enabled and present
|
199
|
-
|
200
|
-
output_lines = result.stderr.split("\n")
|
201
|
-
truncated = output_lines.length > @max_output_lines
|
187
|
+
return unless @log_stderr && result.stderr && !result.stderr.empty?
|
202
188
|
|
203
|
-
|
204
|
-
|
205
|
-
command: request.command,
|
206
|
-
output: truncated ? output_lines.first(@max_output_lines).join("\n") : result.stderr,
|
207
|
-
total_lines: output_lines.length,
|
208
|
-
truncated: truncated,
|
209
|
-
}
|
189
|
+
output_lines = result.stderr.split("\n")
|
190
|
+
truncated = output_lines.length > @max_output_lines
|
210
191
|
|
211
|
-
|
212
|
-
|
192
|
+
{
|
193
|
+
command_id: command_id,
|
194
|
+
command: request.command,
|
195
|
+
output: truncated ? output_lines.first(@max_output_lines).join("\n") : result.stderr,
|
196
|
+
total_lines: output_lines.length,
|
197
|
+
truncated: truncated,
|
198
|
+
}
|
199
|
+
|
200
|
+
# @logger.warn("Command stderr", log_data)
|
213
201
|
end
|
214
202
|
|
215
203
|
# Log command execution error with full context.
|
@@ -262,13 +250,13 @@ module Makit
|
|
262
250
|
end
|
263
251
|
|
264
252
|
# Log commands with high exit codes (potential errors)
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
253
|
+
return unless result.exit_code.positive?
|
254
|
+
|
255
|
+
@logger.debug("Command completed with non-zero exit code",
|
256
|
+
command_id: command_id,
|
257
|
+
command: request.command,
|
258
|
+
exit_code: result.exit_code,
|
259
|
+
success: result.success?)
|
272
260
|
end
|
273
261
|
|
274
262
|
# Calculate total output size (stdout + stderr).
|
@@ -299,7 +287,7 @@ module Makit
|
|
299
287
|
begin
|
300
288
|
# This is a simplified approach for Windows
|
301
289
|
"Unknown"
|
302
|
-
rescue
|
290
|
+
rescue StandardError
|
303
291
|
nil
|
304
292
|
end
|
305
293
|
else
|
@@ -308,11 +296,11 @@ module Makit
|
|
308
296
|
# Try to get memory usage from /proc/self/status
|
309
297
|
if File.exist?("/proc/self/status")
|
310
298
|
status = File.read("/proc/self/status")
|
311
|
-
if match = status.match(/VmRSS:\s+(\d+)\s+kB/)
|
299
|
+
if (match = status.match(/VmRSS:\s+(\d+)\s+kB/))
|
312
300
|
"#{match[1].to_i / 1024}MB"
|
313
301
|
end
|
314
302
|
end
|
315
|
-
rescue
|
303
|
+
rescue StandardError
|
316
304
|
nil
|
317
305
|
end
|
318
306
|
end
|
@@ -39,6 +39,7 @@ module Makit
|
|
39
39
|
# @!attribute [r] metadata
|
40
40
|
# @return [Hash] additional metadata for logging/tracking
|
41
41
|
attr_reader :command, :arguments, :environment, :directory, :timeout, :metadata
|
42
|
+
attr_writer :exit_on_failure, :show_stderr, :show_stdout
|
42
43
|
|
43
44
|
# Initialize a new command request.
|
44
45
|
#
|
@@ -56,7 +57,9 @@ module Makit
|
|
56
57
|
@directory = options[:directory] || Dir.pwd
|
57
58
|
@timeout = options[:timeout] || 30
|
58
59
|
@metadata = options[:metadata] || {}
|
59
|
-
|
60
|
+
@exit_on_failure = options[:exit_on_failure] || true
|
61
|
+
@show_stderr = options[:show_stderr] || true
|
62
|
+
@show_stdout = options[:show_stdout] || false
|
60
63
|
validate_directory(@directory)
|
61
64
|
validate_timeout(@timeout)
|
62
65
|
end
|
@@ -80,6 +83,9 @@ module Makit
|
|
80
83
|
directory: directory,
|
81
84
|
timeout: timeout,
|
82
85
|
metadata: metadata,
|
86
|
+
exit_on_failure: exit_on_failure?,
|
87
|
+
show_stderr: show_stderr?,
|
88
|
+
show_stdout: show_stdout?,
|
83
89
|
}
|
84
90
|
end
|
85
91
|
|
@@ -91,6 +97,10 @@ module Makit
|
|
91
97
|
JSON.generate(to_h, *args)
|
92
98
|
end
|
93
99
|
|
100
|
+
def to_json_pretty(*args)
|
101
|
+
JSON.pretty_generate(to_h, *args)
|
102
|
+
end
|
103
|
+
|
94
104
|
# Create a request from a shell command string.
|
95
105
|
#
|
96
106
|
# @param command_string [String] shell command string to parse
|
@@ -135,6 +145,9 @@ module Makit
|
|
135
145
|
directory: hash[:directory] || hash["directory"],
|
136
146
|
timeout: hash[:timeout] || hash["timeout"],
|
137
147
|
metadata: hash[:metadata] || hash["metadata"] || {},
|
148
|
+
exit_on_failure: hash[:exit_on_failure] || hash["exit_on_failure"],
|
149
|
+
show_stderr: hash[:show_stderr] || hash["show_stderr"],
|
150
|
+
show_stdout: hash[:show_stdout] || hash["show_stdout"],
|
138
151
|
)
|
139
152
|
end
|
140
153
|
|
@@ -170,6 +183,55 @@ module Makit
|
|
170
183
|
Digest::SHA256.hexdigest(content)[0..16]
|
171
184
|
end
|
172
185
|
|
186
|
+
def exit_on_failure?
|
187
|
+
@exit_on_failure
|
188
|
+
end
|
189
|
+
|
190
|
+
def exit_on_failure(exit_on_failure)
|
191
|
+
@exit_on_failure = exit_on_failure
|
192
|
+
self
|
193
|
+
end
|
194
|
+
|
195
|
+
def show_stderr?
|
196
|
+
@show_stderr
|
197
|
+
end
|
198
|
+
|
199
|
+
def show_stderr(show_stderr)
|
200
|
+
@show_stderr = show_stderr
|
201
|
+
self
|
202
|
+
end
|
203
|
+
|
204
|
+
def show_stdout?
|
205
|
+
@show_stdout
|
206
|
+
end
|
207
|
+
|
208
|
+
def show_stdout(show_stdout)
|
209
|
+
@show_stdout = show_stdout
|
210
|
+
self
|
211
|
+
end
|
212
|
+
|
213
|
+
# Execute the command.
|
214
|
+
#
|
215
|
+
# @return [Result] execution result
|
216
|
+
# @raise [ArgumentError] if runner is not set
|
217
|
+
def run
|
218
|
+
# self.exit_on_failure = exit_on_failure
|
219
|
+
# self.show_stderr = true
|
220
|
+
result = Makit::Commands::Runner.default.execute(show_stderr(true))
|
221
|
+
|
222
|
+
# Display stderr if the command failed and show_stderr is enabled
|
223
|
+
puts result.stderr if result.failure? && show_stderr? && !result.stderr.empty?
|
224
|
+
|
225
|
+
# Exit with the command's exit code if it failed and exit_on_failure is enabled
|
226
|
+
exit result.exit_code if result.failure? && exit_on_failure?
|
227
|
+
|
228
|
+
result
|
229
|
+
end
|
230
|
+
|
231
|
+
def try
|
232
|
+
Makit::Commands::Runner.default.execute(exit_on_failure(false))
|
233
|
+
end
|
234
|
+
|
173
235
|
private
|
174
236
|
|
175
237
|
# Validate command parameter.
|
@@ -4,7 +4,6 @@ require_relative "request"
|
|
4
4
|
require_relative "result"
|
5
5
|
require_relative "strategies/synchronous"
|
6
6
|
require_relative "middleware/base"
|
7
|
-
require_relative "middleware/unified_logger"
|
8
7
|
require_relative "middleware/command_logger"
|
9
8
|
|
10
9
|
module Makit
|
@@ -81,13 +80,27 @@ module Makit
|
|
81
80
|
# @return [Result] execution result
|
82
81
|
# @raise [ArgumentError] if request is invalid
|
83
82
|
def execute(request)
|
83
|
+
Makit::Logging.debug("Makit::Commands::Runner.execute starting")
|
84
|
+
# Makit::Logging.debug("Executing request: #{request.to_json_pretty}")
|
84
85
|
# Normalize request to Request object
|
85
86
|
normalized_request = normalize_request(request)
|
86
87
|
|
87
88
|
# Apply middleware chain
|
88
|
-
|
89
|
-
|
89
|
+
Makit::Logging.debug("Makit::Commands::Runner.execute applying middleware chain")
|
90
|
+
result = execute_with_middleware(normalized_request) do |processed_request|
|
91
|
+
Makit::Logging.debug("Makit::Commands::Runner.execute executing strategy")
|
92
|
+
result = @strategy.execute(processed_request)
|
93
|
+
Makit::Logging.debug("Makit::Commands::Runner.execute strategy returned result")
|
94
|
+
result
|
90
95
|
end
|
96
|
+
Makit::Logging.debug("Makit::Commands::Runner.execute returning result")
|
97
|
+
Makit::Logging.debug("Makit::Commands::Runner request.exit_on_failure?: #{request.exit_on_failure?}")
|
98
|
+
# stderr often contains warnings that we don't want to exit on
|
99
|
+
if request.exit_on_failure? && (result.failure?)
|
100
|
+
Makit::Logging.error("exiting with exit code: #{result.exit_code}")
|
101
|
+
exit result.exit_code
|
102
|
+
end
|
103
|
+
result
|
91
104
|
end
|
92
105
|
|
93
106
|
# Execute multiple command requests.
|
@@ -174,6 +187,9 @@ module Makit
|
|
174
187
|
# Execute chain
|
175
188
|
result = chain.call(request, &block)
|
176
189
|
|
190
|
+
# Log high-level success/error using the default logger
|
191
|
+
log_command_result(request, result)
|
192
|
+
|
177
193
|
# Update statistics
|
178
194
|
update_stats(result)
|
179
195
|
|
@@ -298,12 +314,47 @@ module Makit
|
|
298
314
|
raise ArgumentError, "Strategy must respond to #supports?: #{@strategy.class}"
|
299
315
|
end
|
300
316
|
|
317
|
+
# Log command execution result using the default logger.
|
318
|
+
#
|
319
|
+
# @param request [Request] the executed request
|
320
|
+
# @param result [Result] the execution result
|
321
|
+
# @return [void]
|
322
|
+
def log_command_result(request, result)
|
323
|
+
# Build the full command string
|
324
|
+
command_string = "#{request.command} #{request.arguments&.join(" ")}".strip
|
325
|
+
|
326
|
+
# Log success or error using the default logger
|
327
|
+
if result.success?
|
328
|
+
Makit::Logging.success(command_string)
|
329
|
+
else
|
330
|
+
Makit::Logging.error(command_string)
|
331
|
+
end
|
332
|
+
|
333
|
+
# Log the stdout, if there is an error or stdout is enabled
|
334
|
+
if result.failure? || request.show_stdout?
|
335
|
+
if (!result.stdout.empty?)
|
336
|
+
# split the stdout into lines and print each line
|
337
|
+
result.stdout.split("\n").each do |line|
|
338
|
+
Makit::Logging.info(line)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
# Log the stderr
|
344
|
+
return unless request.show_stderr? && !result.stderr.empty?
|
345
|
+
|
346
|
+
# split the stderr into lines and print each line
|
347
|
+
result.stderr.split("\n").each do |line|
|
348
|
+
Makit::Logging.info(line)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
301
352
|
# Log runner initialization for debugging.
|
302
353
|
#
|
303
354
|
# @return [void]
|
304
355
|
def log_runner_initialization
|
305
|
-
# Only log if we have a
|
306
|
-
logger_middleware = @middleware.find { |m| m.is_a?(Middleware::
|
356
|
+
# Only log if we have a command logger middleware
|
357
|
+
logger_middleware = @middleware.find { |m| m.is_a?(Middleware::CommandLogger) }
|
307
358
|
return unless logger_middleware
|
308
359
|
|
309
360
|
logger_middleware.logger.debug("Command runner initialized",
|
@@ -135,8 +135,19 @@ module Makit
|
|
135
135
|
# @param command [String] command to validate
|
136
136
|
# @return [Boolean] true if command is available
|
137
137
|
def command_available?(command)
|
138
|
-
|
139
|
-
|
138
|
+
# Skip validation for dotnet commands on Windows due to path issues
|
139
|
+
return true if command == "dotnet" && RUBY_PLATFORM.match?(/mswin|mingw/)
|
140
|
+
|
141
|
+
# Try Unix-style which first
|
142
|
+
return true if system("which #{command} > /dev/null 2>&1")
|
143
|
+
|
144
|
+
# Try Windows-style where with proper quoting
|
145
|
+
return true if system("where \"#{command}\" > nul 2>&1")
|
146
|
+
|
147
|
+
# Fallback: try to execute the command directly
|
148
|
+
system("#{command} --version > nul 2>&1") ||
|
149
|
+
system("#{command} --help > nul 2>&1") ||
|
150
|
+
system("#{command} /? > nul 2>&1")
|
140
151
|
end
|
141
152
|
|
142
153
|
# Get the full path to a command.
|
@@ -24,7 +24,7 @@ module Makit
|
|
24
24
|
# @option options [Boolean] :validate_commands (true) whether to validate commands exist
|
25
25
|
# @option options [Integer] :max_output_size (1048576) maximum output size in bytes
|
26
26
|
def initialize(**options)
|
27
|
-
@validate_commands =
|
27
|
+
@validate_commands = false # Always disable validation to avoid path issues
|
28
28
|
@max_output_size = options.fetch(:max_output_size, 1024 * 1024) # 1MB default
|
29
29
|
end
|
30
30
|
|
@@ -36,10 +36,15 @@ module Makit
|
|
36
36
|
# Skip command validation for basic commands like echo on Windows
|
37
37
|
# This is a simplified approach for demonstration purposes
|
38
38
|
if @validate_commands && !basic_command?(request.command) && !command_available?(request.command)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
# For dotnet commands, try to execute anyway as validation might be unreliable
|
40
|
+
if request.command == "dotnet"
|
41
|
+
Makit::Logging.debug("Skipping validation for dotnet command due to potential path issues")
|
42
|
+
else
|
43
|
+
return Result.failure(
|
44
|
+
command: request.to_shell_command,
|
45
|
+
error: "Command not found: #{request.command}",
|
46
|
+
)
|
47
|
+
end
|
43
48
|
end
|
44
49
|
|
45
50
|
# Execute using Open3 for cross-platform support
|
@@ -118,7 +123,7 @@ module Makit
|
|
118
123
|
# @param command [String] command name
|
119
124
|
# @return [Boolean] true if it's a basic command
|
120
125
|
def basic_command?(command)
|
121
|
-
%w[echo ruby bundle rake git].include?(command)
|
126
|
+
%w[echo ruby bundle rake git dotnet].include?(command)
|
122
127
|
end
|
123
128
|
|
124
129
|
# Check if execution should stop on first failure.
|
data/lib/makit/commands.rb
CHANGED
@@ -39,4 +39,12 @@ end
|
|
39
39
|
|
40
40
|
# Load command system components (load existing components only)
|
41
41
|
require_relative "commands/result"
|
42
|
+
require_relative "commands/request"
|
43
|
+
require_relative "commands/runner"
|
44
|
+
require_relative "commands/factory"
|
42
45
|
require_relative "commands/middleware/validator"
|
46
|
+
require_relative "commands/middleware/cache"
|
47
|
+
require_relative "commands/middleware/command_logger"
|
48
|
+
require_relative "commands/middleware/base"
|
49
|
+
require_relative "commands/strategies/base"
|
50
|
+
require_relative "commands/strategies/synchronous"
|
@@ -6,7 +6,7 @@ module Makit
|
|
6
6
|
module Configuration
|
7
7
|
# Project configuration management
|
8
8
|
class Project
|
9
|
-
attr_accessor :git_remote_url, :name, :version, :project_type, :steps
|
9
|
+
attr_accessor :git_remote_url, :name, :version, :project_type, :steps, :authors, :description, :license_expression
|
10
10
|
|
11
11
|
def initialize(name, version = nil, project_type = nil)
|
12
12
|
# Support both keyword arguments and positional arguments for compatibility
|
@@ -21,12 +21,15 @@ module Makit
|
|
21
21
|
@version = version
|
22
22
|
@project_type = project_type
|
23
23
|
end
|
24
|
-
|
24
|
+
@authors = "authors"
|
25
|
+
@description = "description"
|
26
|
+
@license_expression = "MIT"
|
25
27
|
@steps = []
|
26
28
|
end
|
27
29
|
|
28
30
|
def add_step(step)
|
29
31
|
raise ArgumentError, "Step must be a Makit::Configuration::Step instance" unless step.is_a?(Step)
|
32
|
+
|
30
33
|
@steps << step
|
31
34
|
end
|
32
35
|
|
@@ -35,17 +38,23 @@ module Makit
|
|
35
38
|
name: @name,
|
36
39
|
version: @version,
|
37
40
|
project_type: @project_type,
|
41
|
+
authors: @authors,
|
42
|
+
description: @description,
|
43
|
+
license_expression: @license_expression,
|
38
44
|
steps: @steps.map(&:to_h),
|
39
45
|
}.to_json(*args)
|
40
46
|
end
|
41
47
|
|
42
48
|
def to_json_pretty
|
43
49
|
JSON.pretty_generate({
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
50
|
+
name: @name,
|
51
|
+
version: @version,
|
52
|
+
project_type: @project_type,
|
53
|
+
authors: @authors,
|
54
|
+
description: @description,
|
55
|
+
license_expression: @license_expression,
|
56
|
+
steps: @steps.map(&:to_h),
|
57
|
+
})
|
49
58
|
end
|
50
59
|
|
51
60
|
def self.from_json(path)
|
@@ -53,6 +62,12 @@ module Makit
|
|
53
62
|
data = JSON.parse(content, symbolize_names: true)
|
54
63
|
|
55
64
|
project = new(data[:name], data[:version], data[:project_type])
|
65
|
+
|
66
|
+
# Set additional fields if they exist in the JSON
|
67
|
+
project.authors = data[:authors] if data[:authors]
|
68
|
+
project.description = data[:description] if data[:description]
|
69
|
+
project.license_expression = data[:license_expression] if data[:license_expression]
|
70
|
+
|
56
71
|
data[:steps].each do |step_data|
|
57
72
|
step = Step.new(
|
58
73
|
name: step_data[:name],
|
@@ -70,6 +85,12 @@ module Makit
|
|
70
85
|
data = JSON.parse(json_string, symbolize_names: true)
|
71
86
|
|
72
87
|
project = new(data[:name], data[:version], data[:project_type])
|
88
|
+
|
89
|
+
# Set additional fields if they exist in the JSON
|
90
|
+
project.authors = data[:authors] if data[:authors]
|
91
|
+
project.description = data[:description] if data[:description]
|
92
|
+
project.license_expression = data[:license_expression] if data[:license_expression]
|
93
|
+
|
73
94
|
data[:steps].each do |step_data|
|
74
95
|
step = Step.new(
|
75
96
|
name: step_data[:name],
|
@@ -92,10 +113,20 @@ module Makit
|
|
92
113
|
|
93
114
|
# Save the project to a specific path as pretty JSON
|
94
115
|
def save_as(path)
|
116
|
+
# Validate that the project has a non-empty name before saving
|
117
|
+
if @name.nil? || @name.strip.empty?
|
118
|
+
raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
|
119
|
+
end
|
120
|
+
|
95
121
|
File.write(path, to_json_pretty)
|
96
122
|
end
|
97
123
|
|
98
124
|
def save
|
125
|
+
# Validate that the project has a non-empty name before saving
|
126
|
+
if @name.nil? || @name.strip.empty?
|
127
|
+
raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
|
128
|
+
end
|
129
|
+
|
99
130
|
save_as(".makit.json")
|
100
131
|
end
|
101
132
|
|
@@ -119,7 +150,16 @@ module Makit
|
|
119
150
|
if File.exist?(".makit.json")
|
120
151
|
from_json(".makit.json")
|
121
152
|
else
|
122
|
-
|
153
|
+
# Makit::Logging.default_logger.warn("Project not configured")
|
154
|
+
# #if defined?(NAME) && defined?(VERSION) && defined?(PROJECT_TYPE)
|
155
|
+
# project = new(name: NAME, version: VERSION, project_type: PROJECT_TYPE)
|
156
|
+
# project.save
|
157
|
+
# else
|
158
|
+
project = new(name: "", version: "0.0.0", project_type: "")
|
159
|
+
Makit::Logging.default_logger.warn("Project not configured")
|
160
|
+
# Makit::Logging.default_logger.warn("Define NAME, VERSION, and PROJECT_TYPE in the Rakefile")
|
161
|
+
# end
|
162
|
+
project
|
123
163
|
end
|
124
164
|
end
|
125
165
|
end
|
@@ -25,9 +25,9 @@ module Makit
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def validate_commands
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
return if @commands.is_a?(Array) && @commands.all? { |cmd| cmd.is_a?(String) }
|
29
|
+
|
30
|
+
raise ArgumentError, "Commands must be an array of strings"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|