makit 0.0.144 → 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 (165) 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/auto.rb +48 -48
  6. data/lib/makit/cli/base.rb +17 -0
  7. data/lib/makit/cli/build_commands.rb +500 -500
  8. data/lib/makit/cli/generators/base_generator.rb +74 -74
  9. data/lib/makit/cli/generators/dotnet_generator.rb +50 -50
  10. data/lib/makit/cli/generators/generator_factory.rb +49 -49
  11. data/lib/makit/cli/generators/node_generator.rb +50 -50
  12. data/lib/makit/cli/generators/ruby_generator.rb +77 -77
  13. data/lib/makit/cli/generators/rust_generator.rb +50 -50
  14. data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -167
  15. data/lib/makit/cli/generators/templates/node_templates.rb +161 -161
  16. data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -26
  17. data/lib/makit/cli/generators/templates/ruby/gemspec.rb +41 -40
  18. data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -33
  19. data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -35
  20. data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -63
  21. data/lib/makit/cli/generators/templates/ruby/test.rb +39 -39
  22. data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -29
  23. data/lib/makit/cli/generators/templates/ruby/version.rb +29 -29
  24. data/lib/makit/cli/generators/templates/rust_templates.rb +128 -128
  25. data/lib/makit/cli/main.rb +78 -69
  26. data/lib/makit/cli/pipeline_commands.rb +311 -0
  27. data/lib/makit/cli/project_commands.rb +868 -868
  28. data/lib/makit/cli/repository_commands.rb +661 -661
  29. data/lib/makit/cli/strategy_commands.rb +207 -212
  30. data/lib/makit/cli/utility_commands.rb +521 -521
  31. data/lib/makit/commands/factory.rb +359 -359
  32. data/lib/makit/commands/middleware/base.rb +73 -73
  33. data/lib/makit/commands/middleware/cache.rb +248 -248
  34. data/lib/makit/commands/middleware/command_logger.rb +312 -312
  35. data/lib/makit/commands/middleware/validator.rb +269 -269
  36. data/lib/makit/commands/request.rb +316 -316
  37. data/lib/makit/commands/result.rb +323 -323
  38. data/lib/makit/commands/runner.rb +386 -386
  39. data/lib/makit/commands/strategies/base.rb +171 -171
  40. data/lib/makit/commands/strategies/child_process.rb +162 -162
  41. data/lib/makit/commands/strategies/factory.rb +136 -136
  42. data/lib/makit/commands/strategies/synchronous.rb +139 -139
  43. data/lib/makit/commands.rb +50 -50
  44. data/lib/makit/configuration/dotnet_project.rb +48 -48
  45. data/lib/makit/configuration/gitlab_helper.rb +61 -58
  46. data/lib/makit/configuration/project.rb +446 -168
  47. data/lib/makit/configuration/rakefile_helper.rb +43 -43
  48. data/lib/makit/configuration/step.rb +34 -34
  49. data/lib/makit/configuration/timeout.rb +74 -74
  50. data/lib/makit/configuration.rb +21 -16
  51. data/lib/makit/content/default_gitignore.rb +7 -7
  52. data/lib/makit/content/default_gitignore.txt +225 -225
  53. data/lib/makit/content/default_rakefile.rb +13 -13
  54. data/lib/makit/content/gem_rakefile.rb +16 -16
  55. data/lib/makit/context.rb +1 -1
  56. data/lib/makit/data.rb +49 -49
  57. data/lib/makit/directories.rb +140 -140
  58. data/lib/makit/directory.rb +262 -262
  59. data/lib/makit/docs/files.rb +89 -89
  60. data/lib/makit/docs/rake.rb +102 -102
  61. data/lib/makit/dotnet/cli.rb +69 -69
  62. data/lib/makit/dotnet/project.rb +217 -217
  63. data/lib/makit/dotnet/solution.rb +38 -38
  64. data/lib/makit/dotnet/solution_classlib.rb +239 -239
  65. data/lib/makit/dotnet/solution_console.rb +264 -264
  66. data/lib/makit/dotnet/solution_maui.rb +354 -354
  67. data/lib/makit/dotnet/solution_wasm.rb +275 -275
  68. data/lib/makit/dotnet/solution_wpf.rb +304 -304
  69. data/lib/makit/dotnet.rb +102 -102
  70. data/lib/makit/email.rb +90 -90
  71. data/lib/makit/environment.rb +142 -142
  72. data/lib/makit/examples/runner.rb +370 -370
  73. data/lib/makit/exceptions.rb +45 -45
  74. data/lib/makit/fileinfo.rb +32 -24
  75. data/lib/makit/files.rb +43 -43
  76. data/lib/makit/gems.rb +40 -40
  77. data/lib/makit/git/cli.rb +54 -54
  78. data/lib/makit/git/repository.rb +266 -90
  79. data/lib/makit/git.rb +104 -98
  80. data/lib/makit/gitlab/pipeline.rb +857 -0
  81. data/lib/makit/gitlab/pipeline_service_impl.rb +1536 -0
  82. data/lib/makit/gitlab_runner.rb +59 -59
  83. data/lib/makit/humanize.rb +218 -137
  84. data/lib/makit/indexer.rb +47 -47
  85. data/lib/makit/io/filesystem.rb +111 -0
  86. data/lib/makit/io/filesystem_service_impl.rb +337 -0
  87. data/lib/makit/logging/configuration.rb +308 -308
  88. data/lib/makit/logging/format_registry.rb +84 -84
  89. data/lib/makit/logging/formatters/base.rb +39 -39
  90. data/lib/makit/logging/formatters/console_formatter.rb +140 -140
  91. data/lib/makit/logging/formatters/json_formatter.rb +65 -65
  92. data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -71
  93. data/lib/makit/logging/formatters/text_formatter.rb +64 -64
  94. data/lib/makit/logging/log_request.rb +119 -119
  95. data/lib/makit/logging/logger.rb +199 -199
  96. data/lib/makit/logging/sinks/base.rb +91 -91
  97. data/lib/makit/logging/sinks/console.rb +72 -72
  98. data/lib/makit/logging/sinks/file_sink.rb +92 -92
  99. data/lib/makit/logging/sinks/structured.rb +123 -123
  100. data/lib/makit/logging/sinks/unified_file_sink.rb +296 -296
  101. data/lib/makit/logging.rb +565 -565
  102. data/lib/makit/markdown.rb +75 -75
  103. data/lib/makit/mp/basic_object_mp.rb +17 -17
  104. data/lib/makit/mp/command_mp.rb +13 -13
  105. data/lib/makit/mp/command_request.mp.rb +17 -17
  106. data/lib/makit/mp/project_mp.rb +199 -199
  107. data/lib/makit/mp/string_mp.rb +205 -199
  108. data/lib/makit/nuget.rb +74 -74
  109. data/lib/makit/podman/podman.rb +458 -0
  110. data/lib/makit/podman/podman_service_impl.rb +1081 -0
  111. data/lib/makit/port.rb +32 -32
  112. data/lib/makit/process.rb +377 -377
  113. data/lib/makit/protoc.rb +112 -107
  114. data/lib/makit/rake/cli.rb +196 -196
  115. data/lib/makit/rake/trace_controller.rb +174 -174
  116. data/lib/makit/rake.rb +81 -81
  117. data/lib/makit/ruby/cli.rb +185 -185
  118. data/lib/makit/ruby.rb +25 -25
  119. data/lib/makit/secrets.rb +51 -51
  120. data/lib/makit/serializer.rb +130 -130
  121. data/lib/makit/services/builder.rb +186 -186
  122. data/lib/makit/services/error_handler.rb +226 -226
  123. data/lib/makit/services/repository_manager.rb +367 -231
  124. data/lib/makit/services/validator.rb +112 -112
  125. data/lib/makit/setup/classlib.rb +101 -101
  126. data/lib/makit/setup/gem.rb +268 -268
  127. data/lib/makit/setup/pages.rb +11 -11
  128. data/lib/makit/setup/razorclasslib.rb +101 -101
  129. data/lib/makit/setup/runner.rb +54 -54
  130. data/lib/makit/setup.rb +5 -5
  131. data/lib/makit/show.rb +110 -110
  132. data/lib/makit/storage.rb +126 -126
  133. data/lib/makit/symbols.rb +175 -170
  134. data/lib/makit/task_info.rb +130 -130
  135. data/lib/makit/tasks/at_exit.rb +15 -15
  136. data/lib/makit/tasks/build.rb +22 -22
  137. data/lib/makit/tasks/clean.rb +13 -13
  138. data/lib/makit/tasks/configure.rb +10 -10
  139. data/lib/makit/tasks/format.rb +10 -10
  140. data/lib/makit/tasks/hook_manager.rb +443 -443
  141. data/lib/makit/tasks/init.rb +49 -49
  142. data/lib/makit/tasks/integrate.rb +29 -29
  143. data/lib/makit/tasks/pull_incoming.rb +13 -13
  144. data/lib/makit/tasks/setup.rb +16 -16
  145. data/lib/makit/tasks/sync.rb +17 -17
  146. data/lib/makit/tasks/tag.rb +16 -16
  147. data/lib/makit/tasks/task_monkey_patch.rb +81 -81
  148. data/lib/makit/tasks/test.rb +22 -22
  149. data/lib/makit/tasks/update.rb +18 -18
  150. data/lib/makit/tasks.rb +20 -20
  151. data/lib/makit/test_cache.rb +239 -239
  152. data/lib/makit/tree.rb +37 -37
  153. data/lib/makit/v1/configuration/project_service_impl.rb +371 -0
  154. data/lib/makit/v1/git/git_repository_service_impl.rb +295 -0
  155. data/lib/makit/v1/makit.v1_pb.rb +35 -35
  156. data/lib/makit/v1/makit.v1_services_pb.rb +27 -27
  157. data/lib/makit/v1/services/repository_manager_service_impl.rb +572 -0
  158. data/lib/makit/version.rb +100 -100
  159. data/lib/makit/version_util.rb +21 -21
  160. data/lib/makit/wix.rb +95 -95
  161. data/lib/makit/yaml.rb +29 -29
  162. data/lib/makit/zip.rb +17 -17
  163. data/lib/makit copy.rb +44 -44
  164. data/lib/makit.rb +111 -43
  165. metadata +61 -36
@@ -1,168 +1,446 @@
1
- # frozen_string_literal: true
2
-
3
- require "json"
4
-
5
- module Makit
6
- module Configuration
7
- # Project configuration management
8
- class Project
9
- attr_accessor :git_remote_url, :name, :version, :project_type, :steps, :authors, :description, :license_expression
10
- attr_accessor :dotnet_projects
11
-
12
- def initialize(name, version = nil, project_type = nil)
13
- # Support both keyword arguments and positional arguments for compatibility
14
- if name.is_a?(Hash)
15
- # Keyword arguments: Project.new(name: "test", version: "1.0.0")
16
- @name = name[:name]
17
- @version = name[:version]
18
- @project_type = name[:project_type]
19
- else
20
- # Positional arguments: Project.new("test", "1.0.0", "nuget")
21
- @name = name
22
- @version = version
23
- @project_type = project_type
24
- end
25
- @authors = "authors"
26
- @description = "description"
27
- @license_expression = "MIT"
28
- @steps = []
29
- end
30
-
31
- def add_step(step)
32
- raise ArgumentError, "Step must be a Makit::Configuration::Step instance" unless step.is_a?(Step)
33
-
34
- @steps << step
35
- end
36
-
37
- 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)
47
- end
48
-
49
- 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
- })
59
- end
60
-
61
- 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)
79
- end
80
-
81
- project
82
- end
83
-
84
- # Class method for deserializing from JSON string (used by serializer)
85
- 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)
102
- end
103
-
104
- project
105
- end
106
-
107
- def to_gitlab_ci(path)
108
- GitLabHelper.to_yaml(self, path)
109
- end
110
-
111
- def to_rakefile
112
- RakefileHelper.generate(self)
113
- end
114
-
115
- # Save the project to a specific path as pretty JSON
116
- def save_as(path)
117
- # Validate that the project has a non-empty name before saving
118
- if @name.nil? || @name.strip.empty?
119
- raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
120
- end
121
-
122
- File.write(path, to_json_pretty)
123
- end
124
-
125
- def save
126
- # Validate that the project has a non-empty name before saving
127
- if @name.nil? || @name.strip.empty?
128
- raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
129
- end
130
-
131
- save_as(".makit.json")
132
- end
133
-
134
- # Display the project configuration in YAML format
135
- def show
136
- require "yaml"
137
-
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
- }
145
-
146
- puts YAML.dump(project_data)
147
- end
148
-
149
- # Load a project from the default .makit.json file
150
- def self.default
151
- if File.exist?(".makit.json")
152
- from_json(".makit.json")
153
- 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
164
- end
165
- end
166
- end
167
- end
168
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
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
+
10
+ module Makit
11
+ module Configuration
12
+ # Project configuration management - Phase 3: Routes calls to gRPC service
13
+ class Project
14
+ attr_accessor :git_remote_url, :name, :version, :project_type, :steps, :authors, :description, :license_expression
15
+ attr_accessor :dotnet_projects
16
+
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
+
25
+ # Support both keyword arguments and positional arguments for compatibility
26
+ if name.is_a?(Hash)
27
+ # Keyword arguments: Project.new(name: "test", version: "1.0.0")
28
+ @name = name[:name]
29
+ @version = name[:version]
30
+ @project_type = name[:project_type]
31
+ else
32
+ # Positional arguments: Project.new("test", "1.0.0", "nuget")
33
+ @name = name
34
+ @version = version
35
+ @project_type = project_type
36
+ end
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
79
+ end
80
+
81
+ def add_step(step)
82
+ raise ArgumentError, "Step must be a Makit::Configuration::Step instance" unless step.is_a?(Step)
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
95
+ @steps << step
96
+ end
97
+
98
+ def 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)
135
+ end
136
+
137
+ def to_json_pretty
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)
174
+ end
175
+
176
+ def self.from_json(path)
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
206
+ end
207
+ end
208
+
209
+ # Class method for deserializing from JSON string (used by serializer)
210
+ def self.decode_json(json_string)
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
239
+ end
240
+ end
241
+
242
+ def to_gitlab_ci(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
255
+ end
256
+
257
+ def to_rakefile
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
268
+ end
269
+
270
+ # Save the project to a specific path as pretty JSON
271
+ def save_as(path)
272
+ # Validate that the project has a non-empty name before saving
273
+ if @name.nil? || @name.strip.empty?
274
+ raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
275
+ end
276
+
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
288
+ end
289
+
290
+ def save
291
+ # Validate that the project has a non-empty name before saving
292
+ if @name.nil? || @name.strip.empty?
293
+ raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
294
+ end
295
+
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
304
+ end
305
+
306
+ # Display the project configuration in YAML format
307
+ def show
308
+ require "yaml"
309
+
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
339
+
340
+ puts YAML.dump(project_data)
341
+ end
342
+
343
+ # Load a project from the default .makit.json file
344
+ def self.default
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)
353
+ else
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
+ )
431
+ end
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
444
+ end
445
+ end
446
+ end