Skip to content

Commit f3fcff8

Browse files
committed
Update husky config
1 parent 0e50cb9 commit f3fcff8

File tree

17 files changed

+216
-150
lines changed

17 files changed

+216
-150
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
"tools": {
55
"husky": {
66
"version": "0.7.1",
7-
"commands": [
8-
"husky"
9-
],
7+
"commands": ["husky"],
108
"rollForward": false
119
}
1210
}
13-
}
11+
}

.github/workflows/Build_main_and_publish_to_nuget.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
30-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
30+
- name: "Cache: .nuke/temp, ~/.nuget/packages"
3131
uses: actions/cache@v4
3232
with:
3333
path: |
3434
.nuke/temp
3535
~/.nuget/packages
3636
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
37-
- name: 'Run: Clean, Compile, Pack, PublishToGitHubNuget, Publish'
37+
- name: "Run: Clean, Compile, Pack, PublishToGitHubNuget, Publish"
3838
run: ./build.cmd Clean Compile Pack PublishToGitHubNuget Publish
3939
env:
4040
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
- name: 'Publish: artifacts'
42+
- name: "Publish: artifacts"
4343
uses: actions/upload-artifact@v4
4444
with:
4545
name: artifacts

.github/workflows/Continuous_build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
30-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
30+
- name: "Cache: .nuke/temp, ~/.nuget/packages"
3131
uses: actions/cache@v4
3232
with:
3333
path: |
3434
.nuke/temp
3535
~/.nuget/packages
3636
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
37-
- name: 'Run: Clean, Compile, Test, Pack'
37+
- name: "Run: Clean, Compile, Test, Pack"
3838
run: ./build.cmd Clean Compile Test Pack
3939
env:
4040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
- name: 'Publish: artifacts'
41+
- name: "Publish: artifacts"
4242
uses: actions/upload-artifact@v4
4343
with:
4444
name: artifacts

.github/workflows/Manual_publish_to_Github_Nuget.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v4
27-
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
27+
- name: "Cache: .nuke/temp, ~/.nuget/packages"
2828
uses: actions/cache@v4
2929
with:
3030
path: |
3131
.nuke/temp
3232
~/.nuget/packages
3333
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
34-
- name: 'Run: Pack, PublishToGitHubNuget'
34+
- name: "Run: Pack, PublishToGitHubNuget"
3535
run: ./build.cmd Pack PublishToGitHubNuget
3636
env:
3737
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
- name: 'Publish: artifacts'
38+
- name: "Publish: artifacts"
3939
uses: actions/upload-artifact@v4
4040
with:
4141
name: artifacts

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
## or put your custom commands -------------------
2020
#echo 'Husky.Net is awesome!'
2121

22-
dotnet husky run
22+
dotnet husky run --group pre-commit

.husky/task-runner.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
{
22
"$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
33
"tasks": [
4+
{
5+
"name": "prettier",
6+
"group": "pre-commit",
7+
"command": "npx",
8+
"args": ["prettier", "--ignore-unknown", "--write", "${staged}"]
9+
},
10+
{
11+
"name": "prettier-html",
12+
"group": "pre-commit",
13+
"command": "npx",
14+
"args": ["prettier", "--write", "--parser=html", "${staged}"],
15+
"include": ["**/*.csproj", "**/nuget.config"]
16+
},
417
{
518
"name": "Run csharpier",
19+
"group": "pre-commit",
620
"command": "dotnet",
7-
"args": [ "csharpier", "${staged}" ],
8-
"include": [ "**/*.cs" ]
21+
"args": ["csharpier", "${staged}"],
22+
"include": ["**/*.cs"]
923
}
1024
]
1125
}

.nuke/build.schema.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
"Configuration": {
1010
"type": "string",
1111
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
12-
"enum": [
13-
"Debug",
14-
"Release"
15-
]
12+
"enum": ["Debug", "Release"]
1613
},
1714
"Continue": {
1815
"type": "boolean",
@@ -109,12 +106,7 @@
109106
"Verbosity": {
110107
"type": "string",
111108
"description": "Logging verbosity during build execution. Default is 'Normal'",
112-
"enum": [
113-
"Minimal",
114-
"Normal",
115-
"Quiet",
116-
"Verbose"
117-
]
109+
"enum": ["Minimal", "Normal", "Quiet", "Verbose"]
118110
}
119111
}
120112
}

