makit 0.0.143 → 0.0.145

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/makit/cli/base.rb +17 -0
  3. data/lib/makit/cli/generators/templates/ruby/gemspec.rb +1 -0
  4. data/lib/makit/cli/main.rb +9 -0
  5. data/lib/makit/cli/pipeline_commands.rb +311 -0
  6. data/lib/makit/cli/strategy_commands.rb +2 -7
  7. data/lib/makit/commands/result.rb +1 -1
  8. data/lib/makit/configuration/dotnet_project.rb +9 -0
  9. data/lib/makit/configuration/gitlab_helper.rb +4 -1
  10. data/lib/makit/configuration/project.rb +362 -84
  11. data/lib/makit/configuration/timeout.rb +1 -1
  12. data/lib/makit/configuration.rb +5 -0
  13. data/lib/makit/fileinfo.rb +8 -0
  14. data/lib/makit/git/repository.rb +207 -31
  15. data/lib/makit/git.rb +6 -0
  16. data/lib/makit/gitlab/pipeline.rb +857 -0
  17. data/lib/makit/gitlab/pipeline_service_impl.rb +1536 -0
  18. data/lib/makit/humanize.rb +81 -0
  19. data/lib/makit/io/filesystem.rb +111 -0
  20. data/lib/makit/io/filesystem_service_impl.rb +337 -0
  21. data/lib/makit/mp/string_mp.rb +15 -9
  22. data/lib/makit/podman/podman.rb +458 -0
  23. data/lib/makit/podman/podman_service_impl.rb +1081 -0
  24. data/lib/makit/process.rb +214 -0
  25. data/lib/makit/protoc.rb +6 -1
  26. data/lib/makit/services/repository_manager.rb +268 -132
  27. data/lib/makit/symbols.rb +5 -0
  28. data/lib/makit/v1/configuration/project_service_impl.rb +371 -0
  29. data/lib/makit/v1/git/git_repository_service_impl.rb +295 -0
  30. data/lib/makit/v1/makit.v1_pb.rb +1 -1
  31. data/lib/makit/v1/makit.v1_services_pb.rb +1 -1
  32. data/lib/makit/v1/services/repository_manager_service_impl.rb +572 -0
  33. data/lib/makit/version.rb +1 -1
  34. data/lib/makit.rb +68 -0
  35. metadata +61 -36
@@ -2,14 +2,26 @@
2
2
 
3
3
  require "json"
4
4
 
5
+ # Only load gRPC service implementation if generated files exist
6
+ if File.exist?(File.join(__dir__, "..", "..", "generated", "makit", "v1", "configuration", "project_service_services_pb.rb"))
7
+ require_relative "../v1/configuration/project_service_impl"
8
+ end
9
+
5
10
  module Makit
6
11
  module Configuration
7
- # Project configuration management
12
+ # Project configuration management - Phase 3: Routes calls to gRPC service
8
13
  class Project
9
14
  attr_accessor :git_remote_url, :name, :version, :project_type, :steps, :authors, :description, :license_expression
10
15
  attr_accessor :dotnet_projects
11
16
 
12
17
  def initialize(name, version = nil, project_type = nil)
18
+ # Check if gRPC service is available
19
+ @grpc_available = defined?(Makit::V1::Configuration::ProjectServiceImpl)
20
+
21
+ if @grpc_available
22
+ @grpc_service = Makit::V1::Configuration::ProjectServiceImpl.new
23
+ end
24
+
13
25
  # Support both keyword arguments and positional arguments for compatibility
14
26
  if name.is_a?(Hash)
15
27
  # Keyword arguments: Project.new(name: "test", version: "1.0.0")
@@ -22,94 +34,237 @@ module Makit
22
34
  @version = version
23
35
  @project_type = project_type
24
36
  end
25
- @authors = "authors"
26
- @description = "description"
27
- @license_expression = "MIT"
28
- @steps = []
37
+
38
+ if @grpc_available
39
+ # Create project via gRPC service (handle empty names)
40
+ if @name && !@name.strip.empty?
41
+ create_request = Makit::V1::Configuration::CreateProjectRequest.new(
42
+ name: @name,
43
+ version: @version || "0.0.0",
44
+ project_type: @project_type || "gem"
45
+ )
46
+ @proto_model = @grpc_service.create_project(create_request, nil)
47
+ else
48
+ # Create empty project directly (bypass gRPC validation for empty names)
49
+ @proto_model = Makit::V1::Configuration::Project.new(
50
+ name: @name || "",
51
+ version: @version || "0.0.0",
52
+ project_type: @project_type || "",
53
+ authors: "authors",
54
+ description: "description",
55
+ license_expression: "MIT",
56
+ steps: []
57
+ )
58
+ end
59
+
60
+ # Initialize Ruby attributes for backward compatibility
61
+ @authors = @proto_model.authors
62
+ @description = @proto_model.description
63
+ @license_expression = @proto_model.license_expression
64
+ @steps = convert_steps_from_proto(@proto_model.steps)
65
+ @git_remote_url = @proto_model.git_remote_url
66
+ @dotnet_projects = @proto_model.dotnet_projects.to_a
67
+ else
68
+ # Fallback implementation when gRPC is not available
69
+ @name = @name || ""
70
+ @version = @version || "0.0.0"
71
+ @project_type = @project_type || ""
72
+ @authors = "authors"
73
+ @description = "description"
74
+ @license_expression = "MIT"
75
+ @steps = []
76
+ @git_remote_url = ""
77
+ @dotnet_projects = []
78
+ end
29
79
  end
30
80
 
31
81
  def add_step(step)
32
82
  raise ArgumentError, "Step must be a Makit::Configuration::Step instance" unless step.is_a?(Step)
33
83
 
84
+ if @grpc_available
85
+ # Add step to Protobuf model
86
+ proto_step = Makit::V1::Configuration::Step.new(
87
+ name: step.name,
88
+ description: step.description,
89
+ commands: step.commands
90
+ )
91
+ @proto_model.steps << proto_step
92
+ end
93
+
94
+ # Update Ruby attribute for backward compatibility
34
95
  @steps << step
35
96
  end
36
97
 
37
98
  def to_json(*args)
38
- {
39
- name: @name,
40
- version: @version,
41
- project_type: @project_type,
42
- authors: @authors,
43
- description: @description,
44
- license_expression: @license_expression,
45
- steps: @steps.map(&:to_h),
46
- }.to_json(*args)
99
+ if @grpc_available
100
+ # Use gRPC service to convert to JSON
101
+ project_data = {
102
+ name: @proto_model.name,
103
+ version: @proto_model.version,
104
+ project_type: @proto_model.project_type,
105
+ authors: @proto_model.authors,
106
+ description: @proto_model.description,
107
+ license_expression: @proto_model.license_expression,
108
+ steps: @proto_model.steps.map do |step|
109
+ {
110
+ name: step.name,
111
+ description: step.description,
112
+ commands: step.commands.to_a
113
+ }
114
+ end
115
+ }
116
+ else
117
+ # Fallback implementation
118
+ project_data = {
119
+ name: @name,
120
+ version: @version,
121
+ project_type: @project_type,
122
+ authors: @authors,
123
+ description: @description,
124
+ license_expression: @license_expression,
125
+ steps: @steps.map do |step|
126
+ {
127
+ name: step.name,
128
+ description: step.description,
129
+ commands: step.commands
130
+ }
131
+ end
132
+ }
133
+ end
134
+ project_data.to_json(*args)
47
135
  end
48
136
 
49
137
  def to_json_pretty
50
- JSON.pretty_generate({
51
- name: @name,
52
- version: @version,
53
- project_type: @project_type,
54
- authors: @authors,
55
- description: @description,
56
- license_expression: @license_expression,
57
- steps: @steps.map(&:to_h),
58
- })
138
+ if @grpc_available
139
+ # Use gRPC service to convert to pretty JSON
140
+ project_data = {
141
+ name: @proto_model.name,
142
+ version: @proto_model.version,
143
+ project_type: @proto_model.project_type,
144
+ authors: @proto_model.authors,
145
+ description: @proto_model.description,
146
+ license_expression: @proto_model.license_expression,
147
+ steps: @proto_model.steps.map do |step|
148
+ {
149
+ name: step.name,
150
+ description: step.description,
151
+ commands: step.commands.to_a
152
+ }
153
+ end
154
+ }
155
+ else
156
+ # Fallback implementation
157
+ project_data = {
158
+ name: @name,
159
+ version: @version,
160
+ project_type: @project_type,
161
+ authors: @authors,
162
+ description: @description,
163
+ license_expression: @license_expression,
164
+ steps: @steps.map do |step|
165
+ {
166
+ name: step.name,
167
+ description: step.description,
168
+ commands: step.commands
169
+ }
170
+ end
171
+ }
172
+ end
173
+ JSON.pretty_generate(project_data)
59
174
  end
60
175
 
61
176
  def self.from_json(path)
