Skip to content

Commit 7cf34bf

Browse files
feat: upgrade to v1.2.0
1 parent c9ce44c commit 7cf34bf

File tree

22 files changed

+57
-50
lines changed

22 files changed

+57
-50
lines changed

src/corePackages/Core.CodeGen/Code/CSharp/CSharpCodeInjector.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ public static async Task AddCodeLinesToMethodAsync(string filePath, string metho
7676
? fileContent[methodStartIndex].TakeWhile(char.IsWhiteSpace).Count() * 2
7777
: methodContent.Where(line => !string.IsNullOrEmpty(line)).Min(line => line.TakeWhile(char.IsWhiteSpace).Count());
7878

79-
fileContent.InsertRange(
80-
methodEndIndex,
81-
collection: codeLines
82-
.Select(line => new string(' ', minimumSpaceCountInMethod) + line)
83-
);
79+
fileContent.InsertRange(methodEndIndex, collection: codeLines.Select(line => new string(' ', minimumSpaceCountInMethod) + line));
8480
await System.IO.File.WriteAllLinesAsync(filePath, contents: fileContent.ToArray());
8581
}
8682

@@ -170,7 +166,6 @@ public static async Task AddCodeLinesToRegionAsync(string filePath, IEnumerable<
170166
if (!string.IsNullOrEmpty(previousLine))
171167
fileContent.Insert(index: indexToAdd, string.Empty);
172168

173-
174169
fileContent.InsertRange(
175170
index: indexToAdd,
176171
collection: linesToAdd.Select(line => new string(' ', minimumSpaceCountInRegion) + line)

src/nArchGen/Application/Features/Create/Commands/New/CreateNewProjectCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ [EnumeratorCancellation] CancellationToken cancellationToken
6666
private async Task downloadStarterProject(string projectName)
6767
{
6868
// Download zip on url
69-
string releaseUrl = "https://github.com/kodlamaio-projects/nArchitecture/archive/refs/tags/v1.1.2.zip";
69+
string releaseUrl = "https://github.com/kodlamaio-projects/nArchitecture/archive/refs/tags/v1.2.0.zip";
7070
using HttpClient client = new();
7171
using HttpResponseMessage response = await client.GetAsync(releaseUrl);
7272
response.EnsureSuccessStatusCode();
@@ -78,7 +78,7 @@ private async Task downloadStarterProject(string projectName)
7878
ZipFile.ExtractToDirectory(zipPath, Environment.CurrentDirectory);
7979
File.Delete(zipPath);
8080
Directory.Move(
81-
sourceDirName: $"{Environment.CurrentDirectory}/nArchitecture-1.1.2",
81+
sourceDirName: $"{Environment.CurrentDirectory}/nArchitecture-1.2.0",
8282
$"{Environment.CurrentDirectory}/{projectName}"
8383
);
8484
}

src/nArchGen/Application/Features/Generate/Commands/Command/GenerateCommandCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Application.Features.Generate.Rules;
1+
using System.Runtime.CompilerServices;
2+
using Application.Features.Generate.Rules;
23
using Core.CodeGen.Code;
34
using Core.CodeGen.Code.CSharp;
45
using Core.CodeGen.File;
@@ -7,7 +8,6 @@
78
using Domain.Constants;
89
using Domain.ValueObjects;
910
using MediatR;
10-
using System.Runtime.CompilerServices;
1111

1212
namespace Application.Features.Generate.Commands.Command;
1313

src/nArchGen/Application/Features/Generate/Commands/Crud/GenerateCrudCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private async Task<string> injectEntityToContext(string projectPath, CrudTemplat
157157
string dbSetPropertyCodeLine = await _templateEngine.RenderAsync(dbSetPropertyTemplateCodeLine, crudTemplateData);
158158
bool isExists = (await File.ReadAllLinesAsync(contextFilePath)).Any(line => line.Contains(dbSetPropertyCodeLine));
159159
if (!isExists)
160-
await CSharpCodeInjector.AddCodeLinesAsPropertyAsync(contextFilePath, codeLines: new[] { dbSetPropertyCodeLine });
160+
await CSharpCodeInjector.AddCodeLinesAsPropertyAsync(contextFilePath, codeLines: [dbSetPropertyCodeLine]);
161161

162162
return contextFilePath;
163163
}

src/nArchGen/ConsoleUI/ConsoleUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PackageIcon>n-architecture-logo.png</PackageIcon>
1818
<RepositoryUrl>https://github.com/kodlamaio-projects/nArchitecture.Gen</RepositoryUrl>
1919
<PackageTags>nArchitecture, nArchGen, cli, framework, tool, code generation</PackageTags>
20-
<Version>1.1.2</Version>
20+
<Version>1.2.0</Version>
2121
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2222
<PackageReadmeFile>README.md</PackageReadmeFile>
2323
</PropertyGroup>

src/nArchGen/ConsoleUI/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"ConsoleUI": {
44
"commandName": "Project",
5-
"commandLineArgs": "generate command"
5+
"commandLineArgs": "generate crud"
66
}
77
}
88
}

