-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve scaffold of report converter app
- Loading branch information
1 parent
1c132e4
commit 5adac79
Showing
13 changed files
with
1,254 additions
and
29 deletions.
There are no files selected for viewing
22 changes: 21 additions & 1 deletion
22
CSF.Screenplay.JsonToHtmlReport/CSF.Screenplay.JsonToHtmlReport.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net2.1;net462;netstandard2.0</TargetFrameworks> | ||
<TargetFrameworks>netcoreapp3.1;net462;netstandard2.0;net6.0;net8.0</TargetFrameworks> | ||
<OutputType Condition="'$(TargetFramework)' != 'netstandard2.0'">Exe</OutputType> | ||
<OutputType Condition="'$(TargetFramework)' == 'netstandard2.0'">Library</OutputType> | ||
<NoWarn>NU1903,NU1902</NoWarn> | ||
<RootNamespace>CSF.Screenplay.JsonToHtmlReport</RootNamespace> | ||
<DocumentationFile>$(MSBuildProjectDirectory)\bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" Condition="'$(TargetFramework)' != 'netstandard2.0'" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" /> | ||
</ItemGroup> | ||
|
||
<Target Name="BuildTemplate" BeforeTargets="DispatchToInnerBuilds"> | ||
<PropertyGroup> | ||
<WebpackTask Condition="'$(Configuration)' == 'Debug'">buildDev</WebpackTask> | ||
<WebpackTask Condition="'$(Configuration)' != 'Debug'">buildProd</WebpackTask> | ||
<NodeCommand>npm</NodeCommand> | ||
</PropertyGroup> | ||
<Exec Command="$(NodeCommand) run $(WebpackTask)" | ||
WorkingDirectory="$(MSBuildProjectDirectory)\templateSrc" /> | ||
<ItemGroup> | ||
<EmbeddedResource Include="$(MSBuildProjectDirectory)\template\template.html" /> | ||
</ItemGroup> | ||
</Target> | ||
</Project> |
17 changes: 17 additions & 0 deletions
17
CSF.Screenplay.JsonToHtmlReport/IConvertsReportJsonToHtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace CSF.Screenplay.JsonToHtmlReport | ||
{ | ||
/// <summary> | ||
/// An object which can convert a JSON Screenplay report to an HTML format. | ||
/// </summary> | ||
public interface IConvertsReportJsonToHtml | ||
{ | ||
/// <summary> | ||
/// Converts the JSON Screenplay report data to HTML asynchronously. | ||
/// </summary> | ||
/// <param name="options">The options for the report conversion.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
Task ConvertAsync(ReportConverterOptions options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#if !NETSTANDARD2_0 | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace CSF.Screenplay.JsonToHtmlReport | ||
{ | ||
/// <summary> | ||
/// The main entry point class for the JSON to HTML report converter application. | ||
/// </summary> | ||
public class Program | ||
{ | ||
/// <summary> | ||
/// The main entry point method for the JSON to HTML report converter application. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// This method scaffolds the application using the Generic Host pattern, then runs that host. | ||
/// This method is available only when the project is built as an executable. It is unavailable for the | ||
/// <c>netstandard2.0</c> target framework. | ||
/// </para> | ||
/// </remarks> | ||
/// <param name="args">The command-line arguments.</param> | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
|
||
static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureServices(RegisterServices) | ||
.ConfigureLogging(logging => | ||
{ | ||
logging.ClearProviders(); | ||
logging.AddConsole(); | ||
}); | ||
|
||
static void RegisterServices(HostBuilderContext hostContext, IServiceCollection services) | ||
=> new ServiceRegistrations().RegisterServices(services); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace CSF.Screenplay.JsonToHtmlReport | ||
{ | ||
/// <summary> | ||
/// Provides functionality to convert JSON reports to HTML format. | ||
/// </summary> | ||
public class ReportConverter : IConvertsReportJsonToHtml | ||
{ | ||
/// <inheritdoc/> | ||
public Task ConvertAsync(ReportConverterOptions options) | ||
{ | ||
// Implementation for converting JSON to HTML report | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
CSF.Screenplay.JsonToHtmlReport/ReportConverterApplication.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#if !NETSTANDARD2_0 | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace CSF.Screenplay.JsonToHtmlReport | ||
{ | ||
/// <summary> | ||
/// An application/background service that begins the JSON to HTML report conversion process. | ||
/// </summary> | ||
public class ReportConverterApplication : BackgroundService | ||
{ | ||
readonly IOptions<ReportConverterOptions> options; | ||
readonly IConvertsReportJsonToHtml reportConverter; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ReportConverterApplication"/> class. | ||
/// </summary> | ||
/// <param name="options">The options for performing the conversion.</param> | ||
/// <param name="reportConverter">The report converter instance to use for conversion.</param> | ||
public ReportConverterApplication(IOptions<ReportConverterOptions> options, | ||
IConvertsReportJsonToHtml reportConverter) | ||
{ | ||
this.options = options ?? throw new System.ArgumentNullException(nameof(options)); | ||
this.reportConverter = reportConverter ?? throw new System.ArgumentNullException(nameof(reportConverter)); | ||
} | ||
|
||
/// <summary> | ||
/// Executes the background service operation. | ||
/// </summary> | ||
/// <param name="stoppingToken">A token that can be used to stop the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation.</returns> | ||
protected override Task ExecuteAsync(CancellationToken stoppingToken) | ||
=> reportConverter.ConvertAsync(options.Value); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace CSF.Screenplay.JsonToHtmlReport | ||
{ | ||
/// <summary> | ||
/// Options for converting a JSON report to HTML. | ||
/// </summary> | ||
public class ReportConverterOptions | ||
{ | ||
/// <summary> | ||
/// Gets or sets the file system path to the JSON report which is to be converted to HTML. | ||
/// </summary> | ||
public string ReportPath { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace CSF.Screenplay.JsonToHtmlReport | ||
{ | ||
/// <summary> | ||
/// Provides methods to register services for the JsonToHtmlReport application (or library). | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// This type is consumed by the JSON to HTML report converter when it is built as an application, | ||
/// but it may also be used when consuming this project as a library, for integrating it into other solutions. | ||
/// </para> | ||
/// </remarks> | ||
public class ServiceRegistrations | ||
{ | ||
/// <summary> | ||
/// Registers the services required for the JsonToHtmlReport application (or library). | ||
/// </summary> | ||
/// <param name="services">The service collection to which the services will be added.</param> | ||
public virtual void RegisterServices(IServiceCollection services) | ||
{ | ||
#if !NETSTANDARD2_0 | ||
services.AddHostedService<ReportConverterApplication>(); | ||
services.AddOptions<ReportConverterOptions>(); | ||
#endif | ||
services.AddTransient<IConvertsReportJsonToHtml, ReportConverter>(); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# HTML template source directory | ||
|
||
This folder contains a very small node/Webpack project, used to build the HTML file template. | ||
This template is used as an embedded resource in the app/library. | ||
This folder contains the _source code_ for that template, but the actual template which is used is output to the `../template` folder. |
Oops, something went wrong.