makit 0.0.112 → 0.0.128
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 +311 -320
- data/lib/makit/commands/middleware/validator.rb +269 -269
- data/lib/makit/commands/request.rb +316 -254
- data/lib/makit/commands/result.rb +323 -323
- data/lib/makit/commands/runner.rb +368 -337
- data/lib/makit/commands/strategies/base.rb +171 -160
- data/lib/makit/commands/strategies/synchronous.rb +139 -134
- data/lib/makit/commands.rb +50 -51
- data/lib/makit/configuration/gitlab_helper.rb +58 -60
- data/lib/makit/configuration/project.rb +167 -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_gitignore.txt +226 -0
- 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 +140 -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/cli.rb +69 -65
- data/lib/makit/dotnet/project.rb +217 -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 +308 -305
- data/lib/makit/logging/format_registry.rb +84 -84
- data/lib/makit/logging/formatters/base.rb +39 -39
- data/lib/makit/logging/formatters/console_formatter.rb +140 -140
- 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 +119 -115
- data/lib/makit/logging/logger.rb +199 -163
- data/lib/makit/logging/sinks/base.rb +91 -91
- data/lib/makit/logging/sinks/console.rb +72 -72
- data/lib/makit/logging/sinks/file_sink.rb +92 -92
- data/lib/makit/logging/sinks/structured.rb +123 -129
- data/lib/makit/logging/sinks/unified_file_sink.rb +296 -303
- data/lib/makit/logging.rb +565 -530
- 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 +191 -193
- 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 -130
- data/lib/makit/services/builder.rb +186 -186
- data/lib/makit/services/error_handler.rb +226 -226
- data/lib/makit/services/repository_manager.rb +231 -229
- data/lib/makit/services/validator.rb +112 -112
- data/lib/makit/setup/classlib.rb +94 -53
- data/lib/makit/setup/gem.rb +268 -263
- data/lib/makit/setup/razorclasslib.rb +91 -0
- data/lib/makit/setup/runner.rb +54 -45
- data/lib/makit/setup.rb +5 -5
- data/lib/makit/show.rb +110 -110
- data/lib/makit/storage.rb +126 -126
- data/lib/makit/symbols.rb +170 -170
- data/lib/makit/task_info.rb +128 -128
- data/lib/makit/tasks/at_exit.rb +15 -13
- data/lib/makit/tasks/build.rb +22 -19
- data/lib/makit/tasks/clean.rb +13 -11
- data/lib/makit/tasks/configure.rb +10 -0
- data/lib/makit/tasks/format.rb +10 -0
- data/lib/makit/tasks/hook_manager.rb +391 -393
- data/lib/makit/tasks/init.rb +49 -47
- data/lib/makit/tasks/integrate.rb +29 -17
- data/lib/makit/tasks/pull_incoming.rb +13 -11
- data/lib/makit/tasks/setup.rb +13 -6
- data/lib/makit/tasks/sync.rb +17 -12
- data/lib/makit/tasks/tag.rb +16 -15
- data/lib/makit/tasks/task_monkey_patch.rb +81 -79
- data/lib/makit/tasks/test.rb +22 -0
- data/lib/makit/tasks/update.rb +18 -0
- data/lib/makit/tasks.rb +20 -15
- data/lib/makit/test_cache.rb +239 -239
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/makit.v1_pb.rb +35 -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 -21
- 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 -44
- data/lib/makit.rb +39 -40
- metadata +69 -7
- data/lib/makit/commands/middleware/unified_logger.rb +0 -243
data/lib/makit/commands.rb
CHANGED
@@ -1,51 +1,50 @@
|
|
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/
|
49
|
-
require_relative "commands/
|
50
|
-
require_relative "commands/strategies/
|
51
|
-
require_relative "commands/strategies/synchronous"
|
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/base"
|
49
|
+
require_relative "commands/strategies/base"
|
50
|
+
require_relative "commands/strategies/synchronous"
|
@@ -1,60 +1,58 @@
|
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
+
def self.generate_yaml(project)
|
37
|
+
yaml = {
|
38
|
+
stages: project.steps.map(&:name),
|
39
|
+
variables: {
|
40
|
+
project_name: project.name,
|
41
|
+
project_version: project.version,
|
42
|
+
},
|
43
|
+
}
|
44
|
+
|
45
|
+
project.steps.each do |step|
|
46
|
+
job_name = "#{step.name}_job"
|
47
|
+
yaml[job_name.to_sym] = {
|
48
|
+
stage: step.name,
|
49
|
+
script: step.commands,
|
50
|
+
description: step.description,
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
yaml.to_yaml
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,127 +1,167 @@
|
|
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
|
-
@
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
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, :authors, :description, :license_expression
|
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
|
+
@authors = "authors"
|
25
|
+
@description = "description"
|
26
|
+
@license_expression = "MIT"
|
27
|
+
@steps = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_step(step)
|
31
|
+
raise ArgumentError, "Step must be a Makit::Configuration::Step instance" unless step.is_a?(Step)
|
32
|
+
|
33
|
+
@steps << step
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_json(*args)
|
37
|
+
{
|
38
|
+
name: @name,
|
39
|
+
version: @version,
|
40
|
+
project_type: @project_type,
|
41
|
+
authors: @authors,
|
42
|
+
description: @description,
|
43
|
+
license_expression: @license_expression,
|
44
|
+
steps: @steps.map(&:to_h),
|
45
|
+
}.to_json(*args)
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_json_pretty
|
49
|
+
JSON.pretty_generate({
|
50
|
+
name: @name,
|
51
|
+
version: @version,
|
52
|
+
project_type: @project_type,
|
53
|
+
authors: @authors,
|
54
|
+
description: @description,
|
55
|
+
license_expression: @license_expression,
|
56
|
+
steps: @steps.map(&:to_h),
|
57
|
+
})
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.from_json(path)
|
61
|
+
content = File.read(path)
|
62
|
+
data = JSON.parse(content, symbolize_names: true)
|
63
|
+
|
64
|
+
project = new(data[:name], data[:version], data[:project_type])
|
65
|
+
|
66
|
+
# Set additional fields if they exist in the JSON
|
67
|
+
project.authors = data[:authors] if data[:authors]
|
68
|
+
project.description = data[:description] if data[:description]
|
69
|
+
project.license_expression = data[:license_expression] if data[:license_expression]
|
70
|
+
|
71
|
+
data[:steps].each do |step_data|
|
72
|
+
step = Step.new(
|
73
|
+
name: step_data[:name],
|
74
|
+
description: step_data[:description],
|
75
|
+
commands: step_data[:commands],
|
76
|
+
)
|
77
|
+
project.add_step(step)
|
78
|
+
end
|
79
|
+
|
80
|
+
project
|
81
|
+
end
|
82
|
+
|
83
|
+
# Class method for deserializing from JSON string (used by serializer)
|
84
|
+
def self.decode_json(json_string)
|
85
|
+
data = JSON.parse(json_string, symbolize_names: true)
|
86
|
+
|
87
|
+
project = new(data[:name], data[:version], data[:project_type])
|
88
|
+
|
89
|
+
# Set additional fields if they exist in the JSON
|
90
|
+
project.authors = data[:authors] if data[:authors]
|
91
|
+
project.description = data[:description] if data[:description]
|
92
|
+
project.license_expression = data[:license_expression] if data[:license_expression]
|
93
|
+
|
94
|
+
data[:steps].each do |step_data|
|
95
|
+
step = Step.new(
|
96
|
+
name: step_data[:name],
|
97
|
+
description: step_data[:description],
|
98
|
+
commands: step_data[:commands],
|
99
|
+
)
|
100
|
+
project.add_step(step)
|
101
|
+
end
|
102
|
+
|
103
|
+
project
|
104
|
+
end
|
105
|
+
|
106
|
+
def to_gitlab_ci(path)
|
107
|
+
GitLabHelper.to_yaml(self, path)
|
108
|
+
end
|
109
|
+
|
110
|
+
def to_rakefile
|
111
|
+
RakefileHelper.generate(self)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Save the project to a specific path as pretty JSON
|
115
|
+
def save_as(path)
|
116
|
+
# Validate that the project has a non-empty name before saving
|
117
|
+
if @name.nil? || @name.strip.empty?
|
118
|
+
raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
|
119
|
+
end
|
120
|
+
|
121
|
+
File.write(path, to_json_pretty)
|
122
|
+
end
|
123
|
+
|
124
|
+
def save
|
125
|
+
# Validate that the project has a non-empty name before saving
|
126
|
+
if @name.nil? || @name.strip.empty?
|
127
|
+
raise ArgumentError, "Project name cannot be empty. Please set a valid project name before saving."
|
128
|
+
end
|
129
|
+
|
130
|
+
save_as(".makit.json")
|
131
|
+
end
|
132
|
+
|
133
|
+
# Display the project configuration in YAML format
|
134
|
+
def show
|
135
|
+
require "yaml"
|
136
|
+
|
137
|
+
project_data = {
|
138
|
+
name: @name,
|
139
|
+
version: @version,
|
140
|
+
project_type: @project_type,
|
141
|
+
git_remote_url: @git_remote_url,
|
142
|
+
steps: @steps.map(&:to_h),
|
143
|
+
}
|
144
|
+
|
145
|
+
puts YAML.dump(project_data)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Load a project from the default .makit.json file
|
149
|
+
def self.default
|
150
|
+
if File.exist?(".makit.json")
|
151
|
+
from_json(".makit.json")
|
152
|
+
else
|
153
|
+
# Makit::Logging.default_logger.warn("Project not configured")
|
154
|
+
# #if defined?(NAME) && defined?(VERSION) && defined?(PROJECT_TYPE)
|
155
|
+
# project = new(name: NAME, version: VERSION, project_type: PROJECT_TYPE)
|
156
|
+
# project.save
|
157
|
+
# else
|
158
|
+
project = new(name: "", version: "0.0.0", project_type: "")
|
159
|
+
Makit::Logging.default_logger.warn("Project not configured")
|
160
|
+
# Makit::Logging.default_logger.warn("Define NAME, VERSION, and PROJECT_TYPE in the Rakefile")
|
161
|
+
# end
|
162
|
+
project
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
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
|