src/nArchGen/Domain/Templates/CRUD/Folders/Application/Features/PLURAL_ENTITY/Commands/Create/CreateENTITYCommand.cs.sbn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Application.Features.{{ entity.name | string.pascalcase | string.plura
1515

1616
public class Create{{ entity.name | string.pascalcase }}Command : IRequest<Created{{ entity.name | string.pascalcase }}Response>{{ if is_secured_operation_used }}, ISecuredRequest{{ end }}{{ if is_caching_used }}, ICacheRemoverRequest{{ end }}{{ if is_logging_used }}, ILoggableRequest{{ end }}{{ if is_transaction_used }}, ITransactionalRequest{{ end }}
1717
{%{{}%}{{ for propertyItem in entity.properties }}
18-
public {{ propertyItem.type }} {{ propertyItem.name | string.pascalcase }} { get; set; }{{ end }}{{ if is_secured_operation_used }}
18+
public {{ if !(propertyItem.type | string.contains "?") }}required {{ end }}{{ propertyItem.type }} {{ propertyItem.name | string.pascalcase }} { get; set; }{{ end }}{{ if is_secured_operation_used }}
1919

2020
public string[] Roles => [Admin, Write, {{ entity.name | string.pascalcase | string.plural }}OperationClaims.Create];{{ end }}{{ if is_caching_used }}
2121

src/nArchGen/Domain/Templates/CRUD/Folders/Application/Features/PLURAL_ENTITY/Commands/Create/CreateENTITYCommandValidator.cs.sbn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Application.Features.{{ entity.name | string.pascalcase | string.plura
55
public class Create{{ entity.name | string.pascalcase }}CommandValidator : AbstractValidator<Create{{ entity.name | string.pascalcase }}Command>
66
{
77
public Create{{ entity.name | string.pascalcase }}CommandValidator()
8-
{%{{}%}{{ for propertyItem in entity.properties }}
9-
RuleFor(c => c.{{ propertyItem.name | string.pascalcase }}).NotEmpty();{{ end }}
8+
{%{{}%}{{ for propertyItem in entity.properties }}{{ if !(propertyItem.type | string.contains "?") }}
9+
RuleFor(c => c.{{ propertyItem.name | string.pascalcase }}).NotEmpty();{{ end }}{{ end }}
1010
}
1111
}

src/nArchGen/Domain/Templates/CRUD/Folders/Application/Features/PLURAL_ENTITY/Commands/Update/UpdateENTITYCommand.cs.sbn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Application.Features.{{ entity.name | string.pascalcase | string.plura
1616
public class Update{{ entity.name | string.pascalcase }}Command : IRequest<Updated{{ entity.name | string.pascalcase }}Response>{{ if is_secured_operation_used }}, ISecuredRequest{{ end }}{{ if is_caching_used }}, ICacheRemoverRequest{{ end }}{{ if is_logging_used }}, ILoggableRequest{{ end }}{{ if is_transaction_used }}, ITransactionalRequest{{ end }}
1717
{
1818
public {{ entity.id_type }} Id { get; set; }{{ for propertyItem in entity.properties }}
19-
public {{ propertyItem.type }} {{ propertyItem.name | string.pascalcase }} { get; set; }{{ end }}{{ if is_secured_operation_used }}
19+
public {{ if !(propertyItem.type | string.contains "?") }}required {{ end }}{{ propertyItem.type }} {{ propertyItem.name | string.pascalcase }} { get; set; }{{ end }}{{ if is_secured_operation_used }}
2020

2121
public string[] Roles => [Admin, Write, {{ entity.name | string.pascalcase | string.plural }}OperationClaims.Update];{{ end }}{{ if is_caching_used }}
2222

src/nArchGen/Domain/Templates/CRUD/Folders/Application/Features/PLURAL_ENTITY/Commands/Update/UpdateENTITYCommandValidator.cs.sbn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Update{{ entity.name | string.pascalcase }}CommandValidator : Abstr
66
{
77
public Update{{ entity.name | string.pascalcase }}CommandValidator()
88
{
9-
RuleFor(c => c.Id).NotEmpty();{{ for propertyItem in entity.properties }}
10-
RuleFor(c => c.{{ propertyItem.name | string.pascalcase }}).NotEmpty();{{ end }}
9+
RuleFor(c => c.Id).NotEmpty();{{ for propertyItem in entity.properties }}{{ if !(propertyItem.type | string.contains "?") }}
10+
RuleFor(c => c.{{ propertyItem.name | string.pascalcase }}).NotEmpty();{{ end }}{{ end }}
1111
}
1212
}

0 commit comments

Comments
 (0)