From b2f65f2ffc3127ec13628471f48a6cb9e525c908 Mon Sep 17 00:00:00 2001 From: Justin Barnett Date: Wed, 9 Apr 2025 07:42:43 -0400 Subject: [PATCH] added public helper methods for project versions --- .../Editor/Helpers/ServerInstaller.cs | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs b/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs index 7f22c41..9d5682f 100644 --- a/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs +++ b/UnityMcpBridge/Editor/Helpers/ServerInstaller.cs @@ -33,15 +33,7 @@ namespace UnityMcpBridge.Editor.Helpers } else { - string pyprojectPath = Path.Combine( - saveLocation, - ServerFolder, - "src", - "pyproject.toml" - ); - string installedVersion = ParseVersionFromPyproject( - File.ReadAllText(pyprojectPath) - ); + string installedVersion = GetInstalledVersion(); string latestVersion = GetLatestVersion(); if (IsNewerVersion(latestVersion, installedVersion)) @@ -148,10 +140,24 @@ namespace UnityMcpBridge.Editor.Helpers RunCommand("git", $"checkout {BranchName}", workingDirectory: location); } + /// + /// Fetches the currently installed version from the local pyproject.toml file. + /// + public static string GetInstalledVersion() + { + string pyprojectPath = Path.Combine( + GetSaveLocation(), + ServerFolder, + "src", + "pyproject.toml" + ); + return ParseVersionFromPyproject(File.ReadAllText(pyprojectPath)); + } + /// /// Fetches the latest version from the GitHub pyproject.toml file. /// - private static string GetLatestVersion() + public static string GetLatestVersion() { using WebClient webClient = new(); string pyprojectContent = webClient.DownloadString(PyprojectUrl); @@ -188,7 +194,7 @@ namespace UnityMcpBridge.Editor.Helpers /// /// Compares two version strings to determine if the latest is newer. /// - private static bool IsNewerVersion(string latest, string installed) + public static bool IsNewerVersion(string latest, string installed) { int[] latestParts = latest.Split('.').Select(int.Parse).ToArray(); int[] installedParts = installed.Split('.').Select(int.Parse).ToArray();