Skip to content

Commit

Permalink
Merge pull request #7940 from abpframework/issue/5689
Browse files Browse the repository at this point in the history
ABP CLI microservice creation should edit tye.yml according to ui type
  • Loading branch information
hikalkan committed Mar 5, 2021
2 parents 00a22cb + 003eca0 commit 829b566
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
{
public class RemoveProjectFromTyeStep : ProjectBuildPipelineStep
{
private readonly string _name;

public RemoveProjectFromTyeStep(string name)
{
_name = name;
}

public override void Execute(ProjectBuildContext context)
{
var tyeFile = context.Files.FirstOrDefault(f => f.Name == "/tye.yaml");

if (tyeFile == null)
{
return;
}

var lines = tyeFile.GetLines();
var newLines = new List<string>();

var nameLine = $"- name:";
var isOneOfTargetLines = false;

foreach (var line in lines)
{
if (line.Equals($"{nameLine} {_name}"))
{
isOneOfTargetLines = true;
continue;
}

if (line.StartsWith(nameLine))
{
isOneOfTargetLines = false;
}

if (!isOneOfTargetLines)
{
newLines.Add(line);
}
}

tyeFile.SetContent(String.Join(Environment.NewLine, newLines));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,43 @@ private static void DeleteUnrelatedProjects(ProjectBuildContext context, List<Pr
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web",null,
"/applications/web/src/MyCompanyName.MyProjectName.Web"));
steps.Add(new RemoveFolderStep("/applications/web"));
steps.Add(new RemoveProjectFromTyeStep("web"));

steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Blazor",null,
"/applications/blazor/src/MyCompanyName.MyProjectName.Blazor"));
steps.Add(new RemoveFolderStep("/applications/blazor"));
steps.Add(new RemoveProjectFromTyeStep("blazor"));

steps.Add(new RemoveFolderStep("/angular"));
break;

case UiFramework.Angular:
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web",null,
"/applications/web/src/MyCompanyName.MyProjectName.Web"));
steps.Add(new RemoveFolderStep("/applications/web"));
steps.Add(new RemoveProjectFromTyeStep("web"));

steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Blazor",null,
"/applications/blazor/src/MyCompanyName.MyProjectName.Blazor"));
steps.Add(new RemoveFolderStep("/applications/blazor"));
steps.Add(new RemoveProjectFromTyeStep("blazor"));
break;

case UiFramework.Blazor:
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web",null,
"/applications/web/src/MyCompanyName.MyProjectName.Web"));
steps.Add(new RemoveFolderStep("/applications/web"));
steps.Add(new RemoveFolderStep("/angular"));
steps.Add(new RemoveProjectFromTyeStep("web"));
break;

case UiFramework.Mvc:
case UiFramework.NotSpecified:
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Blazor",null,
"/applications/blazor/src/MyCompanyName.MyProjectName.Blazor"));
steps.Add(new RemoveFolderStep("/applications/blazor"));
steps.Add(new RemoveProjectFromTyeStep("blazor"));

steps.Add(new RemoveFolderStep("/angular"));
break;
}
Expand Down

0 comments on commit 829b566

Please sign in to comment.