Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add check and solution for Xcode EULA #174

Merged
merged 1 commit into from
Oct 3, 2023
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
18 changes: 18 additions & 0 deletions UnoCheck/Checkups/XCodeCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@ public override Task<DiagnosticResult> Examine(SharedState history)

if (selected is not null && selected.Version.IsCompatible(MinimumVersion, ExactVersion))
{
// customize runner options so the license can be displayed
var options = new ShellProcessRunnerOptions("xcodebuild", "")
{
RedirectOutput = Util.CI
};
var runner = new ShellProcessRunner(options);
var result = runner.WaitForExit();
// Check if user requires EULA to be accepted
if (result.ExitCode == 69)
{
Spectre.Console.AnsiConsole.MarkupLine("[bold red]By fixing this you are accepting the license agreement.[/]");
return Task.FromResult(new DiagnosticResult(
Status.Error,
this,
new Suggestion("Run `sudo xcodebuild -license accept`",
new Solutions.XcodeEulaSolution())));
}

// Selected version is good
ReportStatus($"Xcode.app ({VersionName})", Status.Ok);
return Task.FromResult(DiagnosticResult.Ok(this));
Expand Down
17 changes: 17 additions & 0 deletions UnoCheck/Solutions/XcodeEulaSolution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using DotNetCheck.Models;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace DotNetCheck.Solutions
{
internal class XcodeEulaSolution : Solution
{
public override async Task Implement(SharedState sharedState, CancellationToken cancellationToken)
{
await base.Implement(sharedState, cancellationToken);

_ = await Util.WrapShellCommandWithSudo("xcodebuild", new[] { "-license", "accept" });
}
}
}
Loading