added public helper methods for project versions

main
Justin Barnett 2025-04-09 07:42:43 -04:00
parent 99f38e21bd
commit b2f65f2ffc
1 changed files with 17 additions and 11 deletions

View File

@ -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);
}
/// <summary>
/// Fetches the currently installed version from the local pyproject.toml file.
/// </summary>
public static string GetInstalledVersion()
{
string pyprojectPath = Path.Combine(
GetSaveLocation(),
ServerFolder,
"src",
"pyproject.toml"
);
return ParseVersionFromPyproject(File.ReadAllText(pyprojectPath));
}
/// <summary>
/// Fetches the latest version from the GitHub pyproject.toml file.
/// </summary>
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
/// <summary>
/// Compares two version strings to determine if the latest is newer.
/// </summary>
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();