makit 0.0.53 → 0.0.54

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 +399 -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 +200 -200
  22. data/lib/makit/dotnet.rb +170 -170
  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 +87 -87
  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/serializer.rb +115 -115
  39. data/lib/makit/show.rb +101 -94
  40. data/lib/makit/storage.rb +131 -131
  41. data/lib/makit/symbols.rb +149 -149
  42. data/lib/makit/tasks.rb +61 -61
  43. data/lib/makit/tree.rb +37 -37
  44. data/lib/makit/v1/makit.v1_pb.rb +6 -4
  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 +267 -267
  51. metadata +1 -3
  52. data/lib/generated/makit/v1/makit.v1_pb.rb +0 -35
  53. data/lib/generated/makit/v1/web/link_pb.rb +0 -20
data/lib/makit/tree.rb CHANGED
@@ -1,37 +1,37 @@
1
- # frozen_string_literal: true
2
-
3
- # This module provides classes for the Makit gem.
4
- module Makit
5
- class Tree
6
- def get_source_tree
7
- files = `git ls-files`.split("\n")
8
- tree = {}
9
-
10
- # Build a nested hash representing the file structure
11
- files.each do |file|
12
- parts = file.split("/")
13
- current = tree
14
-
15
- parts.each_with_index do |part, index|
16
- current[part] ||= (index == parts.length - 1 ? nil : {})
17
- current = current[part] unless current[part].nil?
18
- end
19
- end
20
-
21
- generate_tree_string(tree)
22
- end
23
-
24
- def generate_tree_string(tree, indent = "")
25
- result = ""
26
- tree.each do |key, value|
27
- if value.is_a?(Hash)
28
- result << "#{indent}#{key}/\n"
29
- result << generate_tree_string(value, "#{indent} ")
30
- else
31
- result << "#{indent}#{key}\n"
32
- end
33
- end
34
- result
35
- end
36
- end
37
- end
1
+ # frozen_string_literal: true
2
+
3
+ # This module provides classes for the Makit gem.
4
+ module Makit
5
+ class Tree
6
+ def get_source_tree
7
+ files = `git ls-files`.split("\n")
8
+ tree = {}
9
+
10
+ # Build a nested hash representing the file structure
11
+ files.each do |file|
12
+ parts = file.split("/")
13
+ current = tree
14
+
15
+ parts.each_with_index do |part, index|
16
+ current[part] ||= (index == parts.length - 1 ? nil : {})
17
+ current = current[part] unless current[part].nil?
18
+ end
19
+ end
20
+
21
+ generate_tree_string(tree)
22
+ end
23
+
24
+ def generate_tree_string(tree, indent = "")
25
+ result = ""
26
+ tree.each do |key, value|
27
+ if value.is_a?(Hash)
28
+ result << "#{indent}#{key}/\n"
29
+ result << generate_tree_string(value, "#{indent} ")
30
+ else
31
+ result << "#{indent}#{key}\n"
32
+ end
33
+ end
34
+ result
35
+ end
36
+ end
37
+ end
@@ -2,18 +2,20 @@
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # source: lib/makit/v1/makit.v1.proto
4
4
 
5
- require "google/protobuf"
5
+ require 'google/protobuf'
6
6
 
7
- require "google/protobuf/timestamp_pb"
8
- require "google/protobuf/duration_pb"
7
+ require 'google/protobuf/timestamp_pb'
8
+ require 'google/protobuf/duration_pb'
9
9
 
