mirror of https://github.com/abpframework/abp.git
6 changed files with 132 additions and 52 deletions
@ -0,0 +1,68 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps; |
||||
|
|
||||
|
//TODO: Remove this step and move it to the ChangeThemeStep.cs?
|
||||
|
public class ChangeThemeStyleStep : ProjectBuildPipelineStep |
||||
|
{ |
||||
|
public override void Execute(ProjectBuildContext context) |
||||
|
{ |
||||
|
if (!context.BuildArgs.Theme.HasValue || context.BuildArgs.Theme != Theme.LeptonX) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
switch (context.BuildArgs.ThemeStyle) |
||||
|
{ |
||||
|
case ThemeStyle.Light: |
||||
|
ChangeThemeStyle(context, themeStyleName: "Light"); |
||||
|
break; |
||||
|
case ThemeStyle.Dark: |
||||
|
ChangeThemeStyle(context, themeStyleName: "Dark"); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ChangeThemeStyle(ProjectBuildContext context, string themeStyleName) |
||||
|
{ |
||||
|
var defaultThemeStyleName = "LeptonXStyleNames.Dim"; |
||||
|
var newThemeStyleName = $"LeptonXStyleNames.{themeStyleName}"; |
||||
|
|
||||
|
var filePaths = new List<string> |
||||
|
{ |
||||
|
"/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs", |
||||
|
"/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs", |
||||
|
"/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs", |
||||
|
"/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs", |
||||
|
"/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs", |
||||
|
"/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/MyProjectNameAuthServerModule.cs" |
||||
|
}; |
||||
|
|
||||
|
foreach(var filePath in filePaths) |
||||
|
{ |
||||
|
ReplaceThemeStyleName(context, filePath, defaultThemeStyleName, newThemeStyleName); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected void ReplaceThemeStyleName(ProjectBuildContext context, string filePath, string oldThemeStyleName, string newThemeStyleName) |
||||
|
{ |
||||
|
var file = context.FindFile(filePath); |
||||
|
if (file == null) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
file.NormalizeLineEndings(); |
||||
|
|
||||
|
var lines = file.GetLines(); |
||||
|
for (var i = 0; i < lines.Length; i++) |
||||
|
{ |
||||
|
if (lines[i].Contains(oldThemeStyleName)) |
||||
|
{ |
||||
|
lines[i] = lines[i].Replace(oldThemeStyleName, newThemeStyleName); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
file.SetLines(lines); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Building; |
||||
|
public enum ThemeStyle : byte |
||||
|
{ |
||||
|
NotSpecified = 0, |
||||
|
Dim = 1, |
||||
|
Light = 2, |
||||
|
Dark = 3 |
||||
|
} |
||||
@ -1,30 +1,6 @@ |
|||||
using System; |
|
||||
using System.Text; |
|
||||
|
|
||||
namespace Volo.Abp.Cli.Utils; |
namespace Volo.Abp.Cli.Utils; |
||||
|
|
||||
public static class ExceptionMessageHelper |
public static class ExceptionMessageHelper |
||||
{ |
{ |
||||
public static string GetInvalidArgExceptionMessage(string args) |
public static string GetInvalidOptionExceptionMessage(string optionName) => $"The option you provided for {optionName} is invalid!"; |
||||
{ |
|
||||
Check.NotNullOrEmpty(args, nameof(args), minLength: 2); |
|
||||
|
|
||||
var exceptionMessageBuilder = new StringBuilder(); |
|
||||
exceptionMessageBuilder.Append("The option you provided for "); |
|
||||
if (args.Contains(" ")) |
|
||||
{ |
|
||||
foreach (var arg in args.Split(' ')) |
|
||||
{ |
|
||||
exceptionMessageBuilder.Append(arg.ToPascalCase()); |
|
||||
} |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
exceptionMessageBuilder.Append(args.ToPascalCase()); |
|
||||
} |
|
||||
|
|
||||
exceptionMessageBuilder.Append(" is invalid!"); |
|
||||
|
|
||||
return exceptionMessageBuilder.ToString(); |
|
||||
} |
|
||||
} |
} |
||||
Loading…
Reference in new issue