Skip to content

Commit

Permalink
✨ 53 dotnet cli template (#55)
Browse files Browse the repository at this point in the history
* Added assembly name and namespaces to all libraries

* Fixed up namespaces

* Trying to get integration tests to work

* Added nuget nuspec file

* Added GitHub package workflow

* Added read me instructions for publishing the nuget package

* Allow manual workflow trigger

* Update action trigger

* Remove skip duplicate package

* Add manual trigger back

* Updated version

* Fixed build

* Update package version

* Reverted build pipeline settings

* Removed angular from nuspec

* Update nuspec description

Co-authored-by: William Liebenberg <[email protected]>

* Update src/Application/Application.csproj

Co-authored-by: William Liebenberg <[email protected]>

* Update src/Application/Application.csproj

Co-authored-by: William Liebenberg <[email protected]>

* Update src/Application/Common/Behaviours/LoggingBehaviour.cs

Co-authored-by: William Liebenberg <[email protected]>

* Added SSW to namespaces and assembly names

---------

Co-authored-by: William Liebenberg <[email protected]>
  • Loading branch information
danielmackay and william-liebenberg committed May 22, 2023
1 parent aafbadf commit 591fdc5
Show file tree
Hide file tree
Showing 64 changed files with 380 additions and 248 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Package
on:
push:
branches:
- main
paths:
- 'CleanArchitecture.nuspec'
jobs:
publish:
name: Publish to NuGet.org
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: nuget/setup-nuget@v1
with:
nuget-version: '6.x'

- name: Create the package
run: nuget pack CleanArchitecture.nuspec -NoDefaultExcludes

- name: Publish the package
run: nuget push *.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}}
44 changes: 44 additions & 0 deletions .template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "SSW",
"classifications": [
"Web",
"SPA",
"API",
".NET",
"ASP.NET Core",
"EF Core",
"SSW",
"Clean Architecture"
],
"name": "SSW Clean Architecture Solution",
"description": "",
"identity": "SSW.Clean.Architecture.Solution.CSharp",
"groupIdentity": "SSW.Clean.Architecture.Solution",
"shortName": "ssw-ca",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "SSW.CleanArchitecture",
"preferNameDirectory": true,
"sources": [
{
"source": "./",
"target": "./",
"exclude": [
"README.md",
"**/[Bb]in/**",
"**/[Oo]bj/**",
".template.config/**/*",
".vs/**/*",
"**/*.filelist",
"**/*.user",
"**/*.lock.json",
"**/.git/**",
"*.nuspec",
"**/node_modules/**"
]
}
]
}
35 changes: 35 additions & 0 deletions CleanArchitecture.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>

<id>SSW.CleanArchitecture.Template</id>
<version>0.2.3</version>
<title>SSW Clean Architecture Template</title>
<authors>SSW</authors>
<description>SSW Clean Architecture Solution Template for .NET.</description>
<summary>
This is a solution template for creating a WebAPI with ASP.NET Core following the principles of Clean Architecture.
</summary>
<releaseNotes>
</releaseNotes>

<projectUrl>https://github.com/SSWConsulting/CleanArchitectureV2</projectUrl>
<repository type="git" url="https://github.com/SSWConsulting/CleanArchitectureV2.git" branch="main" />

<license type="expression">MIT</license>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<tags>clean-architecture project template csharp dotnet ssw</tags>
<readme>README.md</readme>

<packageTypes>
<packageType name="Template" />
</packageTypes>

</metadata>

<files>
<file src="README.md" />
<file src=".\**" target="content" exclude="**\bin\**;**\obj\**;**\.vs\**;**\.vscode\**;**\.git\**;**\.github\**;**\LICENSE;" />
</files>