10
- descriptor_data = "\n\x1blib/makit/v1/makit.v1.proto\x12\x08makit.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\"\x92\x02\n\rDotNetProject\x12\x10\n\x08template\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0e\n\x06output\x18\x03 \x01(\t\x12\x10\n\x08packages\x18\x04 \x03(\t\x12\x12\n\nreferences\x18\x05 \x03(\t\x12\n\n\x02os\x18\x06 \x01(\t\x12\x10\n\x08\x63ommands\x18\x07 \x03(\t\x12-\n\nbuild_args\x18\x08 \x03(\x0b\x32\x19.makit.v1.DotNetBuildArgs\x12\x31\n\x0cpublish_args\x18\t \x03(\x0b\x32\x1b.makit.v1.DotNetPublishArgs\x12+\n\ttest_args\x18\n \x03(\x0b\x32\x18.makit.v1.DotNetTestArgs\"8\n\x0f\x44otNetBuildArgs\x12\x15\n\rconfiguration\x18\x01 \x01(\t\x12\x0e\n\x06output\x18\x02 \x01(\t\":\n\x11\x44otNetPublishArgs\x12\x15\n\rconfiguration\x18\x01 \x01(\t\x12\x0e\n\x06output\x18\x02 \x01(\t\"7\n\x0e\x44otNetTestArgs\x12\x15\n\rconfiguration\x18\x01 \x01(\t\x12\x0e\n\x06output\x18\x02 \x01(\t\"\xa8\x01\n\x07Project\x12\x16\n\x0egit_remote_url\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x11\n\tartifacts\x18\x03 \x03(\t\x12\x32\n\x10\x63ommand_requests\x18\x04 \x03(\x0b\x32\x18.makit.v1.CommandRequest\x12\x30\n\x0f\x64otnet_projects\x18\x05 \x03(\x0b\x32\x17.makit.v1.DotNetProject\"\xa5\x01\n\x0e\x43ommandRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\targuments\x18\x02 \x03(\t\x12+\n\x07timeout\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x11\n\tdirectory\x18\x04 \x01(\t\x12\x0c\n\x04task\x18\x05 \x01(\t\x12\r\n\x05input\x18\x06 \x01(\x0c\x12\x15\n\rexit_on_error\x18\x07 \x01(\x08\"\x91\x02\n\x07\x43ommand\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x11\n\targuments\x18\x03 \x03(\t\x12\x11\n\texit_code\x18\x04 \x01(\x05\x12\r\n\x05input\x18\x05 \x01(\x0c\x12\x0e\n\x06output\x18\x06 \x01(\x0c\x12\r\n\x05\x65rror\x18\x07 \x01(\x0c\x12.\n\nstarted_at\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\x08\x64uration\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x0c\n\x04user\x18\n \x01(\t\x12\x0e\n\x06\x64\x65vice\x18\x0b \x01(\t\x12\n\n\x02os\x18\x0c \x01(\t\x12\x11\n\tdirectory\x18\r \x01(\t\"I\n\rConfiguration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12*\n\x08\x63ommands\x18\x02 \x03(\x0b\x32\x18.makit.v1.CommandRequest\"3\n\rGitRepository\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x15\n\rrelative_path\x18\x02 \x01(\t\"h\n\x0bGitLogEntry\x12\x0e\n\x06\x63ommit\x18\x01 \x01(\t\x12\x0e\n\x06\x61uthor\x18\x02 \x01(\t\x12(\n\x04\x64\x61te\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07message\x18\x04 \x01(\t\"\xc8\x01\n\nMakeResult\x12\x12\n\nrepository\x18\x01 \x01(\t\x12\x0e\n\x06\x63ommit\x18\x02 \x01(\t\x12\x0e\n\x06\x62ranch\x18\x03 \x01(\t\x12\x0b\n\x03tag\x18\x04 \x01(\t\x12\x0e\n\x06\x64\x65vice\x18\x05 \x01(\t\x12\x1a\n\x12runtime_identifier\x18\x06 \x01(\t\x12#\n\x08\x63ommands\x18\x07 \x03(\x0b\x32\x11.makit.v1.Command\x12\x14\n\x0cinitial_size\x18\x08 \x01(\x05\x12\x12\n\nfinal_size\x18\t \x01(\x05\"?\n\rDotNetNewArgs\x12\x10\n\x08template\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0e\n\x06output\x18\x03 \x01(\t\"^\n\rManifestEntry\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x31\n\rlast_modified\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04size\x18\x03 \x01(\x03**\n\x08Language\x12\x08\n\x04RUBY\x10\x00\x12\n\n\x06\x43SHARP\x10\x01\x12\x08\n\x04RUST\x10\x02*,\n\x0bPackageType\x12\x07\n\x03GEM\x10\x00\x12\t\n\x05NUGET\x10\x01\x12\t\n\x05\x43RATE\x10\x03\x32H\n\x0e\x43ommandService\x12\x36\n\x07\x45xecute\x12\x18.makit.v1.CommandRequest\x1a\x11.makit.v1.Commandb\x06proto3"
10
+
11
+ descriptor_data = "\n\x1blib/makit/v1/makit.v1.proto\x12\x08makit.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\"/\n\x0b\x45nvironment\x12\n\n\x02os\x18\x01 \x01(\t\x12\x14\n\x0c\x61rchitecture\x18\x02 \x01(\t\"\x92\x02\n\rDotNetProject\x12\x10\n\x08template\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0e\n\x06output\x18\x03 \x01(\t\x12\x10\n\x08packages\x18\x04 \x03(\t\x12\x12\n\nreferences\x18\x05 \x03(\t\x12\n\n\x02os\x18\x06 \x01(\t\x12\x10\n\x08\x63ommands\x18\x07 \x03(\t\x12-\n\nbuild_args\x18\x08 \x03(\x0b\x32\x19.makit.v1.DotNetBuildArgs\x12\x31\n\x0cpublish_args\x18\t \x03(\x0b\x32\x1b.makit.v1.DotNetPublishArgs\x12+\n\ttest_args\x18\n \x03(\x0b\x32\x18.makit.v1.DotNetTestArgs\"8\n\x0f\x44otNetBuildArgs\x12\x15\n\rconfiguration\x18\x01 \x01(\t\x12\x0e\n\x06output\x18\x02 \x01(\t\":\n\x11\x44otNetPublishArgs\x12\x15\n\rconfiguration\x18\x01 \x01(\t\x12\x0e\n\x06output\x18\x02 \x01(\t\"7\n\x0e\x44otNetTestArgs\x12\x15\n\rconfiguration\x18\x01 \x01(\t\x12\x0e\n\x06output\x18\x02 \x01(\t\"\xa8\x01\n\x07Project\x12\x16\n\x0egit_remote_url\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x11\n\tartifacts\x18\x03 \x03(\t\x12\x32\n\x10\x63ommand_requests\x18\x04 \x03(\x0b\x32\x18.makit.v1.CommandRequest\x12\x30\n\x0f\x64otnet_projects\x18\x05 \x03(\x0b\x32\x17.makit.v1.DotNetProject\"\xa5\x01\n\x0e\x43ommandRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\targuments\x18\x02 \x03(\t\x12+\n\x07timeout\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x11\n\tdirectory\x18\x04 \x01(\t\x12\x0c\n\x04task\x18\x05 \x01(\t\x12\r\n\x05input\x18\x06 \x01(\x0c\x12\x15\n\rexit_on_error\x18\x07 \x01(\x08\"\x91\x02\n\x07\x43ommand\x12\n\n\x02id\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x11\n\targuments\x18\x03 \x03(\t\x12\x11\n\texit_code\x18\x04 \x01(\x05\x12\r\n\x05input\x18\x05 \x01(\x0c\x12\x0e\n\x06output\x18\x06 \x01(\x0c\x12\r\n\x05\x65rror\x18\x07 \x01(\x0c\x12.\n\nstarted_at\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\x08\x64uration\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x0c\n\x04user\x18\n \x01(\t\x12\x0e\n\x06\x64\x65vice\x18\x0b \x01(\t\x12\n\n\x02os\x18\x0c \x01(\t\x12\x11\n\tdirectory\x18\r \x01(\t\"I\n\rConfiguration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12*\n\x08\x63ommands\x18\x02 \x03(\x0b\x32\x18.makit.v1.CommandRequest\"3\n\rGitRepository\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x15\n\rrelative_path\x18\x02 \x01(\t\"h\n\x0bGitLogEntry\x12\x0e\n\x06\x63ommit\x18\x01 \x01(\t\x12\x0e\n\x06\x61uthor\x18\x02 \x01(\t\x12(\n\x04\x64\x61te\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07message\x18\x04 \x01(\t\"\xc8\x01\n\nMakeResult\x12\x12\n\nrepository\x18\x01 \x01(\t\x12\x0e\n\x06\x63ommit\x18\x02 \x01(\t\x12\x0e\n\x06\x62ranch\x18\x03 \x01(\t\x12\x0b\n\x03tag\x18\x04 \x01(\t\x12\x0e\n\x06\x64\x65vice\x18\x05 \x01(\t\x12\x1a\n\x12runtime_identifier\x18\x06 \x01(\t\x12#\n\x08\x63ommands\x18\x07 \x03(\x0b\x32\x11.makit.v1.Command\x12\x14\n\x0cinitial_size\x18\x08 \x01(\x05\x12\x12\n\nfinal_size\x18\t \x01(\x05\"?\n\rDotNetNewArgs\x12\x10\n\x08template\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0e\n\x06output\x18\x03 \x01(\t\"^\n\rManifestEntry\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x31\n\rlast_modified\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04size\x18\x03 \x01(\x03**\n\x08Language\x12\x08\n\x04RUBY\x10\x00\x12\n\n\x06\x43SHARP\x10\x01\x12\x08\n\x04RUST\x10\x02*,\n\x0bPackageType\x12\x07\n\x03GEM\x10\x00\x12\t\n\x05NUGET\x10\x01\x12\t\n\x05\x43RATE\x10\x03\x32H\n\x0e\x43ommandService\x12\x36\n\x07\x45xecute\x12\x18.makit.v1.CommandRequest\x1a\x11.makit.v1.Commandb\x06proto3"
11
12
 
