makit 0.0.57 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) 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 +404 -399
  14. data/lib/makit/commands.rb +21 -21
  15. data/lib/makit/content/default_gitignore.rb +5 -5
  16. data/lib/makit/content/default_gitignore.txt +222 -222
  17. data/lib/makit/content/default_rakefile.rb +11 -11
  18. data/lib/makit/content/gem_rakefile.rb +14 -14
  19. data/lib/makit/data.rb +50 -50
  20. data/lib/makit/directories.rb +140 -140
  21. data/lib/makit/directory.rb +219 -200
  22. data/lib/makit/dotnet.rb +182 -182
  23. data/lib/makit/environment.rb +127 -127
  24. data/lib/makit/fileinfo.rb +16 -16
  25. data/lib/makit/files.rb +47 -47
  26. data/lib/makit/git.rb +96 -96
  27. data/lib/makit/gitlab_runner.rb +60 -60
  28. data/lib/makit/humanize.rb +129 -129
  29. data/lib/makit/indexer.rb +56 -56
  30. data/lib/makit/logging.rb +96 -96
  31. data/lib/makit/markdown.rb +75 -75
  32. data/lib/makit/mp/basic_object_mp.rb +16 -16
  33. data/lib/makit/mp/command_request.mp.rb +16 -16
  34. data/lib/makit/mp/project_mp.rb +210 -210
  35. data/lib/makit/mp/string_mp.rb +137 -137
  36. data/lib/makit/nuget.rb +57 -57
  37. data/lib/makit/protoc.rb +104 -104
  38. data/lib/makit/secrets.rb +50 -0
  39. data/lib/makit/serializer.rb +115 -115
  40. data/lib/makit/show.rb +111 -111
  41. data/lib/makit/storage.rb +131 -131
  42. data/lib/makit/symbols.rb +149 -149
  43. data/lib/makit/tasks.rb +64 -61
  44. data/lib/makit/tree.rb +37 -37
  45. data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
  46. data/lib/makit/version.rb +68 -68
  47. data/lib/makit/wix.rb +95 -95
  48. data/lib/makit/yaml.rb +19 -19
  49. data/lib/makit/zip.rb +17 -17
  50. data/lib/makit.rb +268 -267
  51. metadata +3 -4
  52. data/lib/generated/makit/v1/makit.v1_pb.rb +0 -35
  53. data/lib/generated/makit/v1/web/link_pb.rb +0 -20
