Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Assets/Tests/Editor/NativeCliInstallerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public void UninstallCompletionTimeout_IsLongEnoughForDeferredWindowsPowerShellC
public void BuildUninstallCommand_OnMacRunsInstalledLauncher()
{
// Verifies that editor uninstall delegates removal to the installed uloop command.
NativeCliInstallCommand command = NativeCliInstaller.BuildUninstallCommand(
NativeCliInstallCommand command = NativeCliCommandBuilder.BuildUninstallCommand(
"/Users/ExampleUser/.local/bin",
RuntimePlatform.OSXEditor);

Expand All @@ -463,7 +463,7 @@ public void BuildUninstallCommand_OnMacRunsInstalledLauncher()
public void BuildUninstallCommand_OnWindowsRunsInstalledLauncher()
{
// Verifies that Windows editor uninstall delegates removal to the installed uloop command.
NativeCliInstallCommand command = NativeCliInstaller.BuildUninstallCommand(
NativeCliInstallCommand command = NativeCliCommandBuilder.BuildUninstallCommand(
"C:\\Users\\ExampleUser\\AppData\\Local\\Programs\\uloop\\bin",
RuntimePlatform.WindowsEditor);

Expand All @@ -478,7 +478,7 @@ public void BuildUninstallCommand_OnWindowsRunsInstalledLauncher()
public void BuildPathWithInstallDirectory_OnWindowsPrependsMissingNativeInstallDir()
{
// Verifies that Unity's current Windows PATH prefers the freshly installed native CLI.
string result = NativeCliInstaller.BuildPathWithInstallDirectory(
string result = NativeCliInstallPathResolver.BuildPathWithInstallDirectory(
"C:\\npm",
"C:\\Users\\ExampleUser\\Programs\\uloop\\bin",
RuntimePlatform.WindowsEditor);
Expand Down Expand Up @@ -506,7 +506,7 @@ private static NativeCliInstallCommand BuildLongRunningInstallCommand()
public void BuildPathWithInstallDirectory_OnWindowsMovesExistingNativeInstallDirToFront()
{
// Verifies that a later Windows native install dir does not leave an earlier npm shim first.
string result = NativeCliInstaller.BuildPathWithInstallDirectory(
string result = NativeCliInstallPathResolver.BuildPathWithInstallDirectory(
"C:\\npm;C:\\USERS\\EXAMPLEUSER\\PROGRAMS\\ULOOP\\BIN",
"C:\\Users\\ExampleUser\\Programs\\uloop\\bin",
RuntimePlatform.WindowsEditor);
Expand All @@ -518,7 +518,7 @@ public void BuildPathWithInstallDirectory_OnWindowsMovesExistingNativeInstallDir
public void BuildPathWithInstallDirectory_OnMacPrependsMissingNativeInstallDir()
{
// Verifies that POSIX PATH prefers the freshly installed native CLI.
string result = NativeCliInstaller.BuildPathWithInstallDirectory(
string result = NativeCliInstallPathResolver.BuildPathWithInstallDirectory(
"/usr/local/bin",
"/Users/ExampleUser/.local/bin",
RuntimePlatform.OSXEditor);
Expand All @@ -530,7 +530,7 @@ public void BuildPathWithInstallDirectory_OnMacPrependsMissingNativeInstallDir()
public void BuildPathWithoutInstallDirectory_OnWindowsRemovesNativeInstallDir()
{
// Verifies that Windows uninstall removes the native CLI directory from PATH without removing npm.
string result = NativeCliInstaller.BuildPathWithoutInstallDirectory(
string result = NativeCliInstallPathResolver.BuildPathWithoutInstallDirectory(
"C:\\npm;C:\\USERS\\EXAMPLEUSER\\PROGRAMS\\ULOOP\\BIN\\;C:\\Tools",
"C:\\Users\\ExampleUser\\Programs\\uloop\\bin",
RuntimePlatform.WindowsEditor);
Expand Down Expand Up @@ -558,7 +558,7 @@ public void FinishSuccessfulInstall_WhenInstallerSucceededUpdatesCurrentProcessP
public void GetDefaultInstallDirectoryFromRoots_OnMacMatchesInstallerDefault()
{
// Verifies that Unity mirrors the POSIX installer default install directory.
string result = NativeCliInstaller.GetDefaultInstallDirectoryFromRoots(
string result = NativeCliInstallPathResolver.GetDefaultInstallDirectoryFromRoots(
RuntimePlatform.OSXEditor,
"/Users/ExampleUser",
null);
Expand All @@ -570,7 +570,7 @@ public void GetDefaultInstallDirectoryFromRoots_OnMacMatchesInstallerDefault()
public void GetDefaultInstallDirectoryFromRoots_OnWindowsMatchesInstallerDefault()
{
// Verifies that Unity mirrors the PowerShell installer default install directory.
string result = NativeCliInstaller.GetDefaultInstallDirectoryFromRoots(
string result = NativeCliInstallPathResolver.GetDefaultInstallDirectoryFromRoots(
RuntimePlatform.WindowsEditor,
null,
"C:\\Users\\ExampleUser\\AppData\\Local");
Expand All @@ -586,7 +586,7 @@ public void GetDefaultInstallDirectoryFromRoots_OnWindowsMatchesInstallerDefault
public void IsPackageOwnedInstallPath_WhenExecutableMatchesInstallDirectoryReturnsTrue()
{
// Verifies that uninstall is available only for the package-owned command path.
bool result = NativeCliInstaller.IsPackageOwnedInstallPath(
bool result = NativeCliInstallPathResolver.IsPackageOwnedInstallPath(
"C:/Users/ExampleUser/AppData/Local/Programs/uloop/bin/uloop.exe",
"C:\\Users\\ExampleUser\\AppData\\Local\\Programs\\uloop\\bin",
RuntimePlatform.WindowsEditor);
Expand All @@ -598,7 +598,7 @@ public void IsPackageOwnedInstallPath_WhenExecutableMatchesInstallDirectoryRetur
public void IsPackageOwnedInstallPath_WhenExecutableIsSharedCommandReturnsFalse()
{
// Verifies that same-version shared commands do not route the settings button to uninstall.
bool result = NativeCliInstaller.IsPackageOwnedInstallPath(
bool result = NativeCliInstallPathResolver.IsPackageOwnedInstallPath(
"C:\\Tools\\uloop.exe",
"C:\\Users\\ExampleUser\\AppData\\Local\\Programs\\uloop\\bin",
RuntimePlatform.WindowsEditor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public Task<bool> IsCliVisibleFromShellAsync(RuntimePlatform platform, Cancellat
return IsShellDetectionUsableForPathSetup(
detection,
platform,
NativeCliInstaller.IsPackageOwnedCurrentUserInstallPath,
NativeCliInstallPathResolver.IsPackageOwnedCurrentUserInstallPath,
minimumDispatcherVersion);
},
ct);
Expand Down Expand Up @@ -185,7 +185,7 @@ private static CliInstallationDetection DetectPackageOwnedCliInstallationBlockin
RuntimePlatform platform,
CancellationToken ct)
{
string executablePath = NativeCliInstaller.GetCurrentUserGlobalCliInstallPath(platform);
string executablePath = NativeCliInstallPathResolver.GetCurrentUserGlobalCliInstallPath(platform);
if (string.IsNullOrEmpty(executablePath) || !File.Exists(executablePath))
{
return new CliInstallationDetection(null, executablePath);
Expand Down Expand Up @@ -243,7 +243,7 @@ internal static ProcessStartInfo BuildShellCliDetectionStartInfo(
if (platform != RuntimePlatform.WindowsEditor)
{
startInfo.EnvironmentVariables[CliConstants.POSIX_PATH_ENVIRONMENT_VARIABLE] =
NativeCliInstaller.BuildPathWithoutInstallDirectory(
NativeCliInstallPathResolver.BuildPathWithoutInstallDirectory(
currentPath,
pathSetupPlan.InstallDirectory,
platform);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class CliPathSetupProfileResolver
{
public static CliPathSetupPlan ResolveCurrentUserPlan(RuntimePlatform platform)
{
string installDirectory = NativeCliInstaller.GetCurrentUserGlobalCliInstallDirectory(platform);
string installDirectory = NativeCliInstallPathResolver.GetCurrentUserGlobalCliInstallDirectory(platform);
string shellPath = NodeEnvironmentResolver.GetUserShell();
return ResolvePlan(
platform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ internal static NativeCliInstallCommand BuildInstallCommandWithPackagePath(
loginShellCommand);
}

internal static NativeCliInstallCommand BuildUninstallCommand(
string installDirectory,
RuntimePlatform platform)
{
UnityEngine.Debug.Assert(!string.IsNullOrWhiteSpace(installDirectory), "installDirectory must not be null or empty");

string installPath = NativeCliInstallPathResolver.GetGlobalCliInstallPath(installDirectory, platform);
return new NativeCliInstallCommand(
installPath,
"uninstall",
$"{QuoteProcessArgument(installPath)} uninstall");
}

private static string BuildPosixRemoteInstallScriptCommand(string scriptUrl, string releaseTag)
{
UnityEngine.Debug.Assert(!string.IsNullOrWhiteSpace(scriptUrl), "scriptUrl must not be null or empty");
Expand Down Expand Up @@ -155,7 +168,7 @@ private static string QuotePowerShellSingleQuotedValue(string value)
return $"'{value.Replace("'", "''")}'";
}

internal static string QuoteProcessArgument(string value)
private static string QuoteProcessArgument(string value)
{
UnityEngine.Debug.Assert(value != null, "value must not be null");
return $"\"{value.Replace("\"", "\\\"")}\"";
Expand Down
Loading
Loading