mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 17:43:04 -06:00
Address review feedback on Publish-MacOSBundle.csx
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/e7db4f40-4bab-4c83-bdba-0d77beeece0e
This commit is contained in:
parent
bb87d5cb36
commit
726ac6b74b
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
<Target Name="PublishMacOSBundle" AfterTargets="Publish" Condition="$(PublishMacOSBundle)">
|
<Target Name="PublishMacOSBundle" AfterTargets="Publish" Condition="$(PublishMacOSBundle)">
|
||||||
<Exec
|
<Exec
|
||||||
Command="dotnet run $(ProjectDir)/Publish-MacOSBundle.csx -- $(PublishDir) $(ProjectDir)/../favicon.icns $(Version) $(AssemblyVersion)"
|
Command="dotnet run $(ProjectDir)/Publish-MacOSBundle.csx -- --publish-dir $(PublishDir) --icons-file $(ProjectDir)/../favicon.icns --full-version $(Version) --short-version $(AssemblyVersion)"
|
||||||
LogStandardErrorAsError="true"
|
LogStandardErrorAsError="true"
|
||||||
/>
|
/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#:package CliFx@2.3.6
|
#!/usr/bin/env -S dotnet run
|
||||||
|
#:package CliFx
|
||||||
|
|
||||||
using CliFx;
|
using CliFx;
|
||||||
using CliFx.Attributes;
|
using CliFx.Attributes;
|
||||||
|
|
@ -12,21 +13,21 @@ 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
|
||||||
{
|
{
|
||||||
[CommandParameter(0, Name = "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; }
|
||||||
|
|
||||||
[CommandParameter(1, Name = "icons-file", Description = "Path to the .icns icons file.")]
|
[CommandOption("icons-file", Description = "Path to the .icns icons file.")]
|
||||||
public required string IconsFilePath { get; init; }
|
public required string IconsFilePath { get; init; }
|
||||||
|
|
||||||
[CommandParameter(2, Name = "full-version", Description = "Full version string (e.g. '1.2.3.4').")]
|
[CommandOption("full-version", Description = "Full version string (e.g. '1.2.3.4').")]
|
||||||
public required string FullVersion { get; init; }
|
public required string FullVersion { get; init; }
|
||||||
|
|
||||||
[CommandParameter(3, Name = "short-version", Description = "Short version string (e.g. '1.2.3').")]
|
[CommandOption("short-version", Description = "Short version string (e.g. '1.2.3').")]
|
||||||
public required string ShortVersion { get; init; }
|
public required string ShortVersion { get; init; }
|
||||||
|
|
||||||
public ValueTask ExecuteAsync(IConsole console)
|
public ValueTask ExecuteAsync(IConsole console)
|
||||||
{
|
{
|
||||||
// Setup paths
|
// Set up paths
|
||||||
var publishDirPath = Path.GetFullPath(PublishDirPath);
|
var publishDirPath = Path.GetFullPath(PublishDirPath);
|
||||||
var tempDirPath = Path.GetFullPath(
|
var tempDirPath = Path.GetFullPath(
|
||||||
Path.Combine(publishDirPath, "../publish-macos-app-temp")
|
Path.Combine(publishDirPath, "../publish-macos-app-temp")
|
||||||
|
|
@ -40,8 +41,6 @@ public class PublishMacOSBundleCommand : ICommand
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Initialize the bundle's directory structure
|
// Initialize the bundle's directory structure
|
||||||
Directory.CreateDirectory(bundleDirPath);
|
|
||||||
Directory.CreateDirectory(contentsDirPath);
|
|
||||||
Directory.CreateDirectory(macosDirPath);
|
Directory.CreateDirectory(macosDirPath);
|
||||||
Directory.CreateDirectory(resourcesDirPath);
|
Directory.CreateDirectory(resourcesDirPath);
|
||||||
|
|
||||||
|
|
@ -49,10 +48,11 @@ public class PublishMacOSBundleCommand : ICommand
|
||||||
File.Copy(
|
File.Copy(
|
||||||
IconsFilePath,
|
IconsFilePath,
|
||||||
Path.Combine(resourcesDirPath, "AppIcon.icns"),
|
Path.Combine(resourcesDirPath, "AppIcon.icns"),
|
||||||
overwrite: true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
// Generate the Info.plist metadata file with the app information
|
// Generate the Info.plist metadata file with the app information
|
||||||
|
// lang=xml
|
||||||
var plistContent = $"""
|
var plistContent = $"""
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
|
@ -91,7 +91,7 @@ public class PublishMacOSBundleCommand : ICommand
|
||||||
// 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, recursive: 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
|
||||||
foreach (var entry in Directory.GetFileSystemEntries(publishDirPath))
|
foreach (var entry in Directory.GetFileSystemEntries(publishDirPath))
|
||||||
|
|
@ -110,7 +110,7 @@ public class PublishMacOSBundleCommand : ICommand
|
||||||
{
|
{
|
||||||
// Clean up the temporary directory
|
// Clean up the temporary directory
|
||||||
if (Directory.Exists(tempDirPath))
|
if (Directory.Exists(tempDirPath))
|
||||||
Directory.Delete(tempDirPath, recursive: true);
|
Directory.Delete(tempDirPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return default;
|
return default;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue