removed logging
parent
e9bc45c0df
commit
f446b502ee
|
|
@ -11,7 +11,7 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
{
|
{
|
||||||
private const string RootFolder = "UnityMCP";
|
private const string RootFolder = "UnityMCP";
|
||||||
private const string ServerFolder = "UnityMcpServer";
|
private const string ServerFolder = "UnityMcpServer";
|
||||||
private const string BranchName = "feature/install-overhaul"; // Adjust branch as needed
|
private const string BranchName = "feature/install-overhaul";
|
||||||
private const string GitUrl = "https://github.com/justinpbarnett/unity-mcp.git";
|
private const string GitUrl = "https://github.com/justinpbarnett/unity-mcp.git";
|
||||||
private const string PyprojectUrl =
|
private const string PyprojectUrl =
|
||||||
"https://raw.githubusercontent.com/justinpbarnett/unity-mcp/refs/heads/"
|
"https://raw.githubusercontent.com/justinpbarnett/unity-mcp/refs/heads/"
|
||||||
|
|
@ -26,30 +26,21 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string saveLocation = GetSaveLocation();
|
string saveLocation = GetSaveLocation();
|
||||||
Debug.Log($"Server save location: {saveLocation}");
|
|
||||||
|
|
||||||
if (!IsServerInstalled(saveLocation))
|
if (!IsServerInstalled(saveLocation))
|
||||||
{
|
{
|
||||||
Debug.Log("Server not found. Installing...");
|
|
||||||
InstallServer(saveLocation);
|
InstallServer(saveLocation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log("Server is installed. Checking version...");
|
|
||||||
string installedVersion = GetInstalledVersion(saveLocation);
|
string installedVersion = GetInstalledVersion(saveLocation);
|
||||||
string latestVersion = GetLatestVersion();
|
string latestVersion = GetLatestVersion();
|
||||||
|
|
||||||
if (IsNewerVersion(latestVersion, installedVersion))
|
if (IsNewerVersion(latestVersion, installedVersion))
|
||||||
{
|
{
|
||||||
Debug.Log(
|
|
||||||
$"Newer version available ({latestVersion} > {installedVersion}). Updating..."
|
|
||||||
);
|
|
||||||
UpdateServer(saveLocation);
|
UpdateServer(saveLocation);
|
||||||
}
|
}
|
||||||
else
|
else { }
|
||||||
{
|
|
||||||
Debug.Log("Server is up to date.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -58,6 +49,11 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetServerPath()
|
||||||
|
{
|
||||||
|
return Path.Combine(GetSaveLocation(), ServerFolder, "src");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the platform-specific save location for the server.
|
/// Gets the platform-specific save location for the server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -65,7 +61,6 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
// Use a user-specific program directory under %USERPROFILE%\AppData\Local\Programs
|
|
||||||
return Path.Combine(
|
return Path.Combine(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
||||||
"AppData",
|
"AppData",
|
||||||
|
|
@ -115,11 +110,8 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool IsServerInstalled(string location)
|
private static bool IsServerInstalled(string location)
|
||||||
{
|
{
|
||||||
bool doesExist =
|
return Directory.Exists(location)
|
||||||
Directory.Exists(location)
|
|
||||||
&& File.Exists(Path.Combine(location, ServerFolder, "version.txt"));
|
&& File.Exists(Path.Combine(location, ServerFolder, "version.txt"));
|
||||||
Debug.Log($"Server does exist: {doesExist}");
|
|
||||||
return doesExist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -167,10 +159,7 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
private static string GetInstalledVersion(string location)
|
private static string GetInstalledVersion(string location)
|
||||||
{
|
{
|
||||||
string versionFile = Path.Combine(location, ServerFolder, "version.txt");
|
string versionFile = Path.Combine(location, ServerFolder, "version.txt");
|
||||||
Debug.Log($"Looking for version at: {versionFile}");
|
return File.ReadAllText(versionFile).Trim();
|
||||||
string versionFileText = File.ReadAllText(versionFile).Trim();
|
|
||||||
Debug.Log($"versionFile text: {versionFileText}");
|
|
||||||
return versionFileText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -178,7 +167,6 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string GetLatestVersion()
|
private static string GetLatestVersion()
|
||||||
{
|
{
|
||||||
Debug.Log("Getting latest version.");
|
|
||||||
using WebClient webClient = new();
|
using WebClient webClient = new();
|
||||||
string pyprojectContent = webClient.DownloadString(PyprojectUrl);
|
string pyprojectContent = webClient.DownloadString(PyprojectUrl);
|
||||||
return ParseVersionFromPyproject(pyprojectContent);
|
return ParseVersionFromPyproject(pyprojectContent);
|
||||||
|
|
@ -189,7 +177,6 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void UpdateServer(string location)
|
private static void UpdateServer(string location)
|
||||||
{
|
{
|
||||||
Debug.Log("Updating Server");
|
|
||||||
// Pull latest changes in the src directory
|
// Pull latest changes in the src directory
|
||||||
string serverDir = Path.Combine(location, ServerFolder, "src");
|
string serverDir = Path.Combine(location, ServerFolder, "src");
|
||||||
RunCommand("git", $"pull origin {BranchName}", workingDirectory: serverDir);
|
RunCommand("git", $"pull origin {BranchName}", workingDirectory: serverDir);
|
||||||
|
|
@ -216,9 +203,7 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
string[] parts = line.Split('=');
|
string[] parts = line.Split('=');
|
||||||
if (parts.Length == 2)
|
if (parts.Length == 2)
|
||||||
{
|
{
|
||||||
string version = parts[1].Trim().Trim('"');
|
return parts[1].Trim().Trim('"');
|
||||||
Debug.Log($"Version is: {version}");
|
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue