makit 0.0.38 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c27f269da0b90889675df5626377f39ea4041da3fd699c55b38cb11765b8f25c
4
- data.tar.gz: 0c38c29372bc46db6fe59fc71791d2ade93a324cb79e7b104b2070ff8e69e326
3
+ metadata.gz: 93de9bfaedfa0557388f5bfd8f241fc289893106553c4947fa726a6ef494c808
4
+ data.tar.gz: e3fa7600024eae44bd5ded8398826064c302aa450850ea7c58f25957229b8ea5
5
5
  SHA512:
6
- metadata.gz: 457c42044259e99d39778189f620bc631b9326f4e85fd632420bb906fd714f9af5caf883492a007f19085fc8d517882ff26aabe2e7ba130eaa79296caed1608d
7
- data.tar.gz: 6dc2f0740d5516062053aa379f039a48bfa02fc44ec2b0f53ab4d2ca16fa01346e56f25bb87cfb96c3eb7fc017b089e0356fce2eb137f7d18d9dc36504b12fce
6
+ metadata.gz: 7f6f494ebbc66fc47fc94a20719d741b8fb85892d26a5bb2399e1b9e769d6e802a02643d1487ef289e1ca05eaacd9e4ec8c13ba02fdf0ad4cca40ace9a7e1289
7
+ data.tar.gz: aa932f069dd2f9a7038038d7c882e39128e2a2a245155ab164c027cc3217a57b1ccfa0512f3164c51614f13a7bf767afb45aeebe20997e9938b4a73b5c0e3b38
@@ -180,5 +180,21 @@ module Makit
180
180
  end
181
181
  end
182
182
  end
183
+
184
+ def self.remove_empty_directories(dir)
185
+ Find.find(dir) do |path|
186
+ if File.directory?(path) && Dir.empty?(path)
187
+ FileUtils.rm_rf(path)
188
+ end
189
+ end
190
+ end
191
+
192
+ def self.remove_empty_directories_recursively(dir)
193
+ Find.find(dir) do |path|
194
+ if File.directory?(path) && Dir.empty?(path)
195
+ FileUtils.rm_rf(path)
196
+ end
197
+ end
198
+ end
183
199
  end
184
200
  end
data/lib/makit/git.rb CHANGED
@@ -32,6 +32,7 @@ module Makit
32
32
  if is_git_repo && !detached
33
33
  "git pull".try
34
34
  "git push origin".try
35
+ "git push origin --tags".try
35
36
  end
36
37
  end
37
38
 
data/lib/makit/show.rb CHANGED
@@ -34,7 +34,8 @@ module Makit
34
34
  if File.file?(path)
35
35
  modified = File.mtime(path)
36
36
  age = (Time.now - modified).to_f
37
- puts "#{file_symbol} #{path} ".colorize(:grey) + "#{Makit::Humanize.get_humanized_size(File.size(path))} ".colorize(:cyan) + "#{Makit::Humanize.get_humanized_duration(age)}".colorize(:cyan)
37
+ humanized_size = Makit::Humanize.get_humanized_size(File.size(path))
38
+ puts "#{file_symbol} ".colorize(:grey) + "#{humanized_size.rjust(10)} ".colorize(:cyan) +" #{path} ".colorize(:grey)
38
39
  else
39
40
  puts "#{path} does not exist"
40
41
  end
@@ -42,7 +43,8 @@ module Makit
42
43
 
43
44
  def file_symbol
44
45
  #📄 (U+1F4C4) – "Page with Curl"
45
- "\u{1F4C4}"
46
+ #"\u{1F4C4}"
47
+ "@"
46
48
  end
47
49
 
48
50
  def directory_symbol
@@ -70,7 +72,37 @@ module Makit
70
72
  puts " ".colorize(:grey) + "#{task}".colorize(:green)
71
73
  #puts ("=" * 100).colorize(:grey)
72
74
  end
