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
4 changes: 2 additions & 2 deletions src/libraries/Highbyte.DotNet6502.Updates/InstallChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public sealed record AppUpdateDescriptor
/// <summary>Argv (after the manager executable) that upgrades this app for the given channel.</summary>
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."),
};
Expand Down
1 change: 1 addition & 0 deletions src/libraries/Highbyte.DotNet6502.Updates/ProcessLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions src/libraries/Highbyte.DotNet6502.Updates/UpdateApplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ private static bool TrySpawnDetachedWindows(string manager, IReadOnlyList<IReadO
WorkingDirectory = Path.GetTempPath(),
};
psi.ArgumentList.Add("-NoProfile");
psi.ArgumentList.Add("-NonInteractive");
psi.ArgumentList.Add("-ExecutionPolicy");
psi.ArgumentList.Add("Bypass");
psi.ArgumentList.Add("-WindowStyle");
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Highbyte.DotNet6502.Updates/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ private UpdateCheckResult BuildResult(SemanticVersion current, SemanticVersion l
/// <summary>Builds the exact upgrade command for the detected channel (Phase A: shown/copied, not auto-run).</summary>
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}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 2 additions & 0 deletions tests/Highbyte.DotNet6502.Updates.Tests/ProcessLaunchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Highbyte.DotNet6502.Updates.Tests/UpdateApplierTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task TrySpawnDetachedRelaunch_RunsUpgradeCommands_InOrder()

var spawned = UpdateApplier.TrySpawnDetachedRelaunch(
manager,
new IReadOnlyList<string>[] { new[] { "update" }, new[] { "upgrade", "--cask", "dotnet-6502" } },
new IReadOnlyList<string>[] { new[] { "update" }, new[] { "upgrade", "--no-ask", "--cask", "dotnet-6502" } },
app.Id,
new RelaunchSpec("/bin/bash", new[] { relaunchScript }),
logFilePath: Path.Combine(dir, "update.log"));
Expand All @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Highbyte.DotNet6502.Updates.Tests/UpdateCheckerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
}

Expand Down
Loading