-
Notifications
You must be signed in to change notification settings - Fork 29
Add ProcessUtils helper and output models for Apple CLI APIs #155
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3dbd570
Add ProcessUtils helper and output models for Apple CLI APIs
rmarinho ed57130
Auto-format source code
3bd4f95
Refactor XcodeLocator to use ProcessUtils.Exec
rmarinho b427040
Fix ProcessUtils tests to work cross-platform (Windows + Unix)
rmarinho 2a38996
Rename UnitTests to tests
rmarinho 63ec3b0
Address Copilot review feedback on ProcessUtils
rmarinho e7b7c4c
Fix NRE in StartProcess and harden process termination
rmarinho de14fa7
Address rolfbjarne review feedback
rmarinho 8a45e3b
Fix Windows echo test quoting issue
rmarinho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Xamarin.MacDev.Models { | ||
|
|
||
| /// <summary> | ||
| /// Information about Xcode Command Line Tools installation. | ||
| /// </summary> | ||
| public class CommandLineToolsInfo { | ||
| /// <summary>Whether the Command Line Tools are installed.</summary> | ||
| public bool IsInstalled { get; set; } | ||
|
|
||
| /// <summary>The CLT version string (e.g. "16.2.0.0.1.1733547573"), or null if not installed.</summary> | ||
| public string? Version { get; set; } | ||
|
|
||
| /// <summary>The CLT install path (e.g. "/Library/Developer/CommandLineTools"), or null if not installed.</summary> | ||
| public string? Path { get; set; } | ||
|
|
||
| public override string ToString () => IsInstalled ? $"CLT {Version} at {Path}" : "CLT not installed"; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Xamarin.MacDev.Models { | ||
|
|
||
| /// <summary> | ||
| /// Overall status of the Apple development environment. | ||
| /// </summary> | ||
| public enum EnvironmentStatus { | ||
| /// <summary>All required components are present.</summary> | ||
| Ok, | ||
| /// <summary>Some optional components are missing.</summary> | ||
| Partial, | ||
| /// <summary>Required components are missing.</summary> | ||
| Missing, | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Result of a comprehensive Apple environment check. | ||
| /// </summary> | ||
| public class EnvironmentCheckResult { | ||
| /// <summary>Information about the active Xcode installation, or null if none found.</summary> | ||
| public XcodeInfo? Xcode { get; set; } | ||
|
|
||
| /// <summary>Information about the Command Line Tools.</summary> | ||
| public CommandLineToolsInfo CommandLineTools { get; set; } = new CommandLineToolsInfo (); | ||
|
|
||
| /// <summary>Installed simulator runtimes.</summary> | ||
| public List<SimulatorRuntimeInfo> Runtimes { get; set; } = new List<SimulatorRuntimeInfo> (); | ||
|
|
||
| /// <summary>Enabled development platforms (e.g. "iOS", "macOS").</summary> | ||
| public List<string> Platforms { get; set; } = new List<string> (); | ||
|
|
||
| /// <summary>Overall environment status.</summary> | ||
| public EnvironmentStatus Status { get; set; } = EnvironmentStatus.Missing; | ||
|
|
||
| /// <summary> | ||
| /// Derives the <see cref="Status"/> from the current state of the environment. | ||
| /// </summary> | ||
| public void DeriveStatus () | ||
| { | ||
| if (Xcode is null || !CommandLineTools.IsInstalled) { | ||
| Status = EnvironmentStatus.Missing; | ||
| return; | ||
| } | ||
|
|
||
| if (Runtimes.Count == 0) { | ||
| Status = EnvironmentStatus.Partial; | ||
| return; | ||
| } | ||
|
|
||
| Status = EnvironmentStatus.Ok; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Xamarin.MacDev.Models { | ||
|
|
||
| /// <summary> | ||
| /// Information about a simulator device from xcrun simctl. | ||
| /// </summary> | ||
| public class SimulatorDeviceInfo { | ||
| /// <summary>The simulator display name (e.g. "iPhone 16 Pro").</summary> | ||
| public string Name { get; set; } = ""; | ||
|
|
||
| /// <summary>The simulator UDID.</summary> | ||
| public string Udid { get; set; } = ""; | ||
|
|
||
| /// <summary>The device state (e.g. "Shutdown", "Booted").</summary> | ||
| public string State { get; set; } = ""; | ||
|
|
||
| /// <summary>The runtime identifier (e.g. "com.apple.CoreSimulator.SimRuntime.iOS-18-2").</summary> | ||
| public string RuntimeIdentifier { get; set; } = ""; | ||
|
|
||
| /// <summary>The device type identifier (e.g. "com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro").</summary> | ||
| public string DeviceTypeIdentifier { get; set; } = ""; | ||
|
|
||
| /// <summary>Whether this simulator is available.</summary> | ||
| public bool IsAvailable { get; set; } | ||
|
|
||
| public bool IsBooted => State == "Booted"; | ||
|
|
||
| public override string ToString () => $"{Name} ({Udid}) [{State}]"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Xamarin.MacDev.Models { | ||
|
|
||
| /// <summary> | ||
| /// Information about a simulator runtime from xcrun simctl. | ||
| /// </summary> | ||
| public class SimulatorRuntimeInfo { | ||
| /// <summary>The platform name (e.g. "iOS", "tvOS", "watchOS", "visionOS").</summary> | ||
| public string Platform { get; set; } = ""; | ||
|
|
||
| /// <summary>The runtime version (e.g. "18.2").</summary> | ||
| public string Version { get; set; } = ""; | ||
|
|
||
| /// <summary>The build version (e.g. "22C150").</summary> | ||
| public string BuildVersion { get; set; } = ""; | ||
|
|
||
| /// <summary>The runtime identifier (e.g. "com.apple.CoreSimulator.SimRuntime.iOS-18-2").</summary> | ||
| public string Identifier { get; set; } = ""; | ||
|
|
||
| /// <summary>The display name (e.g. "iOS 18.2").</summary> | ||
| public string Name { get; set; } = ""; | ||
|
|
||
| /// <summary>Whether this runtime is available for use.</summary> | ||
| public bool IsAvailable { get; set; } | ||
|
|
||
| /// <summary>Whether this runtime is bundled with Xcode (vs downloaded separately).</summary> | ||
| public bool IsBundled { get; set; } | ||
|
|
||
| public override string ToString () => $"{Name} ({Identifier})"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
|
|
||
| #nullable enable | ||
|
|
||
| namespace Xamarin.MacDev.Models { | ||
|
|
||
| /// <summary> | ||
| /// Information about an Xcode installation. | ||
| /// </summary> | ||
| public class XcodeInfo { | ||
| /// <summary>The path to the Xcode.app bundle (e.g. /Applications/Xcode.app).</summary> | ||
| public string Path { get; set; } = ""; | ||
|
|
||
| /// <summary>The Xcode version (e.g. 16.2).</summary> | ||
| public Version Version { get; set; } = new Version (0, 0); | ||
|
|
||
| /// <summary>The Xcode build number (e.g. 16C5032a).</summary> | ||
| public string Build { get; set; } = ""; | ||
|
|
||
| /// <summary>The DTXcode value from the version plist.</summary> | ||
| public string DTXcode { get; set; } = ""; | ||
|
|
||
| /// <summary>Whether this is the currently selected Xcode (via xcode-select).</summary> | ||
| public bool IsSelected { get; set; } | ||
|
|
||
| /// <summary>Whether the Xcode path is or contains a symlink.</summary> | ||
| public bool IsSymlink { get; set; } | ||
|
|
||
| public override string ToString () => $"{Path} ({Version}, {Build})"; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.