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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d93befa57f680339009f0de2fb5f05cc21e5568edc0d11b7b353fd286b809947
4
- data.tar.gz: 47fc7d425c73719c46a9f6230e001ed07c3c01b3aec5b0600e5b9013606970bd
3
+ metadata.gz: f53268e68239cd1ff7e167f3f466d58acf594cb4cd4b0f1ac8c2dac7bdc102ed
4
+ data.tar.gz: fa63343ea47d2a1aba995fe975299d80112fbd1af3d7f68cc670a3d39736a92c
5
5
  SHA512:
6
- metadata.gz: d9c1bfddaab86e85cc088d30280d1c2d8f1b0e629684b0463eed255d1ae654931136fd7484a1ccd17c62541a00d70aef8fd51b3fcfb381bfeb5fd8f2993e0684
7
- data.tar.gz: 9d9b1549633f32e224a2c490b4f9ef228a9bddb4e0a4097ec0a81aff9ca5f1c9c96c074b73dd781d341ac5ddf32553a14e476503df9e5a5288e7c9da0660bf83
6
+ metadata.gz: 533a7a8f644b8e9367f1e9d428cb66e072df4f08373ed87c627c1d42e0543bffad82fb8ee4103a475651895391f1aba014c06657e74a45c92c50cc26d11df871
7
+ data.tar.gz: 4d9c0d9af5d3c7987d0ed969a8b49d2cde25eb2883255900adfeb5de735894d59bab2fcb640aea67dfc2fb52fc5e903ed17dbd8769d92698d9caca11e84e2d6d
@@ -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
- ROOT = File.join(Dir.home, ".makit")
16
- CLONE = File.join(Dir.home, ".makit", "clone")
17
- MAKE = File.join(Dir.home, ".makit", "make")
18
- LOG = File.join(Dir.home, ".makit", "log")
19
- WORK = File.join(Dir.home, ".makit", "work")
20
- REPOS = File.join(Dir.home, ".makit", "repos")
21
- TEMP = File.join(Dir.home, ".makit", "temp")
22
- INSTALL = File.join(Dir.home, ".makit", "install")
23
- NUGET = File.join(Dir.home, ".makit", "nuget")
24
- HOME = Makit::Directory.normalize(Dir.home)
25
- ONEDRIVE = File.join(Dir.home, "OneDrive")
26
- ONEDRIVE_NUGET_SOURCE = File.join(ONEDRIVE, "code", "artifacts", "nuget")
27
- ONEDRIVE_CONSOLE_SOURCE = File.join(ONEDRIVE, "code", "artifacts", "console")
28
- ONEDRIVE_INSTALLER_SOURCE = File.join(ONEDRIVE, "code", "artifacts", "installer")
29
- CURRENT = Dir.pwd
30
- LOCAL_APPLICATION_DATA = File.join(HOME, "AppData", "Local")
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 = Dir.pwd # File.dirname(Rake.application.rakefile)
52
+ RAKEDIR = normalize_path(_rakedir_path) # File.dirname(Rake.application.rakefile)
34
53
 
35
- PROJECT_ROOT = Makit::Directory.find_directory_with_patterns(RAKEDIR, ["Rakefile", "rakefile.rb", ".gitignore"])
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 PROJECT_ROOT.nil?
59
+ PROJECT_ARTIFACTS = if _project_root_path.nil?
40
60
  nil
41
61
  else
42
- File.join(PROJECT_ROOT, "artifacts")
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(HOME, ".nuget", "packages")
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
- GRPC_TOOLS_PATH = File.join(NUGET_PACKAGE_CACHE, "grpc.tools", Makit::Protoc.get_latest_grpc_tools_version)
61
- GRPC_CSHARP_PLUGIN_PATH = Makit::Protoc.find_plugin_path("grpc_csharp_plugin")
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.155"
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 gemspec file
66
- # First tries to find a gemspec in the current project root
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 gemspec is found
69
- # @raise [RuntimeError] If a gemspec is found but version cannot be detected
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 gemspec in project root first (for projects using makit)
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
- # Look for any .gemspec file in project root
80
+ # Use SSOT version file detection (supports multiple file types)
80
81
  if project_root && Dir.exist?(project_root)
81
- gemspec_files = Dir.glob(File.join(project_root, "*.gemspec"))
82
- if gemspec_files.any?
83
- gemspec = gemspec_files.first
84
- gemspec_content = File.read(gemspec)
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 gemspec found, return default version (for non-gem projects)
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 = text.gsub(/VERSION:\s?['|"]([.\d]+)['|"]/, "VERSION: \"#{version}\"") if filename.include?(".yml")
251
- new_text = text.gsub(/version\s?=\s?['|"]([.\d]+)['|"]/, "version='#{version}'") if filename.include?(".gemspec")
252
- new_text = text.gsub(/<Version>([-\w\d.]+)</, "<Version>#{version}<") if filename.include?(".csproj")
253
- new_text = text.gsub(/<version>([-\w\d.]+)</, "<version>#{version}<") if filename.include?(".nuspec")
254
- new_text = text.gsub(/ Version="([\d.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs")
255
- new_text = text.gsub(/VERSION = "([\d.]+)"/, "VERSION = \"#{version}\"") if filename.include?(".rb")
256
- new_text = text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"") if filename.include?(".toml")
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
- relative_path = version_file.sub(project_root + "/", "")
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, project_root)
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(project_root, pattern))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: makit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.155
4
+ version: 0.0.157
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lou Parslow