12
13
  pool = Google::Protobuf::DescriptorPool.generated_pool
13
14
  pool.add_serialized_file(descriptor_data)
14
15
 
15
16
  module Makit
16
17
  module V1
18
+ Environment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Environment").msgclass
17
19
  DotNetProject = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetProject").msgclass
18
20
  DotNetBuildArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetBuildArgs").msgclass
19
21
  DotNetPublishArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetPublishArgs").msgclass
@@ -1,25 +1,25 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # Source: lib/makit/v1/makit.v1.proto for package 'makit.v1'
3
-
4
- require "grpc"
5
- require_relative "makit.v1_pb"
6
-
7
- module Makit
8
- module V1
9
- module CommandService
10
- # Service to execute commands on devices.
11
- class Service
12
- include ::GRPC::GenericService
13
-
14
- self.marshal_class_method = :encode
15
- self.unmarshal_class_method = :decode
16
- self.service_name = "makit.v1.CommandService"
17
-
18
- # Execute a command on a device.
19
- rpc :Execute, ::Makit::V1::CommandRequest, ::Makit::V1::Command
20
- end
21
-
22
- Stub = Service.rpc_stub_class
23
- end
24
- end
25
- end
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: lib/makit/v1/makit.v1.proto for package 'makit.v1'
3
+
4
+ require "grpc"
5
+ require_relative "makit.v1_pb"
6
+
7
+ module Makit
8
+ module V1
9
+ module CommandService
10
+ # Service to execute commands on devices.
11
+ class Service
12
+ include ::GRPC::GenericService
13
+
14
+ self.marshal_class_method = :encode
15
+ self.unmarshal_class_method = :decode
16
+ self.service_name = "makit.v1.CommandService"
17
+
18
+ # Execute a command on a device.
19
+ rpc :Execute, ::Makit::V1::CommandRequest, ::Makit::V1::Command
20
+ end
21
+
22
+ Stub = Service.rpc_stub_class
23
+ end
24
+ end
25
+ end
data/lib/makit/version.rb CHANGED
@@ -1,68 +1,68 @@
1
- # frozen_string_literal: true
2
-
3
- module Makit
4
- VERSION = "0.0.53"
5
-
6
- class Version
7
- # given an array of version strings, return the highest version
8
- def self.get_highest_version(versions)
9
- versions.sort { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }.last
10
- end
11
-
12
-
13
- # example content from .gitlab-ci.yml
14
- #variables:
15
- # VERSION: "0.0.26" # Define the version here
16
-
17
-
18
-
19
- def self.get_version_from_file(path)
20
- if (!File.exist?(path))
21
- raise "file #{path}does not exist"
22
- end
23
-
24
- extension = File.extname(path)
25
- #switch = extension.downcase
26
- #case switch
27
- #if extension == ".csproj"
28
- switch = extension.downcase
29
- case switch
30
- when ".csproj"
31
- Makit::Version.detect_from_file(path, /<Version>([-\w\d.]+)</)
32
- when ".wxs"
33
- Makit::Version.detect_from_file(path, / Version="([\d\.]+)"/)
34
- when ".yml"
35
- Makit::Version.detect_from_file(path, /VERSION:\s*["']?([\d\.]+)["']?/)
36
- else
37
- raise "unrecognized file type"
38
- end
39
- end
40
-
41
- def self.detect_from_file(filename, regex)
42
- if File.exist?(filename)
43
- match = IO.read(filename).match(regex)
44
- match.captures[0] if !match.nil? && match.captures.length.positive?
45
- else
46
- raise "unable to find version in #{filename}"
47
- end
48
- end
49
-
50
- def self.set_version_in_file(filename, version)
51
- text = IO.read(filename)
52
- new_text = text
53
- new_text = text.gsub(/VERSION:\s?['|"]([.\d]+)['|"]/, "VERSION: \"#{version}\"") if filename.include?(".yml")
54
- new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?(".gemspec")
55
- new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?(".csproj")
56
- new_text = text.gsub(/<version>([-\w\d.]+)</, "<version>#{version}<") if filename.include?(".nuspec")
57
- new_text = text.gsub(/ Version="([\d\.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs")
58
- new_text = text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"") if filename.include?(".toml")
59
- File.open(filename, "w") { |f| f.write(new_text) } if new_text != text
60
- end
61
-
62
- def self.set_version_in_files(glob_pattern, version)
63
- Dir.glob(glob_pattern).each do |filename|
64
- set_version_in_file(filename, version)
65
- end
66
- end
67
- end
68
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Makit
4
+ VERSION = "0.0.54"
5
+
6
+ class Version
7
+ # given an array of version strings, return the highest version
8
+ def self.get_highest_version(versions)
9
+ versions.sort { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }.last
10
+ end
11
+
12
+
13
+ # example content from .gitlab-ci.yml
14
+ #variables:
15
+ # VERSION: "0.0.26" # Define the version here
16
+
17
+
18
+
19
+ def self.get_version_from_file(path)
20
+ if (!File.exist?(path))
21
+ raise "file #{path}does not exist"
22
+ end
23
+
24
+ extension = File.extname(path)
25
+ #switch = extension.downcase
26
+ #case switch
27
+ #if extension == ".csproj"
28
+ switch = extension.downcase
29
+ case switch
30
+ when ".csproj"
31
+ Makit::Version.detect_from_file(path, /<Version>([-\w\d.]+)</)
32
+ when ".wxs"
33
+ Makit::Version.detect_from_file(path, / Version="([\d\.]+)"/)
34
+ when ".yml"
35
+ Makit::Version.detect_from_file(path, /VERSION:\s*["']?([\d\.]+)["']?/)
36
+ else
37
+ raise "unrecognized file type"
38
+ end
39
+ end
40
+
41
+ def self.detect_from_file(filename, regex)
42
+ if File.exist?(filename)
43
+ match = IO.read(filename).match(regex)
44
+ match.captures[0] if !match.nil? && match.captures.length.positive?
45
+ else
46
+ raise "unable to find version in #{filename}"
47
+ end
48
+ end
49
+
50
+ def self.set_version_in_file(filename, version)
51
+ text = IO.read(filename)
52
+ new_text = text
53
+ new_text = text.gsub(/VERSION:\s?['|"]([.\d]+)['|"]/, "VERSION: \"#{version}\"") if filename.include?(".yml")
54
+ new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?(".gemspec")
55
+ new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?(".csproj")
56
+ new_text = text.gsub(/<version>([-\w\d.]+)</, "<version>#{version}<") if filename.include?(".nuspec")
57
+ new_text = text.gsub(/ Version="([\d\.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs")
58
+ new_text = text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"") if filename.include?(".toml")
59
+ File.open(filename, "w") { |f| f.write(new_text) } if new_text != text
60
+ end
61
+
62
+ def self.set_version_in_files(glob_pattern, version)
63
+ Dir.glob(glob_pattern).each do |filename|
64
+ set_version_in_file(filename, version)
65
+ end
66
+ end
67
+ end
68
+ end
data/lib/makit/wix.rb CHANGED
@@ -1,95 +1,95 @@
1
- require "securerandom"
2
-
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 Wix
14
- def self.setup
15
- if (Makit::Environment.is_windows?)
16
- # test if dotnet is installed
17
- if !Makit::DotNet::is_installed? # !File.exist?(Makit::Environment.which("dotnet"))
18
- puts "dotnet does not appear to be installed"
19
- else
20
- # test if wix is already installed
21
- if !`dotnet tool list --global`.include?("wix")
22
- "dotnet tool install --global wix".run
23
- end
24
- puts " Wix version " + "#{Wix::version}".colorize(:green)
25
- # display the link to https://wixtoolset.org/
26
- puts " https://wixtoolset.org/".colorize(:green)
27
- # display the link to https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17
28
- puts " https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17".colorize(:green)
29
- end
30
- else
31
- puts "Wix is not supported on non-Windows platforms"
32
- end
33
- end
34
-
35
- def self.version
36
- `wix --version`.strip.split("+").first
37
- end
38
-
39
- def self.setup_package(name, path, files)
40
- # create the path if it does not exist
41
- FileUtils.mkdir_p(path) unless File.directory?(path)
42
- # create the #{name}.wixproj file
43
- File.open("#{path}/#{name}.wixproj", "w") do |f|
44
- f.puts "<Project Sdk=\"WixToolset.Sdk/#{Wix::version}\">"
45
- f.puts "</Project>"
46
- end
47
- # create the Package.wxs file
48
- File.open("#{path}/Package.wxs", "w") do |f|
49
- f.puts "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">"
50
- f.puts " <Package Name=\"#{name}\" Manufacturer=\"Acme\" Version=\"0.0.0.0\" UpgradeCode=\"#{SecureRandom.uuid}\">"
51
- #f.puts " <MajorUpgrade DowngradeErrorMessage=\"!(loc.DowngradeError)\" />"
52
- f.puts " <Files Include=\"#{files}\" />"
53
- #f.puts " <Feature Id=\"Main\">"
54
- #f.puts " <ComponentGroupRef Id=\"Components\" />"
55
- #f.puts " </Feature>"
56
- f.puts " </Package>"
57
- f.puts "</Wix>"
58
- end
59
- end
60
- end # class Wix
61
- end # module Makit
62
-
63
- # Package.wxs with File harvesting
64
- #<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
65
- # <Package Name="MyProduct" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B0B15C00-1DC4-0374-A1D1-E902240936D5">
66
- # <Files Include="path\to\files\**" />
67
- # </Package>
68
- #</Wix>
69
-
70
- #<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
71
- # <Package Name="Msi.Demo" Manufacturer="Acme" Version="1.0.0.0" UpgradeCode="a87571ec-8be3-447e-ae23-b3a94a85b727">
72
- # <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
73
-
74
- # <Feature Id="Main">
75
- # <ComponentGroupRef Id="Components" />
76
- # </Feature>
77
- # </Package>
78
- #</Wix>
79
-
80
- #<Project Sdk="WixToolset.Sdk/5.0.1">
81
- #</Project>
82
-
83
- # Components.wxs
84
- #<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
85
- # <Fragment>
86
- # <ComponentGroup Id="Components" Directory="INSTALLFOLDER">
87
- # <Component Guid="b8085fb3-3718-46df-8bf6-ecf9f968dd3d">
88
- # <File Source="../../artifacts/Msi.Demo.exe" />
89
- # <File Source="../../artifacts/Msi.Demo.dll" />
90
- # <File Source="../../artifacts/Msi.Demo.deps.json" />
91
- # <File Source="../../artifacts/Msi.Demo.runtimeconfig.json" />
92
- # </Component>
93
- # </ComponentGroup>
94
- # </Fragment>
95
- #</Wix>
1
+ require "securerandom"
2
+
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 Wix
14
+ def self.setup
15
+ if (Makit::Environment.is_windows?)
16
+ # test if dotnet is installed
17
+ if !Makit::DotNet::is_installed? # !File.exist?(Makit::Environment.which("dotnet"))
18
+ puts "dotnet does not appear to be installed"
19
+ else
20
+ # test if wix is already installed
21
+ if !`dotnet tool list --global`.include?("wix")
22
+ "dotnet tool install --global wix".run
23
+ end
24
+ puts " Wix version " + "#{Wix::version}".colorize(:green)
25
+ # display the link to https://wixtoolset.org/
26
+ puts " https://wixtoolset.org/".colorize(:green)
27
+ # display the link to https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17
28
+ puts " https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17".colorize(:green)
29
+ end
30
+ else
31
+ puts "Wix is not supported on non-Windows platforms"
32
+ end
33
+ end
34
+
35
+ def self.version
36
+ `wix --version`.strip.split("+").first
37
+ end
38
+
39
+ def self.setup_package(name, path, files)
40
+ # create the path if it does not exist
41
+ FileUtils.mkdir_p(path) unless File.directory?(path)
42
+ # create the #{name}.wixproj file
43
+ File.open("#{path}/#{name}.wixproj", "w") do |f|
44
+ f.puts "<Project Sdk=\"WixToolset.Sdk/#{Wix::version}\">"
45
+ f.puts "</Project>"
46
+ end
47
+ # create the Package.wxs file
48
+ File.open("#{path}/Package.wxs", "w") do |f|
49
+ f.puts "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">"
50
+ f.puts " <Package Name=\"#{name}\" Manufacturer=\"Acme\" Version=\"0.0.0.0\" UpgradeCode=\"#{SecureRandom.uuid}\">"
51
+ #f.puts " <MajorUpgrade DowngradeErrorMessage=\"!(loc.DowngradeError)\" />"
52
+ f.puts " <Files Include=\"#{files}\" />"
53
+ #f.puts " <Feature Id=\"Main\">"
54
+ #f.puts " <ComponentGroupRef Id=\"Components\" />"
55
+ #f.puts " </Feature>"
56
+ f.puts " </Package>"
57
+ f.puts "</Wix>"
58
+ end
59
+ end
60
+ end # class Wix
61
+ end # module Makit
62
+
63
+ # Package.wxs with File harvesting
64
+ #<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
65
+ # <Package Name="MyProduct" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B0B15C00-1DC4-0374-A1D1-E902240936D5">
66
+ # <Files Include="path\to\files\**" />
67
+ # </Package>
68
+ #</Wix>
69
+
70
+ #<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
71
+ # <Package Name="Msi.Demo" Manufacturer="Acme" Version="1.0.0.0" UpgradeCode="a87571ec-8be3-447e-ae23-b3a94a85b727">
72
+ # <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
73
+
74
+ # <Feature Id="Main">
75
+ # <ComponentGroupRef Id="Components" />
76
+ # </Feature>
77
+ # </Package>
78
+ #</Wix>
79
+
80
+ #<Project Sdk="WixToolset.Sdk/5.0.1">
81
+ #</Project>
82
+
83
+ # Components.wxs
84
+ #<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
85
+ # <Fragment>
86
+ # <ComponentGroup Id="Components" Directory="INSTALLFOLDER">
87
+ # <Component Guid="b8085fb3-3718-46df-8bf6-ecf9f968dd3d">
88
+ # <File Source="../../artifacts/Msi.Demo.exe" />
89
+ # <File Source="../../artifacts/Msi.Demo.dll" />
90
+ # <File Source="../../artifacts/Msi.Demo.deps.json" />
91
+ # <File Source="../../artifacts/Msi.Demo.runtimeconfig.json" />
92
+ # </Component>
93
+ # </ComponentGroup>
94
+ # </Fragment>
95
+ #</Wix>
data/lib/makit/yaml.rb CHANGED
@@ -1,19 +1,19 @@
1
- require 'yaml'
2
-
3
- # frozen_string_literal: true
4
-
5
- # This module provides classes for the Makit gem.
6
- module Makit
7
- class Yaml
8
- def self.validate_yaml(file_path)
9
- begin
10
- YAML.load_file(file_path)
11
- puts "#{file_path} is a valid YAML file."
12
- rescue Psych::SyntaxError => e
13
- raise"YAML validation failed for #{file_path}: #{e}"
14
- end
15
- end
16
- end
17
- end
18
-
19
-
1
+ require 'yaml'
2
+
3
+ # frozen_string_literal: true
4
+
5
+ # This module provides classes for the Makit gem.
6
+ module Makit
7
+ class Yaml
8
+ def self.validate_yaml(file_path)
9
+ begin
10
+ YAML.load_file(file_path)
11
+ puts "#{file_path} is a valid YAML file."
12
+ rescue Psych::SyntaxError => e
13
+ raise"YAML validation failed for #{file_path}: #{e}"
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+
data/lib/makit/zip.rb CHANGED
@@ -1,17 +1,17 @@
1
- # frozen_string_literal: true
2
-
3
- require "zip"
4
- require "fileutils"
5
-
6
- module Makit
7
- # Zip a directory
8
- class Zip
9
- def self.zip_directory(directory, zip_file)
10
- ::Zip::File.open(zip_file, ::Zip::File::CREATE) do |zipfile|
11
- Dir[File.join(directory, "**", "**")].each do |file|
12
- zipfile.add(file.sub("#{directory}/", ""), file)
13
- end
14
- end
15
- end
16
- end
17
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "zip"
4
+ require "fileutils"
5
+
6
+ module Makit
7
+ # Zip a directory
8
+ class Zip
9
+ def self.zip_directory(directory, zip_file)
10
+ ::Zip::File.open(zip_file, ::Zip::File::CREATE) do |zipfile|
11
+ Dir[File.join(directory, "**", "**")].each do |file|
12
+ zipfile.add(file.sub("#{directory}/", ""), file)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end