Add `theme` option to CLI

pull/12938/head
Engincan VESKE 3 years ago
parent bd8bfa4b51
commit d07f01e81a

@ -49,10 +49,10 @@ public class CliService : ITransientDependency
var commandLineArgs = CommandLineArgumentParser.Parse(args); var commandLineArgs = CommandLineArgumentParser.Parse(args);
#if !DEBUG #if !DEBUG
if (!commandLineArgs.Options.ContainsKey("skip-cli-version-check")) if (!commandLineArgs.Options.ContainsKey("skip-cli-version-check"))
{ {
await CheckCliVersionAsync(); await CheckCliVersionAsync();
} }
#endif #endif
try try
{ {

@ -93,6 +93,12 @@ public abstract class ProjectCreationCommandBase
Logger.LogInformation("UI Framework: " + uiFramework); Logger.LogInformation("UI Framework: " + uiFramework);
} }
var theme = uiFramework == UiFramework.None ? (Theme?)null : GetTheme(commandLineArgs);
if (theme.HasValue)
{
Logger.LogInformation("Theme: " + theme);
}
var publicWebSite = uiFramework != UiFramework.None && commandLineArgs.Options.ContainsKey(Options.PublicWebSite.Long); var publicWebSite = uiFramework != UiFramework.None && commandLineArgs.Options.ContainsKey(Options.PublicWebSite.Long);
if (publicWebSite) if (publicWebSite)
{ {
@ -134,7 +140,6 @@ public abstract class ProjectCreationCommandBase
if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(template)) if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(template))
{ {
var slnFile = Directory.GetFiles(outputFolderRoot, "*.sln").FirstOrDefault(); var slnFile = Directory.GetFiles(outputFolderRoot, "*.sln").FirstOrDefault();
if (slnFile == null) if (slnFile == null)
{ {
throw new CliUsageException("This command should be run inside a folder that contains a microservice solution!"); throw new CliUsageException("This command should be run inside a folder that contains a microservice solution!");
@ -184,7 +189,8 @@ public abstract class ProjectCreationCommandBase
templateSource, templateSource,
commandLineArgs.Options, commandLineArgs.Options,
connectionString, connectionString,
pwa pwa,
theme
); );
} }
@ -460,6 +466,21 @@ public abstract class ProjectCreationCommandBase
} }
} }
protected virtual Theme GetTheme(CommandLineArgs commandLineArgs)
{
var optionValue = commandLineArgs.Options.GetOrNull(Options.Theme.Long);
switch (optionValue)
{
case null:
case "leptonx-lite":
return Theme.LeptonXLite;
case "basic":
return Theme.Basic;
default:
throw new CliUsageException("The option you provided for Theme is invalid!");
}
}
public static class Options public static class Options
{ {
public static class Template public static class Template
@ -551,5 +572,10 @@ public abstract class ProjectCreationCommandBase
{ {
public const string Short = "pwa"; public const string Short = "pwa";
} }
public static class Theme
{
public const string Long = "theme";
}
} }
} }

@ -0,0 +1,7 @@
namespace Volo.Abp.Cli.ProjectBuilding.Building;
public enum Theme
{
LeptonXLite = 0,
Basic = 1
}

@ -42,6 +42,8 @@ public class ProjectBuildArgs
public bool Pwa { get; set; } public bool Pwa { get; set; }
public Theme? Theme { get; set; }
[NotNull] [NotNull]
public Dictionary<string, string> ExtraProperties { get; set; } public Dictionary<string, string> ExtraProperties { get; set; }
@ -60,7 +62,8 @@ public class ProjectBuildArgs
[CanBeNull] string templateSource = null, [CanBeNull] string templateSource = null,
Dictionary<string, string> extraProperties = null, Dictionary<string, string> extraProperties = null,
[CanBeNull] string connectionString = null, [CanBeNull] string connectionString = null,
bool pwa = false) bool pwa = false,
Theme? theme = null)
{ {
SolutionName = Check.NotNull(solutionName, nameof(solutionName)); SolutionName = Check.NotNull(solutionName, nameof(solutionName));
TemplateName = templateName; TemplateName = templateName;
@ -77,5 +80,6 @@ public class ProjectBuildArgs
ExtraProperties = extraProperties ?? new Dictionary<string, string>(); ExtraProperties = extraProperties ?? new Dictionary<string, string>();
ConnectionString = connectionString; ConnectionString = connectionString;
Pwa = pwa; Pwa = pwa;
Theme = theme;
} }
} }

