Skip to content

Commit dc23824

Browse files
committed
releases provider refactoring
1 parent fdf8432 commit dc23824

20 files changed

Lines changed: 485 additions & 751 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Core.All.Enums;
2+
3+
/// <summary>
4+
/// Identifies the application entity for self-update release queries.
5+
/// </summary>
6+
public enum AppReleaseEnum
7+
{
8+
/// <summary>
9+
/// The BuildLauncher application itself.
10+
/// </summary>
11+
MainApp
12+
}

src/Core.All/Helpers/VersionComparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static bool InternalCompare(ReadOnlySpan<char> v1, ReadOnlySpan<char> v2
8080
};
8181
}
8282

83-
private static int CompareVersions(ReadOnlySpan<char> v1, ReadOnlySpan<char> v2)
83+
public static int CompareVersions(ReadOnlySpan<char> v1, ReadOnlySpan<char> v2)
8484
{
8585
var dash1 = v1.IndexOf('-');
8686
var dash2 = v2.IndexOf('-');
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Core.All.Providers;
2+
3+
namespace Core.All.Interfaces;
4+
5+
/// <summary>
6+
/// Maps entity enum values to their repository configuration for fetching releases.
7+
/// </summary>
8+
/// <typeparam name="T">Enum type identifying the entity (port, tool, app).</typeparam>
9+
public interface IRepositoriesProvider<in T> where T : Enum
10+
{
11+
/// <summary>
12+
/// Returns the repository configuration for the specified release enum.
13+
/// </summary>
14+
/// <param name="releaseEnum">Target release enum.</param>
15+
RepositoryEntity GetRepo(T releaseEnum);
16+
}

src/Core.All/Providers/ReleaseProvider.cs

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/Core.All/Providers/RepoAppReleasesProvider.cs

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Core.All.Serializable.Downloadable;
2+
3+
namespace Core.All.Providers;
4+
5+
/// <summary>
6+
/// Describes a source repository: where to fetch releases from and how to match assets per OS.
7+
/// </summary>
8+
public readonly struct RepositoryEntity
9+
{
10+
/// <summary>
11+
/// URL to the releases API (GitHub) or custom source. <c>null</c> means no releases available.
12+
/// </summary>
13+
public required Uri? RepoUrl { get; init; }
14+
15+
/// <summary>
16+
/// Predicate to identify the Windows asset within a release's asset list. <c>null</c> if Windows releases are not supported.
17+
/// </summary>
18+
public required Func<GitHubReleaseAsset, bool>? WindowsReleasePredicate { get; init; }
19+
20+
/// <summary>
21+
/// Predicate to identify the Linux asset within a release's asset list. <c>null</c> if Linux releases are not supported.
22+
/// </summary>
23+
public required Func<GitHubReleaseAsset, bool>? LinuxReleasePredicate { get; init; }
24+
25+
/// <summary>
26+
/// Custom parser for non-GitHub sources. Takes the response stream and returns a release model, or <c>null</c>.
27+
/// </summary>
28+
public Func<Stream, GeneralReleaseJsonModel?>? CustomReleaseParser { get; init; }
29+
30+
/// <summary>
31+
/// Custom function to extract the version string from a release and its matched asset. Falls back to <c>release.TagName</c> when <c>null</c>.
32+
/// </summary>
33+
public Func<GitHubReleaseJsonModel, GitHubReleaseAsset, string>? VersionSelector { get; init; }
34+
35+
/// <summary>
36+
/// Shared cache key for repos used by multiple entities (e.g., NBlood/PCExhumed/RedNukem sharing the same GitHub repo).
37+
/// When set, releases are fetched once and reused across all entities with the same key.
38+
/// </summary>
39+
public string? SharedCacheKey { get; init; }
40+
}

src/Core.All/RepositoryEntity.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)