75
+
76
+ def info(text)
77
+ puts " ".colorize(:grey) + "#{text}".colorize(:cyan)
78
+ end
79
+
80
+ def success(text)
81
+ puts " ".colorize(:grey) + "#{text}".colorize(:green)
82
+ end
83
+
84
+ def version(path)
85
+ puts " #{Makit::Version.get_version_from_file(path)}".colorize(:green) + " found in #{path}".colorize(:grey)
86
+ #if(!File.exist?(path))
87
+ # puts "file #{path}does not exist"
88
+ # return
89
+ #end
90
+
91
+ #extension = File.extname(path)
92
+ #switch = extension.downcase
93
+ #case switch
94
+ #if extension == ".csproj"
95
+ # version = Makit::Version.detect_from_file(path, /<Version>([-\w\d.]+)</)
96
+ # if version.empty?
97
+ # puts "no version found in #{path}"
98
+ # else
99
+ # puts " #{version}".colorize(:green) + " found in #{path}".colorize(:grey)
100
+ # end
101
+ # else
102
+ ## puts "unrecognized file type"
103
+ #end
104
+ end
73
105
  end
74
106
  end
75
107
 
76
- #Code42-#{VERSION}-win10-x64 ".colorize(:grey) + "#{Makit::Humanize.get_humanized_size(Makit::Directory.get_size("artifacts/Code42-0.0.0-win10-x64"))}".colorize(:cyan)
108
+
data/lib/makit/tasks.rb CHANGED
@@ -15,19 +15,19 @@ end
15
15
 
16
16
  desc "Remove any temporary products."
17
17
  task :clean do
18
- puts ":clean".colorize(:blue)
18
+ Makit::SHOW.task(:clean)
19
19
  Makit::RUNNER.run(Makit::RUNNER.parse_command_request("git clean -dXf"))
20
20
  end
21
21
 
22
22
  desc "Integrate changes into the git repository."
23
23
  task :integrate do
24
- puts ":integrate".colorize(:blue)
24
+ Makit::SHOW.task(:integrate)
25
25
  Makit::Git.integrate
26
26
  end
27
27
 
28
28
  desc "Sync changes with the git repository."
29
29
  task :sync do
30
- puts ":sync".colorize(:blue)
30
+ Makit::SHOW.task(:sync)
31
31
  Makit::Git.sync
32
32
  end
33
33
 
@@ -38,13 +38,13 @@ end
38
38
 
39
39
  desc "Format source code."
40
40
  task :format do
41
- puts ":format".colorize(:blue)
41
+ Makit::SHOW.task(:format)
42
42
  Makit::RUNNER.try("rufo .") if File.exist?("Gemfile") || File.exist?("Rakefile")
43
43
  end
44
44
 
45
45
  desc "Update dependencies."
46
46
  task :update do
47
- puts ":update".colorize(:blue)
47
+ Makit::SHOW.task(:update)
48
48
  system("bundle update") if File.exist?("Gemfile")
49
49
  # glob all *.csproj files
50
50
  Dir.glob("**/*.csproj").each do |file|
