diff --git a/src/libraries/Highbyte.DotNet6502.Updates/InstallChannel.cs b/src/libraries/Highbyte.DotNet6502.Updates/InstallChannel.cs index 15af646ef..6fbda2117 100644 --- a/src/libraries/Highbyte.DotNet6502.Updates/InstallChannel.cs +++ b/src/libraries/Highbyte.DotNet6502.Updates/InstallChannel.cs @@ -59,8 +59,8 @@ public sealed record AppUpdateDescriptor /// Argv (after the manager executable) that upgrades this app for the given channel. public string[] UpgradeArgs(InstallChannel channel) => channel switch { - InstallChannel.Homebrew when HomebrewIsCask => new[] { "upgrade", "--cask", HomebrewPackage }, - InstallChannel.Homebrew => new[] { "upgrade", HomebrewPackage }, + InstallChannel.Homebrew when HomebrewIsCask => new[] { "upgrade", "--no-ask", "--cask", HomebrewPackage }, + InstallChannel.Homebrew => new[] { "upgrade", "--no-ask", "--formula", HomebrewPackage }, InstallChannel.Scoop => new[] { "update", ScoopPackage }, _ => throw new ArgumentOutOfRangeException(nameof(channel), channel, "No upgrade args for a non-managed channel."), }; diff --git a/src/libraries/Highbyte.DotNet6502.Updates/ProcessLaunch.cs b/src/libraries/Highbyte.DotNet6502.Updates/ProcessLaunch.cs index 40c2ba2bc..ec5f30e5b 100644 --- a/src/libraries/Highbyte.DotNet6502.Updates/ProcessLaunch.cs +++ b/src/libraries/Highbyte.DotNet6502.Updates/ProcessLaunch.cs @@ -34,6 +34,7 @@ public static ProcessStartInfo BuildStartInfo( case ".ps1": psi.FileName = powerShellExe; psi.ArgumentList.Add("-NoProfile"); + psi.ArgumentList.Add("-NonInteractive"); psi.ArgumentList.Add("-ExecutionPolicy"); psi.ArgumentList.Add("Bypass"); psi.ArgumentList.Add("-File"); diff --git a/src/libraries/Highbyte.DotNet6502.Updates/UpdateApplier.cs b/src/libraries/Highbyte.DotNet6502.Updates/UpdateApplier.cs index 33e1741c0..0d6d063e8 100644 --- a/src/libraries/Highbyte.DotNet6502.Updates/UpdateApplier.cs +++ b/src/libraries/Highbyte.DotNet6502.Updates/UpdateApplier.cs @@ -202,6 +202,7 @@ private static bool TrySpawnDetachedWindows(string manager, IReadOnlyListBuilds the exact upgrade command for the detected channel (Phase A: shown/copied, not auto-run). public string BuildUpgradeCommand(InstallChannel channel) => channel switch { - InstallChannel.Homebrew when _descriptor.HomebrewIsCask => $"brew update && brew upgrade --cask {_descriptor.HomebrewPackage}", - InstallChannel.Homebrew => $"brew update && brew upgrade {_descriptor.HomebrewPackage}", + InstallChannel.Homebrew when _descriptor.HomebrewIsCask => $"brew update && brew upgrade --no-ask --cask {_descriptor.HomebrewPackage}", + InstallChannel.Homebrew => $"brew update && brew upgrade --no-ask --formula {_descriptor.HomebrewPackage}", // ';' (not '&&') separates the metadata refresh from the app upgrade: Scoop runs under // PowerShell, where ';' is the portable statement separator ('&&' is PowerShell 7+ only). InstallChannel.Scoop => $"scoop update; scoop update {_descriptor.ScoopPackage}", diff --git a/tests/Highbyte.DotNet6502.Updates.Tests/AppUpdateDescriptorTests.cs b/tests/Highbyte.DotNet6502.Updates.Tests/AppUpdateDescriptorTests.cs index 9455d2c56..790ae6efe 100644 --- a/tests/Highbyte.DotNet6502.Updates.Tests/AppUpdateDescriptorTests.cs +++ b/tests/Highbyte.DotNet6502.Updates.Tests/AppUpdateDescriptorTests.cs @@ -20,7 +20,7 @@ public void HomebrewCaskUpgradeCommandArgs_UpdateTapBeforeUpgrade() Assert.Collection( commands, command => Assert.Equal(new[] { "update" }, command), - command => Assert.Equal(new[] { "upgrade", "--cask", "dotnet-6502" }, command)); + command => Assert.Equal(new[] { "upgrade", "--no-ask", "--cask", "dotnet-6502" }, command)); } [Fact] diff --git a/tests/Highbyte.DotNet6502.Updates.Tests/ConsoleUpdateCliTests.cs b/tests/Highbyte.DotNet6502.Updates.Tests/ConsoleUpdateCliTests.cs index 560a2b709..56de18f5e 100644 --- a/tests/Highbyte.DotNet6502.Updates.Tests/ConsoleUpdateCliTests.cs +++ b/tests/Highbyte.DotNet6502.Updates.Tests/ConsoleUpdateCliTests.cs @@ -25,11 +25,11 @@ public void FormatNoticeLine_MatchesSpecWording() Status = UpdateCheckStatus.UpdateAvailable, CurrentVersion = current, LatestVersion = latest, - SuggestedCommand = "brew update && brew upgrade dotnet-6502-terminal", + SuggestedCommand = "brew update && brew upgrade --no-ask --formula dotnet-6502-terminal", }; Assert.Equal( - "A newer version v0.40.2-alpha is available (you have v0.39.3-alpha). Run 'brew update && brew upgrade dotnet-6502-terminal' to update.", + "A newer version v0.40.2-alpha is available (you have v0.39.3-alpha). Run 'brew update && brew upgrade --no-ask --formula dotnet-6502-terminal' to update.", ConsoleUpdateCli.FormatNoticeLine(result)); } diff --git a/tests/Highbyte.DotNet6502.Updates.Tests/ProcessLaunchTests.cs b/tests/Highbyte.DotNet6502.Updates.Tests/ProcessLaunchTests.cs index 8afcec895..3cf41435e 100644 --- a/tests/Highbyte.DotNet6502.Updates.Tests/ProcessLaunchTests.cs +++ b/tests/Highbyte.DotNet6502.Updates.Tests/ProcessLaunchTests.cs @@ -22,6 +22,7 @@ public void Windows_Ps1Shim_IsRunViaPowerShellFile_DefaultsToWindowsPowerShell() var psi = ProcessLaunch.BuildStartInfo(@"C:\scoop\shims\scoop.ps1", new[] { "update", "dotnet-6502" }, isWindows: true); Assert.Equal("powershell.exe", psi.FileName); + Assert.Contains("-NonInteractive", psi.ArgumentList); Assert.Contains("-File", psi.ArgumentList); Assert.Contains(@"C:\scoop\shims\scoop.ps1", psi.ArgumentList); Assert.Contains("update", psi.ArgumentList); @@ -33,6 +34,7 @@ public void Windows_Ps1Shim_UsesGivenPowerShellHost() var psi = ProcessLaunch.BuildStartInfo(@"C:\scoop\shims\scoop.ps1", new[] { "update", "x" }, isWindows: true, powerShellExe: "pwsh.exe"); Assert.Equal("pwsh.exe", psi.FileName); + Assert.Contains("-NonInteractive", psi.ArgumentList); Assert.Contains("-File", psi.ArgumentList); } diff --git a/tests/Highbyte.DotNet6502.Updates.Tests/UpdateApplierTests.cs b/tests/Highbyte.DotNet6502.Updates.Tests/UpdateApplierTests.cs index 33b20e162..4851eb7a3 100644 --- a/tests/Highbyte.DotNet6502.Updates.Tests/UpdateApplierTests.cs +++ b/tests/Highbyte.DotNet6502.Updates.Tests/UpdateApplierTests.cs @@ -64,7 +64,7 @@ public async Task TrySpawnDetachedRelaunch_RunsUpgradeCommands_InOrder() var spawned = UpdateApplier.TrySpawnDetachedRelaunch( manager, - new IReadOnlyList[] { new[] { "update" }, new[] { "upgrade", "--cask", "dotnet-6502" } }, + new IReadOnlyList[] { new[] { "update" }, new[] { "upgrade", "--no-ask", "--cask", "dotnet-6502" } }, app.Id, new RelaunchSpec("/bin/bash", new[] { relaunchScript }), logFilePath: Path.Combine(dir, "update.log")); @@ -76,7 +76,7 @@ public async Task TrySpawnDetachedRelaunch_RunsUpgradeCommands_InOrder() Assert.True(await WaitForFileAsync(relaunchMarker, TimeSpan.FromSeconds(15)), "relaunch did not run"); var commandLogAppeared = await WaitForFileAsync(log, TimeSpan.FromSeconds(5)); Assert.True(commandLogAppeared, "manager command log was not written"); - Assert.Equal(new[] { "update", "upgrade --cask dotnet-6502" }, await File.ReadAllLinesAsync(log)); + Assert.Equal(new[] { "update", "upgrade --no-ask --cask dotnet-6502" }, await File.ReadAllLinesAsync(log)); } finally { diff --git a/tests/Highbyte.DotNet6502.Updates.Tests/UpdateCheckerTests.cs b/tests/Highbyte.DotNet6502.Updates.Tests/UpdateCheckerTests.cs index 63121d8c0..8fb171367 100644 --- a/tests/Highbyte.DotNet6502.Updates.Tests/UpdateCheckerTests.cs +++ b/tests/Highbyte.DotNet6502.Updates.Tests/UpdateCheckerTests.cs @@ -95,7 +95,7 @@ public async Task LogsInformation_WhenUpdateAvailable() await checker.CheckAsync(); - Assert.Contains(logger.Messages, m => m.Contains("v0.40.2-alpha") && m.Contains("brew update && brew upgrade dotnet-6502-terminal")); + Assert.Contains(logger.Messages, m => m.Contains("v0.40.2-alpha") && m.Contains("brew update && brew upgrade --no-ask --formula dotnet-6502-terminal")); } [Fact] @@ -132,7 +132,7 @@ public async Task UpdateAvailable_BuildsCommandAndReleaseUrl() Assert.Equal(UpdateCheckStatus.UpdateAvailable, result.Status); Assert.True(result.IsUpdateAvailable); Assert.Equal("0.40.2-alpha", result.LatestVersion!.ToString()); - Assert.Equal("brew update && brew upgrade dotnet-6502-terminal", result.SuggestedCommand); + Assert.Equal("brew update && brew upgrade --no-ask --formula dotnet-6502-terminal", result.SuggestedCommand); Assert.Equal("https://example/releases/v0.40.2-alpha", result.ReleaseNotesUrl); } @@ -184,7 +184,7 @@ public async Task CadenceWindow_ReusesCache_NoSecondNetworkCall() // Second check within the 24h window reuses the cache written by the first. var second = await MakeChecker(source, detector, "0.40.1-alpha").CheckAsync(); Assert.Equal(UpdateCheckStatus.UpdateAvailable, second.Status); - Assert.Equal("brew update && brew upgrade dotnet-6502-terminal", second.SuggestedCommand); + Assert.Equal("brew update && brew upgrade --no-ask --formula dotnet-6502-terminal", second.SuggestedCommand); Assert.Equal(1, source.CallCount); // no new network call }