From 5fd97a9d9d34f37a9a4e946232f9936957b61b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20T=C3=BCken?= Date: Wed, 23 Oct 2019 14:48:11 +0300 Subject: [PATCH 1/2] Cli create app template without ui. --- .../Volo/Abp/Cli/Commands/NewCommand.cs | 2 + .../ProjectBuilding/Building/UiFramework.cs | 5 +- .../Building/UiFrameworkExtensions.cs | 1 + .../Templates/App/AppTemplateBase.cs | 85 +++++++++++-------- 4 files changed, 55 insertions(+), 38 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs index e30ed7a77f..43e413c5b6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs @@ -199,6 +199,8 @@ namespace Volo.Abp.Cli.Commands var optionValue = commandLineArgs.Options.GetOrNull(Options.UiFramework.Short, Options.UiFramework.Long); switch (optionValue) { + case "none": + return UiFramework.None; case "mvc": return UiFramework.Mvc; case "angular": diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs index eab34d141b..1ea2760b1c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFramework.cs @@ -3,7 +3,8 @@ public enum UiFramework { NotSpecified = 0, - Mvc = 1, - Angular = 2 + None = 1, + Mvc = 2, + Angular = 3 } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs index 09eb0c474c..9161c9c63e 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/UiFrameworkExtensions.cs @@ -6,6 +6,7 @@ { switch (uiFramework) { + case UiFramework.None: return "none"; case UiFramework.Mvc: return "mvc"; case UiFramework.Angular: return "angular"; case UiFramework.NotSpecified: return "NotSpecified"; diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs index 8278a29b81..2774cbbaa0 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Volo.Abp.Cli.ProjectBuilding.Building; using Volo.Abp.Cli.ProjectBuilding.Building.Steps; @@ -52,50 +53,62 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App } } - private void DeleteUnrelatedProjects(ProjectBuildContext context, List steps) + private static void DeleteUnrelatedProjects(ProjectBuildContext context, List steps) { - if (context.BuildArgs.UiFramework == UiFramework.Mvc) + switch (context.BuildArgs.UiFramework) { - if (context.BuildArgs.ExtraProperties.ContainsKey("tiered")) - { - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); - steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.Web.Host", "MyCompanyName.MyProjectName.Web")); - } - else - { - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); - steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44303")); - } + case UiFramework.None: + case UiFramework.Angular: + ConfigureHosts(context, steps); + break; + case UiFramework.Mvc: + case UiFramework.NotSpecified: + ConfigureMvcUi(context, steps); + break; + } - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); + if (context.BuildArgs.UiFramework != UiFramework.Angular) + { + steps.Add(new RemoveFolderStep("/angular")); } + } - if (context.BuildArgs.UiFramework != UiFramework.Mvc) + private static void ConfigureMvcUi(ProjectBuildContext context, List steps) + { + if (context.BuildArgs.ExtraProperties.ContainsKey("tiered")) { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); - - if (context.BuildArgs.ExtraProperties.ContainsKey("separate-identity-server")) - { - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); - steps.Add(new AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep()); - } - else - { - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); - steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); - steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds", "MyCompanyName.MyProjectName.HttpApi.Host")); - steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44305")); - } + steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.Web.Host", "MyCompanyName.MyProjectName.Web")); + } + else + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); + steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44303")); } - if (context.BuildArgs.UiFramework != UiFramework.Angular) + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); + } + + private static void ConfigureHosts(ProjectBuildContext context, List steps) + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); + + if (context.BuildArgs.ExtraProperties.ContainsKey("separate-identity-server")) { - steps.Add(new RemoveFolderStep("/angular")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); + steps.Add(new AngularEnvironmentFilePortChangeForSeparatedIdentityServersStep()); + } + else + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); + steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds", "MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44305")); } } @@ -114,12 +127,12 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App ); } - private void UpdateNuGetConfig(ProjectBuildContext context, List steps) + private static void UpdateNuGetConfig(ProjectBuildContext context, List steps) { steps.Add(new UpdateNuGetConfigStep("/aspnet-core/NuGet.Config")); } - private void CleanupFolderHierarchy(ProjectBuildContext context, List steps) + private static void CleanupFolderHierarchy(ProjectBuildContext context, List steps) { if (context.BuildArgs.UiFramework == UiFramework.Mvc) { From 46faea99aaf66a9657a89d3af6bb00708a652503 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 13 Nov 2019 14:38:46 +0800 Subject: [PATCH 2/2] Independently configure UI & update cli documents. --- docs/en/CLI.md | 2 ++ docs/zh-Hans/CLI.md | 20 ++++++------ .../Templates/App/AppTemplateBase.cs | 31 ++++++++++++++++--- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/docs/en/CLI.md b/docs/en/CLI.md index 06df019f78..57bda25004 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -46,6 +46,8 @@ abp new Acme.BookStore * `--tiered`: Creates a tiered solution where Web and Http API layers are physically separated. If not specified, it creates a layered solution which is less complex and suitable for most scenarios. * `angular`: Angular. There are some additional options for this template: * `--separate-identity-server`: Separates the identity server application from the API host application. If not specified, you will have a single endpoint in the server side. + * `none`: Without UI. There are some additional options for this template: + * `--separate-identity-server`: Separates the identity server application from the API host application. If not specified, you will have a single endpoint in the server side. * `--database-provider` or `-d`: Specifies the database provider. Default provider is `ef`. Available providers: * `ef`: Entity Framework Core. * `mongodb`: MongoDB. diff --git a/docs/zh-Hans/CLI.md b/docs/zh-Hans/CLI.md index 767d971b28..f5f230d9f2 100644 --- a/docs/zh-Hans/CLI.md +++ b/docs/zh-Hans/CLI.md @@ -40,19 +40,21 @@ abp new Acme.BookStore #### Options * `--template` 或者 `-t`: 指定模板. 默认的模板是 `app`,会生成web项目.可用的模板有: - * `app` (default): [应用程序模板](Startup-Templates/Application.md)。 其他选项: - * `--ui` 或者 `-u`: 指定ui框架。默认`mvc`框架。其他选项: - * `mvc`: ASP.NET Core MVC。此模板的其他选项: - * `--tiered`: 创建分层解决方案,Web和Http Api层在物理上是分开的。如果未指定会创建一个分层的解决方案,此解决方案没有那么复杂,适合大多数场景。 + * `app` (default): [应用程序模板](Startup-Templates/Application.md). 其他选项: + * `--ui` 或者 `-u`: 指定ui框架.默认`mvc`框架.其他选项: + * `mvc`: ASP.NET Core MVC.此模板的其他选项: + * `--tiered`: 创建分层解决方案,Web和Http Api层在物理上是分开的.如果未指定会创建一个分层的解决方案,此解决方案没有那么复杂,适合大多数场景. * `angular`: Angular. 这个模板还有一些额外的选项: - * `--separate-identity-server`: Separates the identity server application from the API host application. If not specified, you will have a single endpoint in the server side. - * `--database-provider` 或者 `-d`: 指定数据库提供程序。默认是 `ef`。其他选项: + * `--separate-identity-server`: 将Identity Server应用程序与API host应用程序分开. 如果未指定,则服务器端将只有一个端点. + * `none`: 无UI. 这个模板还有一些额外的选项: + * `--separate-identity-server`: 将Identity Server应用程序与API host应用程序分开. 如果未指定,则服务器端将只有一个端点. + * `--database-provider` 或者 `-d`: 指定数据库提供程序.默认是 `ef`.其他选项: * `ef`: Entity Framework Core. * `mongodb`: MongoDB. * `module`: [Module template](Startup-Templates/Module.md). 其他选项: - * `--no-ui`: 不包含UI。仅创建服务模块(也称为微服务 - 没有UI)。 -* `--output-folder` 或者 `-o`: 指定输出文件夹,默认是当前目录。 -* `--version` 或者 `-v`: 指定ABP和模板的版本。它可以是 [release tag](https://github.com/abpframework/abp/releases) 或者 [branch name](https://github.com/abpframework/abp/branches). 如果没有指定,则使用最新版本。大多数情况下,您会希望使用最新的版本。 + * `--no-ui`: 不包含UI.仅创建服务模块(也称为微服务 - 没有UI). +* `--output-folder` 或者 `-o`: 指定输出文件夹,默认是当前目录. +* `--version` 或者 `-v`: 指定ABP和模板的版本.它可以是 [release tag](https://github.com/abpframework/abp/releases) 或者 [branch name](https://github.com/abpframework/abp/branches). 如果没有指定,则使用最新版本.大多数情况下,您会希望使用最新的版本. ### add-package diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs index 2774cbbaa0..1ca4a7f287 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs @@ -58,12 +58,16 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App switch (context.BuildArgs.UiFramework) { case UiFramework.None: + ConfigureWithoutUi(context, steps); + break; + case UiFramework.Angular: - ConfigureHosts(context, steps); + ConfigureWithAngularUi(context, steps); break; + case UiFramework.Mvc: case UiFramework.NotSpecified: - ConfigureMvcUi(context, steps); + ConfigureWithMvcUi(context, steps); break; } @@ -73,7 +77,26 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App } } - private static void ConfigureMvcUi(ProjectBuildContext context, List steps) + private static void ConfigureWithoutUi(ProjectBuildContext context, List steps) + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests")); + + if (context.BuildArgs.ExtraProperties.ContainsKey("separate-identity-server")) + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); + } + else + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.IdentityServer")); + steps.Add(new AppTemplateProjectRenameStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds", "MyCompanyName.MyProjectName.HttpApi.Host")); + steps.Add(new AppTemplateChangeConsoleTestClientPortSettingsStep("44305")); + } + } + + private static void ConfigureWithMvcUi(ProjectBuildContext context, List steps) { if (context.BuildArgs.ExtraProperties.ContainsKey("tiered")) { @@ -92,7 +115,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.HttpApi.HostWithIds")); } - private static void ConfigureHosts(ProjectBuildContext context, List steps) + private static void ConfigureWithAngularUi(ProjectBuildContext context, List steps) { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Host"));