@@ -1,33 +1,34 @@
1
- # frozen_string_literal: true
2
- # Generated by the protocol buffer compiler. DO NOT EDIT!
3
- # source: lib/makit/v1/makit.v1.proto
4
-
5
- require "google/protobuf"
6
-
7
- require "google/protobuf/timestamp_pb"
8
- require "google/protobuf/duration_pb"
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"
11
-
12
- pool = Google::Protobuf::DescriptorPool.generated_pool
13
- pool.add_serialized_file(descriptor_data)
14
-
15
- module Makit
16
- module V1
17
- DotNetProject = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetProject").msgclass
18
- DotNetBuildArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetBuildArgs").msgclass
19
- DotNetPublishArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetPublishArgs").msgclass
20
- DotNetTestArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetTestArgs").msgclass
21
- Project = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Project").msgclass
22
- CommandRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.CommandRequest").msgclass
23
- Command = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Command").msgclass
24
- Configuration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Configuration").msgclass
25
- GitRepository = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.GitRepository").msgclass
26
- GitLogEntry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.GitLogEntry").msgclass
27
- MakeResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.MakeResult").msgclass
28
- DotNetNewArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetNewArgs").msgclass
29
- ManifestEntry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.ManifestEntry").msgclass
30
- Language = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Language").enummodule
31
- PackageType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.PackageType").enummodule
32
- end
33
- end
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: lib/makit/v1/makit.v1.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require 'google/protobuf/timestamp_pb'
8
+ require 'google/protobuf/duration_pb'
9
+
10
+
11
+ 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"
12
+
13
+ pool = Google::Protobuf::DescriptorPool.generated_pool
14
+ pool.add_serialized_file(descriptor_data)
15
+
16
+ module Makit
17
+ module V1
18
+ DotNetProject = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetProject").msgclass
19
+ DotNetBuildArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetBuildArgs").msgclass
20
+ DotNetPublishArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetPublishArgs").msgclass
21
+ DotNetTestArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetTestArgs").msgclass
22
+ Project = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Project").msgclass
23
+ CommandRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.CommandRequest").msgclass
24
+ Command = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Command").msgclass
25
+ Configuration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Configuration").msgclass
26
+ GitRepository = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.GitRepository").msgclass
27
+ GitLogEntry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.GitLogEntry").msgclass
28
+ MakeResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.MakeResult").msgclass
29
+ DotNetNewArgs = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.DotNetNewArgs").msgclass
30
+ ManifestEntry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.ManifestEntry").msgclass
31
+ Language = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.Language").enummodule
32
+ PackageType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("makit.v1.PackageType").enummodule
33
+ end
34
+ end
data/lib/makit/version.rb CHANGED
@@ -1,12 +1,52 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Makit
4
- VERSION = "0.0.38"
4
+ VERSION = "0.0.40"
5
5
 
6
6
  class Version
7
7
  # given an array of version strings, return the highest version
8
8
  def self.get_highest_version(versions)
9
9
  versions.sort { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }.last
10
10
  end
11
+
12
+ def self.get_version_from_file(path)
13
+ if(!File.exist?(path))
14
+ raise "file #{path}does not exist"
15
+ end
16
+
17
+ extension = File.extname(path)
18
+ #switch = extension.downcase
19
+ #case switch
20
+ #if extension == ".csproj"
21
+ switch = extension.downcase
22
+ case switch
23
+ when ".csproj"
24
+ Makit::Version.detect_from_file(path, /<Version>([-\w\d.]+)</)
25
+ when ".wxs"
26
+ Makit::Version.detect_from_file(path, / Version="([\d\.]+)"/)
27
+ else
28
+ raise "unrecognized file type"
29
+ end
30
+ end
31
+
32
+ def self.detect_from_file(filename, regex)
33
+ if File.exist?(filename)
34
+ match = IO.read(filename).match(regex)
35
+ match.captures[0] if !match.nil? && match.captures.length.positive?
36
+ else
37
+ raise "unable to find version in #{filename}"
38
+ end
39
+ end
40
+
41
+ def self.set_version_in_file(filename, version)
42
+ text = IO.read(filename)
43
+ new_text = text
44
+ new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?(".gemspec")
45
+ new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?(".csproj")
46
+ new_text = text.gsub(/<version>([-\w\d.]+)</, "<version>#{version}<") if filename.include?(".nuspec")
47
+ new_text = text.gsub(/ Version="([\d\.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs")
48
+ new_text = text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"") if filename.include?(".toml")
49
+ File.open(filename, "w") { |f| f.write(new_text) } if new_text != text
50
+ end
11
51
  end
12
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: makit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-05 00:00:00.000000000 Z
11
+ date: 2024-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp