Skip to content

Commit 29020d7

Browse files
committed
Huge refactoring to change the design to the clean architecture
#89
1 parent 89606c1 commit 29020d7

104 files changed

Lines changed: 1680 additions & 1286 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FlowCtl.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlowCtl", "src\FlowCtl\Flow
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4DAB0B5E-75FA-4AF9-89D0-96017DF8200A}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowCtl.Core", "src\FlowCtl.Core\FlowCtl.Core.csproj", "{E2259DA4-A2A2-4205-92D5-C860390E3B93}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowCtl.Infrastructure", "src\FlowCtl.Infrastructure\FlowCtl.Infrastructure.csproj", "{6304C327-4A5F-4959-B623-0D2D2FC1778D}"
13+
EndProject
1014
Global
1115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1216
Debug|Any CPU = Debug|Any CPU
@@ -17,12 +21,22 @@ Global
1721
{3C2DE8AB-DE5E-4C9B-884C-5857B30F5A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
1822
{3C2DE8AB-DE5E-4C9B-884C-5857B30F5A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
1923
{3C2DE8AB-DE5E-4C9B-884C-5857B30F5A5A}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{E2259DA4-A2A2-4205-92D5-C860390E3B93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{E2259DA4-A2A2-4205-92D5-C860390E3B93}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{E2259DA4-A2A2-4205-92D5-C860390E3B93}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{E2259DA4-A2A2-4205-92D5-C860390E3B93}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{6304C327-4A5F-4959-B623-0D2D2FC1778D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{6304C327-4A5F-4959-B623-0D2D2FC1778D}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{6304C327-4A5F-4959-B623-0D2D2FC1778D}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{6304C327-4A5F-4959-B623-0D2D2FC1778D}.Release|Any CPU.Build.0 = Release|Any CPU
2032
EndGlobalSection
2133
GlobalSection(SolutionProperties) = preSolution
2234
HideSolutionNode = FALSE
2335
EndGlobalSection
2436
GlobalSection(NestedProjects) = preSolution
2537
{3C2DE8AB-DE5E-4C9B-884C-5857B30F5A5A} = {4DAB0B5E-75FA-4AF9-89D0-96017DF8200A}
38+
{E2259DA4-A2A2-4205-92D5-C860390E3B93} = {4DAB0B5E-75FA-4AF9-89D0-96017DF8200A}
39+
{6304C327-4A5F-4959-B623-0D2D2FC1778D} = {4DAB0B5E-75FA-4AF9-89D0-96017DF8200A}
2640
EndGlobalSection
2741
GlobalSection(ExtensibilityGlobals) = postSolution
2842
SolutionGuid = {907D7732-BC4A-4634-A23C-C90A3981F438}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace FlowCtl.Core.Authentication;
2+
3+
public class AuthenticationData
4+
{
5+
public AuthenticationType Type { get; set; }
6+
public string? Username { get; set; }
7+
public string? Password { get; set; }
8+
public string? AccessToken { get; set; }
9+
public DateTime? Expiry { get; set; }
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace FlowCtl.Core.Authentication;
2+
3+
public enum AuthenticationType
4+
{
5+
Basic,
6+
Bearer
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace FlowCtl.Core.Authentication;
2+
3+
public interface IAuthenticationManager
4+
{
5+
bool IsLoggedIn { get; }
6+
AuthenticationData LoginBasic(string username, string password);
7+
AuthenticationData LoginBearer(string token);
8+
void Logout();
9+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace FlowCtl.Core.Exceptions;
2+
3+
public enum ErrorCode
4+
{
5+
None = 0,
6+
7+
#region Application error codes
8+
ApplicationStartArgumentIsRequired = 1001,
9+
#endregion
10+
11+
#region Serialization error codes
12+
Serialization = 1101,
13+
#endregion
14+
15+
#region Unknown error codes
16+
UnknownError = 9999
17+
#endregion
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace FlowCtl.Core.Exceptions;
2+
3+
public class ErrorMessage
4+
{
5+
private const string PrefixErrorMessage = "FCL"; // Abbreviation for FlowCtl
6+
7+
public int Code { get; }
8+
public string Message { get; }
9+
10+
public ErrorMessage(int code, string message)
11+
{
12+
Code = code;
13+
Message = message;
14+
}
15+
16+
public override string ToString() => $"[{PrefixErrorMessage}{Code}] {Message}";
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace FlowCtl.Core.Exceptions;
2+
3+
public class FlowCtlException : Exception
4+
{
5+
public int ErrorCode { get; }
6+
public string ErrorMessage { get; }
7+
8+
public FlowCtlException(ErrorMessage errorMessage) : this(errorMessage.Code, errorMessage.Message)
9+
{
10+
11+
}
12+
13+
public FlowCtlException(int errorCode, string errorMessage) : base(errorMessage)
14+
{
15+
ErrorCode = errorCode;
16+
ErrorMessage = errorMessage;
17+
}
18+
19+
public FlowCtlException(int errorCode, string errorMessage, Exception innerException) : base(errorMessage, innerException)
20+
{
21+
ErrorCode = errorCode;
22+
ErrorMessage = errorMessage;
23+
}
24+
25+
public override string ToString() => new ErrorMessage(ErrorCode, ErrorMessage).ToString();
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
</Project>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
namespace FlowCtl.Core.Github;
2+
3+
using System;
4+
using System.Runtime.InteropServices;
5+
6+
public static class GitHubSettings
7+
{
8+
// Organization and Repository Names
9+
public const string Organization = "flowsynx";
10+
public const string FlowSynxRepository = "flowsynx";
11+
public const string FlowCtlRepository = "flowctl";
12+
13+
// Archive and Hash File Extensions
14+
private static readonly string HashFileExtension = "sha256";
15+
private static readonly string CompressionFileExtension = GetCompressionExtension();
16+
17+
// OS & Architecture Info
18+
private static readonly string OSType = GetOperatingSystemType();
19+
private static readonly string Architecture = RuntimeInformation.ProcessArchitecture.ToString();
20+
21+
// Archive Names
22+
private static readonly string ArchiveName = $"{OSType}-{Architecture}.{CompressionFileExtension}";
23+
private static string ArchiveTemporaryName => $"{Guid.NewGuid()}.{CompressionFileExtension}";
24+
private static string ArchiveTemporaryHashName => $"{Guid.NewGuid()}.{CompressionFileExtension}";
25+
26+
// FlowSynx Filenames
27+
public static string FlowSynxArchiveFileName => $"{FlowSynxRepository}-{ArchiveName.ToLower()}";
28+
public static string FlowSynxArchiveTemporaryFileName => $"{FlowSynxRepository}-{ArchiveTemporaryName.ToLower()}";
29+
public static string FlowSynxArchiveHashFileName => $"{FlowSynxRepository}-{ArchiveName.ToLower()}.{HashFileExtension}";
30+
public static string FlowSynxArchiveTemporaryHashFileName => $"{FlowSynxRepository}-{ArchiveTemporaryHashName.ToLower()}.{HashFileExtension}";
31+
32+
// FlowCtl Filenames
33+
public static string FlowCtlArchiveFileName => $"{FlowCtlRepository}-{ArchiveName.ToLower()}";
34+
public static string FlowCtlArchiveHashFileName => $"{FlowCtlRepository}-{ArchiveName.ToLower()}.{HashFileExtension}";
35+
36+
// Determine OS platform
37+
private static string GetOperatingSystemType()
38+
{
39+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
40+
return "Linux";
41+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
42+
return "OSX";
43+
return "Windows";
44+
}
45+
46+
// Determine compression extension based on OS
47+
private static string GetCompressionExtension()
48+
{
49+
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "zip" : "tar.gz";
50+
}
51+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace FlowCtl.Core.Github;
2+
3+
public interface IGitHubReleaseManager
4+
{
5+
Task<string> GetLatestVersion(string owner, string repository);
6+
Task<string> DownloadAsset(string owner, string repository, string assetName, string downloadPath, string? versionTag = null);
7+
Task<string> DownloadHashAsset(string owner, string repository, string hashAssetName, string downloadPath, string? versionTag = null);
8+
string GetAssetHashCode(string filePath);
9+
bool ValidateDownloadedAsset(string downloadedFilePath, string hashFilePath);
10+
}

0 commit comments

Comments
 (0)