@ -87,6 +87,7 @@ public abstract class AppNoLayersTemplateBase : AppTemplateBase
UpdateNuGetConfig(context, steps); UpdateNuGetConfig(context, steps);
ChangeConnectionString(context, steps); ChangeConnectionString(context, steps);
ConfigureDockerFiles(context, steps); ConfigureDockerFiles(context, steps);
ConfigureTheme(context);
if (context.BuildArgs.UiFramework != UiFramework.Angular) if (context.BuildArgs.UiFramework != UiFramework.Angular)
{ {

@ -33,6 +33,7 @@ public abstract class AppTemplateBase : TemplateInfo
RemoveMigrations(context, steps); RemoveMigrations(context, steps);
ConfigureTieredArchitecture(context, steps); ConfigureTieredArchitecture(context, steps);
ConfigurePublicWebSite(context, steps); ConfigurePublicWebSite(context, steps);
ConfigureTheme(context);
RemoveUnnecessaryPorts(context, steps); RemoveUnnecessaryPorts(context, steps);
RandomizeSslPorts(context, steps); RandomizeSslPorts(context, steps);
RandomizeStringEncryption(context, steps); RandomizeStringEncryption(context, steps);
@ -176,6 +177,22 @@ public abstract class AppTemplateBase : TemplateInfo
} }
} }
protected void ConfigureTheme(ProjectBuildContext context)
{
if (context.BuildArgs.Theme.HasValue)
{
if (context.BuildArgs.Theme == Theme.LeptonXLite)
{
context.Symbols.Add("LEPTONX-LITE");
}
if (context.BuildArgs.Theme == Theme.Basic)
{
context.Symbols.Add("BASIC");
}
}
}
protected void ConfigurePublicWebSite(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps) protected void ConfigurePublicWebSite(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps)
{ {
if (!context.BuildArgs.PublicWebSite) if (!context.BuildArgs.PublicWebSite)

@ -20,11 +20,11 @@ public class Program
.MinimumLevel.Override("System.Net.Http.HttpClient", LogEventLevel.Warning) .MinimumLevel.Override("System.Net.Http.HttpClient", LogEventLevel.Warning)
.MinimumLevel.Override("Volo.Abp.IdentityModel", LogEventLevel.Information) .MinimumLevel.Override("Volo.Abp.IdentityModel", LogEventLevel.Information)
#if DEBUG #if DEBUG
.MinimumLevel.Override("Volo.Abp.Cli", LogEventLevel.Debug) .MinimumLevel.Override("Volo.Abp.Cli", LogEventLevel.Debug)
#else #else
.MinimumLevel.Override("Volo.Abp.Cli", LogEventLevel.Information) .MinimumLevel.Override("Volo.Abp.Cli", LogEventLevel.Information)
#endif #endif
.Enrich.FromLogContext() .Enrich.FromLogContext()
.WriteTo.File(Path.Combine(CliPaths.Log, "abp-cli-logs.txt")) .WriteTo.File(Path.Combine(CliPaths.Log, "abp-cli-logs.txt"))
.WriteTo.Console() .WriteTo.Console()
.CreateLogger(); .CreateLogger();

@ -18,6 +18,9 @@
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.5" /> <PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.5" />
<!--<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>-->
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="1.0.0-beta.2" />
<!--</TEMPLATE-REMOVE>-->
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -26,7 +29,9 @@
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.Client\Volo.Abp.AspNetCore.Mvc.Client.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.Client\Volo.Abp.AspNetCore.Mvc.Client.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Authentication.OpenIdConnect\Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Authentication.OpenIdConnect\Volo.Abp.AspNetCore.Authentication.OpenIdConnect.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.Web\Volo.Abp.Http.Client.Web.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.Web\Volo.Abp.Http.Client.Web.csproj" />
<!--<TEMPLATE-REMOVE IF-NOT='BASIC'>-->
<ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<!--</TEMPLATE-REMOVE>-->
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Serilog\Volo.Abp.AspNetCore.Serilog.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Serilog\Volo.Abp.AspNetCore.Serilog.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel.Web\Volo.Abp.Http.Client.IdentityModel.Web.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel.Web\Volo.Abp.Http.Client.IdentityModel.Web.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" />

@ -19,8 +19,14 @@ using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI; using Volo.Abp.AspNetCore.Mvc.UI;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling;
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling;
//</TEMPLATE-REMOVE>
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.AspNetCore.Serilog;
@ -50,7 +56,12 @@ namespace MyCompanyName.MyProjectName.Web;
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule), typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpAspNetCoreMvcClientModule), typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpHttpClientWebModule), typeof(AbpHttpClientWebModule),
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule),
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
//</TEMPLATE-REMOVE>
typeof(AbpAutofacModule), typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule), typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpSettingManagementWebModule), typeof(AbpSettingManagementWebModule),
@ -94,6 +105,19 @@ public class MyProjectNameWebModule : AbpModule
private void ConfigureBundles() private void ConfigureBundles()
{ {
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
Configure<AbpBundlingOptions>(options =>
{
options.StyleBundles.Configure(
LeptonXLiteThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
});
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
Configure<AbpBundlingOptions>(options => Configure<AbpBundlingOptions>(options =>
{ {
options.StyleBundles.Configure( options.StyleBundles.Configure(
@ -104,6 +128,7 @@ public class MyProjectNameWebModule : AbpModule
} }
); );
}); });
//</TEMPLATE-REMOVE>
} }
private void ConfigureCache() private void ConfigureCache()