</package>
1 change: 1 addition & 0 deletions CleanArchitecture.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
CleanArchitecture.nuspec = CleanArchitecture.nuspec
Directory.Build.Props = Directory.Build.Props
docker-compose.yml = docker-compose.yml
global.json = global.json
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,13 @@
- you will know when your tests pass when they should have failed
- Inserts bugs into the production code to make sure our tests are effective and testing the right behavior
- Using [Stryker Mutator](https://stryker-mutator.io/)

## Publishing Template

Template will be published to NuGet.org when changes are made to `CleanArchitecture.nuspec` on the `main` branch.

### Process

1. Update the `version` attribute in `CleanArchitecture.nuspec`
2. Merge your PR
3. `package` GitHub Action will run and publish the new version to NuGet.org
2 changes: 2 additions & 0 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>SSW.CleanArchitecture.Application</RootNamespace>
<AssemblyName>SSW.CleanArchitecture.Application</AssemblyName>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Common/Behaviours/LoggingBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Application.Common.Interfaces;
using SSW.CleanArchitecture.Application.Common.Interfaces;
using MediatR.Pipeline;
using Microsoft.Extensions.Logging;

namespace CleanArchitecture.Application.Common.Behaviours;
namespace SSW.CleanArchitecture.Application.Common.Behaviours;

public class LoggingBehaviour<TRequest> : IRequestPreProcessor<TRequest> where TRequest : notnull
{
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Common/Behaviours/PerformanceBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Diagnostics;
using Application.Common.Interfaces;
using Microsoft.Extensions.Logging;
using SSW.CleanArchitecture.Application.Common.Interfaces;

namespace CleanArchitecture.Application.Common.Behaviours;
namespace SSW.CleanArchitecture.Application.Common.Behaviours;

public class PerformanceBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging;

namespace CleanArchitecture.Application.Common.Behaviours;
namespace SSW.CleanArchitecture.Application.Common.Behaviours;

public class UnhandledExceptionBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse> where TRequest : notnull
{
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Behaviours/ValidationBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CleanArchitecture.Application.Common.Behaviours;
namespace SSW.CleanArchitecture.Application.Common.Behaviours;

public class ValidationBehaviour<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
where TRequest : notnull
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace CleanArchitecture.Application.Common.Exceptions;
namespace SSW.CleanArchitecture.Application.Common.Exceptions;

public class NotFoundException : Exception
{
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Exceptions/ValidationException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentValidation.Results;

namespace CleanArchitecture.Application.Common.Exceptions;
namespace SSW.CleanArchitecture.Application.Common.Exceptions;

public class ValidationException : Exception
{
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Interfaces/ICurrentUserService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Application.Common.Interfaces;
namespace SSW.CleanArchitecture.Application.Common.Interfaces;

public interface ICurrentUserService
{
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Interfaces/IDateTime.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Application.Common.Interfaces;
namespace SSW.CleanArchitecture.Application.Common.Interfaces;

public interface IDateTime
{
Expand Down
6 changes: 3 additions & 3 deletions src/Application/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using CleanArchitecture.Application.Common.Behaviours;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using SSW.CleanArchitecture.Application.Common.Behaviours;

namespace Application;
namespace SSW.CleanArchitecture.Application;

public static class DependencyInjection
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Application.Features.TodoItems.Specifications;
using Ardalis.Specification;
using Domain.Entities;
using Domain.Events;
using Ardalis.Specification;
using SSW.CleanArchitecture.Application.Features.TodoItems.Specifications;
using SSW.CleanArchitecture.Domain.Events;
using SSW.CleanArchitecture.Domain.Entities;

namespace Application.Features.TodoItems.Commands.CreateTodoItem;
namespace SSW.CleanArchitecture.Application.Features.TodoItems.Commands.CreateTodoItem;

public record CreateTodoItemCommand(string? Title) : IRequest<Guid>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace Application.Features.TodoItems.Commands.CreateTodoItem;
using SSW.CleanArchitecture.Domain.Entities;

namespace SSW.CleanArchitecture.Application.Features.TodoItems.Commands.CreateTodoItem;

public class CreateTodoItemMapping : Profile
{
public CreateTodoItemMapping()
{
CreateMap<CreateTodoItemCommand, Domain.Entities.TodoItem>();
CreateMap<CreateTodoItemCommand, TodoItem>();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Application.Features.TodoItems.Commands.CreateTodoItem;
using Domain.Events;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;
using SSW.CleanArchitecture.Domain.Events;

namespace Application.Features.TodoItems.EventHandlers;
namespace SSW.CleanArchitecture.Application.Features.TodoItems.EventHandlers;

public class TodoItemCreatedEventHandler : INotificationHandler<TodoItemCreatedEvent>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace Application.Features.TodoItems.Queries.GetAllTodoItems;
using SSW.CleanArchitecture.Domain.Entities;

namespace SSW.CleanArchitecture.Application.Features.TodoItems.Queries.GetAllTodoItems;

public class GetAllTodoItemsMapping : Profile
{
public GetAllTodoItemsMapping()
{
CreateMap<Domain.Entities.TodoItem, TodoItemDto>()
CreateMap<TodoItem, TodoItemDto>()
.ForMember(d => d.Id, opt => opt.MapFrom(s => s.Id.Value));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Application.Features.TodoItems.Specifications;
using Ardalis.Specification;
using Domain.Entities;
using SSW.CleanArchitecture.Application.Features.TodoItems.Specifications;
using SSW.CleanArchitecture.Domain.Entities;

namespace Application.Features.TodoItems.Queries.GetAllTodoItems;
namespace SSW.CleanArchitecture.Application.Features.TodoItems.Queries.GetAllTodoItems;

public record GetAllTodoItemsQuery : IRequest<IReadOnlyList<TodoItemDto>>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Application.Features.TodoItems.Queries.GetAllTodoItems;
namespace SSW.CleanArchitecture.Application.Features.TodoItems.Queries.GetAllTodoItems;

public class TodoItemDto
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Ardalis.Specification;
using Domain.Entities;
using SSW.CleanArchitecture.Domain.Entities;

namespace Application.Features.TodoItems.Specifications;
namespace SSW.CleanArchitecture.Application.Features.TodoItems.Specifications;

public sealed class AllTodoItemSpec : Specification<TodoItem>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Ardalis.Specification;
using Domain.Entities;
using SSW.CleanArchitecture.Domain.Entities;

namespace Application.Features.TodoItems.Specifications;
namespace SSW.CleanArchitecture.Application.Features.TodoItems.Specifications;

public sealed class TodoItemByTitleSpec : Specification<TodoItem>
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Common/AuditableEntity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Domain.Common;
namespace SSW.CleanArchitecture.Domain.Common;

public abstract class AuditableEntity
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Common/BaseEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations.Schema;

namespace Domain.Common;
namespace SSW.CleanArchitecture.Domain.Common;

public abstract class BaseEntity<TId> : AuditableEntity, IDomainEvents
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Common/BaseEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MediatR;

namespace Domain.Common;
namespace SSW.CleanArchitecture.Domain.Common;

public record BaseEvent : INotification;
2 changes: 1 addition & 1 deletion src/Domain/Common/IDomainEvents.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Domain.Common;
namespace SSW.CleanArchitecture.Domain.Common;

public interface IDomainEvents
{
Expand Down
2 changes: 2 additions & 0 deletions src/Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>SSW.CleanArchitecture.Domain</RootNamespace>
<AssemblyName>SSW.CleanArchitecture.Domain</AssemblyName>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
5 changes: 4 additions & 1 deletion src/Domain/Entities/TodoItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Domain.Entities;
using SSW.CleanArchitecture.Domain.Common;
using SSW.CleanArchitecture.Domain.Enum;

namespace SSW.CleanArchitecture.Domain.Entities;


public record TodoItemId(Guid Value);
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Enum/PriorityLevel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Domain.Enum;
namespace SSW.CleanArchitecture.Domain.Enum;

public enum PriorityLevel
{
Expand Down
5 changes: 3 additions & 2 deletions src/Domain/Events/TodoItemCreatedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Domain.Entities;
using SSW.CleanArchitecture.Domain.Common;
using SSW.CleanArchitecture.Domain.Entities;

namespace Domain.Events;
namespace SSW.CleanArchitecture.Domain.Events;

public record TodoItemCreatedEvent(TodoItem Item) : BaseEvent;
4 changes: 2 additions & 2 deletions src/Domain/GlobalUsing.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
global using Domain.Common;
global using Domain.Enum;
global using SSW.CleanArchitecture.Domain.Common;
global using SSW.CleanArchitecture.Domain.Enum;
12 changes: 6 additions & 6 deletions src/Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Application.Common.Interfaces;
using Ardalis.Specification;
using Infrastructure.Persistence;
using Infrastructure.Persistence.Interceptors;
using Infrastructure.Services;
using Ardalis.Specification;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SSW.CleanArchitecture.Application.Common.Interfaces;
using SSW.CleanArchitecture.Infrastructure.Persistence;
using SSW.CleanArchitecture.Infrastructure.Persistence.Interceptors;
using SSW.CleanArchitecture.Infrastructure.Services;

namespace Infrastructure;
namespace SSW.CleanArchitecture.Infrastructure;

public static class DependencyInjection
{
Expand Down
Loading

0 comments on commit 591fdc5

Please sign in to comment.