62
- content = File.read(path)
63
- data = JSON.parse(content, symbolize_names: true)
64
-
65
- project = new(data[:name], data[:version], data[:project_type])
66
-
67
- # Set additional fields if they exist in the JSON
68
- project.authors = data[:authors] if data[:authors]
69
- project.description = data[:description] if data[:description]
70
- project.license_expression = data[:license_expression] if data[:license_expression]
71
-
72
- data[:steps].each do |step_data|
73
- step = Step.new(
74
- name: step_data[:name],
75
- description: step_data[:description],
76
- commands: step_data[:commands],
77
- )
78
- project.add_step(step)
177
+ if defined?(Makit::V1::Configuration::ProjectServiceImpl)
178
+ # Use gRPC service to load from file
179
+ grpc_service = Makit::V1::Configuration::ProjectServiceImpl.new
180
+ request = Makit::V1::Configuration::LoadFromFileRequest.new(path: path)
181
+ proto_model = grpc_service.load_from_file(request, nil)
182
+
183
+ # Convert Protobuf model to Ruby object
184
+ convert_from_proto_model(proto_model)
185
+ else
186
+ # Fallback implementation
187
+ content = File.read(path)
188
+ data = JSON.parse(content, symbolize_names: true)
189
+ new(data[:name], data[:version], data[:project_type]).tap do |project|
190
+ project.authors = data[:authors] || "authors"
191
+ project.description = data[:description] || "description"
192
+ project.license_expression = data[:license_expression] || "MIT"
193
+ project.git_remote_url = data[:git_remote_url] || ""
194
+ project.dotnet_projects = data[:dotnet_projects] || []
195
+
196
+ # Load steps
197
+ (data[:steps] || []).each do |step_data|
198
+ step = Step.new(
199
+ name: step_data[:name] || "",
200
+ description: step_data[:description] || "",
201
+ commands: step_data[:commands] || []
202
+ )
203
+ project.steps << step
204
+ end
205
+ end
79
206
  end
80
-
81
- project
82
207
  end
83
208
 
84
209
  # Class method for deserializing from JSON string (used by serializer)
85
210
  def self.decode_json(json_string)
86
- data = JSON.parse(json_string, symbolize_names: true)
87
-
88
- project = new(data[:name], data[:version], data[:project_type])
89
-
90
- # Set additional fields if they exist in the JSON
91
- project.authors = data[:authors] if data[:authors]
92
- project.description = data[:description] if data[:description]
93
- project.license_expression = data[:license_expression] if data[:license_expression]
94
-
95
- data[:steps].each do |step_data|
96
- step = Step.new(
97
- name: step_data[:name],
98
- description: step_data[:description],
99
- commands: step_data[:commands],
100
- )
101
- project.add_step(step)
211
+ if defined?(Makit::V1::Configuration::ProjectServiceImpl)
212
+ # Use gRPC service to load from JSON string
213
+ grpc_service = Makit::V1::Configuration::ProjectServiceImpl.new
214
+ request = Makit::V1::Configuration::LoadFromJsonRequest.new(json_string: json_string)
215
+ proto_model = grpc_service.load_from_json(request, nil)
216
+
217
+ # Convert Protobuf model to Ruby object
218
+ convert_from_proto_model(proto_model)
219
+ else
220
+ # Fallback implementation
221
+ data = JSON.parse(json_string, symbolize_names: true)
222
+ new(data[:name], data[:version], data[:project_type]).tap do |project|
223
+ project.authors = data[:authors] || "authors"
224
+ project.description = data[:description] || "description"
225
+ project.license_expression = data[:license_expression] || "MIT"
226
+ project.git_remote_url = data[:git_remote_url] || ""
227
+ project.dotnet_projects = data[:dotnet_projects] || []
228
+
229
+ # Load steps
230
+ (data[:steps] || []).each do |step_data|
231
+ step = Step.new(
232
+ name: step_data[:name] || "",
233
+ description: step_data[:description] || "",
234
+ commands: step_data[:commands] || []
235
+ )
236
+ project.steps << step
237
+ end
238
+ end
102
239
  end
103
-
104
- project
105
240
  end
106
241
 
107
242
  def to_gitlab_ci(path)
108
- GitLabHelper.to_yaml(self, path)
243
+ if @grpc_available
244
+ # Use gRPC service to generate GitLab CI
245
+ request = Makit::V1::Configuration::GenerateGitlabCiRequest.new(
246
+ project: @proto_model,
247
+ path: path
248
+ )
249
+ @grpc_service.generate_gitlab_ci(request, nil)
250
+ else
251
+ # Fallback implementation - just create a basic GitLab CI file
252
+ require_relative "gitlab_helper"
253
+ Makit::Configuration::GitLabHelper.to_yaml(self, path)
254
+ end
109
255
  end
