From ba1058553d408a3ef0b33eee88dacea2d4dc46a1 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 4 Dec 2023 15:50:41 +0800 Subject: [PATCH] Remove `AppTemplateRemoveMongodbCollectionFixtureStep`. --- .../Templates/App/AppTemplateBase.cs | 1 - ...plateRemoveMongodbCollectionFixtureStep.cs | 74 ------------------- 2 files changed, 75 deletions(-) delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateRemoveMongodbCollectionFixtureStep.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs index 90eceabb73..e434ebd822 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs @@ -107,7 +107,6 @@ public abstract class AppTemplateBase : TemplateInfo if (context.BuildArgs.DatabaseProvider != DatabaseProvider.MongoDb) { - steps.Add(new AppTemplateRemoveMongodbCollectionFixtureStep()); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests")); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateRemoveMongodbCollectionFixtureStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateRemoveMongodbCollectionFixtureStep.cs deleted file mode 100644 index ed290508a2..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateRemoveMongodbCollectionFixtureStep.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Volo.Abp.Cli.ProjectBuilding.Building; - -namespace Volo.Abp.Cli.ProjectBuilding.Templates.App; - -public class AppTemplateRemoveMongodbCollectionFixtureStep : ProjectBuildPipelineStep -{ - public override void Execute(ProjectBuildContext context) - { - if (context.Template.IsNoLayer()) - { - return; - } - - //MyCompanyName.MyProjectName.Application.Tests - RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs"); - RemoveKeyword(context, - "/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs", - "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); - - //MyCompanyName.MyProjectName.Domain.Tests - RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs"); - RemoveKeyword(context, - "/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs", - "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); - - //MyCompanyName.MyProjectName.EntityFrameworkCore.Tests - RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs"); - RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs"); - RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs"); - RemoveKeyword(context, - "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs", - "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); - - //MyCompanyName.MyProjectName.Web.Tests - RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs"); - RemoveKeyword(context, - "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs", - "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); - - //MyCompanyName.MyProjectName.TestBase - RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs"); - } - - private static void RemoveFile(ProjectBuildContext context, string targetModuleFilePath) - { - var file = context.Files.FirstOrDefault(x => x.Name == targetModuleFilePath); - if (file != null) - { - context.Files.Remove(file); - } - } - - private static void RemoveKeyword(ProjectBuildContext context, string targetModuleFilePath, string keyword) - { - var file = context.GetFile(targetModuleFilePath); - - file.NormalizeLineEndings(); - - var lines = file.GetLines(); - var newLines = new List(); - - for (var i = 0; i < lines.Length; i++) - { - if (!lines[i].Contains(keyword)) - { - newLines.Add(lines[i]); - } - } - - file.SetLines(newLines); - } -}