Skip to content

Commit

Permalink
Hotfix/template generation (#8)
Browse files Browse the repository at this point in the history
* fix(template): fix namespace, add editorconfig and some more refactor

* fix: add oracle migrations and change template value

* doc: change url
  • Loading branch information
christianrd committed Sep 10, 2024
1 parent 68b17f1 commit a8d56d1
Show file tree
Hide file tree
Showing 26 changed files with 1,059 additions and 104 deletions.
382 changes: 382 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- develop
- release/*
paths-ignore:
- .gitignore
- CODE_OF_CONDUCT.md
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- develop
- release/*
paths:
- 'FastCleanArchitecture.nuspec'
Expand Down
15 changes: 9 additions & 6 deletions .template.config/template.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Cristian D. Rodriguez V.",
"author": "christiandr",
"classifications": [
"Web",
"API",
"Clean Architecture"
"Clean Architecture",
"template",
"Fast Clean Architecture"
],
"name": "Fast Clean Architecture Solution",
"defaultName": "FastCleanArchitecture",
Expand Down Expand Up @@ -42,7 +44,7 @@
"generator": "constant",
"replaces": "fcaPackageVersion",
"parameters": {
"value": "8.0.6"
"value": "8.0.8"
}
}
},
Expand All @@ -63,7 +65,8 @@
".idea/**/*",
"**/.git/**",
"**/azure-pipelines.yml",
"README.md"
"README.md",
"**/.github/**"
],
"rename": {
"README-template.md": "README.md"
Expand All @@ -72,7 +75,7 @@
{
"condition": "(UseLocalDB)",
"exclude": [
"src/Infrastructure/Data/Oracle/**",
"src/Infrastructure/Data/OracleMigrations/**",
"src/API/appsettings.Oracle.json",
"tests/Application.FunctionalTests/OracleTestDatabase.cs"
]
Expand All @@ -86,7 +89,7 @@
"tests/Application.FunctionalTests/TestcontainersTestDatabase.cs"
],
"rename": {
"src/Infrastructure/Data/Oracle/": "src/Infrastructure/Data/Migrations/",
"src/Infrastructure/Data/OracleMigrations/": "src/Infrastructure/Data/Migrations/",
"appsettings.Oracle.json": "appsettings.json",
"TestDatabase.Oracle.cs": "TestDatabase.cs"
}
Expand Down
6 changes: 3 additions & 3 deletions FastCleanArchitecture.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>8.0.8</version>
<title>Fast Clean Architecture Solution Template</title>
<authors>christiandr</authors>
<description>Fast Clean Architecture Solution Template for .NET 8.0.8.</description>
<description>Fast Clean Architecture Solution Template for .NET 8.</description>
<summary>
A Clean Architecture Solution Template for creating apps using Web API only with DotNet.
</summary>
Expand All @@ -16,7 +16,7 @@

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

Expand All @@ -28,6 +28,6 @@
<files>
<file src=".template.config\icon.png" />
<file src="README.md" />
<file src=".\**" target="content" exclude="**\bin\**;**\obj\**;.\.vs\**;.\.vscode\**;content\Directory.Build.*;.\.git\**;.\README.md;" />
<file src=".\**" target="content" exclude="**\bin\**;**\obj\**;.\.vs\**;.\.vscode\**;content\Directory.Build.*;.\.git\**;.\.github\workflows\package.yml;.\.github\workflows\codeql.yml;.\.github\workflows\build.yml;.\.github\ISSUE_TEMPLATE\**;.\.github\icon.png;.\.github\FUNDING.md;.\CODE_OF_CONDUCT.md;.\LICENSE;.\README.md;" />
</files>
</package>
8 changes: 4 additions & 4 deletions README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Run `dotnet build -tl` to build the solution.
To run the web application:

```bash
cd .\src\Web\
cd .\src\API\
dotnet watch run
```

Expand All @@ -30,16 +30,16 @@ Start in the `.\src\Application\` folder.
Create a new command:

```
dotnet new fca-usecase --name CreateTodoList --feature-name TodoLists --usecase-type command --return-type int
dotnet new fast-ca-usecase --name CreateTodoList --feature-name TodoLists --usecase-type command --return-type int
```

Create a new query:

```
dotnet new fca-usecase -n GetTodos -fn TodoLists -ut query -rt TodosVm
dotnet new fast-ca-usecase -n GetTodos -fn TodoLists -ut query -rt TodosVm
```

If you encounter the error *"No templates or subcommands found matching: 'fca-usecase'."*, install the template and try again:
If you encounter the error *"No templates or subcommands found matching: 'fast-ca-usecase'."*, install the template and try again:

```bash
dotnet new install Fast.Clean.Architecture.Solution.Template::fcaPackageVersion
Expand Down
102 changes: 100 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,100 @@
# FastCleanArchitecture
Is a clean architecture solution template writed for .Net projects.
# Fast Clean Architecture Template

[![Nuget](https://img.shields.io/nuget/v/Fast.Clean.Architecture.Solution.Template?label=NuGet)](https://www.nuget.org/packages/Fast.Clean.Architecture.Solution.Template)
[![Nuget](https://img.shields.io/nuget/dt/Fast.Clean.Architecture.Solution.Template?label=Downloads)](https://www.nuget.org/packages/Fast.Clean.Architecture.Solution.Template)

The purpose of this template is to offer a simple and effective solution for building enterprise applications
by harnessing the capabilities of Clean Architecture and ASP.NET Core.
With this template, you can easily set up a Web API following Clean Architecture and Domain Drive Design principles.
Starting is quick and easy�just install the .NET template (detailed instructions provided below).


## Getting Started

The following prerequisites are required to build and run the solution:

- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) (latest version)
- [Node.js](https://nodejs.org/) (latest LTS, only required if you are using Angular or React)

The easiest way to get started is to install the [.NET template](https://www.nuget.org/packages/Fast.Clean.Architecture.Solution.Template):
```
dotnet new install Clean.Architecture.Solution.Template::8.0.8
```

Once installed, create a new solution using the template. You can choose to use Angular, React, or create a Web API-only solution. Specify the client framework using the `-cf` or `--client-framework` option, and provide the output directory where your project will be created. Here are some examples:

To create a ASP.NET Core Web API solution:
```bash
dotnet new fast-ca-sln -o YourProjectName
```

Launch the app:
```bash
cd src/API
dotnet run
```

To learn more, run the following command:
```bash
dotnet new fast-ca-sln --help
```

You can create use cases (commands or queries) by navigating to `./src/Application` and running `dotnet new fast-ca-usecase`. Here are some examples:

To create a new command:
```bash
dotnet new fast-ca-usecase --name CreateTodoList --feature-name TodoLists --usecase-type command --return-type int
```

To create a query:
```bash
dotnet new fast-ca-usecase -n GetTodos -fn TodoLists -ut query -rt TodosVm
```

To learn more, run the following command:
```bash
dotnet new fast-ca-usecase --help
```

## Database

The template is configured to use SQL Server by default. If you would prefer to use SQLite, create your solution using the following command:

```bash
dotnet new fast-ca-sln --use-oracle
```

When you run the application the database will be automatically created (if necessary) and the latest migrations will be applied.

Running database migrations is easy. Ensure you add the following flags to your command (values assume you are executing from repository root)

* `--project src/Infrastructure` (optional if in this folder)
* `--startup-project src/API`
* `--output-dir Data/Migrations`

For example, to add a new migration from the root folder:

`dotnet ef migrations add "SampleMigration" --project src\Infrastructure --startup-project src\API --output-dir Data\Migrations`

## Deploy

The template includes a full CI/CD pipeline. The pipeline is responsible for building, testing, publishing and deploying the solution to Azure.

## Technologies

* [ASP.NET Core 8](https://docs.microsoft.com/en-us/aspnet/core/introduction-to-aspnet-core)
* [Entity Framework Core 8](https://docs.microsoft.com/en-us/ef/core/)
* [MediatR](https://github.com/jbogard/MediatR)
* [FluentValidation](https://fluentvalidation.net/)
* [NUnit](https://nunit.org/), [FluentAssertions](https://fluentassertions.com/), [Moq](https://github.com/devlooped/moq) & [Respawn](https://github.com/jbogard/Respawn)

## Versions
The main branch is now on .NET 8.0.

## Support

If you are having problems, please let me know by [create a new issue](https://github.com/christianrd/FastCleanArchitecture/issues/new/choose).

## License

This project is licensed with the [MIT license](LICENSE).
9 changes: 8 additions & 1 deletion fastCleanArchitecture.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application.UnitTests", "te
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "src\Infrastructure\Infrastructure.csproj", "{2559E67B-B202-4E5A-9091-8E6418D22E08}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "API", "src\API\API.csproj", "{3A7EAD0E-2F46-4022-9119-96593FFEC72D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "API", "src\API\API.csproj", "{3A7EAD0E-2F46-4022-9119-96593FFEC72D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C7FBE7FF-00ED-4E1B-B015-CC61AE8E0FD3}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
FastCleanArchitecture.nuspec = FastCleanArchitecture.nuspec
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
15 changes: 8 additions & 7 deletions src/API/API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
<UserSecretsId>f5e32e1e-4b42-4557-9635-b9a0c84f3591</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
<CompanyName>Fast Clean Architecture</CompanyName>
<Company>$(CompanyName)</Company>
<RootNamespace>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</RootNamespace>
<AssemblyName>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</AssemblyName>
<Authors>Cristian D. Rodríguez V.</Authors>
<NuspecFile>.\..\..\FastCleanArchitecture.nuspec</NuspecFile>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
<CompanyName>FastCleanArchitecture</CompanyName>
<Company>$(CompanyName)</Company>
<RootNamespace>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</RootNamespace>
<AssemblyName>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/API/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Server={YOUR-SERVER};Initial Catalog=FastCleanArchitecture;Persist Security Info=False;User ID={YOUR-USER};Password={YOUR-PASSWORD};MultipleActiveResultSets=False;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"DefaultConnection": ""
},
"AllowedHosts": "*"
}
}
12 changes: 12 additions & 0 deletions src/API/appsettings.oracle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "DATA SOURCE={SOURCE};PERSIST SECURITY INFO=True;USER ID={YOUR-USER}; password={YOUR-PASSWORD}; Pooling=False;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
11 changes: 4 additions & 7 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<CompanyName>Fast Clean Architecture</CompanyName>
<Company>$(CompanyName)</Company>
<RootNamespace>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</RootNamespace>
<AssemblyName>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</AssemblyName>
<Authors>Cristian D. Rodríguez V.</Authors>
<NuspecFile>.\..\..\FastCleanArchitecture.nuspec</NuspecFile>
<NuspecProperties>version=$(PackageVersion)</NuspecProperties>
<CompanyName>FastCleanArchitecture</CompanyName>
<Company>$(CompanyName)</Company>
<RootNamespace>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</RootNamespace>
<AssemblyName>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</AssemblyName>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<CompanyName>FastCleanArchitecture</CompanyName>
<Company>$(CompanyName)</Company>
<RootNamespace>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</RootNamespace>
<AssemblyName>$(CompanyName.Replace(" ", "")).$(MSBuildProjectName.Replace(" ", ""))</AssemblyName>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit a8d56d1

Please sign in to comment.