@ -3,6 +3,8 @@
"name": "my-app", "name": "my-app",
"private": true, "private": true,
"dependencies": { "dependencies": {
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
"@abp/aspnetcore.mvc.ui.theme.basic": "^5.3.0-rc.3" "@abp/aspnetcore.mvc.ui.theme.basic": "^5.3.0-rc.3"
//</TEMPLATE-REMOVE>
} }
} }

@ -33,13 +33,18 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" /> <PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" /> <PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<!--<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>-->
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="1.0.0-beta.2" />
<!--</TEMPLATE-REMOVE>-->
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\MyCompanyName.MyProjectName.EntityFrameworkCore\MyCompanyName.MyProjectName.EntityFrameworkCore.csproj" />
<!--<TEMPLATE-REMOVE IF-NOT='BASIC'>-->
<ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" /> <ProjectReference Include="..\..\..\..\..\modules\basic-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic\Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.csproj" />
<!--</TEMPLATE-REMOVE>-->
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Swashbuckle\Volo.Abp.Swashbuckle.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Serilog\Volo.Abp.AspNetCore.Serilog.csproj" /> <ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.AspNetCore.Serilog\Volo.Abp.AspNetCore.Serilog.csproj" />

@ -18,8 +18,14 @@ using Volo.Abp.AspNetCore.Mvc.UI;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy;
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling;
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling;
//</TEMPLATE-REMOVE>
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
@ -47,7 +53,12 @@ namespace MyCompanyName.MyProjectName.Web;
typeof(AbpIdentityWebModule), typeof(AbpIdentityWebModule),
typeof(AbpSettingManagementWebModule), typeof(AbpSettingManagementWebModule),
typeof(AbpAccountWebModule), typeof(AbpAccountWebModule),
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
typeof(AbpAspNetCoreMvcUiBasicThemeModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule),
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
//</TEMPLATE-REMOVE>
typeof(AbpTenantManagementWebModule), typeof(AbpTenantManagementWebModule),
typeof(AbpAspNetCoreSerilogModule), typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule) typeof(AbpSwashbuckleModule)
@ -96,6 +107,17 @@ public class MyProjectNameWebModule : AbpModule
{ {
Configure<AbpBundlingOptions>(options => Configure<AbpBundlingOptions>(options =>
{ {
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
options.StyleBundles.Configure(
LeptonXLiteThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
options.StyleBundles.Configure( options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global, BasicThemeBundles.Styles.Global,
bundle => bundle =>
@ -103,6 +125,7 @@ public class MyProjectNameWebModule : AbpModule
bundle.AddFiles("/global-styles.css"); bundle.AddFiles("/global-styles.css");
} }
); );
//</TEMPLATE-REMOVE>
}); });
} }

@ -3,6 +3,8 @@
"name": "my-app", "name": "my-app",
"private": true, "private": true,
"dependencies": { "dependencies": {
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
"@abp/aspnetcore.mvc.ui.theme.basic": "^5.3.0-rc.3" "@abp/aspnetcore.mvc.ui.theme.basic": "^5.3.0-rc.3"
//</TEMPLATE-REMOVE>
} }
} }

Loading…
Cancel
Save