makit 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/makit/apache.rb +32 -32
- data/lib/makit/cli/clean.rb +14 -14
- data/lib/makit/cli/clone.rb +59 -59
- data/lib/makit/cli/init.rb +38 -38
- data/lib/makit/cli/main.rb +33 -33
- data/lib/makit/cli/make.rb +54 -54
- data/lib/makit/cli/new.rb +37 -37
- data/lib/makit/cli/nuget_cache.rb +38 -38
- data/lib/makit/cli/pull.rb +31 -31
- data/lib/makit/cli/setup.rb +71 -71
- data/lib/makit/cli/work.rb +21 -21
- data/lib/makit/command_runner.rb +274 -237
- data/lib/makit/commands.rb +21 -21
- data/lib/makit/content/default_gitignore.rb +5 -5
- data/lib/makit/content/default_rakefile.rb +11 -11
- data/lib/makit/content/gem_rakefile.rb +14 -14
- data/lib/makit/data.rb +50 -50
- data/lib/makit/directories.rb +140 -140
- data/lib/makit/directory.rb +151 -120
- data/lib/makit/dotnet.rb +83 -75
- data/lib/makit/environment.rb +123 -123
- data/lib/makit/files.rb +47 -47
- data/lib/makit/git.rb +66 -66
- data/lib/makit/gitlab_runner.rb +60 -60
- data/lib/makit/humanize.rb +89 -89
- data/lib/makit/logging.rb +96 -96
- data/lib/makit/markdown.rb +75 -75
- data/lib/makit/mp/basic_object_mp.rb +16 -16
- data/lib/makit/mp/command_request.mp.rb +13 -0
- data/lib/makit/mp/project_mp.rb +156 -149
- data/lib/makit/mp/string_mp.rb +101 -101
- data/lib/makit/nuget.rb +57 -57
- data/lib/makit/protoc.rb +61 -61
- data/lib/makit/serializer.rb +115 -70
- data/lib/makit/storage.rb +131 -131
- data/lib/makit/symbols.rb +149 -149
- data/lib/makit/tasks.rb +67 -67
- data/lib/makit/tree.rb +37 -37
- data/lib/makit/v1/makit.v1_pb.rb +5 -5
- data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
- data/lib/makit/version.rb +12 -12
- data/lib/makit/wix.rb +95 -95
- data/lib/makit/zip.rb +17 -17
- data/lib/makit.rb +243 -243
- metadata +4 -39
- data/.makit.project.json +0 -4
- data/.makit.project.yml +0 -2
- data/.rubocop.yml +0 -22
- data/.ruby-version +0 -1
- data/CHANGELOG.md +0 -8
- data/CODE_OF_CONDUCT.md +0 -84
- data/LICENSE +0 -21
- data/README.md +0 -119
- data/Rakefile +0 -200
- data/docs/Commands.md +0 -50
- data/docs_/Commands.md +0 -166
- data/docs_/Minitest.Timeouts.md +0 -332
- data/examples/protoc/Rakefile +0 -31
- data/examples/rake_default/Rakefile +0 -6
- data/examples/rubygem-foo/.gitkeep +0 -0
- data/examples/rubygem-foo/Rakefile +0 -3
- data/examples/run_mp/Rakefile +0 -8
- data/exe/makit +0 -5
- data/lib/makit/content/default_gitignore.txt +0 -222
- data/lib/makit/content/ruby_gitlab-ci.yml +0 -15
- data/lib/makit/v1/makit.v1.proto +0 -103
- data/makit.generated.sln +0 -30
- data/makit.sln +0 -69
- data/pages/.gitignore +0 -5
- data/pages/404.html +0 -25
- data/pages/Gemfile +0 -33
- data/pages/Gemfile.lock +0 -88
- data/pages/_config.yml +0 -55
- data/pages/_layouts/default.html +0 -1
- data/pages/_posts/2024-10-05-welcome-to-jekyll.markdown +0 -29
- data/pages/about.markdown +0 -18
- data/pages/index.markdown +0 -6
- data/sig/makit.rbs +0 -4
- data/src/ClassLib/Class1.cs +0 -6
- data/src/ClassLib/ClassLib.csproj +0 -13
@@ -1,16 +1,16 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "json"
|
3
|
-
require "yaml"
|
4
|
-
|
5
|
-
# monkey patch String class with a run method
|
6
|
-
|
7
|
-
class BasicObject
|
8
|
-
def to_json
|
9
|
-
self.to_json
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_pretty_json
|
13
|
-
json = self.to_json
|
14
|
-
::JSON.pretty_generate(::JSON.parse(json))
|
15
|
-
end
|
16
|
-
end # class BasicObject
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "json"
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
# monkey patch String class with a run method
|
6
|
+
|
7
|
+
class BasicObject
|
8
|
+
def to_json
|
9
|
+
self.to_json
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_pretty_json
|
13
|
+
json = self.to_json
|
14
|
+
::JSON.pretty_generate(::JSON.parse(json))
|
15
|
+
end
|
16
|
+
end # class BasicObject
|
data/lib/makit/mp/project_mp.rb
CHANGED
@@ -1,149 +1,156 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "json"
|
3
|
-
require "yaml"
|
4
|
-
|
5
|
-
module Makit
|
6
|
-
module V1
|
7
|
-
class Project
|
8
|
-
def to_yaml
|
9
|
-
data = JSON.parse(self.to_pretty_json)
|
10
|
-
data.to_yaml.sub(/^---\n/, "")
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.create
|
14
|
-
project = Makit::V1::Project.new
|
15
|
-
project.set_default_values
|
16
|
-
project
|
17
|
-
end
|
18
|
-
|
19
|
-
def open(filename)
|
20
|
-
other = Makit::V1::Project::create_from_file(filename)
|
21
|
-
self.name = other.name
|
22
|
-
self.git_remote_url = other.git_remote_url
|
23
|
-
self.dotnet_projects = other.dotnet_projects
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.create_from_file(filename)
|
27
|
-
extension = File.extname(filename)
|
28
|
-
case extension
|
29
|
-
when ".yml"
|
30
|
-
yaml = File.read(filename)
|
31
|
-
create_from_yaml(yaml)
|
32
|
-
when ".json"
|
33
|
-
json = File.read(filename)
|
34
|
-
create_from_json(json)
|
35
|
-
else
|
36
|
-
raise "unsupported file extension: #{extension}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.create_from_yaml(yaml)
|
41
|
-
json = JSON.pretty_generate(YAML.load(yaml))
|
42
|
-
project = Makit::V1::Project.decode_json(json)
|
43
|
-
project
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.create_from_json(json)
|
47
|
-
project = Makit::V1::Project.decode_json(json)
|
48
|
-
project
|
49
|
-
end
|
50
|
-
|
51
|
-
def set_default_values
|
52
|
-
#self.language = "csharp"
|
53
|
-
#self.primary_artifact_type = "nuget"
|
54
|
-
if self.git_remote_url.nil? || self.git_remote_url.empty?
|
55
|
-
self.git_remote_url = `git remote get-url origin`.strip
|
56
|
-
end
|
57
|
-
if self.name.nil? || self.name.empty?
|
58
|
-
if (!self.git_remote_url.nil? && !self.git_remote_url.empty?)
|
59
|
-
self.name = get_name(File.basename(self.git_remote_url, ".git")) # get_capitalized_name(File.basename(self.git_remote_url, ".git"))
|
60
|
-
else
|
61
|
-
self.name = get_name(File.basename(Dir.getwd)) # get_capitalized_name(File.basename(Dir.getwd))
|
62
|
-
end
|
63
|
-
end
|
64
|
-
self
|
65
|
-
end
|
66
|
-
|
67
|
-
def get_name(name)
|
68
|
-
if !self.git_remote_url.nil? && !self.git_remote_url.empty?
|
69
|
-
is_dotnet = self.git_remote_url.include?("nuget")
|
70
|
-
if is_dotnet
|
71
|
-
get_capitalized_name(name)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
name.downcase
|
75
|
-
end
|
76
|
-
|
77
|
-
def get_capitalized_name(name)
|
78
|
-
name.split(".").map(&:capitalize).join(".")
|
79
|
-
end
|
80
|
-
|
81
|
-
def save_as(filename)
|
82
|
-
extension = File.extname(filename)
|
83
|
-
case extension
|
84
|
-
when ".json"
|
85
|
-
File.write(filename, self.to_pretty_json)
|
86
|
-
when ".yml"
|
87
|
-
File.write(filename, self.to_yaml)
|
88
|
-
else
|
89
|
-
raise "unsupported file extension: #{extension}"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def with_dotnet_project(template, name, output)
|
94
|
-
if !self.dotnet_projects.any? { |project| project.output == output }
|
95
|
-
project = Makit::V1::DotNetProject.new
|
96
|
-
project.template = template
|
97
|
-
project.name = name
|
98
|
-
project.output = output
|
99
|
-
self.dotnet_projects << project
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def setup
|
104
|
-
setup_dotnet_projects
|
105
|
-
end
|
106
|
-
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "json"
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
module Makit
|
6
|
+
module V1
|
7
|
+
class Project
|
8
|
+
def to_yaml
|
9
|
+
data = JSON.parse(self.to_pretty_json)
|
10
|
+
data.to_yaml.sub(/^---\n/, "")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.create
|
14
|
+
project = Makit::V1::Project.new
|
15
|
+
project.set_default_values
|
16
|
+
project
|
17
|
+
end
|
18
|
+
|
19
|
+
def open(filename)
|
20
|
+
other = Makit::V1::Project::create_from_file(filename)
|
21
|
+
self.name = other.name
|
22
|
+
self.git_remote_url = other.git_remote_url
|
23
|
+
self.dotnet_projects = other.dotnet_projects
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.create_from_file(filename)
|
27
|
+
extension = File.extname(filename)
|
28
|
+
case extension
|
29
|
+
when ".yml"
|
30
|
+
yaml = File.read(filename)
|
31
|
+
create_from_yaml(yaml)
|
32
|
+
when ".json"
|
33
|
+
json = File.read(filename)
|
34
|
+
create_from_json(json)
|
35
|
+
else
|
36
|
+
raise "unsupported file extension: #{extension}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.create_from_yaml(yaml)
|
41
|
+
json = JSON.pretty_generate(YAML.load(yaml))
|
42
|
+
project = Makit::V1::Project.decode_json(json)
|
43
|
+
project
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.create_from_json(json)
|
47
|
+
project = Makit::V1::Project.decode_json(json)
|
48
|
+
project
|
49
|
+
end
|
50
|
+
|
51
|
+
def set_default_values
|
52
|
+
#self.language = "csharp"
|
53
|
+
#self.primary_artifact_type = "nuget"
|
54
|
+
if self.git_remote_url.nil? || self.git_remote_url.empty?
|
55
|
+
self.git_remote_url = `git remote get-url origin`.strip
|
56
|
+
end
|
57
|
+
if self.name.nil? || self.name.empty?
|
58
|
+
if (!self.git_remote_url.nil? && !self.git_remote_url.empty?)
|
59
|
+
self.name = get_name(File.basename(self.git_remote_url, ".git")) # get_capitalized_name(File.basename(self.git_remote_url, ".git"))
|
60
|
+
else
|
61
|
+
self.name = get_name(File.basename(Dir.getwd)) # get_capitalized_name(File.basename(Dir.getwd))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_name(name)
|
68
|
+
if !self.git_remote_url.nil? && !self.git_remote_url.empty?
|
69
|
+
is_dotnet = self.git_remote_url.include?("nuget")
|
70
|
+
if is_dotnet
|
71
|
+
get_capitalized_name(name)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
name.downcase
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_capitalized_name(name)
|
78
|
+
name.split(".").map(&:capitalize).join(".")
|
79
|
+
end
|
80
|
+
|
81
|
+
def save_as(filename)
|
82
|
+
extension = File.extname(filename)
|
83
|
+
case extension
|
84
|
+
when ".json"
|
85
|
+
File.write(filename, self.to_pretty_json)
|
86
|
+
when ".yml"
|
87
|
+
File.write(filename, self.to_yaml)
|
88
|
+
else
|
89
|
+
raise "unsupported file extension: #{extension}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def with_dotnet_project(template, name, output)
|
94
|
+
if !self.dotnet_projects.any? { |project| project.output == output }
|
95
|
+
project = Makit::V1::DotNetProject.new
|
96
|
+
project.template = template
|
97
|
+
project.name = name
|
98
|
+
project.output = output
|
99
|
+
self.dotnet_projects << project
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def setup
|
104
|
+
setup_dotnet_projects
|
105
|
+
end
|
106
|
+
|
107
|
+
def build
|
108
|
+
build_dotnet_projects
|
109
|
+
end
|
110
|
+
|
111
|
+
def setup_dotnet_projects
|
112
|
+
if self.dotnet_projects.any?
|
113
|
+
if (!File.exist?("#{self.name}.sln"))
|
114
|
+
puts " Creating solution file: " + "#{self.name}.sln".colorize(:green)
|
115
|
+
"dotnet new sln -n #{self.name}".run unless File.exist?("#{self.name}.sln")
|
116
|
+
else
|
117
|
+
puts " Solution file already exists: " + "#{self.name}.sln".colorize(:yellow)
|
118
|
+
end
|
119
|
+
self.dotnet_projects.each do |project|
|
120
|
+
add_project = true
|
121
|
+
if (project.os == "windows" && !Makit::Environment.is_windows?)
|
122
|
+
add_project = false
|
123
|
+
end
|
124
|
+
if (add_project)
|
125
|
+
Makit::DotNet.new_project(project.template, project.name, project.output)
|
126
|
+
# add any nuget packages to the project
|
127
|
+
project_filename = "#{project.output}/#{project.name}.csproj"
|
128
|
+
project.packages.each { |package|
|
129
|
+
Makit::DotNet::add_package(project_filename, package)
|
130
|
+
}
|
131
|
+
end
|
132
|
+
end
|
133
|
+
Makit::DotNet.new_solution(self.name)
|
134
|
+
Makit::DotNet.sln_add_projects(self.name)
|
135
|
+
else
|
136
|
+
puts " no dotnet projects found".colorize(:yellow)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def build_dotnet_projects
|
141
|
+
self.dotnet_projects.each do |project|
|
142
|
+
project.build_args.each do |build_arg|
|
143
|
+
project_path = File.join(project.output, "#{project.name}.csproj")
|
144
|
+
Makit::DotNet.build(project_path, build_arg.configuration, build_arg.output)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_dotnet_projects
|
150
|
+
self.dotnet_projects.each do |project|
|
151
|
+
"dotnet test #{project.output} --configuration Release".run
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end # class Project
|
155
|
+
end # module V1
|
156
|
+
end # module Makit
|
data/lib/makit/mp/string_mp.rb
CHANGED
@@ -1,101 +1,101 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "json"
|
3
|
-
# monkey patch String class with a run method
|
4
|
-
|
5
|
-
class String
|
6
|
-
def run(args = nil)
|
7
|
-
if args.nil?
|
8
|
-
command = self
|
9
|
-
Makit::RUNNER.run(Makit::RUNNER::parse_command_request(command))
|
10
|
-
else
|
11
|
-
command = self
|
12
|
-
request = Makit::RUNNER.parse_args(command)
|
13
|
-
if args.is_a?(Hash)
|
14
|
-
args.each do |key, value|
|
15
|
-
request.send("#{key}=", value)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
Makit::RUNNER.run(request)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def try(args = nil)
|
23
|
-
if args.nil?
|
24
|
-
command = self
|
25
|
-
Makit::RUNNER.try(command)
|
26
|
-
else
|
27
|
-
command = self
|
28
|
-
request = Makit::RUNNER.parse_args(command)
|
29
|
-
if args.is_a?(Hash)
|
30
|
-
args.each do |key, value|
|
31
|
-
request.send("#{key}=", value)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
Makit::RUNNER.try(request)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Read a value from a JSON file
|
39
|
-
# key is a string with the key to read, e.g. "AzureAd.Authority"
|
40
|
-
def get_json_value(key)
|
41
|
-
json = File.read(self)
|
42
|
-
data = JSON.parse(json)
|
43
|
-
|
44
|
-
# key delimiter is '.' so we can access nested keys
|
45
|
-
key.split(".").each do |k|
|
46
|
-
data = data[k]
|
47
|
-
end
|
48
|
-
data
|
49
|
-
end
|
50
|
-
|
51
|
-
alias_method :retrieve, :get_json_value
|
52
|
-
|
53
|
-
# Set a value in a JSON file
|
54
|
-
# key is a string with the key to set, e.g. "AzureAd.Authority"
|
55
|
-
def set_json_value(key, value)
|
56
|
-
file = File.read(self)
|
57
|
-
data = JSON.parse(file)
|
58
|
-
keys = key.split(".")
|
59
|
-
current = data
|
60
|
-
|
61
|
-
# Traverse and create any missing keys
|
62
|
-
keys[0..-2].each do |k|
|
63
|
-
current[k] ||= {} # Create a new hash if the key doesn't exist
|
64
|
-
current = current[k]
|
65
|
-
end
|
66
|
-
|
67
|
-
# Set the value for the final key
|
68
|
-
current[keys[-1]] = value
|
69
|
-
|
70
|
-
# Write the JSON back to the file
|
71
|
-
File.write(self, JSON.pretty_generate(data))
|
72
|
-
end
|
73
|
-
|
74
|
-
# Alias for set_json_value
|
75
|
-
alias_method :assign, :set_json_value
|
76
|
-
|
77
|
-
def to_lines(max_length = 80, indent_length = 5)
|
78
|
-
if (self.length <= max_length)
|
79
|
-
return self
|
80
|
-
else
|
81
|
-
indent = " " * indent_length
|
82
|
-
words = self.split(" ")
|
83
|
-
lines = []
|
84
|
-
line = ""
|
85
|
-
words.each do |word|
|
86
|
-
if ((line + word).length > max_length)
|
87
|
-
lines << line
|
88
|
-
line = indent + word
|
89
|
-
else
|
90
|
-
if (line.length == 0)
|
91
|
-
line = word
|
92
|
-
else
|
93
|
-
line += " " + word
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
lines << line
|
98
|
-
return lines.join("\n")
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "json"
|
3
|
+
# monkey patch String class with a run method
|
4
|
+
|
5
|
+
class String
|
6
|
+
def run(args = nil)
|
7
|
+
if args.nil?
|
8
|
+
command = self
|
9
|
+
Makit::RUNNER.run(Makit::RUNNER::parse_command_request(command))
|
10
|
+
else
|
11
|
+
command = self
|
12
|
+
request = Makit::RUNNER.parse_args(command)
|
13
|
+
if args.is_a?(Hash)
|
14
|
+
args.each do |key, value|
|
15
|
+
request.send("#{key}=", value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
Makit::RUNNER.run(request)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def try(args = nil)
|
23
|
+
if args.nil?
|
24
|
+
command = self
|
25
|
+
Makit::RUNNER.try(command)
|
26
|
+
else
|
27
|
+
command = self
|
28
|
+
request = Makit::RUNNER.parse_args(command)
|
29
|
+
if args.is_a?(Hash)
|
30
|
+
args.each do |key, value|
|
31
|
+
request.send("#{key}=", value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
Makit::RUNNER.try(request)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Read a value from a JSON file
|
39
|
+
# key is a string with the key to read, e.g. "AzureAd.Authority"
|
40
|
+
def get_json_value(key)
|
41
|
+
json = File.read(self)
|
42
|
+
data = JSON.parse(json)
|
43
|
+
|
44
|
+
# key delimiter is '.' so we can access nested keys
|
45
|
+
key.split(".").each do |k|
|
46
|
+
data = data[k]
|
47
|
+
end
|
48
|
+
data
|
49
|
+
end
|
50
|
+
|
51
|
+
alias_method :retrieve, :get_json_value
|
52
|
+
|
53
|
+
# Set a value in a JSON file
|
54
|
+
# key is a string with the key to set, e.g. "AzureAd.Authority"
|
55
|
+
def set_json_value(key, value)
|
56
|
+
file = File.read(self)
|
57
|
+
data = JSON.parse(file)
|
58
|
+
keys = key.split(".")
|
59
|
+
current = data
|
60
|
+
|
61
|
+
# Traverse and create any missing keys
|
62
|
+
keys[0..-2].each do |k|
|
63
|
+
current[k] ||= {} # Create a new hash if the key doesn't exist
|
64
|
+
current = current[k]
|
65
|
+
end
|
66
|
+
|
67
|
+
# Set the value for the final key
|
68
|
+
current[keys[-1]] = value
|
69
|
+
|
70
|
+
# Write the JSON back to the file
|
71
|
+
File.write(self, JSON.pretty_generate(data))
|
72
|
+
end
|
73
|
+
|
74
|
+
# Alias for set_json_value
|
75
|
+
alias_method :assign, :set_json_value
|
76
|
+
|
77
|
+
def to_lines(max_length = 80, indent_length = 5)
|
78
|
+
if (self.length <= max_length)
|
79
|
+
return self
|
80
|
+
else
|
81
|
+
indent = " " * indent_length
|
82
|
+
words = self.split(" ")
|
83
|
+
lines = []
|
84
|
+
line = ""
|
85
|
+
words.each do |word|
|
86
|
+
if ((line + word).length > max_length)
|
87
|
+
lines << line
|
88
|
+
line = indent + word
|
89
|
+
else
|
90
|
+
if (line.length == 0)
|
91
|
+
line = word
|
92
|
+
else
|
93
|
+
line += " " + word
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
lines << line
|
98
|
+
return lines.join("\n")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/lib/makit/nuget.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
require "tmpdir"
|
2
|
-
# This module provides classes for the Makit gem.
|
3
|
-
module Makit
|
4
|
-
# This class provide methods for working with the Nuget package cache
|
5
|
-
#
|
6
|
-
# Example:
|
7
|
-
#
|
8
|
-
# Makit::Directory.cache("Google.Protobuf", "3.27.2")
|
9
|
-
#
|
10
|
-
# dotnet nuget locals all --list
|
11
|
-
# dotnet nuget locals all --clear
|
12
|
-
#
|
13
|
-
class NuGet
|
14
|
-
def self.get_cache_dir(package, version)
|
15
|
-
File.join(Makit::Directories::NUGET_PACKAGE_CACHE, package, version)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.cache(package, version)
|
19
|
-
# if the package is already cached, there is nothing to do
|
20
|
-
if (!Dir.exist?(get_cache_dir(package, version)))
|
21
|
-
Dir.mktmpdir do |dir|
|
22
|
-
# Use the temp directory here
|
23
|
-
Dir.chdir(dir) do
|
24
|
-
system("dotnet new classlib -n ClassLib")
|
25
|
-
Dir.chdir("ClassLib") do
|
26
|
-
|
27
|
-
# display a list of directories in the current directory
|
28
|
-
puts Dir.entries(Dir.pwd)
|
29
|
-
# display a list of files in the current directory
|
30
|
-
puts Dir.entries(Dir.pwd)
|
31
|
-
puts "dotnet add ClassLib.csproj package #{package} --version #{version}"
|
32
|
-
system("dotnet add ClassLib.csproj package #{package} --version #{version}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
# The directory and its contents will be removed automatically after the block
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.clear_cache(package, version)
|
41
|
-
if (Dir.exist?(get_cache_dir(package, version)))
|
42
|
-
FileUtils.rm_rf(get_cache_dir(package, version))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# get the latest version of the package
|
47
|
-
def self.get_latest_version(package)
|
48
|
-
dir = File.join(Makit::Directories::NUGET_PACKAGE_CACHE, package)
|
49
|
-
if (Dir.exist?(dir))
|
50
|
-
versions = Dir.entries(dir).select { |entry| File.directory?(File.join(dir, entry)) && !(entry == "." || entry == "..") }
|
51
|
-
highest_version = Makit::Version::get_highest_version(versions)
|
52
|
-
return highest_version
|
53
|
-
end
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
require "tmpdir"
|
2
|
+
# This module provides classes for the Makit gem.
|
3
|
+
module Makit
|
4
|
+
# This class provide methods for working with the Nuget package cache
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# Makit::Directory.cache("Google.Protobuf", "3.27.2")
|
9
|
+
#
|
10
|
+
# dotnet nuget locals all --list
|
11
|
+
# dotnet nuget locals all --clear
|
12
|
+
#
|
13
|
+
class NuGet
|
14
|
+
def self.get_cache_dir(package, version)
|
15
|
+
File.join(Makit::Directories::NUGET_PACKAGE_CACHE, package, version)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.cache(package, version)
|
19
|
+
# if the package is already cached, there is nothing to do
|
20
|
+
if (!Dir.exist?(get_cache_dir(package, version)))
|
21
|
+
Dir.mktmpdir do |dir|
|
22
|
+
# Use the temp directory here
|
23
|
+
Dir.chdir(dir) do
|
24
|
+
system("dotnet new classlib -n ClassLib")
|
25
|
+
Dir.chdir("ClassLib") do
|
26
|
+
|
27
|
+
# display a list of directories in the current directory
|
28
|
+
puts Dir.entries(Dir.pwd)
|
29
|
+
# display a list of files in the current directory
|
30
|
+
puts Dir.entries(Dir.pwd)
|
31
|
+
puts "dotnet add ClassLib.csproj package #{package} --version #{version}"
|
32
|
+
system("dotnet add ClassLib.csproj package #{package} --version #{version}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
# The directory and its contents will be removed automatically after the block
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.clear_cache(package, version)
|
41
|
+
if (Dir.exist?(get_cache_dir(package, version)))
|
42
|
+
FileUtils.rm_rf(get_cache_dir(package, version))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# get the latest version of the package
|
47
|
+
def self.get_latest_version(package)
|
48
|
+
dir = File.join(Makit::Directories::NUGET_PACKAGE_CACHE, package)
|
49
|
+
if (Dir.exist?(dir))
|
50
|
+
versions = Dir.entries(dir).select { |entry| File.directory?(File.join(dir, entry)) && !(entry == "." || entry == "..") }
|
51
|
+
highest_version = Makit::Version::get_highest_version(versions)
|
52
|
+
return highest_version
|
53
|
+
end
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|