Skip to content

Commit a318378

Browse files
feat(*): upgrade to NArchitecture v1.1.0
1 parent 6734468 commit a318378

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

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

Lines changed: 23 additions & 4 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.0.0.zip";
69+
string releaseUrl = "https://github.com/kodlamaio-projects/nArchitecture/archive/refs/tags/v1.1.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.0.0",
81+
sourceDirName: $"{Environment.CurrentDirectory}/nArchitecture-1.1.0",
8282
$"{Environment.CurrentDirectory}/{projectName}"
8383
);
8484
}
@@ -204,6 +204,7 @@ private async Task removeSecurityMechanism(string projectName)
204204
$"{projectSourcePath}/Application/Services/OperationClaims",
205205
$"{projectSourcePath}/Application/Services/UserOperationClaims",
206206
$"{projectSourcePath}/Application/Services/UsersService",
207+
$"{projectSourcePath}/Domain/Entities",
207208
$"{projectTestsPath}/{projectName.ToPascalCase()}.Application.Tests/Features/Auth",
208209
$"{projectTestsPath}/{projectName.ToPascalCase()}.Application.Tests/Features/Users",
209210
$"{projectTestsPath}/{projectName.ToPascalCase()}.Application.Tests/Mocks/Repositories/Auth",
@@ -258,16 +259,31 @@ await FileHelper.RemoveLinesAsync(
258259
"using Application.Services.UsersService;",
259260
"services.AddScoped<IAuthService, AuthManager>();",
260261
"services.AddScoped<IAuthenticatorService, AuthenticatorManager>();",
261-
"services.AddScoped<IUserService, UserManager>();"
262+
"services.AddScoped<IUserService, UserManager>();",
263+
"using NArchitecture.Core.Security.DependencyInjection;",
264+
"services.AddSecurityServices<Guid, int>();",
262265
}
263266
).Any(line.Contains)
264267
);
268+
await FileHelper.RemoveLinesAsync(
269+
filePath: $"{projectSourcePath}/Application/Application.csproj",
270+
predicate: line =>
271+
(new[] { "<PackageReference Include=\"NArchitecture.Core.Security.DependencyInjection\" Version=\"1.0.0\" />", }).Any(
272+
line.Contains
273+
)
274+
);
275+
await FileHelper.RemoveLinesAsync(
276+
filePath: $"{projectSourcePath}/Domain/Domain.csproj",
277+
predicate: line =>
278+
(new[] { "<PackageReference Include=\"NArchitecture.Core.Security\" Version=\"1.1.1\" />" }).Any(line.Contains)
279+
);
265280
await FileHelper.RemoveLinesAsync(
266281
filePath: $"{projectSourcePath}/Persistence/Contexts/BaseDbContext.cs",
267282
predicate: line =>
268283
(
269284
new[]
270285
{
286+
"using Domain.Entities;",
271287
"DbSet<EmailAuthenticator> EmailAuthenticators",
272288
"DbSet<OperationClaim> OperationClaim",
273289
"DbSet<OtpAuthenticator> OtpAuthenticator",
@@ -321,13 +337,16 @@ await FileHelper.RemoveContentAsync(
321337
"using Microsoft.AspNetCore.Authentication.JwtBearer;\n",
322338
"using Microsoft.IdentityModel.Tokens;\n",
323339
"using Microsoft.OpenApi.Models;\n",
324-
"builder.Services.AddSecurityServices();\n",
325340
"const string tokenOptionsConfigurationSection = \"TokenOptions\";\nTokenOptions tokenOptions =\n builder.Configuration.GetSection(tokenOptionsConfigurationSection).Get<TokenOptions>()\n ?? throw new InvalidOperationException($\"\\\"{tokenOptionsConfigurationSection}\\\" section cannot found in configuration.\");\nbuilder\n .Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)\n .AddJwtBearer(options =>\n {\n options.TokenValidationParameters = new TokenValidationParameters\n {\n ValidateIssuer = true,\n ValidateAudience = true,\n ValidateLifetime = true,\n ValidIssuer = tokenOptions.Issuer,\n ValidAudience = tokenOptions.Audience,\n ValidateIssuerSigningKey = true,\n IssuerSigningKey = SecurityKeyHelper.CreateSecurityKey(tokenOptions.SecurityKey)\n };\n });\n\n",
326341
" opt.AddSecurityDefinition(\n name: \"Bearer\",\n securityScheme: new OpenApiSecurityScheme\n {\n Name = \"Authorization\",\n Type = SecuritySchemeType.Http,\n Scheme = \"Bearer\",\n BearerFormat = \"JWT\",\n In = ParameterLocation.Header,\n Description =\n \"JWT Authorization header using the Bearer scheme. Example: \\\"Authorization: Bearer YOUR_TOKEN\\\". \\r\\n\\r\\n\"\n + \"`Enter your token in the text input below.`\"\n }\n );\n opt.OperationFilter<BearerSecurityRequirementOperationFilter>();\n",
327342
"app.UseAuthentication();\n",
328343
"app.UseAuthorization();\n"
329344
}
330345
);
346+
await FileHelper.RemoveContentAsync(
347+
filePath: $"{projectSourcePath}/WebAPI/WebAPI.csproj",
348+
contents: new[] { "<PackageReference Include=\"NArchitecture.Core.Security.WebApi.Swagger\" Version=\"1.0.0\" />;", }
349+
);
331350
}
332351

333352
private async Task initializeGitRepository(string projectName)

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.0.2</Version>
20+
<Version>1.1.0</Version>
2121
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2222
<PackageReadmeFile>README.md</PackageReadmeFile>
2323
</PropertyGroup>

0 commit comments

Comments
 (0)