Remove CliFx dependency from script to fix macOS CI timeout

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/55dce499-3afd-4c84-a913-19f7412efe1b
This commit is contained in:
copilot-swe-agent[bot] 2026-03-23 19:14:51 +00:00
parent 8d03008e2e
commit d8b46b5610

View file

@ -1,44 +1,29 @@
#!/usr/bin/env -S dotnet run --
#:package CliFx
using CliFx;
using CliFx.Attributes;
using CliFx.Infrastructure;
return await new CliApplicationBuilder()
.AddCommand<PublishMacOSBundleCommand>()
.Build()
.RunAsync(args);
[Command(Description = "Publishes the GUI app as a macOS .app bundle.")]
public class PublishMacOSBundleCommand : ICommand
// Set up arguments
string GetArg(string name)
{
private const string BundleName = "DiscordChatExporter.app";
private const string AppName = "DiscordChatExporter";
private const string AppCopyright = "© Oleksii Holub";
private const string AppIdentifier = "me.Tyrrrz.DiscordChatExporter";
private const string AppSpokenName = "Discord Chat Exporter";
private const string AppIconName = "AppIcon";
var idx = Array.IndexOf(args, name);
if (idx < 0 || idx + 1 >= args.Length)
throw new InvalidOperationException($"Missing required option: {name}");
return args[idx + 1];
}
[CommandOption("publish-dir", Description = "Path to the publish output directory.")]
public required string PublishDirPath { get; init; }
var publishDirPathArg = GetArg("--publish-dir");
var iconsFilePathArg = GetArg("--icons-file");
var fullVersionArg = GetArg("--full-version");
var shortVersionArg = GetArg("--short-version");
[CommandOption("icons-file", Description = "Path to the .icns icons file.")]
public required string IconsFilePath { get; init; }
const string BundleName = "DiscordChatExporter.app";
const string AppName = "DiscordChatExporter";
const string AppCopyright = "© Oleksii Holub";
const string AppIdentifier = "me.Tyrrrz.DiscordChatExporter";
const string AppSpokenName = "Discord Chat Exporter";
const string AppIconName = "AppIcon";
[CommandOption("full-version", Description = "Full version string (e.g. '1.2.3.4').")]
public required string FullVersion { get; init; }
[CommandOption("short-version", Description = "Short version string (e.g. '1.2.3').")]
public required string ShortVersion { get; init; }
public async ValueTask ExecuteAsync(IConsole console)
{
// Set up paths
var publishDirPath = Path.GetFullPath(PublishDirPath);
var tempDirPath = Path.GetFullPath(
Path.Combine(publishDirPath, "../publish-macos-app-temp")
);
var publishDirPath = Path.GetFullPath(publishDirPathArg);
var tempDirPath = Path.GetFullPath(Path.Combine(publishDirPath, "../publish-macos-app-temp"));
// Ensure the temporary directory is clean before use in case a previous run crashed
if (Directory.Exists(tempDirPath))
@ -51,11 +36,7 @@ public class PublishMacOSBundleCommand : ICommand
{
// Copy icons into the .app's Resources folder
Directory.CreateDirectory(Path.Combine(contentsDirPath, "Resources"));
File.Copy(
IconsFilePath,
Path.Combine(contentsDirPath, "Resources", "AppIcon.icns"),
true
);
File.Copy(iconsFilePathArg, Path.Combine(contentsDirPath, "Resources", "AppIcon.icns"), true);
// Generate the Info.plist metadata file with the app information
// lang=xml
@ -81,9 +62,9 @@ public class PublishMacOSBundleCommand : ICommand
<key>CFBundleIconName</key>
<string>{AppIconName}</string>
<key>CFBundleVersion</key>
<string>{FullVersion}</string>
<string>{fullVersionArg}</string>
<key>CFBundleShortVersionString</key>
<string>{ShortVersion}</string>
<string>{shortVersionArg}</string>
<key>NSHighResolutionCapable</key>
<true />
<key>CFBundlePackageType</key>
@ -103,11 +84,7 @@ public class PublishMacOSBundleCommand : ICommand
Directory.CreateDirectory(Path.Combine(contentsDirPath, "MacOS"));
foreach (var entryPath in Directory.GetFileSystemEntries(publishDirPath))
{
var destinationPath = Path.Combine(
contentsDirPath,
"MacOS",
Path.GetFileName(entryPath)
);
var destinationPath = Path.Combine(contentsDirPath, "MacOS", Path.GetFileName(entryPath));
if (Directory.Exists(entryPath))
Directory.Move(entryPath, destinationPath);
@ -124,5 +101,3 @@ public class PublishMacOSBundleCommand : ICommand
if (Directory.Exists(tempDirPath))
Directory.Delete(tempDirPath, true);
}
}
}