110
256
 
111
257
  def to_rakefile
112
- RakefileHelper.generate(self)
258
+ if @grpc_available
259
+ # Use gRPC service to generate Rakefile
260
+ request = Makit::V1::Configuration::GenerateRakefileRequest.new(project: @proto_model)
261
+ response = @grpc_service.generate_rakefile(request, nil)
262
+ response.content
263
+ else
264
+ # Fallback implementation
265
+ require_relative "rakefile_helper"
266
+ Makit::Configuration::RakefileHelper.generate(self)
267
+ end
113
268
  end
114
269
 
115
270
  # Save the project to a specific path as pretty JSON
@@ -119,7 +274,17 @@ module Makit
119
274
  raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
120
275
  end
121
276
 
122
- File.write(path, to_json_pretty)
277
+ if @grpc_available
278
+ # Use gRPC service to save to file
279
+ request = Makit::V1::Configuration::SaveToFileRequest.new(
280
+ project: @proto_model,
281
+ path: path
282
+ )
283
+ @grpc_service.save_to_file(request, nil)
284
+ else
285
+ # Fallback implementation
286
+ File.write(path, to_json_pretty)
287
+ end
123
288
  end
124
289
 
125
290
  def save
@@ -128,41 +293,154 @@ module Makit
128
293
  raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
129
294
  end
130
295
 
131
- save_as(".makit.json")
296
+ if @grpc_available
297
+ # Use gRPC service to save to default location
298
+ request = Makit::V1::Configuration::SaveToDefaultRequest.new(project: @proto_model)
299
+ @grpc_service.save_to_default(request, nil)
300
+ else
301
+ # Fallback implementation
302
+ File.write(".makit.json", to_json_pretty)
303
+ end
132
304
  end
133
305
 
134
306
  # Display the project configuration in YAML format
135
307
  def show
136
308
  require "yaml"
137
309
 
138
- project_data = {
139
- name: @name,
140
- version: @version,
141
- project_type: @project_type,
142
- git_remote_url: @git_remote_url,
143
- steps: @steps.map(&:to_h),
144
- }
310
+ if @grpc_available
311
+ project_data = {
312
+ name: @proto_model.name,
313
+ version: @proto_model.version,
314
+ project_type: @proto_model.project_type,
315
+ git_remote_url: @proto_model.git_remote_url,
316
+ steps: @proto_model.steps.map do |step|
317
+ {
318
+ name: step.name,
319
+ description: step.description,
320
+ commands: step.commands.to_a
321
+ }
322
+ end
323
+ }
324
+ else
325
+ project_data = {
326
+ name: @name,
327
+ version: @version,
328
+ project_type: @project_type,
329
+ git_remote_url: @git_remote_url,
330
+ steps: @steps.map do |step|
331
+ {
332
+ name: step.name,
333
+ description: step.description,
334
+ commands: step.commands
335
+ }
336
+ end
337
+ }
338
+ end
145
339
 
146
340
  puts YAML.dump(project_data)
147
341
  end
148
342
 
149
343
  # Load a project from the default .makit.json file
150
344
  def self.default
151
- if File.exist?(".makit.json")
152
- from_json(".makit.json")
345
+ if defined?(Makit::V1::Configuration::ProjectServiceImpl)
346
+ # Use gRPC service to load default project
347
+ grpc_service = Makit::V1::Configuration::ProjectServiceImpl.new
348
+ request = Google::Protobuf::Empty.new
349
+ proto_model = grpc_service.load_default(request, nil)
350
+
351
+ # Convert Protobuf model to Ruby object
352
+ convert_from_proto_model(proto_model)
153
353
  else
