makit 0.0.99 → 0.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -0
  3. data/exe/makit +5 -0
  4. data/lib/makit/apache.rb +28 -32
  5. data/lib/makit/cli/build_commands.rb +500 -0
  6. data/lib/makit/cli/generators/base_generator.rb +74 -0
  7. data/lib/makit/cli/generators/dotnet_generator.rb +50 -0
  8. data/lib/makit/cli/generators/generator_factory.rb +49 -0
  9. data/lib/makit/cli/generators/node_generator.rb +50 -0
  10. data/lib/makit/cli/generators/ruby_generator.rb +77 -0
  11. data/lib/makit/cli/generators/rust_generator.rb +50 -0
  12. data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -0
  13. data/lib/makit/cli/generators/templates/node_templates.rb +161 -0
  14. data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -0
  15. data/lib/makit/cli/generators/templates/ruby/gemspec.rb +40 -0
  16. data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -0
  17. data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -0
  18. data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -0
  19. data/lib/makit/cli/generators/templates/ruby/test.rb +39 -0
  20. data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -0
  21. data/lib/makit/cli/generators/templates/ruby/version.rb +29 -0
  22. data/lib/makit/cli/generators/templates/rust_templates.rb +128 -0
  23. data/lib/makit/cli/main.rb +62 -33
  24. data/lib/makit/cli/project_commands.rb +868 -0
  25. data/lib/makit/cli/repository_commands.rb +661 -0
  26. data/lib/makit/cli/utility_commands.rb +521 -0
  27. data/lib/makit/commands/factory.rb +359 -0
  28. data/lib/makit/commands/middleware/base.rb +73 -0
  29. data/lib/makit/commands/middleware/cache.rb +248 -0
  30. data/lib/makit/commands/middleware/command_logger.rb +320 -0
  31. data/lib/makit/commands/middleware/unified_logger.rb +243 -0
  32. data/lib/makit/commands/middleware/validator.rb +269 -0
  33. data/lib/makit/commands/request.rb +254 -0
  34. data/lib/makit/commands/result.rb +323 -0
  35. data/lib/makit/commands/runner.rb +337 -0
  36. data/lib/makit/commands/strategies/base.rb +160 -0
  37. data/lib/makit/commands/strategies/synchronous.rb +134 -0
  38. data/lib/makit/commands.rb +51 -21
  39. data/lib/makit/configuration/gitlab_helper.rb +60 -0
  40. data/lib/makit/configuration/project.rb +127 -0
  41. data/lib/makit/configuration/rakefile_helper.rb +43 -0
  42. data/lib/makit/configuration/step.rb +34 -0
  43. data/lib/makit/configuration.rb +14 -0
  44. data/lib/makit/content/default_gitignore.rb +7 -5
  45. data/lib/makit/content/default_rakefile.rb +13 -11
  46. data/lib/makit/content/gem_rakefile.rb +16 -14
  47. data/lib/makit/context.rb +1 -0
  48. data/lib/makit/data.rb +49 -50
  49. data/lib/makit/directories.rb +141 -145
  50. data/lib/makit/directory.rb +262 -276
  51. data/lib/makit/docs/files.rb +89 -94
  52. data/lib/makit/docs/rake.rb +102 -106
  53. data/lib/makit/dotnet/cli.rb +65 -0
  54. data/lib/makit/dotnet/project.rb +153 -0
  55. data/lib/makit/dotnet/solution.rb +38 -0
  56. data/lib/makit/dotnet/solution_classlib.rb +239 -0
  57. data/lib/makit/dotnet/solution_console.rb +264 -0
  58. data/lib/makit/dotnet/solution_maui.rb +354 -0
  59. data/lib/makit/dotnet/solution_wasm.rb +275 -0
  60. data/lib/makit/dotnet/solution_wpf.rb +304 -0
  61. data/lib/makit/dotnet.rb +102 -219
  62. data/lib/makit/email.rb +90 -61
  63. data/lib/makit/environment.rb +142 -139
  64. data/lib/makit/examples/runner.rb +370 -0
  65. data/lib/makit/exceptions.rb +45 -0
  66. data/lib/makit/fileinfo.rb +24 -26
  67. data/lib/makit/files.rb +43 -47
  68. data/lib/makit/gems.rb +29 -28
  69. data/lib/makit/git/cli.rb +54 -0
  70. data/lib/makit/git/repository.rb +90 -0
  71. data/lib/makit/git.rb +98 -145
  72. data/lib/makit/gitlab_runner.rb +59 -60
  73. data/lib/makit/humanize.rb +137 -129
  74. data/lib/makit/indexer.rb +47 -56
  75. data/lib/makit/logging/configuration.rb +305 -0
  76. data/lib/makit/logging/format_registry.rb +84 -0
  77. data/lib/makit/logging/formatters/base.rb +39 -0
  78. data/lib/makit/logging/formatters/console_formatter.rb +140 -0
  79. data/lib/makit/logging/formatters/json_formatter.rb +65 -0
  80. data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -0
  81. data/lib/makit/logging/formatters/text_formatter.rb +64 -0
  82. data/lib/makit/logging/log_request.rb +115 -0
  83. data/lib/makit/logging/logger.rb +163 -0
  84. data/lib/makit/logging/sinks/base.rb +91 -0
  85. data/lib/makit/logging/sinks/console.rb +72 -0
  86. data/lib/makit/logging/sinks/file_sink.rb +92 -0
  87. data/lib/makit/logging/sinks/structured.rb +129 -0
  88. data/lib/makit/logging/sinks/unified_file_sink.rb +303 -0
  89. data/lib/makit/logging.rb +530 -106
  90. data/lib/makit/markdown.rb +75 -75
  91. data/lib/makit/mp/basic_object_mp.rb +17 -16
  92. data/lib/makit/mp/command_mp.rb +13 -13
  93. data/lib/makit/mp/command_request.mp.rb +17 -16
  94. data/lib/makit/mp/project_mp.rb +199 -210
  95. data/lib/makit/mp/string_mp.rb +193 -176
  96. data/lib/makit/nuget.rb +74 -72
  97. data/lib/makit/port.rb +32 -34
  98. data/lib/makit/process.rb +163 -65
  99. data/lib/makit/protoc.rb +107 -104
  100. data/lib/makit/rake/cli.rb +196 -0
  101. data/lib/makit/rake.rb +25 -25
  102. data/lib/makit/ruby/cli.rb +185 -0
  103. data/lib/makit/ruby.rb +25 -0
  104. data/lib/makit/secrets.rb +51 -51
  105. data/lib/makit/serializer.rb +130 -115
  106. data/lib/makit/services/builder.rb +186 -0
  107. data/lib/makit/services/error_handler.rb +226 -0
  108. data/lib/makit/services/repository_manager.rb +229 -0
  109. data/lib/makit/services/validator.rb +112 -0
  110. data/lib/makit/setup/classlib.rb +53 -0
  111. data/lib/makit/setup/gem.rb +263 -0
  112. data/lib/makit/setup/runner.rb +45 -0
  113. data/lib/makit/setup.rb +5 -0
  114. data/lib/makit/show.rb +110 -110
  115. data/lib/makit/storage.rb +126 -131
  116. data/lib/makit/symbols.rb +170 -149
  117. data/lib/makit/task_info.rb +128 -86
  118. data/lib/makit/tasks/at_exit.rb +13 -0
  119. data/lib/makit/tasks/build.rb +19 -0
  120. data/lib/makit/tasks/clean.rb +11 -0
  121. data/lib/makit/tasks/hook_manager.rb +393 -0
  122. data/lib/makit/tasks/init.rb +47 -0
  123. data/lib/makit/tasks/integrate.rb +17 -0
  124. data/lib/makit/tasks/pull_incoming.rb +11 -0
  125. data/lib/makit/tasks/setup.rb +6 -0
  126. data/lib/makit/tasks/sync.rb +12 -0
  127. data/lib/makit/tasks/tag.rb +15 -0
  128. data/lib/makit/tasks/task_monkey_patch.rb +79 -0
  129. data/lib/makit/tasks.rb +15 -150
  130. data/lib/makit/test_cache.rb +239 -0
  131. data/lib/makit/tree.rb +37 -37
  132. data/lib/makit/v1/makit.v1_pb.rb +3 -4
  133. data/lib/makit/v1/makit.v1_services_pb.rb +27 -25
  134. data/lib/makit/version.rb +5 -61
  135. data/lib/makit/version_util.rb +21 -0
  136. data/lib/makit/wix.rb +95 -95
  137. data/lib/makit/yaml.rb +29 -17
  138. data/lib/makit/zip.rb +17 -17
  139. data/lib/makit copy.rb +44 -0
  140. data/lib/makit.rb +40 -267
  141. metadata +117 -110
  142. data/lib/makit/cli/clean.rb +0 -14
  143. data/lib/makit/cli/clone.rb +0 -59
  144. data/lib/makit/cli/init.rb +0 -38
  145. data/lib/makit/cli/make.rb +0 -54
  146. data/lib/makit/cli/new.rb +0 -37
  147. data/lib/makit/cli/nuget_cache.rb +0 -38
  148. data/lib/makit/cli/pull.rb +0 -31
  149. data/lib/makit/cli/setup.rb +0 -71
  150. data/lib/makit/cli/work.rb +0 -21
  151. data/lib/makit/command_runner.rb +0 -404
  152. data/lib/makit/content/default_gitignore.txt +0 -222
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Makit
4
+ module Services
5
+ # Service class responsible for validating all input parameters
6
+ # Used by various Makit operations to ensure data integrity
7
+ class Validator
8
+ # Git-related validation constants
9
+ COMMIT_HASH_LENGTH = 40
10
+ COMMIT_LATEST = "latest"
11
+ MAX_PAGINATION_LIMIT = 1000
12
+ MAX_DIRECTORY_PATH_LENGTH = 255
13
+
14
+ class << self
15
+ # Validate directory parameter for initialization operations
16
+ #
17
+ # @param directory [String] the directory path to validate
18
+ # @raise [ArgumentError] if directory parameter is invalid
19
+ def validate_directory_parameter(directory)
20
+ raise ArgumentError, "directory parameter cannot be nil" if directory.nil?
21
+ raise ArgumentError, "directory parameter cannot be empty" if directory.to_s.strip.empty?
22
+ raise ArgumentError, "directory path contains invalid characters" if directory.to_s.include?("\0")
23
+ raise ArgumentError, "directory path is too long" if directory.to_s.length > MAX_DIRECTORY_PATH_LENGTH
24
+ end
25
+
26
+ # Validate URL parameter for git repository operations
27
+ #
28
+ # @param url [String] the repository URL to validate
29
+ # @raise [ArgumentError] if URL parameter is invalid
30
+ def validate_url_parameter(url)
31
+ raise ArgumentError, "URL parameter cannot be nil" if url.nil?
32
+ raise ArgumentError, "URL parameter cannot be empty" if url.to_s.strip.empty?
33
+
34
+ url_str = url.to_s.strip
35
+ # Basic URL format validation - accept git@, https://, http://, and simple names like "user/repo"
36
+ valid_patterns = [
37
+ %r{\Agit@[\w.-]+:[\w._/-]+\.git\z}, # SSH format: git@github.com:user/repo.git
38
+ %r{\Ahttps?://[\w.-]+/[\w._/-]+(\.git)?\z}, # HTTPS format: https://github.com/user/repo
39
+ %r{\A[\w.-]+/[\w._-]+\z}, # Simple format: user/repo
40
+ ]
41
+
42
+ return if valid_patterns.any? { |pattern| url_str.match?(pattern) }
43
+
44
+ raise ArgumentError, "Invalid URL format: #{url_str}"
45
+ end
46
+
47
+ # Validate commit parameter for git operations
48
+ #
49
+ # @param commit [String] the commit hash or "latest" to validate
50
+ # @raise [ArgumentError] if commit parameter is invalid
51
+ def validate_commit_parameter(commit)
52
+ raise ArgumentError, "commit parameter cannot be nil" if commit.nil?
53
+
54
+ commit_str = commit.to_s.strip
55
+ raise ArgumentError, "commit parameter cannot be empty" if commit_str.empty?
56
+
57
+ # Allow "latest" or valid commit hash formats
58
+ return if commit_str == COMMIT_LATEST
59
+ return if commit_str.match?(/\A[0-9a-f]{7,#{COMMIT_HASH_LENGTH}}\z/i)
60
+
61
+ raise ArgumentError, "Invalid commit format: #{commit_str}. Must be 'latest' or a valid git commit hash."
62
+ end
63
+
64
+ # Validate pagination parameters for log operations
65
+ #
66
+ # @param limit [Integer] maximum number of items to retrieve
67
+ # @param skip [Integer] number of items to skip
68
+ # @raise [ArgumentError] if pagination parameters are invalid
69
+ def validate_pagination_parameters(limit, skip)
70
+ unless limit.is_a?(Integer) && limit.positive?
71
+ raise ArgumentError,
72
+ "limit parameter must be a positive integer"
73
+ end
74
+ raise ArgumentError, "skip parameter must be a non-negative integer" unless skip.is_a?(Integer) && skip >= 0
75
+ raise ArgumentError, "limit parameter is too large" if limit > MAX_PAGINATION_LIMIT
76
+ end
77
+
78
+ # Validate that a directory exists and is accessible
79
+ #
80
+ # @param directory [String] the directory path to check
81
+ # @param description [String] human-readable description for error messages
82
+ # @raise [Makit::DirectoryError] if directory doesn't exist or isn't accessible
83
+ def validate_directory_exists(directory, description = "directory")
84
+ return if Dir.exist?(directory)
85
+
86
+ raise Makit::DirectoryError, "#{description} does not exist: #{directory}"
87
+ end
88
+
89
+ # Validate boolean parameters
90
+ #
91
+ # @param value [Object] the value to check
92
+ # @param parameter_name [String] the parameter name for error messages
93
+ # @raise [ArgumentError] if value is not boolean
94
+ def validate_boolean_parameter(value, parameter_name)
95
+ return if [true, false].include?(value)
96
+
97
+ raise ArgumentError, "#{parameter_name} must be true or false, got #{value.class}"
98
+ end
99
+
100
+ # Validate string parameters that cannot be empty
101
+ #
102
+ # @param value [String] the string value to validate
103
+ # @param parameter_name [String] the parameter name for error messages
104
+ # @raise [ArgumentError] if string is nil or empty
105
+ def validate_required_string(value, parameter_name)
106
+ raise ArgumentError, "#{parameter_name} cannot be nil" if value.nil?
107
+ raise ArgumentError, "#{parameter_name} cannot be empty" if value.to_s.strip.empty?
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ require_relative "../configuration/project"
3
+
4
+ module Makit
5
+ module Setup
6
+ class ClassLib
7
+ def self.run
8
+ #puts "Setting up Nuget project..."
9
+ project = Makit::Configuration::Project.default
10
+ Makit::DotNet::Project.new_project("classlib", project.name, "source/#{project.name}", "--framework net8.0")
11
+ Makit::DotNet::Project.new_project("TUnit", "#{project.name}.Tests", "tests/#{project.name}")
12
+ Makit::DotNet::Project.add_reference("tests/#{project.name}/#{project.name}.Tests.csproj", "source/#{project.name}/#{project.name}.csproj")
13
+ update_build_step(project)
14
+ update_test_step(project)
15
+
16
+ project.save
17
+ Makit::Logging.default_logger.info("Project setup completed")
18
+ end
19
+
20
+ def self.update_build_step(project)
21
+ build_commands = Array.new
22
+ build_commands << "dotnet build source/#{project.name}/#{project.name}.csproj --configuration Release"
23
+ steps = project.steps
24
+ if steps.any? { |step| step.name == "build" }
25
+ build_step = steps.find { |step| step.name == "build" }
26
+ build_step.commands = build_commands
27
+ else
28
+ build_step = Makit::Configuration::Step.new(name: "build", description: "Build the project artifacts", commands: build_commands)
29
+ build_step.commands = build_commands
30
+ project.add_step(build_step)
31
+ end
32
+ build_step.commands = build_commands
33
+
34
+ project.save
35
+ end
36
+
37
+ def self.update_test_step(project)
38
+ test_commands = Array.new
39
+ test_commands << "dotnet test tests/#{project.name}/#{project.name}.Tests.csproj"
40
+ steps = project.steps
41
+ if steps.any? { |step| step.name == "test" }
42
+ test_step = steps.find { |step| step.name == "test" }
43
+ test_step.commands = test_commands
44
+ else
45
+ test_step = Makit::Configuration::Step.new(name: "test", description: "Run the project tests", commands: test_commands)
46
+ test_step.commands = test_commands
47
+ project.add_step(test_step)
48
+ end
49
+ project.save
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,263 @@
1
+ # frozen_string_literal: true
2
+ require_relative "../configuration/project"
3
+
4
+ module Makit
5
+ module Setup
6
+ class Gem
7
+ def self.run
8
+ project = Makit::Configuration::Project.default
9
+ Makit::Logging.default_logger.info("Setting up Ruby gem project: #{project.name}")
10
+
11
+ # Create basic gem structure
12
+ create_gem_structure(project)
13
+
14
+ # Update build and test steps
15
+ update_build_step(project)
16
+ update_test_step(project)
17
+
18
+ project.save
19
+ Makit::Logging.default_logger.info("Ruby gem project setup completed")
20
+ end
21
+
22
+ private
23
+
24
+ def self.create_gem_structure(project)
25
+ # Create directories
26
+ FileUtils.mkdir_p("lib/#{project.name}")
27
+ FileUtils.mkdir_p("test")
28
+ FileUtils.mkdir_p("exe")
29
+
30
+ # Create basic gem files
31
+ create_gemspec(project)
32
+ create_gemfile(project)
33
+ create_main_lib(project)
34
+ create_version_file(project)
35
+ create_rakefile(project)
36
+ create_test_helper(project)
37
+ create_test_file(project)
38
+ create_readme(project)
39
+ end
40
+
41
+ def self.create_gemspec(project)
42
+ gemspec_content = <<~GEMSPEC
43
+ # frozen_string_literal: true
44
+
45
+ require_relative "lib/#{project.name}/version"
46
+
47
+ Gem::Specification.new do |spec|
48
+ spec.name = "#{project.name}"
49
+ spec.version = #{project.name.capitalize}::VERSION
50
+ spec.authors = ["Your Name"]
51
+ spec.email = ["your.email@example.com"]
52
+
53
+ spec.summary = "A Ruby gem"
54
+ spec.description = "A Ruby gem description"
55
+ spec.homepage = "https://github.com/yourusername/#{project.name}"
56
+ spec.license = "MIT"
57
+
58
+ spec.files = Dir["lib/**/*.rb", "exe/**/*", "README.md", "LICENSE.txt"]
59
+ spec.bindir = "exe"
60
+ spec.executables = []
61
+ spec.require_paths = ["lib"]
62
+
63
+ spec.add_development_dependency "bundler", "~> 2.0"
64
+ spec.add_development_dependency "rake", "~> 13.0"
65
+ spec.add_development_dependency "minitest", "~> 5.0"
66
+ end
67
+ GEMSPEC
68
+
69
+ gemspec_path = "#{project.name}.gemspec"
70
+ return if File.exist?(gemspec_path)
71
+ File.write(gemspec_path, gemspec_content)
72
+ end
73
+
74
+ def self.create_gemfile(project)
75
+ gemfile_content = <<~GEMFILE
76
+ # frozen_string_literal: true
77
+
78
+ source "https://rubygems.org"
79
+
80
+ # Specify your gem's dependencies in #{project.name}.gemspec
81
+ gemspec
82
+ GEMFILE
83
+
84
+ return if File.exist?("Gemfile")
85
+ File.write("Gemfile", gemfile_content)
86
+ end
87
+
88
+ def self.create_main_lib(project)
89
+ main_lib_path = "lib/#{project.name}.rb"
90
+ return if File.exist?(main_lib_path)
91
+
92
+ main_lib_content = <<~MAIN_LIB
93
+ # frozen_string_literal: true
94
+
95
+ require_relative "#{project.name}/version"
96
+
97
+ module #{project.name.capitalize}
98
+ class Error < StandardError; end
99
+ # Your code goes here...
100
+ end
101
+ MAIN_LIB
102
+
103
+ File.write(main_lib_path, main_lib_content)
104
+ end
105
+
106
+ def self.create_version_file(project)
107
+ version_path = "lib/#{project.name}/version.rb"
108
+ return if File.exist?(version_path)
109
+
110
+ version_content = <<~VERSION
111
+ # frozen_string_literal: true
112
+
113
+ module #{project.name.capitalize}
114
+ VERSION = "#{project.version}"
115
+ end
116
+ VERSION
117
+
118
+ File.write(version_path, version_content)
119
+ end
120
+
121
+ def self.create_rakefile(project)
122
+ return if File.exist?("Rakefile")
123
+
124
+ rakefile_content = <<~RAKEFILE
125
+ # frozen_string_literal: true
126
+
127
+ require "bundler/gem_tasks"
128
+ require "minitest/test_task"
129
+ require "makit"
130
+
131
+ Minitest::TestTask.create
132
+
133
+ task :default => [:build, :install] do
134
+ end
135
+ RAKEFILE
136
+
137
+ File.write("Rakefile", rakefile_content)
138
+ end
139
+
140
+ def self.create_test_helper(project)
141
+ return if File.exist?("test/test_helper.rb")
142
+
143
+ test_helper_content = <<~TEST_HELPER
144
+ # frozen_string_literal: true
145
+
146
+ require "minitest/autorun"
147
+ require_relative "../lib/#{project.name}"
148
+ TEST_HELPER
149
+
150
+ File.write("test/test_helper.rb", test_helper_content)
151
+ end
152
+
153
+ def self.create_test_file(project)
154
+ test_content = <<~TEST
155
+ # frozen_string_literal: true
156
+
157
+ require "test_helper"
158
+
159
+ class #{project.name.capitalize}Test < Minitest::Test
160
+ def test_that_it_has_a_version_number
161
+ refute_nil ::#{project.name.capitalize}::VERSION
162
+ end
163
+
164
+ def test_it_does_something_useful
165
+ assert false
166
+ end
167
+ end
168
+ TEST
169
+
170
+ File.write("test/#{project.name}_test.rb", test_content)
171
+ end
172
+
173
+ def self.create_readme(project)
174
+ readme_content = <<~README
175
+ # #{project.name.capitalize}
176
+
177
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/#{project.name}`. To experiment with that code, run `bin/console` for an interactive prompt.
178
+
179
+ TODO: Delete this and the text above, and describe your gem
180
+
181
+ ## Installation
182
+
183
+ Add this line to your application's Gemfile:
184
+
185
+ ```ruby
186
+ gem "#{project.name}"
187
+ ```
188
+
189
+ And then execute:
190
+
191
+ $ bundle
192
+
193
+ Or install it yourself as:
194
+
195
+ $ gem install #{project.name}
196
+
197
+ ## Usage
198
+
199
+ ```ruby
200
+ require "#{project.name}"
201
+
202
+ # TODO: Write usage instructions here
203
+ ```
204
+
205
+ ## Development
206
+
207
+ After checking out the repo, run `bundle install` to install dependencies. Then, run `rake test` to run the tests.
208
+
209
+ ## Contributing
210
+
211
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/#{project.name}.
212
+
213
+ ## License
214
+
215
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
216
+ README
217
+
218
+ File.write("README.md", readme_content)
219
+ end
220
+
221
+ def self.update_build_step(project)
222
+ build_commands = [
223
+ "bundle exec rake build",
224
+ ]
225
+
226
+ steps = project.steps
227
+ if steps.any? { |step| step.name == "build" }
228
+ build_step = steps.find { |step| step.name == "build" }
229
+ build_step.commands = build_commands
230
+ else
231
+ build_step = Makit::Configuration::Step.new(
232
+ name: "build",
233
+ description: "Build the gem",
234
+ commands: build_commands,
235
+ )
236
+ project.add_step(build_step)
237
+ end
238
+ build_step.commands = build_commands
239
+ project.save
240
+ end
241
+
242
+ def self.update_test_step(project)
243
+ test_commands = [
244
+ "bundle exec rake test",
245
+ ]
246
+
247
+ steps = project.steps
248
+ if steps.any? { |step| step.name == "test" }
249
+ test_step = steps.find { |step| step.name == "test" }
250
+ test_step.commands = test_commands
251
+ else
252
+ test_step = Makit::Configuration::Step.new(
253
+ name: "test",
254
+ description: "Run the tests",
255
+ commands: test_commands,
256
+ )
257
+ project.add_step(test_step)
258
+ end
259
+ project.save
260
+ end
261
+ end
262
+ end
263
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ require_relative "classlib"
3
+ require_relative "gem"
4
+
5
+ module Makit
6
+ module Setup
7
+ class Runner
8
+ def self.run
9
+
10
+ # open .makit.json and get project type, to determine which setup to run
11
+ if File.exist?(".makit.json")
12
+ begin
13
+ project = Makit::Serializer.open(".makit.json", Makit::Configuration::Project)
14
+
15
+ # Update version to match VERSION constant if it exists
16
+ if defined?(Makit::VERSION)
17
+ project.version = Makit::VERSION
18
+ end
19
+
20
+ # Check if the file contains compact JSON and resave as pretty JSON
21
+ current_content = File.read(".makit.json")
22
+ pretty_content = project.to_json_pretty
23
+
24
+ # Only rewrite if the content is different (i.e., if it was compact or version changed)
25
+ if current_content.strip != pretty_content.strip
26
+ File.write(".makit.json", pretty_content)
27
+ end
28
+ rescue
29
+ raise "Error opening .makit.json"
30
+ end
31
+ project_type = project.project_type
32
+ case project_type
33
+ when "classlib"
34
+ Makit::Setup::ClassLib.run
35
+ when "gem"
36
+ Makit::Setup::Gem.run
37
+ else
38
+ Makit::Logging.default_logger.warn("Unsupported project type: #{project_type}")
39
+ #puts "Unsupported project type: #{project_type}"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "setup/runner"
4
+ require_relative "setup/classlib"
5
+ require_relative "setup/gem"