Convert bundleName to a const; rename entry/destination to entryPath/destinationPath

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/313fa6a5-01c1-4e7b-93cd-1fcc2c4a7a95
This commit is contained in:
copilot-swe-agent[bot] 2026-03-23 18:36:00 +00:00
parent 8a4cb05d02
commit 6c3c937e0e

View file

@ -13,6 +13,8 @@ return await new CliApplicationBuilder()
[Command(Description = "Publishes the GUI app as a macOS .app bundle.")] [Command(Description = "Publishes the GUI app as a macOS .app bundle.")]
public class PublishMacOSBundleCommand : ICommand public class PublishMacOSBundleCommand : ICommand
{ {
private const string BundleName = "DiscordChatExporter.app";
[CommandOption("publish-dir", Description = "Path to the publish output directory.")] [CommandOption("publish-dir", Description = "Path to the publish output directory.")]
public required string PublishDirPath { get; init; } public required string PublishDirPath { get; init; }
@ -32,8 +34,7 @@ public class PublishMacOSBundleCommand : ICommand
var tempDirPath = Path.GetFullPath( var tempDirPath = Path.GetFullPath(
Path.Combine(publishDirPath, "../publish-macos-app-temp") Path.Combine(publishDirPath, "../publish-macos-app-temp")
); );
var bundleName = "DiscordChatExporter.app"; var bundleDirPath = Path.Combine(tempDirPath, BundleName);
var bundleDirPath = Path.Combine(tempDirPath, bundleName);
var contentsDirPath = Path.Combine(bundleDirPath, "Contents"); var contentsDirPath = Path.Combine(bundleDirPath, "Contents");
try try
@ -84,23 +85,27 @@ public class PublishMacOSBundleCommand : ICommand
await File.WriteAllTextAsync(Path.Combine(contentsDirPath, "Info.plist"), plistContent); await File.WriteAllTextAsync(Path.Combine(contentsDirPath, "Info.plist"), plistContent);
// Delete the previous bundle if it exists // Delete the previous bundle if it exists
var existingBundlePath = Path.Combine(publishDirPath, bundleName); var existingBundlePath = Path.Combine(publishDirPath, BundleName);
if (Directory.Exists(existingBundlePath)) if (Directory.Exists(existingBundlePath))
Directory.Delete(existingBundlePath, true); Directory.Delete(existingBundlePath, true);
// Move all files from the publish directory into the MacOS directory // Move all files from the publish directory into the MacOS directory
Directory.CreateDirectory(Path.Combine(contentsDirPath, "MacOS")); Directory.CreateDirectory(Path.Combine(contentsDirPath, "MacOS"));
foreach (var entry in Directory.GetFileSystemEntries(publishDirPath)) foreach (var entryPath in Directory.GetFileSystemEntries(publishDirPath))
{ {
var destination = Path.Combine(contentsDirPath, "MacOS", Path.GetFileName(entry)); var destinationPath = Path.Combine(
if (Directory.Exists(entry)) contentsDirPath,
Directory.Move(entry, destination); "MacOS",
Path.GetFileName(entryPath)
);
if (Directory.Exists(entryPath))
Directory.Move(entryPath, destinationPath);
else else
File.Move(entry, destination); File.Move(entryPath, destinationPath);
} }
// Move the final bundle into the publish directory for upload // Move the final bundle into the publish directory for upload
Directory.Move(bundleDirPath, Path.Combine(publishDirPath, bundleName)); Directory.Move(bundleDirPath, Path.Combine(publishDirPath, BundleName));
} }
finally finally
{ {