.nuke/parameters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"$schema": "./build.schema.json",
33
"Solution": "dotnet-dispatcher.sln"
4-
}
4+
}

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# dotnet-dispatcher 0.1
2+
23
A simple dispatcher for .NET Core that uses Roslyn code generation to emit CQRS dispatcher code. Currently in extremely early stage, but I feel there's something to it.
34

45
## Why?
6+
57
I'm a great 'not-friend' of things like reflection, Activator and runtime type determination. When writing CQRS code, I would like to have my dispatcher code generated in compile time, with all optimalizations and other goodies that come with it.
68

79
## Enter DotnetDispatcher
10+
811
To generate a dispatcher is as simple as this:
912

1013
```csharp
1114
using DotnetDispatcher.Attributes;
1215
using DotnetDispatcher.Core;
1316

14-
namespace ConsoleTester;
17+
namespace ConsoleTester;
1518

1619
public record SampleQuery : IQuery<SampleQueryResponse>;
1720

@@ -42,22 +45,28 @@ namespace ConsoleTester
4245
}
4346
}
4447
```
45-
Aside from the Dispatch code, a matching interface is also generated. This allows for easy mocking of the dispatcher as well as using dependency injection. You can have multiple dispatchers in a project, if you want to. Alternatively, you can repeat the use of the GenerateDispatcher attribute with other types that implement `IQuery<TResponse>`, `ICommand<TResponse>` or `ICommand`.
4648

49+
Aside from the Dispatch code, a matching interface is also generated. This allows for easy mocking of the dispatcher as well as using dependency injection. You can have multiple dispatchers in a project, if you want to. Alternatively, you can repeat the use of the GenerateDispatcher attribute with other types that implement `IQuery<TResponse>`, `ICommand<TResponse>` or `ICommand`.
4750

4851
## Download and install
52+
4953
There are three nuget packages to install:
54+
5055
- `DotnetDispatcher.Core` - contains interfaces your commands and queries should implement, as well as the `DispatcherBase` class
5156
- `DotnetDispatcher.Attributes` - contains the `GenerateDispatcher` attribute
5257
- `DotnetDispatcher.Generator` - contains the code generator
5358

5459
## How to use
60+
5561
Assuming you have an API project and a Domain project in your solution, where the generated dispatcher is part of the API project and the commands and queries are part of the Domain project:
62+
5663
- The API project should reference the Domain project, as well as the `DotnetDispatcher.Generator` and `DotnetDispatcher.Attributes` packages
5764
- The Domain project should reference the `DotnetDispatcher.Core` package
5865

5966
The actual implementation in the projects is as such:
67+
6068
- The domain project contains the query and the query handler
69+
6170
```csharp
6271
public record SampleQuery : IQuery<SampleQueryResponse>;
6372

@@ -73,6 +82,7 @@ public class SampleQueryHandler : IQueryHandler<SampleQuery, SampleQueryResponse
7382
```
7483

7584
- The API project contains the dispatcher itself
85+
7686
```csharp
7787
[GenerateDispatcher(typeof(SampleQuery), typeof(SampleQueryHandler))]
7888
public partial class MyAppDispatcher : DispatcherBase
@@ -82,7 +92,9 @@ public partial class MyAppDispatcher : DispatcherBase
8292
}
8393
}
8494
```
95+
8596
This generates the dispatcher code as well as an IServiceCollection extension method that allows you to register the dispatcher in the DI container. You can use it in the API project like this:
97+
8698
```csharp
8799
var serviceCollection = new ServiceCollection();
88100

@@ -96,4 +108,4 @@ var sampleQueryResponse = await appDispatcher.Dispatch(new SampleQuery(), Cancel
96108
Console.WriteLine(sampleQueryResponse.Value);
97109
```
98110

99-
#### Enjoy. And feel free to contribute, report bugs, give suggestions and all that good stuff.
111+
#### Enjoy. And feel free to contribute, report bugs, give suggestions and all that good stuff.

build/_build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
<PackageDownload Include="GitVersion.CommandLine" Version="[5.12.0]" />
1616
<PackageDownload Include="GitVersion.Tool" Version="[5.12.0]" />
1717
</ItemGroup>
18-
</Project>
18+
</Project>

0 commit comments

Comments
 (0)