-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7940 from abpframework/issue/5689
ABP CLI microservice creation should edit tye.yml according to ui type
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemoveProjectFromTyeStep.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters