makit 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/lib/makit/apache.rb +32 -32
  3. data/lib/makit/cli/clean.rb +14 -14
  4. data/lib/makit/cli/clone.rb +59 -59
  5. data/lib/makit/cli/init.rb +38 -38
  6. data/lib/makit/cli/main.rb +33 -33
  7. data/lib/makit/cli/make.rb +54 -54
  8. data/lib/makit/cli/new.rb +37 -37
  9. data/lib/makit/cli/nuget_cache.rb +38 -38
  10. data/lib/makit/cli/pull.rb +31 -31
  11. data/lib/makit/cli/setup.rb +71 -71
  12. data/lib/makit/cli/work.rb +21 -21
  13. data/lib/makit/command_runner.rb +274 -237
  14. data/lib/makit/commands.rb +21 -21
  15. data/lib/makit/content/default_gitignore.rb +5 -5
  16. data/lib/makit/content/default_rakefile.rb +11 -11
  17. data/lib/makit/content/gem_rakefile.rb +14 -14
  18. data/lib/makit/data.rb +50 -50
  19. data/lib/makit/directories.rb +140 -140
  20. data/lib/makit/directory.rb +151 -120
  21. data/lib/makit/dotnet.rb +83 -75
  22. data/lib/makit/environment.rb +123 -123
  23. data/lib/makit/files.rb +47 -47
  24. data/lib/makit/git.rb +66 -66
  25. data/lib/makit/gitlab_runner.rb +60 -60
  26. data/lib/makit/humanize.rb +89 -89
  27. data/lib/makit/logging.rb +96 -96
  28. data/lib/makit/markdown.rb +75 -75
  29. data/lib/makit/mp/basic_object_mp.rb +16 -16
  30. data/lib/makit/mp/command_request.mp.rb +13 -0
  31. data/lib/makit/mp/project_mp.rb +156 -149
  32. data/lib/makit/mp/string_mp.rb +101 -101
  33. data/lib/makit/nuget.rb +57 -57
  34. data/lib/makit/protoc.rb +61 -61
  35. data/lib/makit/serializer.rb +115 -70
  36. data/lib/makit/storage.rb +131 -131
  37. data/lib/makit/symbols.rb +149 -149
  38. data/lib/makit/tasks.rb +67 -67
  39. data/lib/makit/tree.rb +37 -37
  40. data/lib/makit/v1/makit.v1_pb.rb +5 -5
  41. data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
  42. data/lib/makit/version.rb +12 -12
  43. data/lib/makit/wix.rb +95 -95
  44. data/lib/makit/zip.rb +17 -17
  45. data/lib/makit.rb +243 -243
  46. metadata +4 -39
  47. data/.makit.project.json +0 -4
  48. data/.makit.project.yml +0 -2
  49. data/.rubocop.yml +0 -22
  50. data/.ruby-version +0 -1
  51. data/CHANGELOG.md +0 -8
  52. data/CODE_OF_CONDUCT.md +0 -84
  53. data/LICENSE +0 -21
  54. data/README.md +0 -119
  55. data/Rakefile +0 -200
  56. data/docs/Commands.md +0 -50
  57. data/docs_/Commands.md +0 -166
  58. data/docs_/Minitest.Timeouts.md +0 -332
  59. data/examples/protoc/Rakefile +0 -31
  60. data/examples/rake_default/Rakefile +0 -6
  61. data/examples/rubygem-foo/.gitkeep +0 -0
  62. data/examples/rubygem-foo/Rakefile +0 -3
  63. data/examples/run_mp/Rakefile +0 -8
  64. data/exe/makit +0 -5
  65. data/lib/makit/content/default_gitignore.txt +0 -222
  66. data/lib/makit/content/ruby_gitlab-ci.yml +0 -15
  67. data/lib/makit/v1/makit.v1.proto +0 -103
  68. data/makit.generated.sln +0 -30
  69. data/makit.sln +0 -69
  70. data/pages/.gitignore +0 -5
  71. data/pages/404.html +0 -25
  72. data/pages/Gemfile +0 -33
  73. data/pages/Gemfile.lock +0 -88
  74. data/pages/_config.yml +0 -55
  75. data/pages/_layouts/default.html +0 -1
  76. data/pages/_posts/2024-10-05-welcome-to-jekyll.markdown +0 -29
  77. data/pages/about.markdown +0 -18
  78. data/pages/index.markdown +0 -6
  79. data/sig/makit.rbs +0 -4
  80. data/src/ClassLib/Class1.cs +0 -6
  81. 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
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ require "digest"
3
+
4
+ module Makit
5
+ module V1
6
+ class CommandRequest
7
+ def to_hash
8
+ int_hash = Digest::SHA256.hexdigest("{self.name}.#{self.arguments.join(" ")}")
9
+ int_hash
10
+ end
11
+ end
12
+ end
13
+ end # module Makit
@@ -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 setup_dotnet_projects
108
- if self.dotnet_projects.any?
109
- if (!File.exist?("#{self.name}.sln"))
110
- puts " Creating solution file: " + "#{self.name}.sln".colorize(:green)
111
- "dotnet new sln -n #{self.name}".run unless File.exist?("#{self.name}.sln")
112
- else
113
- puts " Solution file already exists: " + "#{self.name}.sln".colorize(:yellow)
114
- end
115
- self.dotnet_projects.each do |project|
116
- add_project = true
117
- if (project.os == "windows" && !Makit::Environment.is_windows?)
118
- add_project = false
119
- end
120
- if (add_project)
121
- Makit::DotNet.new_project(project.template, project.name, project.output)
122
- # add any nuget packages to the project
123
- project_filename = "#{project.output}/#{project.name}.csproj"
124
- project.packages.each { |package|
125
- Makit::DotNet::add_package(project_filename, package)
126
- }
127
- end
128
- end
129
- Makit::DotNet.new_solution(self.name)
130
- Makit::DotNet.sln_add_projects(self.name)
131
- else
132
- puts " no dotnet projects found".colorize(:yellow)
133
- end
134
- end
135
-
136
- def build_dotnet_projects
137
- self.dotnet_projects.each do |project|
138
- "dotnet build #{project.output} --configuration Release".run
139
- end
140
- end
141
-
142
- def test_dotnet_projects
143
- self.dotnet_projects.each do |project|
144
- "dotnet test #{project.output} --configuration Release".run
145
- end
146
- end
147
- end # class Project
148
- end # module V1
149
- end # module Makit
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
@@ -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