Skip to content

Commit 4d4f3cd

Browse files
authored
refactor: migrate marketplace client (#76)
1 parent 82af0b4 commit 4d4f3cd

File tree

12 files changed

+165
-48
lines changed

12 files changed

+165
-48
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<PackageVersion Include="AspNetCore.HealthChecks.MongoDb" Version="9.0.0"/>
77
<PackageVersion Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0"/>
88
<PackageVersion Include="Docker.DotNet" Version="3.125.15"/>
9+
<PackageVersion Include="DxWorks.Hub.Sdk" Version="1.0.3"/>
910
<PackageVersion Include="FluentValidation" Version="11.11.0"/>
1011
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0"/>
1112
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.1"/>

ScriptBee.Marketplace.Client/Data/PluginVersion.cs

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

ScriptBee.Marketplace.Client/ScriptBee.Marketplace.Client.csproj

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

ScriptBee.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service.Plugin.Tests", "tes
7171
EndProject
7272
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service.Plugin", "src\Application\Domain\Service.Plugin\Service.Plugin.csproj", "{23230FA8-50CC-4883-ABC3-8BA66BC92023}"
7373
EndProject
74+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marketplace.Client", "src\Adapters\Driven\Marketplace.Client\Marketplace.Client.csproj", "{D8626754-E493-456D-A809-9AA76677E8F8}"
75+
EndProject
76+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marketplace.Client.Tests", "test\Adapters\Driven\Marketplace.Client.Tests\Marketplace.Client.Tests.csproj", "{6B16EF85-94DA-427B-ADAA-55565AC89287}"
77+
EndProject
7478
Global
7579
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7680
Debug|Any CPU = Debug|Any CPU
@@ -217,5 +221,13 @@ Global
217221
{23230FA8-50CC-4883-ABC3-8BA66BC92023}.Debug|Any CPU.Build.0 = Debug|Any CPU
218222
{23230FA8-50CC-4883-ABC3-8BA66BC92023}.Release|Any CPU.ActiveCfg = Release|Any CPU
219223
{23230FA8-50CC-4883-ABC3-8BA66BC92023}.Release|Any CPU.Build.0 = Release|Any CPU
224+
{D8626754-E493-456D-A809-9AA76677E8F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
225+
{D8626754-E493-456D-A809-9AA76677E8F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
226+
{D8626754-E493-456D-A809-9AA76677E8F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
227+
{D8626754-E493-456D-A809-9AA76677E8F8}.Release|Any CPU.Build.0 = Release|Any CPU
228+
{6B16EF85-94DA-427B-ADAA-55565AC89287}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
229+
{6B16EF85-94DA-427B-ADAA-55565AC89287}.Debug|Any CPU.Build.0 = Debug|Any CPU
230+
{6B16EF85-94DA-427B-ADAA-55565AC89287}.Release|Any CPU.ActiveCfg = Release|Any CPU
231+
{6B16EF85-94DA-427B-ADAA-55565AC89287}.Release|Any CPU.Build.0 = Release|Any CPU
220232
EndGlobalSection
221233
EndGlobal

ScriptBee.Marketplace.Client/Data/MarketPlaceProject.cs renamed to src/Adapters/Driven/Marketplace.Client/Data/MarketPlaceProject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public enum MarketPlaceProjectType
44
{
55
Plugin,
6-
Bundle
6+
Bundle,
77
}
88

99
public record MarketPlaceProject(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace ScriptBee.Marketplace.Client.Data;
2+
3+
public record PluginVersion(string Url, Version Version, string ManifestUrl);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<RootNamespace>ScriptBee.Marketplace.Client</RootNamespace>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="DxWorks.Hub.Sdk" />
9+
<PackageReference Include="Microsoft.Extensions.DependencyInjection"/>
10+
<PackageReference Include="Microsoft.Extensions.Http"/>
11+
</ItemGroup>
12+
</Project>

ScriptBee.Marketplace.Client/ScriptBeeMarketplaceClientExtensions.cs renamed to src/Adapters/Driven/Marketplace.Client/ScriptBeeMarketplaceClientExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ namespace ScriptBee.Marketplace.Client;
66

77
public static class ScriptBeeMarketplaceClientExtensions
88
{
9-
public static IServiceCollection AddScriptBeeMarketplaceClient(this IServiceCollection services,
10-
Action<DxWorksHubSdkOptions>? configureOptionsAction = null)
9+
public static IServiceCollection AddScriptBeeMarketplaceClient(
10+
this IServiceCollection services,
11+
Action<DxWorksHubSdkOptions>? configureOptionsAction = null
12+
)
1113
{
1214
services.AddDxWorksHubSdk(configureOptionsAction);
1315
services.AddSingleton<IMarketPluginFetcher, MarketPluginFetcher>();

ScriptBee.Marketplace.Client/Services/IMarketPluginFetcher.cs renamed to src/Adapters/Driven/Marketplace.Client/Services/IMarketPluginFetcher.cs

File renamed without changes.

ScriptBee.Marketplace.Client/Services/MarketPluginFetcher.cs renamed to src/Adapters/Driven/Marketplace.Client/Services/MarketPluginFetcher.cs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,26 @@
44

55
namespace ScriptBee.Marketplace.Client.Services;
66

7-
public sealed class MarketPluginFetcher : IMarketPluginFetcher
7+
public sealed class MarketPluginFetcher(IScriptBeeClient hubClient) : IMarketPluginFetcher
88
{
9-
private readonly IScriptBeeClient _hubClient;
10-
11-
12-
public MarketPluginFetcher(IScriptBeeClient hubClient)
13-
{
14-
_hubClient = hubClient;
15-
}
16-
179
public async Task UpdateRepositoryAsync(CancellationToken cancellationToken = default)
1810
{
19-
await _hubClient.UpdateRepositoryAsync(cancellationToken);
11+
await hubClient.UpdateRepositoryAsync(cancellationToken);
2012
}
2113

2214
public IEnumerable<MarketPlaceProject> GetProjectsAsync()
2315
{
24-
return _hubClient.GetScriptBeeProjects()
25-
.Select(ConvertToPlugin);
16+
return hubClient.GetScriptBeeProjects().Select(ConvertToPlugin);
2617
}
2718

2819
private static MarketPlaceProject ConvertToPlugin(ScriptBeeProject project)
2920
{
30-
var projectType = project.Type == ScriptBeeProjectTypes.Bundle
31-
? MarketPlaceProjectType.Bundle
32-
: MarketPlaceProjectType.Plugin;
21+
var projectType =
22+
project.Type == ScriptBeeProjectTypes.Bundle
23+
? MarketPlaceProjectType.Bundle
24+
: MarketPlaceProjectType.Plugin;
3325

34-
return new MarketPlaceProject
35-
(
26+
return new MarketPlaceProject(
3627
project.Id,
3728
project.Name,
3829
projectType,
@@ -44,11 +35,6 @@ private static MarketPlaceProject ConvertToPlugin(ScriptBeeProject project)
4435

4536
private static PluginVersion ConvertToPluginVersion(ScriptBeeProjectVersion version)
4637
{
47-
return new PluginVersion
48-
(
49-
version.DownloadUrl,
50-
version.Version,
51-
version.Manifest
52-
);
38+
return new PluginVersion(version.DownloadUrl, version.Version, version.Manifest);
5339
}
5440
}

0 commit comments

Comments
 (0)