@@ -1,137 +1,137 @@
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 cache_run()
23
- command = self
24
- Makit::RUNNER.cache_run(Makit::RUNNER::parse_command_request(command))
25
- end
26
-
27
- def cache_run(timestamp = nil)
28
- if timestamp.nil?
29
- timestamp = Makit::GIT_FILE_INFOS.first.mtime #GIT_FILE_INFOS. Makit::Directory.get_newest_git_file_timestamp(Makit::Directories::PROJECT_ROOT)
30
- #timestamp = Makit::Timestamp.now
31
- end
32
-
33
- command = self
34
- Makit::RUNNER.cache_run(Makit::RUNNER::parse_command_request(command), timestamp)
35
- end
36
-
37
- def try(args = nil)
38
- if args.nil?
39
- command = self
40
- Makit::RUNNER.try(command)
41
- else
42
- command = self
43
- request = Makit::RUNNER.parse_args(command)
44
- if args.is_a?(Hash)
45
- args.each do |key, value|
46
- request.send("#{key}=", value)
47
- end
48
- end
49
- Makit::RUNNER.try(request)
50
- end
51
- end
52
-
53
- def cache_try()
54
- command = self
55
- Makit::RUNNER.cache_try(Makit::RUNNER::parse_command_request(command))
56
- end
57
-
58
- def cache_try(timestamp = nil)
59
- if timestamp.nil?
60
- timestamp = Makit::GIT_FILE_INFOS.first.mtime #GIT_FILE_INFOS. Makit::Directory.get_newest_git_file_timestamp(Makit::Directories::PROJECT_ROOT)
61
- #timestamp = Makit::Timestamp.now
62
- end
63
-
64
- command = self
65
- Makit::RUNNER.cache_try(Makit::RUNNER::parse_command_request(command), timestamp)
66
- end
67
-
68
- # Read a value from a JSON file
69
- # key is a string with the key to read, e.g. "AzureAd.Authority"
70
- def get_json_value(key)
71
- json = File.read(self)
72
- data = JSON.parse(json)
73
-
74
- # key delimiter is '.' so we can access nested keys
75
- key.split(".").each do |k|
76
- data = data[k]
77
- end
78
- data
79
- end
80
-
81
- alias_method :retrieve, :get_json_value
82
-
83
- # Set a value in a JSON file
84
- # key is a string with the key to set, e.g. "AzureAd.Authority"
85
- def set_json_value(key, value)
86
- file = File.read(self)
87
- data = JSON.parse(file)
88
- keys = key.split(".")
89
- current = data
90
-
91
- # Traverse and create any missing keys
92
- keys[0..-2].each do |k|
93
- current[k] ||= {} # Create a new hash if the key doesn't exist
94
- current = current[k]
95
- end
96
-
97
- # Set the value for the final key
98
- current[keys[-1]] = value
99
-
100
- # Write the JSON back to the file
101
- File.write(self, JSON.pretty_generate(data))
102
- end
103
-
104
- # Alias for set_json_value
105
- alias_method :assign, :set_json_value
106
-
107
- def strip_color_codes
108
- # Regular expression to remove ANSI color codes
109
- cleaned_content = self.gsub(/\e\[[\d;]+m/, "")
110
- cleaned_content
111
- end
112
-
113
- def to_lines(max_length = 80, indent_length = 5)
114
- if (self.length <= max_length)
115
- return self
116
- else
117
- indent = " " * indent_length
118
- words = self.split(" ")
119
- lines = []
120
- line = ""
121
- words.each do |word|
122
- if ((line + word).length > max_length)
123
- lines << line
124
- line = indent + word
125
- else
126
- if (line.length == 0)
127
- line = word
128
- else
129
- line += " " + word
130
- end
131
- end
132
- end
133
- lines << line
134
- return lines.join("\n")
135
- end
136
- end
137
- 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 cache_run()
23
+ command = self
24
+ Makit::RUNNER.cache_run(Makit::RUNNER::parse_command_request(command))
25
+ end
26
+
27
+ def cache_run(timestamp = nil)
28
+ if timestamp.nil?
29
+ timestamp = Makit::GIT_FILE_INFOS.first.mtime #GIT_FILE_INFOS. Makit::Directory.get_newest_git_file_timestamp(Makit::Directories::PROJECT_ROOT)
30
+ #timestamp = Makit::Timestamp.now
31
+ end
32
+
33
+ command = self
34
+ Makit::RUNNER.cache_run(Makit::RUNNER::parse_command_request(command), timestamp)
35
+ end
36
+
37
+ def try(args = nil)
38
+ if args.nil?
39
+ command = self
40
+ Makit::RUNNER.try(command)
41
+ else
42
+ command = self
43
+ request = Makit::RUNNER.parse_args(command)
44
+ if args.is_a?(Hash)
45
+ args.each do |key, value|
46
+ request.send("#{key}=", value)
47
+ end
48
+ end
49
+ Makit::RUNNER.try(request)
50
+ end
51
+ end
52
+
53
+ def cache_try()
54
+ command = self
55
+ Makit::RUNNER.cache_try(Makit::RUNNER::parse_command_request(command))
56
+ end
57
+
58
+ def cache_try(timestamp = nil)
59
+ if timestamp.nil?
60
+ timestamp = Makit::GIT_FILE_INFOS.first.mtime #GIT_FILE_INFOS. Makit::Directory.get_newest_git_file_timestamp(Makit::Directories::PROJECT_ROOT)
61
+ #timestamp = Makit::Timestamp.now
62
+ end
63
+
64
+ command = self
65
+ Makit::RUNNER.cache_try(Makit::RUNNER::parse_command_request(command), timestamp)
66
+ end
67
+
68
+ # Read a value from a JSON file
69
+ # key is a string with the key to read, e.g. "AzureAd.Authority"
70
+ def get_json_value(key)
71
+ json = File.read(self)
72
+ data = JSON.parse(json)
73
+
74
+ # key delimiter is '.' so we can access nested keys
75
+ key.split(".").each do |k|
76
+ data = data[k]
77
+ end
78
+ data
79
+ end
80
+
81
+ alias_method :retrieve, :get_json_value
82
+
83
+ # Set a value in a JSON file
84
+ # key is a string with the key to set, e.g. "AzureAd.Authority"
85
+ def set_json_value(key, value)
86
+ file = File.read(self)
87
+ data = JSON.parse(file)
88
+ keys = key.split(".")
89
+ current = data
90
+
91
+ # Traverse and create any missing keys
92
+ keys[0..-2].each do |k|
93
+ current[k] ||= {} # Create a new hash if the key doesn't exist
94
+ current = current[k]
95
+ end
96
+
97
+ # Set the value for the final key
98
+ current[keys[-1]] = value
99
+
100
+ # Write the JSON back to the file
101
+ File.write(self, JSON.pretty_generate(data))
102
+ end
103
+
104
+ # Alias for set_json_value
105
+ alias_method :assign, :set_json_value
106
+
107
+ def strip_color_codes
108
+ # Regular expression to remove ANSI color codes
109
+ cleaned_content = self.gsub(/\e\[[\d;]+m/, "")
110
+ cleaned_content
111
+ end
112
+
113
+ def to_lines(max_length = 80, indent_length = 5)
114
+ if (self.length <= max_length)
115
+ return self
116
+ else
117
+ indent = " " * indent_length
118
+ words = self.split(" ")
119
+ lines = []
120
+ line = ""
121
+ words.each do |word|
122
+ if ((line + word).length > max_length)
123
+ lines << line
124
+ line = indent + word
125
+ else
126
+ if (line.length == 0)
127
+ line = word
128
+ else
129
+ line += " " + word
130
+ end
131
+ end
132
+ end
133
+ lines << line
134
+ return lines.join("\n")
135
+ end
136
+ end
137
+ 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
data/lib/makit/protoc.rb CHANGED
@@ -1,104 +1,104 @@
1
- # frozen_string_literal: true
2
- require "pathname"
3
-
4
- # This module provides classes for the Makit gem.
5
- module Makit
6
- # This class provide methods for working with the system Environment.
7
- #
8
- class Protoc
9
- def self.grpc_tools_path
10
- File.join(Makit::Directories::NUGET_PACKAGE_CACHE, "grpc.tools", Makit::Protoc::get_latest_grpc_tools_version)
11
- end
12
-
13
- def self.grpc_csharp_plugin_path
14
- Makit::Protoc::find_plugin_path("grpc_csharp_plugin")
15
- end
16
- def self.setup
17
- if (!Dir.exist?(Makit::Directories::NUGET_PACKAGE_CACHE))
18
- puts " warning: Nuget package cache directory #{Makit::Directories::NUGET_PACKAGE_CACHE} not found".colorize(:red)
19
- puts " warning: Unable to proceed with protoc setup".colorize(:red)
20
- else
21
- Makit::NuGet::cache("Grpc.Tools", "2.66.0")
22
- raise "Nuget package path #{Makit::Directories::NUGET_PACKAGE_CACHE} not found" if !Dir.exist?(Makit::Directories::NUGET_PACKAGE_CACHE)
23
-
24
- # test if protoc is installed by running >protoc --version
25
- which_protoc = Makit::Environment.which("protoc")
26
- if (Makit::Environment.which("protoc").nil?)
27
- puts " protoc not found, installing...".colorize(:red)
28
- "go version".run
29
- "go install google.golang.org/protobuf/cmd/protoc-gen-go@latest".run
30
- "go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest".run
31
- "go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest".run
32
- else
33
- puts " protoc found at #{which_protoc}".colorize(:green)
34
- end
35
- raise "protoc not found" if !Makit::Environment.which("protoc")
36
-
37
- #"git clone https://github.com/googleapis/googleapis.git third_party".run unless File.directory?("third_party/google")
38
- puts " grpc_tools_path " + "#{Makit::Protoc::grpc_tools_path}".colorize(:green)
39
- puts " grpc_csharp_plugin_path " + "#{Makit::Protoc::grpc_csharp_plugin_path}".colorize(:green)
40
- end
41
- end
42
-
43
- # get the latest version of the grpc.tools package
44
- def self.get_latest_grpc_tools_version
45
- Makit::NuGet::get_latest_version("Grpc.Tools")
46
- end
47
-
48
- #GRPC_CSHARP_PLUGIN_PATH = Makit::Protoc::find_plugin_path("grpc_csharp_plugin")
49
- def self.find_plugin_path(plugin_name)
50
- # search for a file matching the pattern *grpc_csharp_plugin* in the grpc.tools directory
51
- # should match on Windows and Linux
52
- if (Makit::Environment.is_windows?)
53
- plugin_name = plugin_name + ".exe"
54
- end
55
-
56
- plugin_path = Dir.glob("#{Makit::Directories::GRPC_TOOLS_PATH}/**/#{plugin_name}").first
57
-
58
- raise "Plugin path #{plugin_path} not found" if !File.exist?(plugin_path)
59
- plugin_path
60
- end
61
-
62
- def self.get_proto_files_from_path(proto_source_dir)
63
- proto_files = Array.new()
64
- Dir.chdir(proto_source_dir) do
65
- Dir.glob("**/*.proto").each do |proto|
66
- proto_files << proto
67
- end
68
- end
69
- proto_files
70
- end
71
-
72
- def self.generate_source_file(proto_filename, language, csharp_output_dir)
73
- FileUtils.mkdir_p(csharp_output_dir) unless Dir.exist?(csharp_output_dir)
74
- "protoc --#{language}_out=#{csharp_output_dir} #{proto_filename}".run
75
- end
76
-
77
- # language: charp, ruby, go, etc.
78
- def self.generate_source_files(proto_source_dir, language, output_dir)
79
- debug = false
80
- puts "Generating source files for #{language} in #{proto_source_dir} to #{output_dir}" if debug
81
- FileUtils.mkdir_p(output_dir) unless Dir.exist?(output_dir)
82
-
83
- path_a = Pathname.new(proto_source_dir)
84
- path_b = Pathname.new(output_dir)
85
- output_relative_path = path_b.relative_path_from(path_a)
86
- puts "output_relative_path: #{output_relative_path}" if debug
87
-
88
- Dir.chdir(proto_source_dir) do
89
- Dir.glob("**/*.proto").each do |proto|
90
- puts "Generating #{proto}" if debug
91
- if (language == "csharp")
92
- namespace_dir = File.dirname(proto)
93
- output_dir = "#{output_relative_path}/#{namespace_dir}"
94
- puts "Generating #{proto} in #{output_dir}" if debug
95
- FileUtils.mkdir_p("#{output_dir}") unless Dir.exist?("#{output_dir}")
96
- "protoc --csharp_out=#{output_dir} #{proto}".run
97
- else
98
- "protoc --#{language}_out=#{output_relative_path} #{proto}".run
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end
1
+ # frozen_string_literal: true
2
+ require "pathname"
3
+
4
+ # This module provides classes for the Makit gem.
5
+ module Makit
6
+ # This class provide methods for working with the system Environment.
7
+ #
8
+ class Protoc
9
+ def self.grpc_tools_path
10
+ File.join(Makit::Directories::NUGET_PACKAGE_CACHE, "grpc.tools", Makit::Protoc::get_latest_grpc_tools_version)
11
+ end
12
+
13
+ def self.grpc_csharp_plugin_path
14
+ Makit::Protoc::find_plugin_path("grpc_csharp_plugin")
15
+ end
16
+ def self.setup
17
+ if (!Dir.exist?(Makit::Directories::NUGET_PACKAGE_CACHE))
18
+ puts " warning: Nuget package cache directory #{Makit::Directories::NUGET_PACKAGE_CACHE} not found".colorize(:red)
19
+ puts " warning: Unable to proceed with protoc setup".colorize(:red)
20
+ else
21
+ Makit::NuGet::cache("Grpc.Tools", "2.66.0")
22
+ raise "Nuget package path #{Makit::Directories::NUGET_PACKAGE_CACHE} not found" if !Dir.exist?(Makit::Directories::NUGET_PACKAGE_CACHE)
23
+
24
+ # test if protoc is installed by running >protoc --version
25
+ which_protoc = Makit::Environment.which("protoc")
26
+ if (Makit::Environment.which("protoc").nil?)
27
+ puts " protoc not found, installing...".colorize(:red)
28
+ "go version".run
29
+ "go install google.golang.org/protobuf/cmd/protoc-gen-go@latest".run
30
+ "go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest".run
31
+ "go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest".run
32
+ else
33
+ puts " protoc found at #{which_protoc}".colorize(:green)
34
+ end
35
+ raise "protoc not found" if !Makit::Environment.which("protoc")
36
+
37
+ #"git clone https://github.com/googleapis/googleapis.git third_party".run unless File.directory?("third_party/google")
38
+ puts " grpc_tools_path " + "#{Makit::Protoc::grpc_tools_path}".colorize(:green)
39
+ puts " grpc_csharp_plugin_path " + "#{Makit::Protoc::grpc_csharp_plugin_path}".colorize(:green)
40
+ end
41
+ end
42
+
43
+ # get the latest version of the grpc.tools package
44
+ def self.get_latest_grpc_tools_version
45
+ Makit::NuGet::get_latest_version("Grpc.Tools")
46
+ end
47
+
48
+ #GRPC_CSHARP_PLUGIN_PATH = Makit::Protoc::find_plugin_path("grpc_csharp_plugin")
49
+ def self.find_plugin_path(plugin_name)
50
+ # search for a file matching the pattern *grpc_csharp_plugin* in the grpc.tools directory
51
+ # should match on Windows and Linux
52
+ if (Makit::Environment.is_windows?)
53
+ plugin_name = plugin_name + ".exe"
54
+ end
55
+
56
+ plugin_path = Dir.glob("#{Makit::Directories::GRPC_TOOLS_PATH}/**/#{plugin_name}").first
57
+
58
+ raise "Plugin path #{plugin_path} not found" if !File.exist?(plugin_path)
59
+ plugin_path
60
+ end
61
+
62
+ def self.get_proto_files_from_path(proto_source_dir)
63
+ proto_files = Array.new()
64
+ Dir.chdir(proto_source_dir) do
65
+ Dir.glob("**/*.proto").each do |proto|
66
+ proto_files << proto
67
+ end
68
+ end
69
+ proto_files
70
+ end
71
+
72
+ def self.generate_source_file(proto_filename, language, csharp_output_dir)
73
+ FileUtils.mkdir_p(csharp_output_dir) unless Dir.exist?(csharp_output_dir)
74
+ "protoc --#{language}_out=#{csharp_output_dir} #{proto_filename}".run
75
+ end
76
+
77
+ # language: charp, ruby, go, etc.
78
+ def self.generate_source_files(proto_source_dir, language, output_dir)
79
+ debug = false
80
+ puts "Generating source files for #{language} in #{proto_source_dir} to #{output_dir}" if debug
81
+ FileUtils.mkdir_p(output_dir) unless Dir.exist?(output_dir)
82
+
83
+ path_a = Pathname.new(proto_source_dir)
84
+ path_b = Pathname.new(output_dir)
85
+ output_relative_path = path_b.relative_path_from(path_a)
86
+ puts "output_relative_path: #{output_relative_path}" if debug
87
+
88
+ Dir.chdir(proto_source_dir) do
89
+ Dir.glob("**/*.proto").each do |proto|
90
+ puts "Generating #{proto}" if debug
91
+ if (language == "csharp")
92
+ namespace_dir = File.dirname(proto)
93
+ output_dir = "#{output_relative_path}/#{namespace_dir}"
94
+ puts "Generating #{proto} in #{output_dir}" if debug
95
+ FileUtils.mkdir_p("#{output_dir}") unless Dir.exist?("#{output_dir}")
96
+ "protoc --csharp_out=#{output_dir} #{proto}".run
97
+ else
98
+ "protoc --#{language}_out=#{output_relative_path} #{proto}".run
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,50 @@
1
+
2
+ module Makit
3
+ class Secrets
4
+
5
+ def add(key, value)
6
+ secrets_hash = get_secrets_hash()
7
+ secrets_hash[key] = value
8
+ save_secrets_hash(secrets_hash)
9
+ end
10
+
11
+ def remove(key)
12
+ secrets_hash = get_secrets_hash()
13
+ secrets_hash.delete(key)
14
+ save_secrets_hash(secrets_hash)
15
+ end
16
+
17
+ def has_key?(key)
18
+ secrets_hash = get_secrets_hash()
19
+ return secrets_hash.key?(key)
20
+ end
21
+
22
+ def get(key)
23
+ secrets_hash = get_secrets_hash()
24
+ return secrets_hash[key]
25
+ end
26
+
27
+ def set(key, value)
28
+ secrets_hash = get_secrets_hash()
29
+ secrets_hash[key] = value
30
+ save_secrets_hash(secrets_hash)
31
+ end
32
+
33
+ def get_secrets_filename()
34
+ return "#{Makit::Environment::root_dir}/secrets.json"
35
+ end
36
+
37
+ def get_secrets_hash()
38
+ secrets_file = get_secrets_filename()
39
+ if File.exist?(secrets_file)
40
+ text = IO.read(secrets_file)
41
+ return JSON.parse(text)
42
+ end
43
+ end
44
+
45
+ def save_secrets_hash(hash)
46
+ secrets_file = get_secrets_filename()
47
+ File.open(secrets_file, "w") { |f| f.puts hash.to_json }
48
+ end
49
+ end
50
+ end