makit 0.0.155 → 0.0.157
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.
- checksums.yaml +4 -4
- data/lib/makit/directories.rb +56 -26
- data/lib/makit/version.rb +47 -25
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f53268e68239cd1ff7e167f3f466d58acf594cb4cd4b0f1ac8c2dac7bdc102ed
|
|
4
|
+
data.tar.gz: fa63343ea47d2a1aba995fe975299d80112fbd1af3d7f68cc670a3d39736a92c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 533a7a8f644b8e9367f1e9d428cb66e072df4f08373ed87c627c1d42e0543bffad82fb8ee4103a475651895391f1aba014c06657e74a45c92c50cc26d11df871
|
|
7
|
+
data.tar.gz: 4d9c0d9af5d3c7987d0ed969a8b49d2cde25eb2883255900adfeb5de735894d59bab2fcb640aea67dfc2fb52fc5e903ed17dbd8769d92698d9caca11e84e2d6d
|
data/lib/makit/directories.rb
CHANGED
|
@@ -12,42 +12,62 @@ module Makit
|
|
|
12
12
|
# This class provide methods for working with the system Environment.
|
|
13
13
|
#
|
|
14
14
|
module Directories
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
# Helper method to normalize paths to use backslashes on Windows
|
|
16
|
+
def self.normalize_path(path)
|
|
17
|
+
return nil if path.nil?
|
|
18
|
+
return path if path.empty?
|
|
19
|
+
|
|
20
|
+
if Makit::Environment.is_windows?
|
|
21
|
+
# Convert forward slashes to backslashes on Windows
|
|
22
|
+
path.gsub(/\//, "\\")
|
|
23
|
+
else
|
|
24
|
+
# Keep forward slashes on Unix-like systems
|
|
25
|
+
path
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Build paths first, then normalize them to handle dependencies
|
|
30
|
+
_home_path = Makit::Directory.normalize(Dir.home)
|
|
31
|
+
_onedrive_path = File.join(Dir.home, "OneDrive")
|
|
32
|
+
_rakedir_path = Dir.pwd
|
|
33
|
+
|
|
34
|
+
ROOT = normalize_path(File.join(Dir.home, ".makit"))
|
|
35
|
+
CLONE = normalize_path(File.join(Dir.home, ".makit", "clone"))
|
|
36
|
+
MAKE = normalize_path(File.join(Dir.home, ".makit", "make"))
|
|
37
|
+
LOG = normalize_path(File.join(Dir.home, ".makit", "log"))
|
|
38
|
+
WORK = normalize_path(File.join(Dir.home, ".makit", "work"))
|
|
39
|
+
REPOS = normalize_path(File.join(Dir.home, ".makit", "repos"))
|
|
40
|
+
TEMP = normalize_path(File.join(Dir.home, ".makit", "temp"))
|
|
41
|
+
INSTALL = normalize_path(File.join(Dir.home, ".makit", "install"))
|
|
42
|
+
NUGET = normalize_path(File.join(Dir.home, ".makit", "nuget"))
|
|
43
|
+
HOME = normalize_path(_home_path)
|
|
44
|
+
ONEDRIVE = normalize_path(_onedrive_path)
|
|
45
|
+
ONEDRIVE_NUGET_SOURCE = normalize_path(File.join(_onedrive_path, "code", "artifacts", "nuget"))
|
|
46
|
+
ONEDRIVE_CONSOLE_SOURCE = normalize_path(File.join(_onedrive_path, "code", "artifacts", "console"))
|
|
47
|
+
ONEDRIVE_INSTALLER_SOURCE = normalize_path(File.join(_onedrive_path, "code", "artifacts", "installer"))
|
|
48
|
+
CURRENT = normalize_path(Dir.pwd)
|
|
49
|
+
LOCAL_APPLICATION_DATA = normalize_path(File.join(_home_path, "AppData", "Local"))
|
|
31
50
|
# Rake.application.init
|
|
32
51
|
# Rake.application.load_rakefile
|
|
33
|
-
RAKEDIR =
|
|
52
|
+
RAKEDIR = normalize_path(_rakedir_path) # File.dirname(Rake.application.rakefile)
|
|
34
53
|
|
|
35
|
-
|
|
54
|
+
_project_root_path = Makit::Directory.find_directory_with_patterns(_rakedir_path, ["Rakefile", "rakefile.rb", ".gitignore"])
|
|
55
|
+
PROJECT_ROOT = normalize_path(_project_root_path)
|
|
36
56
|
# PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, "Rakefile")
|
|
37
57
|
# PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, "rakefile.rb")
|
|
38
58
|
# PROJECT_ROOT = Makit::Directory.find_directory_with_pattern(RAKEDIR, ".gitignore")
|
|
39
|
-
PROJECT_ARTIFACTS = if
|
|
59
|
+
PROJECT_ARTIFACTS = if _project_root_path.nil?
|
|
40
60
|
nil
|
|
41
61
|
else
|
|
42
|
-
File.join(
|
|
62
|
+
normalize_path(File.join(_project_root_path, "artifacts"))
|
|
43
63
|
end
|
|
44
|
-
LOCAL_NUGET_SOURCE = File.join(Dir.home, ".makit", "nuget")
|
|
64
|
+
LOCAL_NUGET_SOURCE = normalize_path(File.join(Dir.home, ".makit", "nuget"))
|
|
45
65
|
if Makit::Environment.get_os == "Windows"
|
|
46
66
|
# NUGET_PACKAGE_CACHE = "#{ENV["USERPROFILE"]}\\.nuget\\packages"
|
|
47
|
-
NUGET_PACKAGE_CACHE = File.join(
|
|
48
|
-
SERVICES = File.join("C:", "Program Files")
|
|
67
|
+
NUGET_PACKAGE_CACHE = normalize_path(File.join(_home_path, ".nuget", "packages"))
|
|
68
|
+
SERVICES = normalize_path(File.join("C:", "Program Files"))
|
|
49
69
|
else
|
|
50
|
-
NUGET_PACKAGE_CACHE = Makit::Directory.normalize("#{Dir.home}/.nuget/packages")
|
|
70
|
+
NUGET_PACKAGE_CACHE = normalize_path(Makit::Directory.normalize("#{Dir.home}/.nuget/packages"))
|
|
51
71
|
SERVICES = if Makit::Environment.get_os == "macOS"
|
|
52
72
|
"/Library/LaunchDaemons"
|
|
53
73
|
else
|
|
@@ -56,9 +76,19 @@ module Makit
|
|
|
56
76
|
end
|
|
57
77
|
if Makit::NuGet.get_latest_version("Grpc.Tools").nil?
|
|
58
78
|
puts " warning: Grpc.Tools not found in Nuget cache"
|
|
79
|
+
GRPC_TOOLS_PATH = nil
|
|
80
|
+
GRPC_CSHARP_PLUGIN_PATH = nil
|
|
59
81
|
else
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
_grpc_tools_version = Makit::Protoc.get_latest_grpc_tools_version
|
|
83
|
+
GRPC_TOOLS_PATH = normalize_path(File.join(NUGET_PACKAGE_CACHE, "grpc.tools", _grpc_tools_version))
|
|
84
|
+
# Now that GRPC_TOOLS_PATH is defined, we can use it in find_plugin_path
|
|
85
|
+
begin
|
|
86
|
+
_grpc_csharp_plugin_path = Makit::Protoc.find_plugin_path("grpc_csharp_plugin")
|
|
87
|
+
GRPC_CSHARP_PLUGIN_PATH = normalize_path(_grpc_csharp_plugin_path)
|
|
88
|
+
rescue => e
|
|
89
|
+
# If plugin path can't be found, set to nil
|
|
90
|
+
GRPC_CSHARP_PLUGIN_PATH = nil
|
|
91
|
+
end
|
|
62
92
|
end
|
|
63
93
|
|
|
64
94
|
FileUtils.mkdir_p(ROOT)
|
data/lib/makit/version.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Makit
|
|
4
4
|
# Static version for now to avoid circular dependency issues
|
|
5
|
-
#VERSION = "0.0.
|
|
5
|
+
#VERSION = "0.0.157"
|
|
6
6
|
|
|
7
7
|
# Version management utilities for various file formats
|
|
8
8
|
#
|
|
@@ -62,13 +62,14 @@ module Makit
|
|
|
62
62
|
#
|
|
63
63
|
class Version
|
|
64
64
|
|
|
65
|
-
# Attempt to detect the version from the
|
|
66
|
-
#
|
|
65
|
+
# Attempt to detect the version from the SSOT (Single Source of Truth) version file
|
|
66
|
+
# Uses the same logic as Makit::Version.info to find version files in priority order:
|
|
67
|
+
# *.gemspec, Directory.Build.props, Cargo.toml, package.json, pyproject.toml, pom.xml
|
|
67
68
|
# Falls back to makit.gemspec only if we're in the makit gem directory
|
|
68
|
-
# @return [String] The version string, or "0.0.0" if no
|
|
69
|
-
# @raise [RuntimeError] If a
|
|
69
|
+
# @return [String] The version string, or "0.0.0" if no version file is found
|
|
70
|
+
# @raise [RuntimeError] If a version file is found but version cannot be detected
|
|
70
71
|
def self.version
|
|
71
|
-
# Try to find
|
|
72
|
+
# Try to find version file in project root using SSOT logic (same as Makit::Version.info)
|
|
72
73
|
project_root = begin
|
|
73
74
|
require_relative "directories" unless defined?(Makit::Directories)
|
|
74
75
|
Makit::Directories::PROJECT_ROOT
|
|
@@ -76,14 +77,12 @@ module Makit
|
|
|
76
77
|
find_project_root(Dir.pwd)
|
|
77
78
|
end
|
|
78
79
|
|
|
79
|
-
#
|
|
80
|
+
# Use SSOT version file detection (supports multiple file types)
|
|
80
81
|
if project_root && Dir.exist?(project_root)
|
|
81
|
-
|
|
82
|
-
if
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
match = gemspec_content.match(/spec\.version\s*=\s*["']([^"']+)["']/)
|
|
86
|
-
return match[1] if match
|
|
82
|
+
version_file = find_ssot_version_file(project_root)
|
|
83
|
+
if version_file && File.exist?(version_file)
|
|
84
|
+
version = extract_version_from_ssot_file(version_file)
|
|
85
|
+
return version if version
|
|
87
86
|
end
|
|
88
87
|
end
|
|
89
88
|
|
|
@@ -115,7 +114,7 @@ module Makit
|
|
|
115
114
|
end
|
|
116
115
|
end
|
|
117
116
|
|
|
118
|
-
# If no
|
|
117
|
+
# If no version file found, return default version (for non-gem projects)
|
|
119
118
|
"0.0.0"
|
|
120
119
|
end
|
|
121
120
|
|
|
@@ -247,13 +246,30 @@ module Makit
|
|
|
247
246
|
text = File.read(filename)
|
|
248
247
|
# VERSION = "0.0.138rake" (.rb file)
|
|
249
248
|
new_text = text
|
|
250
|
-
new_text =
|
|
251
|
-
new_text =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
new_text =
|
|
249
|
+
new_text = new_text.gsub(/VERSION:\s?['|"]([.\d]+)['|"]/, "VERSION: \"#{version}\"") if filename.include?(".yml")
|
|
250
|
+
new_text = new_text.gsub(/spec\.version\s*=\s*['"]([^'"]+)['"]/, "spec.version = '#{version}'") if filename.include?(".gemspec")
|
|
251
|
+
# Handle Directory.Build.props and .csproj files (both use <Version> tag)
|
|
252
|
+
if filename.include?("Directory.Build.props") || filename.include?(".csproj")
|
|
253
|
+
new_text = new_text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<")
|
|
254
|
+
end
|
|
255
|
+
new_text = new_text.gsub(/<version>([-\w\d.]+)</, "<version>#{version}<") if filename.include?(".nuspec")
|
|
256
|
+
new_text = new_text.gsub(/ Version="([\d.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs")
|
|
257
|
+
new_text = new_text.gsub(/VERSION = "([\d.]+)"/, "VERSION = \"#{version}\"") if filename.include?(".rb")
|
|
258
|
+
# Handle Cargo.toml, pyproject.toml, and other .toml files
|
|
259
|
+
if filename.include?(".toml")
|
|
260
|
+
new_text = new_text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"")
|
|
261
|
+
end
|
|
262
|
+
# Handle package.json
|
|
263
|
+
if filename.include?("package.json")
|
|
264
|
+
require "json"
|
|
265
|
+
json = JSON.parse(new_text)
|
|
266
|
+
json["version"] = version
|
|
267
|
+
new_text = JSON.pretty_generate(json)
|
|
268
|
+
end
|
|
269
|
+
# Handle pom.xml
|
|
270
|
+
if filename.include?("pom.xml")
|
|
271
|
+
new_text = new_text.gsub(%r{<version>([^<]+)</version>}, "<version>#{version}</version>")
|
|
272
|
+
end
|
|
257
273
|
File.write(filename, new_text) if new_text != text
|
|
258
274
|
end
|
|
259
275
|
|
|
@@ -321,8 +337,11 @@ module Makit
|
|
|
321
337
|
|
|
322
338
|
raise "Version not found in #{version_file}" if version.nil?
|
|
323
339
|
|
|
324
|
-
# Display information with relative path
|
|
325
|
-
|
|
340
|
+
# Display information with relative path (Windows-safe path handling)
|
|
341
|
+
# Normalize both paths to forward slashes for comparison, then convert back if needed
|
|
342
|
+
normalized_version_file = version_file.gsub(/\\/, "/")
|
|
343
|
+
normalized_project_root = project_root.gsub(/\\/, "/")
|
|
344
|
+
relative_path = normalized_version_file.sub(normalized_project_root + "/", "")
|
|
326
345
|
puts " Version File: #{relative_path}"
|
|
327
346
|
puts " Version: #{version}"
|
|
328
347
|
end
|
|
@@ -393,9 +412,12 @@ module Makit
|
|
|
393
412
|
# @param project_root [String] Path to the project root directory
|
|
394
413
|
# @return [String, nil] Path to the version file, or nil if not found
|
|
395
414
|
def self.find_ssot_version_file(project_root)
|
|
415
|
+
# Normalize project_root for file operations (Ruby's File methods work with forward slashes)
|
|
416
|
+
normalized_root = project_root.gsub(/\\/, "/")
|
|
417
|
+
|
|
396
418
|
# Check for manually defined VERSION_FILE constant first
|
|
397
419
|
if defined?(VERSION_FILE) && !VERSION_FILE.nil?
|
|
398
|
-
version_file = File.expand_path(VERSION_FILE,
|
|
420
|
+
version_file = File.expand_path(VERSION_FILE, normalized_root)
|
|
399
421
|
return version_file if File.exist?(version_file)
|
|
400
422
|
warn " Warning: VERSION_FILE constant points to non-existent file: #{VERSION_FILE}"
|
|
401
423
|
end
|
|
@@ -411,7 +433,7 @@ module Makit
|
|
|
411
433
|
]
|
|
412
434
|
|
|
413
435
|
version_file_patterns.each do |pattern|
|
|
414
|
-
matches = Dir.glob(File.join(
|
|
436
|
+
matches = Dir.glob(File.join(normalized_root, pattern))
|
|
415
437
|
next if matches.empty?
|
|
416
438
|
|
|
417
439
|
# For gemspec, prefer the one matching the project name or take the first
|