makit 0.0.111 → 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.
- checksums.yaml +4 -4
- data/README.md +41 -41
- data/exe/makit +5 -5
- data/lib/makit/apache.rb +28 -28
- data/lib/makit/cli/build_commands.rb +500 -500
- data/lib/makit/cli/generators/base_generator.rb +74 -74
- data/lib/makit/cli/generators/dotnet_generator.rb +50 -50
- data/lib/makit/cli/generators/generator_factory.rb +49 -49
- data/lib/makit/cli/generators/node_generator.rb +50 -50
- data/lib/makit/cli/generators/ruby_generator.rb +77 -77
- data/lib/makit/cli/generators/rust_generator.rb +50 -50
- data/lib/makit/cli/generators/templates/dotnet_templates.rb +167 -167
- data/lib/makit/cli/generators/templates/node_templates.rb +161 -161
- data/lib/makit/cli/generators/templates/ruby/gemfile.rb +26 -26
- data/lib/makit/cli/generators/templates/ruby/gemspec.rb +40 -40
- data/lib/makit/cli/generators/templates/ruby/main_lib.rb +33 -33
- data/lib/makit/cli/generators/templates/ruby/rakefile.rb +35 -35
- data/lib/makit/cli/generators/templates/ruby/readme.rb +63 -63
- data/lib/makit/cli/generators/templates/ruby/test.rb +39 -39
- data/lib/makit/cli/generators/templates/ruby/test_helper.rb +29 -29
- data/lib/makit/cli/generators/templates/ruby/version.rb +29 -29
- data/lib/makit/cli/generators/templates/rust_templates.rb +128 -128
- data/lib/makit/cli/main.rb +62 -62
- data/lib/makit/cli/project_commands.rb +868 -868
- data/lib/makit/cli/repository_commands.rb +661 -661
- data/lib/makit/cli/utility_commands.rb +521 -521
- data/lib/makit/commands/factory.rb +359 -359
- data/lib/makit/commands/middleware/base.rb +73 -73
- data/lib/makit/commands/middleware/cache.rb +248 -248
- data/lib/makit/commands/middleware/command_logger.rb +320 -323
- data/lib/makit/commands/middleware/unified_logger.rb +243 -243
- data/lib/makit/commands/middleware/validator.rb +269 -269
- data/lib/makit/commands/request.rb +254 -254
- data/lib/makit/commands/result.rb +323 -323
- data/lib/makit/commands/runner.rb +337 -317
- data/lib/makit/commands/strategies/base.rb +160 -160
- data/lib/makit/commands/strategies/synchronous.rb +134 -134
- data/lib/makit/commands.rb +51 -42
- data/lib/makit/configuration/gitlab_helper.rb +60 -60
- data/lib/makit/configuration/project.rb +127 -127
- data/lib/makit/configuration/rakefile_helper.rb +43 -43
- data/lib/makit/configuration/step.rb +34 -34
- data/lib/makit/configuration.rb +14 -14
- data/lib/makit/content/default_gitignore.rb +7 -7
- data/lib/makit/content/default_rakefile.rb +13 -13
- data/lib/makit/content/gem_rakefile.rb +16 -16
- data/lib/makit/context.rb +1 -1
- data/lib/makit/data.rb +49 -49
- data/lib/makit/directories.rb +141 -141
- data/lib/makit/directory.rb +262 -262
- data/lib/makit/docs/files.rb +89 -89
- data/lib/makit/docs/rake.rb +102 -102
- data/lib/makit/dotnet/project.rb +153 -153
- data/lib/makit/dotnet/solution.rb +38 -38
- data/lib/makit/dotnet/solution_classlib.rb +239 -239
- data/lib/makit/dotnet/solution_console.rb +264 -264
- data/lib/makit/dotnet/solution_maui.rb +354 -354
- data/lib/makit/dotnet/solution_wasm.rb +275 -275
- data/lib/makit/dotnet/solution_wpf.rb +304 -304
- data/lib/makit/dotnet.rb +102 -102
- data/lib/makit/email.rb +90 -90
- data/lib/makit/environment.rb +142 -142
- data/lib/makit/examples/runner.rb +370 -370
- data/lib/makit/exceptions.rb +45 -45
- data/lib/makit/fileinfo.rb +24 -24
- data/lib/makit/files.rb +43 -43
- data/lib/makit/gems.rb +40 -40
- data/lib/makit/git/cli.rb +54 -54
- data/lib/makit/git/repository.rb +90 -90
- data/lib/makit/git.rb +98 -98
- data/lib/makit/gitlab_runner.rb +59 -59
- data/lib/makit/humanize.rb +137 -137
- data/lib/makit/indexer.rb +47 -47
- data/lib/makit/logging/configuration.rb +305 -305
- data/lib/makit/logging/formatters/base.rb +39 -39
- data/lib/makit/logging/formatters/console_formatter.rb +140 -127
- data/lib/makit/logging/formatters/json_formatter.rb +65 -65
- data/lib/makit/logging/formatters/plain_text_formatter.rb +71 -71
- data/lib/makit/logging/formatters/text_formatter.rb +64 -64
- data/lib/makit/logging/log_request.rb +115 -115
- data/lib/makit/logging/logger.rb +163 -159
- data/lib/makit/logging/sinks/console.rb +72 -72
- data/lib/makit/logging/sinks/file_sink.rb +92 -92
- data/lib/makit/logging/sinks/unified_file_sink.rb +303 -303
- data/lib/makit/logging.rb +530 -521
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +17 -17
- data/lib/makit/mp/command_mp.rb +13 -13
- data/lib/makit/mp/command_request.mp.rb +17 -17
- data/lib/makit/mp/project_mp.rb +199 -199
- data/lib/makit/mp/string_mp.rb +193 -348
- data/lib/makit/nuget.rb +74 -74
- data/lib/makit/port.rb +32 -32
- data/lib/makit/process.rb +163 -163
- data/lib/makit/protoc.rb +107 -107
- data/lib/makit/rake/cli.rb +196 -196
- data/lib/makit/rake.rb +25 -25
- data/lib/makit/ruby/cli.rb +185 -185
- data/lib/makit/ruby.rb +25 -25
- data/lib/makit/secrets.rb +51 -51
- data/lib/makit/serializer.rb +130 -117
- data/lib/makit/services/builder.rb +186 -186
- data/lib/makit/services/error_handler.rb +226 -226
- data/lib/makit/services/repository_manager.rb +229 -229
- data/lib/makit/services/validator.rb +112 -112
- data/lib/makit/setup/classlib.rb +53 -53
- data/lib/makit/setup/gem.rb +30 -17
- data/lib/makit/setup/runner.rb +45 -40
- data/lib/makit/setup.rb +5 -0
- data/lib/makit/show.rb +110 -110
- data/lib/makit/storage.rb +126 -126
- data/lib/makit/symbols.rb +170 -161
- data/lib/makit/task_info.rb +128 -128
- data/lib/makit/tasks/at_exit.rb +13 -13
- data/lib/makit/tasks/build.rb +19 -18
- data/lib/makit/tasks/clean.rb +11 -11
- data/lib/makit/tasks/hook_manager.rb +393 -239
- data/lib/makit/tasks/init.rb +47 -47
- data/lib/makit/tasks/integrate.rb +17 -15
- data/lib/makit/tasks/pull_incoming.rb +11 -12
- data/lib/makit/tasks/setup.rb +6 -6
- data/lib/makit/tasks/sync.rb +12 -11
- data/lib/makit/tasks/tag.rb +15 -0
- data/lib/makit/tasks/task_monkey_patch.rb +79 -79
- data/lib/makit/tasks.rb +10 -0
- data/lib/makit/test_cache.rb +239 -239
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/makit.v1_pb.rb +34 -34
- data/lib/makit/v1/makit.v1_services_pb.rb +27 -27
- data/lib/makit/version.rb +5 -5
- data/lib/makit/version_util.rb +21 -0
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/yaml.rb +29 -29
- data/lib/makit/zip.rb +17 -17
- data/lib/makit copy.rb +44 -0
- data/lib/makit.rb +40 -8
- metadata +50 -7
- data/lib/makit/command_runner.rb +0 -463
- data/lib/makit/commands/compatibility.rb +0 -365
- data/lib/makit/task_hooks.rb +0 -125
data/lib/makit/commands.rb
CHANGED
@@ -1,42 +1,51 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "English"
|
4
|
-
require "open3"
|
5
|
-
require "socket"
|
6
|
-
require "etc"
|
7
|
-
require "logger"
|
8
|
-
|
9
|
-
# This module provides classes for the Makit gem.
|
10
|
-
module Makit
|
11
|
-
# Commands module provides a modern, flexible command execution framework
|
12
|
-
# with middleware support, validation, caching, and structured logging.
|
13
|
-
module Commands
|
14
|
-
# Custom exception for security-related command validation failures
|
15
|
-
class SecurityError < StandardError; end
|
16
|
-
|
17
|
-
# Custom exception for command execution failures
|
18
|
-
class ExecutionError < StandardError
|
19
|
-
attr_reader :exit_code, :stderr
|
20
|
-
|
21
|
-
def initialize(message, exit_code: nil, stderr: nil)
|
22
|
-
@exit_code = exit_code
|
23
|
-
@stderr = stderr
|
24
|
-
super(message)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# This class provide methods running commands.
|
30
|
-
#
|
31
|
-
class LegacyCommands < Array
|
32
|
-
# Generate the commands based on the current directory.
|
33
|
-
def auto_generate
|
34
|
-
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["install"]) if File.exist?("Gemfile")
|
35
|
-
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: %w[exec rake]) if File.exist?("Rakefile")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# Load command system components (load existing components only)
|
41
|
-
require_relative "commands/result"
|
42
|
-
require_relative "commands/
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "English"
|
4
|
+
require "open3"
|
5
|
+
require "socket"
|
6
|
+
require "etc"
|
7
|
+
require "logger"
|
8
|
+
|
9
|
+
# This module provides classes for the Makit gem.
|
10
|
+
module Makit
|
11
|
+
# Commands module provides a modern, flexible command execution framework
|
12
|
+
# with middleware support, validation, caching, and structured logging.
|
13
|
+
module Commands
|
14
|
+
# Custom exception for security-related command validation failures
|
15
|
+
class SecurityError < StandardError; end
|
16
|
+
|
17
|
+
# Custom exception for command execution failures
|
18
|
+
class ExecutionError < StandardError
|
19
|
+
attr_reader :exit_code, :stderr
|
20
|
+
|
21
|
+
def initialize(message, exit_code: nil, stderr: nil)
|
22
|
+
@exit_code = exit_code
|
23
|
+
@stderr = stderr
|
24
|
+
super(message)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# This class provide methods running commands.
|
30
|
+
#
|
31
|
+
class LegacyCommands < Array
|
32
|
+
# Generate the commands based on the current directory.
|
33
|
+
def auto_generate
|
34
|
+
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: ["install"]) if File.exist?("Gemfile")
|
35
|
+
self << Makit::V1::CommandRequest.new(name: "bundle", arguments: %w[exec rake]) if File.exist?("Rakefile")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Load command system components (load existing components only)
|
41
|
+
require_relative "commands/result"
|
42
|
+
require_relative "commands/request"
|
43
|
+
require_relative "commands/runner"
|
44
|
+
require_relative "commands/factory"
|
45
|
+
require_relative "commands/middleware/validator"
|
46
|
+
require_relative "commands/middleware/cache"
|
47
|
+
require_relative "commands/middleware/command_logger"
|
48
|
+
require_relative "commands/middleware/unified_logger"
|
49
|
+
require_relative "commands/middleware/base"
|
50
|
+
require_relative "commands/strategies/base"
|
51
|
+
require_relative "commands/strategies/synchronous"
|
@@ -1,60 +1,60 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "yaml"
|
4
|
-
|
5
|
-
module Makit
|
6
|
-
module Configuration
|
7
|
-
# Helper for GitLab CI YAML conversion
|
8
|
-
class GitLabHelper
|
9
|
-
def self.to_yaml(project, path)
|
10
|
-
yaml_content = generate_yaml(project)
|
11
|
-
File.write(path, yaml_content)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.from_yaml(path)
|
15
|
-
content = File.read(path)
|
16
|
-
data = YAML.safe_load(content, symbolize_names: true, permitted_classes: [Symbol])
|
17
|
-
|
18
|
-
project = Project.new(name: data[:name] || "Unknown", version: data[:version] || "1.0.0")
|
19
|
-
|
20
|
-
# Extract steps from GitLab CI jobs
|
21
|
-
data.each do |key, value|
|
22
|
-
next unless value.is_a?(Hash) && value[:script]
|
23
|
-
|
24
|
-
step_name = key.to_s.gsub(/_job$/, "")
|
25
|
-
step = Step.new(
|
26
|
-
name: step_name,
|
27
|
-
description: value[:description] || "GitLab CI job: #{step_name}",
|
28
|
-
commands: value[:script],
|
29
|
-
)
|
30
|
-
project.add_step(step)
|
31
|
-
end
|
32
|
-
|
33
|
-
project
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def self.generate_yaml(project)
|
39
|
-
yaml = {
|
40
|
-
stages: project.steps.map(&:name),
|
41
|
-
variables: {
|
42
|
-
project_name: project.name,
|
43
|
-
project_version: project.version,
|
44
|
-
},
|
45
|
-
}
|
46
|
-
|
47
|
-
project.steps.each do |step|
|
48
|
-
job_name = "#{step.name}_job"
|
49
|
-
yaml[job_name.to_sym] = {
|
50
|
-
stage: step.name,
|
51
|
-
script: step.commands,
|
52
|
-
description: step.description,
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
|
-
yaml.to_yaml
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
module Makit
|
6
|
+
module Configuration
|
7
|
+
# Helper for GitLab CI YAML conversion
|
8
|
+
class GitLabHelper
|
9
|
+
def self.to_yaml(project, path)
|
10
|
+
yaml_content = generate_yaml(project)
|
11
|
+
File.write(path, yaml_content)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.from_yaml(path)
|
15
|
+
content = File.read(path)
|
16
|
+
data = YAML.safe_load(content, symbolize_names: true, permitted_classes: [Symbol])
|
17
|
+
|
18
|
+
project = Project.new(name: data[:name] || "Unknown", version: data[:version] || "1.0.0")
|
19
|
+
|
20
|
+
# Extract steps from GitLab CI jobs
|
21
|
+
data.each do |key, value|
|
22
|
+
next unless value.is_a?(Hash) && value[:script]
|
23
|
+
|
24
|
+
step_name = key.to_s.gsub(/_job$/, "")
|
25
|
+
step = Step.new(
|
26
|
+
name: step_name,
|
27
|
+
description: value[:description] || "GitLab CI job: #{step_name}",
|
28
|
+
commands: value[:script],
|
29
|
+
)
|
30
|
+
project.add_step(step)
|
31
|
+
end
|
32
|
+
|
33
|
+
project
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def self.generate_yaml(project)
|
39
|
+
yaml = {
|
40
|
+
stages: project.steps.map(&:name),
|
41
|
+
variables: {
|
42
|
+
project_name: project.name,
|
43
|
+
project_version: project.version,
|
44
|
+
},
|
45
|
+
}
|
46
|
+
|
47
|
+
project.steps.each do |step|
|
48
|
+
job_name = "#{step.name}_job"
|
49
|
+
yaml[job_name.to_sym] = {
|
50
|
+
stage: step.name,
|
51
|
+
script: step.commands,
|
52
|
+
description: step.description,
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
yaml.to_yaml
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,127 +1,127 @@
|
|
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
|
10
|
-
|
11
|
-
def initialize(name, version = nil, project_type = nil)
|
12
|
-
# Support both keyword arguments and positional arguments for compatibility
|
13
|
-
if name.is_a?(Hash)
|
14
|
-
# Keyword arguments: Project.new(name: "test", version: "1.0.0")
|
15
|
-
@name = name[:name]
|
16
|
-
@version = name[:version]
|
17
|
-
@project_type = name[:project_type]
|
18
|
-
else
|
19
|
-
# Positional arguments: Project.new("test", "1.0.0", "nuget")
|
20
|
-
@name = name
|
21
|
-
@version = version
|
22
|
-
@project_type = project_type
|
23
|
-
end
|
24
|
-
|
25
|
-
@steps = []
|
26
|
-
end
|
27
|
-
|
28
|
-
def add_step(step)
|
29
|
-
raise ArgumentError, "Step must be a Makit::Configuration::Step instance" unless step.is_a?(Step)
|
30
|
-
@steps << step
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_json(*args)
|
34
|
-
{
|
35
|
-
name: @name,
|
36
|
-
version: @version,
|
37
|
-
project_type: @project_type,
|
38
|
-
steps: @steps.map(&:to_h),
|
39
|
-
}.to_json(*args)
|
40
|
-
end
|
41
|
-
|
42
|
-
def to_json_pretty
|
43
|
-
JSON.pretty_generate({
|
44
|
-
name: @name,
|
45
|
-
version: @version,
|
46
|
-
project_type: @project_type,
|
47
|
-
steps: @steps.map(&:to_h),
|
48
|
-
})
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.from_json(path)
|
52
|
-
content = File.read(path)
|
53
|
-
data = JSON.parse(content, symbolize_names: true)
|
54
|
-
|
55
|
-
project = new(data[:name], data[:version], data[:project_type])
|
56
|
-
data[:steps].each do |step_data|
|
57
|
-
step = Step.new(
|
58
|
-
name: step_data[:name],
|
59
|
-
description: step_data[:description],
|
60
|
-
commands: step_data[:commands],
|
61
|
-
)
|
62
|
-
project.add_step(step)
|
63
|
-
end
|
64
|
-
|
65
|
-
project
|
66
|
-
end
|
67
|
-
|
68
|
-
# Class method for deserializing from JSON string (used by serializer)
|
69
|
-
def self.decode_json(json_string)
|
70
|
-
data = JSON.parse(json_string, symbolize_names: true)
|
71
|
-
|
72
|
-
project = new(data[:name], data[:version], data[:project_type])
|
73
|
-
data[:steps].each do |step_data|
|
74
|
-
step = Step.new(
|
75
|
-
name: step_data[:name],
|
76
|
-
description: step_data[:description],
|
77
|
-
commands: step_data[:commands],
|
78
|
-
)
|
79
|
-
project.add_step(step)
|
80
|
-
end
|
81
|
-
|
82
|
-
project
|
83
|
-
end
|
84
|
-
|
85
|
-
def to_gitlab_ci(path)
|
86
|
-
GitLabHelper.to_yaml(self, path)
|
87
|
-
end
|
88
|
-
|
89
|
-
def to_rakefile
|
90
|
-
RakefileHelper.generate(self)
|
91
|
-
end
|
92
|
-
|
93
|
-
# Save the project to a specific path as pretty JSON
|
94
|
-
def save_as(path)
|
95
|
-
File.write(path, to_json_pretty)
|
96
|
-
end
|
97
|
-
|
98
|
-
def save
|
99
|
-
save_as(".makit.json")
|
100
|
-
end
|
101
|
-
|
102
|
-
# Display the project configuration in YAML format
|
103
|
-
def show
|
104
|
-
require "yaml"
|
105
|
-
|
106
|
-
project_data = {
|
107
|
-
name: @name,
|
108
|
-
version: @version,
|
109
|
-
project_type: @project_type,
|
110
|
-
git_remote_url: @git_remote_url,
|
111
|
-
steps: @steps.map(&:to_h),
|
112
|
-
}
|
113
|
-
|
114
|
-
puts YAML.dump(project_data)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Load a project from the default .makit.json file
|
118
|
-
def self.default
|
119
|
-
if File.exist?(".makit.json")
|
120
|
-
from_json(".makit.json")
|
121
|
-
else
|
122
|
-
new(name: "", version: "0.0.0", project_type: "")
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
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
|
10
|
+
|
11
|
+
def initialize(name, version = nil, project_type = nil)
|
12
|
+
# Support both keyword arguments and positional arguments for compatibility
|
13
|
+
if name.is_a?(Hash)
|
14
|
+
# Keyword arguments: Project.new(name: "test", version: "1.0.0")
|
15
|
+
@name = name[:name]
|
16
|
+
@version = name[:version]
|
17
|
+
@project_type = name[:project_type]
|
18
|
+
else
|
19
|
+
# Positional arguments: Project.new("test", "1.0.0", "nuget")
|
20
|
+
@name = name
|
21
|
+
@version = version
|
22
|
+
@project_type = project_type
|
23
|
+
end
|
24
|
+
|
25
|
+
@steps = []
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_step(step)
|
29
|
+
raise ArgumentError, "Step must be a Makit::Configuration::Step instance" unless step.is_a?(Step)
|
30
|
+
@steps << step
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_json(*args)
|
34
|
+
{
|
35
|
+
name: @name,
|
36
|
+
version: @version,
|
37
|
+
project_type: @project_type,
|
38
|
+
steps: @steps.map(&:to_h),
|
39
|
+
}.to_json(*args)
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_json_pretty
|
43
|
+
JSON.pretty_generate({
|
44
|
+
name: @name,
|
45
|
+
version: @version,
|
46
|
+
project_type: @project_type,
|
47
|
+
steps: @steps.map(&:to_h),
|
48
|
+
})
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.from_json(path)
|
52
|
+
content = File.read(path)
|
53
|
+
data = JSON.parse(content, symbolize_names: true)
|
54
|
+
|
55
|
+
project = new(data[:name], data[:version], data[:project_type])
|
56
|
+
data[:steps].each do |step_data|
|
57
|
+
step = Step.new(
|
58
|
+
name: step_data[:name],
|
59
|
+
description: step_data[:description],
|
60
|
+
commands: step_data[:commands],
|
61
|
+
)
|
62
|
+
project.add_step(step)
|
63
|
+
end
|
64
|
+
|
65
|
+
project
|
66
|
+
end
|
67
|
+
|
68
|
+
# Class method for deserializing from JSON string (used by serializer)
|
69
|
+
def self.decode_json(json_string)
|
70
|
+
data = JSON.parse(json_string, symbolize_names: true)
|
71
|
+
|
72
|
+
project = new(data[:name], data[:version], data[:project_type])
|
73
|
+
data[:steps].each do |step_data|
|
74
|
+
step = Step.new(
|
75
|
+
name: step_data[:name],
|
76
|
+
description: step_data[:description],
|
77
|
+
commands: step_data[:commands],
|
78
|
+
)
|
79
|
+
project.add_step(step)
|
80
|
+
end
|
81
|
+
|
82
|
+
project
|
83
|
+
end
|
84
|
+
|
85
|
+
def to_gitlab_ci(path)
|
86
|
+
GitLabHelper.to_yaml(self, path)
|
87
|
+
end
|
88
|
+
|
89
|
+
def to_rakefile
|
90
|
+
RakefileHelper.generate(self)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Save the project to a specific path as pretty JSON
|
94
|
+
def save_as(path)
|
95
|
+
File.write(path, to_json_pretty)
|
96
|
+
end
|
97
|
+
|
98
|
+
def save
|
99
|
+
save_as(".makit.json")
|
100
|
+
end
|
101
|
+
|
102
|
+
# Display the project configuration in YAML format
|
103
|
+
def show
|
104
|
+
require "yaml"
|
105
|
+
|
106
|
+
project_data = {
|
107
|
+
name: @name,
|
108
|
+
version: @version,
|
109
|
+
project_type: @project_type,
|
110
|
+
git_remote_url: @git_remote_url,
|
111
|
+
steps: @steps.map(&:to_h),
|
112
|
+
}
|
113
|
+
|
114
|
+
puts YAML.dump(project_data)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Load a project from the default .makit.json file
|
118
|
+
def self.default
|
119
|
+
if File.exist?(".makit.json")
|
120
|
+
from_json(".makit.json")
|
121
|
+
else
|
122
|
+
new(name: "", version: "0.0.0", project_type: "")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -1,43 +1,43 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Makit
|
4
|
-
module Configuration
|
5
|
-
# Helper for Rakefile generation
|
6
|
-
class RakefileHelper
|
7
|
-
def self.generate(project)
|
8
|
-
rakefile_content = []
|
9
|
-
|
10
|
-
# Add header comment
|
11
|
-
rakefile_content << "# Generated Rakefile for #{project.name} v#{project.version}"
|
12
|
-
rakefile_content << "# Generated by Makit::Configuration::RakefileHelper"
|
13
|
-
rakefile_content << ""
|
14
|
-
|
15
|
-
# Add default task
|
16
|
-
if project.steps.any?
|
17
|
-
default_tasks = project.steps.map(&:name).join(",")
|
18
|
-
rakefile_content << "desc 'Run all project steps'"
|
19
|
-
rakefile_content << "task :default => [:#{default_tasks}]"
|
20
|
-
rakefile_content << ""
|
21
|
-
end
|
22
|
-
|
23
|
-
# Add individual step tasks
|
24
|
-
project.steps.each do |step|
|
25
|
-
rakefile_content << "desc '#{step.description}'"
|
26
|
-
rakefile_content << "task :#{step.name} do"
|
27
|
-
step.commands.each do |command|
|
28
|
-
rakefile_content << " sh '#{command}'"
|
29
|
-
end
|
30
|
-
rakefile_content << "end"
|
31
|
-
rakefile_content << ""
|
32
|
-
end
|
33
|
-
|
34
|
-
rakefile_content.join("\n")
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.write(project, path)
|
38
|
-
content = generate(project)
|
39
|
-
File.write(path, content)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Makit
|
4
|
+
module Configuration
|
5
|
+
# Helper for Rakefile generation
|
6
|
+
class RakefileHelper
|
7
|
+
def self.generate(project)
|
8
|
+
rakefile_content = []
|
9
|
+
|
10
|
+
# Add header comment
|
11
|
+
rakefile_content << "# Generated Rakefile for #{project.name} v#{project.version}"
|
12
|
+
rakefile_content << "# Generated by Makit::Configuration::RakefileHelper"
|
13
|
+
rakefile_content << ""
|
14
|
+
|
15
|
+
# Add default task
|
16
|
+
if project.steps.any?
|
17
|
+
default_tasks = project.steps.map(&:name).join(",")
|
18
|
+
rakefile_content << "desc 'Run all project steps'"
|
19
|
+
rakefile_content << "task :default => [:#{default_tasks}]"
|
20
|
+
rakefile_content << ""
|
21
|
+
end
|
22
|
+
|
23
|
+
# Add individual step tasks
|
24
|
+
project.steps.each do |step|
|
25
|
+
rakefile_content << "desc '#{step.description}'"
|
26
|
+
rakefile_content << "task :#{step.name} do"
|
27
|
+
step.commands.each do |command|
|
28
|
+
rakefile_content << " sh '#{command}'"
|
29
|
+
end
|
30
|
+
rakefile_content << "end"
|
31
|
+
rakefile_content << ""
|
32
|
+
end
|
33
|
+
|
34
|
+
rakefile_content.join("\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.write(project, path)
|
38
|
+
content = generate(project)
|
39
|
+
File.write(path, content)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Makit
|
4
|
-
module Configuration
|
5
|
-
# Individual step in a project configuration
|
6
|
-
class Step
|
7
|
-
attr_accessor :name, :description, :commands
|
8
|
-
|
9
|
-
def initialize(name:, description:, commands:)
|
10
|
-
@name = name
|
11
|
-
@description = description
|
12
|
-
@commands = commands.is_a?(Array) ? commands : [commands]
|
13
|
-
|
14
|
-
validate_commands
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_h
|
18
|
-
{
|
19
|
-
name: @name,
|
20
|
-
description: @description,
|
21
|
-
commands: @commands,
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def validate_commands
|
28
|
-
unless @commands.is_a?(Array) && @commands.all? { |cmd| cmd.is_a?(String) }
|
29
|
-
raise ArgumentError, "Commands must be an array of strings"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Makit
|
4
|
+
module Configuration
|
5
|
+
# Individual step in a project configuration
|
6
|
+
class Step
|
7
|
+
attr_accessor :name, :description, :commands
|
8
|
+
|
9
|
+
def initialize(name:, description:, commands:)
|
10
|
+
@name = name
|
11
|
+
@description = description
|
12
|
+
@commands = commands.is_a?(Array) ? commands : [commands]
|
13
|
+
|
14
|
+
validate_commands
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_h
|
18
|
+
{
|
19
|
+
name: @name,
|
20
|
+
description: @description,
|
21
|
+
commands: @commands,
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def validate_commands
|
28
|
+
unless @commands.is_a?(Array) && @commands.all? { |cmd| cmd.is_a?(String) }
|
29
|
+
raise ArgumentError, "Commands must be an array of strings"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/makit/configuration.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Load all configuration classes
|
4
|
-
require_relative "configuration/project"
|
5
|
-
require_relative "configuration/step"
|
6
|
-
require_relative "configuration/gitlab_helper"
|
7
|
-
require_relative "configuration/rakefile_helper"
|
8
|
-
|
9
|
-
# Main configuration module that loads all configuration classes
|
10
|
-
module Makit
|
11
|
-
module Configuration
|
12
|
-
# All configuration classes are now loaded above
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Load all configuration classes
|
4
|
+
require_relative "configuration/project"
|
5
|
+
require_relative "configuration/step"
|
6
|
+
require_relative "configuration/gitlab_helper"
|
7
|
+
require_relative "configuration/rakefile_helper"
|
8
|
+
|
9
|
+
# Main configuration module that loads all configuration classes
|
10
|
+
module Makit
|
11
|
+
module Configuration
|
12
|
+
# All configuration classes are now loaded above
|
13
|
+
end
|
14
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Makit
|
4
|
-
module Content
|
5
|
-
GITIGNORE = File.read(File.join(__dir__, "default_gitignore.txt"))
|
6
|
-
end
|
7
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Makit
|
4
|
+
module Content
|
5
|
+
GITIGNORE = File.read(File.join(__dir__, "default_gitignore.txt"))
|
6
|
+
end
|
7
|
+
end
|