Add `theme` option to CLI

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

@ -93,6 +93,12 @@ public abstract class ProjectCreationCommandBase
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);
if (publicWebSite)
{
@ -134,7 +140,6 @@ public abstract class ProjectCreationCommandBase
if (MicroserviceServiceTemplateBase.IsMicroserviceServiceTemplate(template))
{
var slnFile = Directory.GetFiles(outputFolderRoot, "*.sln").FirstOrDefault();
if (slnFile == null)
{
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,
commandLineArgs.Options,
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 Template
@ -551,5 +572,10 @@ public abstract class ProjectCreationCommandBase
{
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 Theme? Theme { get; set; }
[NotNull]
public Dictionary<string, string> ExtraProperties { get; set; }
@ -60,7 +62,8 @@ public class ProjectBuildArgs
[CanBeNull] string templateSource = null,
Dictionary<string, string> extraProperties = null,
[CanBeNull] string connectionString = null,
bool pwa = false)
bool pwa = false,
Theme? theme = null)
{
SolutionName = Check.NotNull(solutionName, nameof(solutionName));
TemplateName = templateName;
@ -77,5 +80,6 @@ public class ProjectBuildArgs
ExtraProperties = extraProperties ?? new Dictionary<string, string>();
ConnectionString = connectionString;
Pwa = pwa;
Theme = theme;
}
}

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

@ -33,6 +33,7 @@ public abstract class AppTemplateBase : TemplateInfo
RemoveMigrations(context, steps);
ConfigureTieredArchitecture(context, steps);
ConfigurePublicWebSite(context, steps);
ConfigureTheme(context);
RemoveUnnecessaryPorts(context, steps);
RandomizeSslPorts(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)
{
if (!context.BuildArgs.PublicWebSite)

@ -18,6 +18,9 @@
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<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>
@ -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.Authentication.OpenIdConnect\Volo.Abp.AspNetCore.Authentication.OpenIdConnect.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" />
<!--</TEMPLATE-REMOVE>-->
<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.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.Bootstrap;
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.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.Toolbars;
using Volo.Abp.AspNetCore.Serilog;
@ -50,7 +56,12 @@ namespace MyCompanyName.MyProjectName.Web;
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpHttpClientWebModule),
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
//</TEMPLATE-REMOVE>
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpSettingManagementWebModule),
@ -94,6 +105,19 @@ public class MyProjectNameWebModule : AbpModule
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 =>
{
options.StyleBundles.Configure(
@ -104,6 +128,7 @@ public class MyProjectNameWebModule : AbpModule
}
);
});
//</TEMPLATE-REMOVE>
}
private void ConfigureCache()

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

@ -33,13 +33,18 @@
<ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="5.0.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>
<ProjectReference Include="..\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj" />
<ProjectReference Include="..\MyCompanyName.MyProjectName.HttpApi\MyCompanyName.MyProjectName.HttpApi.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" />
<!--</TEMPLATE-REMOVE>-->
<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.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.Bundling;
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.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.Serilog;
using Volo.Abp.Autofac;
@ -47,7 +53,12 @@ namespace MyCompanyName.MyProjectName.Web;
typeof(AbpIdentityWebModule),
typeof(AbpSettingManagementWebModule),
typeof(AbpAccountWebModule),
//<TEMPLATE-REMOVE IF-NOT='BASIC'>
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
//</TEMPLATE-REMOVE>
//<TEMPLATE-REMOVE IF-NOT='LEPTONX-LITE'>
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
//</TEMPLATE-REMOVE>
typeof(AbpTenantManagementWebModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
@ -96,6 +107,17 @@ public class MyProjectNameWebModule : AbpModule
{
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(
BasicThemeBundles.Styles.Global,
bundle =>
@ -103,6 +125,7 @@ public class MyProjectNameWebModule : AbpModule
bundle.AddFiles("/global-styles.css");
}
);
//</TEMPLATE-REMOVE>
});
}

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

Loading…
Cancel
Save