154
- # Makit::Logging.default_logger.warn("Project not configured")
155
- # #if defined?(NAME) && defined?(VERSION) && defined?(PROJECT_TYPE)
156
- # project = new(name: NAME, version: VERSION, project_type: PROJECT_TYPE)
157
- # project.save
158
- # else
159
- project = new(name: "", version: "0.0.0", project_type: "")
160
- Makit::Logging.default_logger.warn("Project not configured")
161
- # Makit::Logging.default_logger.warn("Define NAME, VERSION, and PROJECT_TYPE in the Rakefile")
162
- # end
163
- project
354
+ # Fallback implementation
355
+ if File.exist?(".makit.json")
356
+ from_json(".makit.json")
357
+ else
358
+ new("", "0.0.0", "")
359
+ end
360
+ end
361
+ end
362
+
363
+ # Update project attributes
364
+ def name=(value)
365
+ @name = value
366
+ update_proto_attribute(:name, value) if @grpc_available
367
+ end
368
+
369
+ def version=(value)
370
+ @version = value
371
+ update_proto_attribute(:version, value) if @grpc_available
372
+ end
373
+
374
+ def project_type=(value)
375
+ @project_type = value
376
+ update_proto_attribute(:project_type, value) if @grpc_available
377
+ end
378
+
379
+ def authors=(value)
380
+ @authors = value
381
+ update_proto_attribute(:authors, value) if @grpc_available
382
+ end
383
+
384
+ def description=(value)
385
+ @description = value
386
+ update_proto_attribute(:description, value) if @grpc_available
387
+ end
388
+
389
+ def license_expression=(value)
390
+ @license_expression = value
391
+ update_proto_attribute(:license_expression, value) if @grpc_available
392
+ end
393
+
394
+ def git_remote_url=(value)
395
+ @git_remote_url = value
396
+ update_proto_attribute(:git_remote_url, value) if @grpc_available
397
+ end
398
+
399
+ def dotnet_projects=(value)
400
+ @dotnet_projects = value
401
+ @proto_model.dotnet_projects.replace(value || []) if @grpc_available
402
+ end
403
+
404
+ private
405
+
406
+ # Convert Protobuf model to Ruby Project object
407
+ def self.convert_from_proto_model(proto_model)
408
+ project = new(proto_model.name, proto_model.version, proto_model.project_type)
409
+
410
+ # Update all attributes from Protobuf model
411
+ project.instance_variable_set(:@proto_model, proto_model)
412
+ project.instance_variable_set(:@authors, proto_model.authors)
413
+ project.instance_variable_set(:@description, proto_model.description)
414
+ project.instance_variable_set(:@license_expression, proto_model.license_expression)
415
+ project.instance_variable_set(:@git_remote_url, proto_model.git_remote_url)
416
+ project.instance_variable_set(:@dotnet_projects, proto_model.dotnet_projects.to_a)
417
+ project.instance_variable_set(:@steps, project.send(:convert_steps_from_proto, proto_model.steps))
418
+
419
+ project
420
+ end
421
+
422
+ # Convert Protobuf steps to Ruby Step objects
423
+ def convert_steps_from_proto(proto_steps)
424
+ return [] unless @grpc_available
425
+ proto_steps.map do |proto_step|
426
+ Step.new(
427
+ name: proto_step.name,
428
+ description: proto_step.description,
429
+ commands: proto_step.commands.to_a
430
+ )
164
431
  end
165
432
  end
433
+
434
+ # Update a single attribute in the Protobuf model
435
+ def update_proto_attribute(attribute, value)
436
+ return unless @grpc_available
437
+ updates = { attribute.to_s => value }
438
+ request = Makit::V1::Configuration::UpdateProjectRequest.new(
439
+ project: @proto_model,
440
+ updates: updates
441
+ )
442
+ @proto_model = @grpc_service.update_project(request, nil)
443
+ end
166
444
  end
167
445
  end
168
- end
446
+ end
@@ -7,7 +7,7 @@ module Makit
7
7
  # Default timeout values for different operations
8
8
  DEFAULTS = {
9
9
  # Command execution timeouts
10
- command: 30,
10
+ command: 120,
11
11
  git_clone: 300,
12
12
  git_pull: 120,
13
13
  bundle_install: 300,
@@ -8,6 +8,11 @@ require_relative "configuration/gitlab_helper"
8
8
  require_relative "configuration/rakefile_helper"
9
9
  require_relative "configuration/timeout"
10
10
 
11
+ # Load gRPC service implementation only if generated files exist
12
+ if File.exist?(File.join(__dir__, "generated", "makit", "v1", "configuration", "project_service_services_pb.rb"))
13
+ require_relative "v1/configuration/project_service_impl"
14
+ end
15
+
11
16
  # Main configuration module that loads all configuration classes
12
17
  module Makit
13
18
  module Configuration
@@ -13,6 +13,14 @@ module Makit
13
13
  @size = size
14
14
  end
15
15
 
16
+ def to_h
17
+ {
18
+ name: @name,
19
+ mtime: @mtime,
20
+ size: @size
21
+ }
22
+ end
23
+
16
24
  def self.get_file_infos(filenames)
17
25
  filenames.map do |filename|
18
26
  FileInfo.new(name: filename, mtime: File.mtime(filename), size: File.size(filename))