From e74ff061b45f966ada92d4e95712c660f8e0a80c Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 18 Apr 2019 17:50:23 +0300 Subject: [PATCH 01/10] Added solution builder code and created command parser --- framework/Volo.Abp.sln | 28 ++-- framework/src/Volo.Abp.Cli/Program.cs | 12 -- .../src/Volo.Abp.Cli/Volo.Abp.Cli.csproj | 12 ++ .../Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs | 13 ++ .../Volo/Abp/Cli/Args/CommandLineArgs.cs | 62 +++++++++ .../Abp/Cli/Args/CommandLineArgumentParser.cs | 104 +++++++++++++++ .../Volo/Abp/Cli/Args/CommandLineOptions.cs | 9 ++ .../Cli/Args/ICommandLineArgumentParser.cs | 7 + .../Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs | 29 ++++ .../Volo/Abp/Cli/Commands/CommandSelector.cs | 20 +++ .../Volo/Abp/Cli/Commands/ICommandSelector.cs | 7 + .../Volo/Abp/Cli/Commands/IConsoleCommand.cs | 9 ++ .../Volo/Abp/Cli/Commands/MainHelpCommand.cs | 23 ++++ .../Abp/Cli/Commands/NewProjectCommand.cs | 21 +++ .../src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs | 24 ++++ .../Building/DatabaseProvider.cs | 9 ++ .../Building/GithubRepositoryInfo.cs | 25 ++++ .../Building/ProjectBuildContext.cs | 29 ++++ .../Building/ProjectBuildContextExtensions.cs | 20 +++ .../Building/ProjectBuildPipeline.cs | 22 +++ .../Building/ProjectBuildPipelineBuilder.cs | 22 +++ .../Building/ProjectBuildPipelineStep.cs | 7 + .../Building/ProjectBuildRequest.cs | 23 ++++ .../Building/ProjectResult.cs | 7 + .../Steps/CreateProjectResultZipStep.cs | 23 ++++ .../Building/Steps/FileEntryListReadStep.cs | 58 ++++++++ .../Building/Steps/GithubDownloadStep.cs | 33 +++++ .../Steps/NugetReferenceReplaceStep.cs | 113 ++++++++++++++++ .../Steps/RemoveProjectFromSolutionStep.cs | 71 ++++++++++ .../Building/Steps/SolutionRenameStep.cs | 116 ++++++++++++++++ .../SwitchEntityFrameworkCoreToMongoDbStep.cs | 80 +++++++++++ .../Building/Steps/TemplateCodeDeleteStep.cs | 19 +++ .../Building/TemplateInfo.cs | 33 +++++ .../Abp/SolutionTemplating/DownloadInfo.cs | 37 +++++ .../Abp/SolutionTemplating/Files/FileEntry.cs | 126 ++++++++++++++++++ .../Files/FileEntryExtensions.cs | 81 +++++++++++ .../SolutionTemplating/Files/FileEntryList.cs | 13 ++ .../Files/FileEntryListExtensions.cs | 24 ++++ .../Github/GithubManager.cs | 94 +++++++++++++ .../Github/GithubRelease.cs | 21 +++ .../SolutionTemplating/SolutionBuildResult.cs | 15 +++ .../Abp/SolutionTemplating/SolutionBuilder.cs | 64 +++++++++ .../Abp/SolutionTemplating/SolutionName.cs | 50 +++++++ .../SolutionTemplating/StandardVersions.cs | 9 ++ .../Zipping/ZipFileExtensions.cs | 57 ++++++++ .../Volo/Abp/AbpApplicationBase.cs | 2 +- .../Volo.Abp.Cli.Tests.csproj | 15 +++ .../Volo/Abp/Cli/AbpCliTestBase.cs | 7 + .../Volo/Abp/Cli/AbpCliTestModule.cs | 13 ++ .../Cli/CommandLineArgumentParser_Tests.cs | 68 ++++++++++ 50 files changed, 1762 insertions(+), 24 deletions(-) delete mode 100644 framework/src/Volo.Abp.Cli/Program.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineOptions.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/DownloadInfo.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntry.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubManager.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuilder.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionName.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/StandardVersions.cs create mode 100644 framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs create mode 100644 framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj create mode 100644 framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestBase.cs create mode 100644 framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestModule.cs create mode 100644 framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index 10be5a757d..d63ef20752 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.156 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.168 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}" EndProject @@ -219,11 +218,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp", "src\Volo.Abp\Vo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.AspNetCore.Authentication.JwtBearer", "src\Volo.Abp.AspNetCore.Authentication.JwtBearer\Volo.Abp.AspNetCore.Authentication.JwtBearer.csproj", "{46C6336C-A1D8-4858-98CE-6F4C698C5A77}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Cli", "src\Volo.Abp.Cli\Volo.Abp.Cli.csproj", "{69168816-4394-4DDA-BB6B-C21983D37F0B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Cli", "src\Volo.Abp.Cli\Volo.Abp.Cli.csproj", "{69168816-4394-4DDA-BB6B-C21983D37F0B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.FluentValidation", "src\Volo.Abp.FluentValidation\Volo.Abp.FluentValidation.csproj", "{43D5FE61-ECBF-4B16-AD95-0043E18EB93A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.FluentValidation", "src\Volo.Abp.FluentValidation\Volo.Abp.FluentValidation.csproj", "{43D5FE61-ECBF-4B16-AD95-0043E18EB93A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.FluentValidation.Tests", "test\Volo.Abp.FluentValidation.Tests\Volo.Abp.FluentValidation.Tests.csproj", "{E9E1714F-7ED2-4BD1-BA4A-BA06E398288A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.FluentValidation.Tests", "test\Volo.Abp.FluentValidation.Tests\Volo.Abp.FluentValidation.Tests.csproj", "{E9E1714F-7ED2-4BD1-BA4A-BA06E398288A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Cli.Tests", "test\Volo.Abp.Cli.Tests\Volo.Abp.Cli.Tests.csproj", "{92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -655,6 +656,10 @@ Global {46C6336C-A1D8-4858-98CE-6F4C698C5A77}.Debug|Any CPU.Build.0 = Debug|Any CPU {46C6336C-A1D8-4858-98CE-6F4C698C5A77}.Release|Any CPU.ActiveCfg = Release|Any CPU {46C6336C-A1D8-4858-98CE-6F4C698C5A77}.Release|Any CPU.Build.0 = Release|Any CPU + {69168816-4394-4DDA-BB6B-C21983D37F0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69168816-4394-4DDA-BB6B-C21983D37F0B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69168816-4394-4DDA-BB6B-C21983D37F0B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69168816-4394-4DDA-BB6B-C21983D37F0B}.Release|Any CPU.Build.0 = Release|Any CPU {43D5FE61-ECBF-4B16-AD95-0043E18EB93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {43D5FE61-ECBF-4B16-AD95-0043E18EB93A}.Debug|Any CPU.Build.0 = Debug|Any CPU {43D5FE61-ECBF-4B16-AD95-0043E18EB93A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -663,10 +668,10 @@ Global {E9E1714F-7ED2-4BD1-BA4A-BA06E398288A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E9E1714F-7ED2-4BD1-BA4A-BA06E398288A}.Release|Any CPU.ActiveCfg = Release|Any CPU {E9E1714F-7ED2-4BD1-BA4A-BA06E398288A}.Release|Any CPU.Build.0 = Release|Any CPU - {69168816-4394-4DDA-BB6B-C21983D37F0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {69168816-4394-4DDA-BB6B-C21983D37F0B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69168816-4394-4DDA-BB6B-C21983D37F0B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {69168816-4394-4DDA-BB6B-C21983D37F0B}.Release|Any CPU.Build.0 = Release|Any CPU + {92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -778,9 +783,10 @@ Global {575BEFA1-19C2-49B1-8D31-B5D4472328DE} = {447C8A77-E5F0-4538-8687-7383196D04EA} {6C161F55-54B6-42A5-B177-3B0ED50323C1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {46C6336C-A1D8-4858-98CE-6F4C698C5A77} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {69168816-4394-4DDA-BB6B-C21983D37F0B} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {43D5FE61-ECBF-4B16-AD95-0043E18EB93A} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {E9E1714F-7ED2-4BD1-BA4A-BA06E398288A} = {447C8A77-E5F0-4538-8687-7383196D04EA} - {69168816-4394-4DDA-BB6B-C21983D37F0B} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF} = {447C8A77-E5F0-4538-8687-7383196D04EA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Cli/Program.cs b/framework/src/Volo.Abp.Cli/Program.cs deleted file mode 100644 index 5e9dcd4006..0000000000 --- a/framework/src/Volo.Abp.Cli/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Volo.Abp.Cli -{ - public class Program - { - private static void Main(string[] args) - { - Console.WriteLine("Welcome to ABP CLI..! This tool is in development. There is no functionality yet. So, bye bye... ;)"); - } - } -} diff --git a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj index 29b80cb98a..fb8b3b9e19 100644 --- a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj +++ b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj @@ -7,6 +7,18 @@ netcoreapp2.2 true abp + + + + + + + + + + + + diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs new file mode 100644 index 0000000000..0b891e1299 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Domain; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Cli +{ + [DependsOn( + typeof(AbpDddDomainModule) + )] + public class AbpCliModule : AbpModule + { + + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs new file mode 100644 index 0000000000..27108a76c4 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs @@ -0,0 +1,62 @@ +using System.Linq; +using System.Text; +using JetBrains.Annotations; +using Volo.Abp.Cli.Args; + +namespace Volo.Abp.Cli +{ + public class CommandLineArgs + { + [CanBeNull] + public string Command { get; } + + [CanBeNull] + public string Target { get; } + + [NotNull] + public CommandLineOptions Options { get; } + + public CommandLineArgs([CanBeNull] string command = null, [CanBeNull] string target = null) + { + Command = command; + Target = target; + Options = new CommandLineOptions(); + } + + public static CommandLineArgs Empty() + { + return new CommandLineArgs(); + } + + public override string ToString() + { + var sb = new StringBuilder(); + + if (Command != null) + { + sb.AppendLine($"Command: {Command}"); + } + + if (Target != null) + { + sb.AppendLine($"Target: {Target}"); + } + + if (Options.Any()) + { + sb.AppendLine("Options:"); + foreach (var option in Options) + { + sb.AppendLine($" - {option.Key} = {option.Value}"); + } + } + + if (sb.Length <= 0) + { + sb.Append(""); + } + + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs new file mode 100644 index 0000000000..7125699546 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Cli.Args +{ + public class CommandLineArgumentParser : ICommandLineArgumentParser, ITransientDependency + { + public CommandLineArgs Parse(string[] args) + { + if (args.IsNullOrEmpty()) + { + return CommandLineArgs.Empty(); + } + + var argumentList = args.ToList(); + + //Get command + + var command = argumentList[0]; + argumentList.RemoveAt(0); + + if (!argumentList.Any()) + { + return new CommandLineArgs(command); + } + + //Get target + + var target = argumentList[0]; + if (target.StartsWith("-")) + { + target = null; + } + else + { + argumentList.RemoveAt(0); + } + + if (!argumentList.Any()) + { + return new CommandLineArgs(command, target); + } + + //Get options + + var commandLineArgs = new CommandLineArgs(command, target); + + while (argumentList.Any()) + { + var optionName = ParseOptionName(argumentList[0]); + argumentList.RemoveAt(0); + + if (!argumentList.Any()) + { + commandLineArgs.Options[optionName] = null; + break; + } + + if (IsOptionName(argumentList[0])) + { + commandLineArgs.Options[optionName] = null; + continue; + } + + commandLineArgs.Options[optionName] = argumentList[0]; + argumentList.RemoveAt(0); + } + + return commandLineArgs; + } + + private static bool IsOptionName(string argument) + { + return argument.StartsWith("-") || argument.StartsWith("--"); + } + + private static string ParseOptionName(string argument) + { + if (argument.StartsWith("--")) + { + if (argument.Length <= 2) + { + throw new ArgumentException("Should specify an option name after '--' prefix!"); + } + + return argument.RemovePreFix("--"); + } + + if (argument.StartsWith("-")) + { + if (argument.Length <= 1) + { + throw new ArgumentException("Should specify an option name after '--' prefix!"); + } + + return argument.RemovePreFix("-"); + } + + throw new ArgumentException("Option names should start with '-' or '--'."); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineOptions.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineOptions.cs new file mode 100644 index 0000000000..93f23fdd76 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineOptions.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Volo.Abp.Cli.Args +{ + public class CommandLineOptions : Dictionary + { + + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs new file mode 100644 index 0000000000..c467541210 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Cli.Args +{ + public interface ICommandLineArgumentParser + { + CommandLineArgs Parse(string[] args); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs new file mode 100644 index 0000000000..6c51b0cd30 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs @@ -0,0 +1,29 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Cli.Args; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Cli +{ + public class CliService : ITransientDependency + { + protected ICommandLineArgumentParser CommandLineArgumentParser { get; } + protected ICommandSelector CommandSelector { get; } + + public CliService( + ICommandLineArgumentParser commandLineArgumentParser, + ICommandSelector commandSelector) + { + CommandLineArgumentParser = commandLineArgumentParser; + CommandSelector = commandSelector; + } + + public async Task RunAsync(string[] args) + { + var commandLineArgs = CommandLineArgumentParser.Parse(args); + var command = CommandSelector.Select(commandLineArgs); + await command.ExecuteAsync(); + Console.WriteLine(commandLineArgs); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs new file mode 100644 index 0000000000..c5d410f400 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs @@ -0,0 +1,20 @@ +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Cli +{ + public class CommandSelector : ICommandSelector, ITransientDependency + { + public IConsoleCommand Select(CommandLineArgs commandLineArgs) + { + //TODO: Create options to define commands + //TODO: Get from dependency injection instead of new? + + if (commandLineArgs.Command == "new") + { + return new NewProjectCommand(commandLineArgs); + } + + return new MainHelpCommand(commandLineArgs); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs new file mode 100644 index 0000000000..86d2f1d2f0 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Cli +{ + public interface ICommandSelector + { + IConsoleCommand Select(CommandLineArgs commandLineArgs); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs new file mode 100644 index 0000000000..a3e822a160 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.Cli +{ + public interface IConsoleCommand + { + Task ExecuteAsync(); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs new file mode 100644 index 0000000000..5bb1894229 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.Cli +{ + public class MainHelpCommand : IConsoleCommand + { + public MainHelpCommand(CommandLineArgs commandLineArgs) + { + + } + + public Task ExecuteAsync() + { + Console.WriteLine("*********** ABP CLI ****************"); + Console.WriteLine(); + Console.WriteLine("Usage:"); + Console.WriteLine(); + Console.WriteLine(" abp [options]"); + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs new file mode 100644 index 0000000000..5ef068e5ae --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace Volo.Abp.Cli +{ + public class NewProjectCommand : IConsoleCommand + { + protected CommandLineArgs CommandLineArgs { get; } + + public NewProjectCommand(CommandLineArgs commandLineArgs) + { + CommandLineArgs = commandLineArgs; + } + + public Task ExecuteAsync() + { + Console.WriteLine("TODO: Create new project"); + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs new file mode 100644 index 0000000000..c7f321a8e1 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Threading; + +namespace Volo.Abp.Cli +{ + public class Program + { + private static void Main(string[] args) + { + using (var application = AbpApplicationFactory.Create()) + { + application.Initialize(); + + AsyncHelper.RunSync( + () => application.ServiceProvider + .GetRequiredService() + .RunAsync(args) + ); + + application.Shutdown(); + } + } + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs new file mode 100644 index 0000000000..1e2e4efc00 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.SolutionTemplating.Building +{ + public enum DatabaseProvider : byte + { + Irrelevant = 0, + EntityFrameworkCore = 1, + MongoDb = 2 + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs new file mode 100644 index 0000000000..f9d8812076 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs @@ -0,0 +1,25 @@ +using System; + +namespace Volo.Abp.SolutionTemplating.Building +{ + public class GithubRepositoryInfo + { + public string RepositoryNameWithOrganization { get; } + + public string RepositoryName { get; } + + public string AccessToken { get; } + + public GithubRepositoryInfo(string repositoryNameWithOrganization, string accessToken) + { + if (!repositoryNameWithOrganization.Contains("/")) + { + throw new ApplicationException($"{nameof(repositoryNameWithOrganization)} '{repositoryNameWithOrganization}' is not valid! It should be formatted as 'organization-name/repository-name'." ); + } + + RepositoryNameWithOrganization = repositoryNameWithOrganization; + RepositoryName = repositoryNameWithOrganization.Split('/')[1]; + AccessToken = accessToken; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs new file mode 100644 index 0000000000..297e7f056f --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs @@ -0,0 +1,29 @@ +using JetBrains.Annotations; +using Volo.Abp.SolutionTemplating.Files; + +namespace Volo.Abp.SolutionTemplating.Building +{ + public class ProjectBuildContext + { + public ProjectBuildRequest Request { get; } + + public string TemplatesFolder { get; } + + public TemplateInfo Template { get; } + + public FileEntryList Files { get; set; } + + public ProjectResult Result { get; set; } + + public ProjectBuildContext( + [NotNull] TemplateInfo template, + ProjectBuildRequest request, + string templatesFolder) + { + Template = Check.NotNull(template, nameof(template)); + Request = request; + TemplatesFolder = templatesFolder; + Result = new ProjectResult(); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs new file mode 100644 index 0000000000..7178a24238 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; +using Volo.Abp.SolutionTemplating.Files; + +namespace Volo.Abp.SolutionTemplating.Building +{ + public static class ProjectBuildContextExtensions + { + public static FileEntry GetFile(this ProjectBuildContext context, string filePath) + { + var file = context.Files.FirstOrDefault(f => f.Name == filePath); + if (file == null) + { + throw new ApplicationException("Could not find file: " + filePath); + } + + return file; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs new file mode 100644 index 0000000000..3e2e617517 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace Volo.Abp.SolutionTemplating.Building +{ + public class ProjectBuildPipeline + { + public List Steps { get; } + + public ProjectBuildPipeline() + { + Steps = new List(); + } + + public void Execute(ProjectBuildContext context) + { + foreach (var step in Steps) + { + step.Execute(context); + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs new file mode 100644 index 0000000000..41d760e4df --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs @@ -0,0 +1,22 @@ +using Volo.Abp.SolutionTemplating.Building.Steps; + +namespace Volo.Abp.SolutionTemplating.Building +{ + public static class ProjectBuildPipelineBuilder + { + public static ProjectBuildPipeline Build(ProjectBuildContext context) + { + var pipeline = new ProjectBuildPipeline(); + + pipeline.Steps.Add(new GithubDownloadStep()); + pipeline.Steps.Add(new FileEntryListReadStep()); + pipeline.Steps.AddRange(context.Template.GetCustomSteps(context)); + pipeline.Steps.Add(new NugetReferenceReplaceStep()); + pipeline.Steps.Add(new TemplateCodeDeleteStep()); + pipeline.Steps.Add(new SolutionRenameStep()); + pipeline.Steps.Add(new CreateProjectResultZipStep()); + + return pipeline; + } + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs new file mode 100644 index 0000000000..d6ec90325f --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.SolutionTemplating.Building +{ + public abstract class ProjectBuildPipelineStep + { + public abstract void Execute(ProjectBuildContext context); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs new file mode 100644 index 0000000000..4f4bec11b8 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs @@ -0,0 +1,23 @@ +namespace Volo.Abp.SolutionTemplating.Building +{ + public class ProjectBuildRequest + { + public SolutionName SolutionName { get; } + + public DatabaseProvider DatabaseProvider { get; } + + public string Version { get; } + + public bool ReplaceLocalReferencesToNuget { get; set; } + + public ProjectBuildRequest( + SolutionName solutionName, + DatabaseProvider databaseProvider, + string version) + { + SolutionName = solutionName; + DatabaseProvider = databaseProvider; + Version = version; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs new file mode 100644 index 0000000000..3afc3e1a17 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.SolutionTemplating.Building +{ + public class ProjectResult + { + public byte[] ZipContent { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs new file mode 100644 index 0000000000..88f2558e58 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs @@ -0,0 +1,23 @@ +using Ionic.Zip; +using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.SolutionTemplating.Zipping; + +namespace Volo.Abp.SolutionTemplating.Building.Steps +{ + public class CreateProjectResultZipStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + context.Result.ZipContent = CreateZipFileFromEntries(context.Files); + } + + private static byte[] CreateZipFileFromEntries(FileEntryList entries) + { + using (var resultZipFile = new ZipFile()) + { + entries.CopyToZipFile(resultZipFile); + return resultZipFile.GetBytes(); + } + } + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs new file mode 100644 index 0000000000..62ec0d9f66 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs @@ -0,0 +1,58 @@ +using System.IO; +using Ionic.Zip; +using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.SolutionTemplating.Zipping; + +namespace Volo.Abp.SolutionTemplating.Building.Steps +{ + public class FileEntryListReadStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + if (context.Template.RootPathInZipFile == null) + { + context.Files = GetEntriesFromZipFile(context.Template.FilePath); + return; + } + + var entryListCachePath = CreateCachePath(context); + + if (File.Exists(entryListCachePath)) + { + context.Files = GetEntriesFromZipFile(entryListCachePath); + return; + } + + context.Files = GetEntriesFromZipFile( + context.Template.FilePath, + context.Template.RootPathInZipFile); + + SaveCachedEntries(entryListCachePath, context.Files); + } + + private static FileEntryList GetEntriesFromZipFile(string filePath, string rootFolder = null) + { + using (var templateFileStream = File.OpenRead(filePath)) + { + using (var templateZipFile = ZipFile.Read(templateFileStream)) + { + return templateZipFile.ToFileEntryList(rootFolder); + } + } + } + + private static void SaveCachedEntries(string filePath, FileEntryList entries) + { + using (var resultZipFile = new ZipFile()) + { + entries.CopyToZipFile(resultZipFile); + resultZipFile.Save(filePath); + } + } + + private string CreateCachePath(ProjectBuildContext context) + { + return context.Template.FilePath.Replace(".zip", "-filtered.zip"); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs new file mode 100644 index 0000000000..d34c67ec66 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs @@ -0,0 +1,33 @@ +using System; +using System.IO; +using Volo.Abp.SolutionTemplating.Github; + +namespace Volo.Abp.SolutionTemplating.Building.Steps +{ + public class GithubDownloadStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + var githubManager = new GithubManager(); + + context.Template.Version = githubManager.GetVersion(context); + + context.Template.FilePath = Path.Combine( + context.TemplatesFolder, + $"{context.Template.Name}-{context.Template.Version}.zip" + ); + + context.Template.RootPathInZipFile = context.Template.GithubRepository.RepositoryName + "-" + context.Template.Version.RemovePreFix("v") + context.Template.RootPathInZipFile; + + try + { + githubManager.DownloadIfNotExist(context); + } + catch (Exception e) + { + throw e; //TODO: !!! + //var existingVersion = githubManager.GetExistingVersion(context); + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs new file mode 100644 index 0000000000..7336dbd397 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs @@ -0,0 +1,113 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using HtmlAgilityPack; +using Volo.Abp.SolutionTemplating.Files; + +namespace Volo.Abp.SolutionTemplating.Building.Steps +{ + public class NugetReferenceReplaceStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + new NugetReferenceReplacer( + context.Files, + "MyCompanyName", + "MyProjectName", + context.Template.Version + ).Run(); + } + + private class NugetReferenceReplacer + { + private readonly List _entries; + private readonly string _companyNamePlaceHolder; + private readonly string _projectNamePlaceHolder; + private readonly string _latestNugetPackageVersion; + + public NugetReferenceReplacer(List entries, string companyNamePlaceHolder, string projectNamePlaceHolder, string latestNugetPackageVersion) + { + _entries = entries; + _companyNamePlaceHolder = companyNamePlaceHolder; + _projectNamePlaceHolder = projectNamePlaceHolder; + _latestNugetPackageVersion = latestNugetPackageVersion; + } + + public void Run() + { + foreach (var fileEntry in _entries) + { + if (fileEntry.Name.EndsWith(".csproj")) + { + fileEntry.SetContent(ProcessFileContent(fileEntry.Content)); + } + } + } + + private string ProcessFileContent(string content) + { + Check.NotNull(content, nameof(content)); + + var doc = new HtmlDocument(); + + doc.Load(GenerateStreamFromString(content)); + + var nodes = doc.DocumentNode.SelectNodes("//projectreference[@include]"); + + if (nodes == null) + { + return content; + } + + return ProcessReferenceNodes(nodes, content); + } + + private string ProcessReferenceNodes(HtmlNodeCollection nodes, string content) + { + Check.NotNull(nodes, nameof(nodes)); + Check.NotNull(content, nameof(content)); + + foreach (var node in nodes) + { + var valueAttr = node.Attributes.FirstOrDefault(a => a.Name.ToLower() == "include"); + + // ReSharper disable once PossibleNullReferenceException : Can not be null because nodes are selected with include attribute filter in previous method + if (valueAttr.Value.Contains($"{_companyNamePlaceHolder}.{_projectNamePlaceHolder}")) + { + continue; + } + + var newValue = ConvertToNugetReference(valueAttr.Value); + + var oldLine = $" file.Name.StartsWith(_projectFolderPath)); + var solutionFile = context.GetFile(_solutionFilePath); + solutionFile.NormalizeLineEndings(); + solutionFile.SetLines(RemoveProject(solutionFile.GetLines().ToList())); + } + + private List RemoveProject(List solutionFileLines) + { + var projectKey = FindProjectKey(solutionFileLines); + var newSolutionFileLines = new List(); + var firstOccurence = true; + + for (var i = 0; i < solutionFileLines.Count; ++i) + { + if (solutionFileLines[i].Contains(projectKey)) + { + if (firstOccurence) + { + firstOccurence = false; + ++i; //Skip "EndProject" line too. + } + + continue; + } + + newSolutionFileLines.Add(solutionFileLines[i]); + } + + return newSolutionFileLines; + } + + private string FindProjectKey(List solutionFileLines) + { + foreach (var solutionFileLine in solutionFileLines) + { + if (solutionFileLine.Contains(_projectName)) + { + var curlyBracketStartIndex = solutionFileLine.LastIndexOf("{", StringComparison.OrdinalIgnoreCase); + var curlyBracketEndIndex = solutionFileLine.LastIndexOf("}", StringComparison.OrdinalIgnoreCase); + return solutionFileLine.Substring(curlyBracketStartIndex + 1, curlyBracketEndIndex - curlyBracketStartIndex - 1); + } + } + + throw new ApplicationException($"The solution file '{_solutionFilePath}' does not contain a project '{_projectName}'"); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs new file mode 100644 index 0000000000..a45fabfd5b --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Volo.Abp.SolutionTemplating.Files; + +namespace Volo.Abp.SolutionTemplating.Building.Steps +{ + public class SolutionRenameStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + new SolutionRenamer( + context.Files, + "MyCompanyName", + "MyProjectName", + context.Request.SolutionName.CompanyName, + context.Request.SolutionName.ProjectName + ).Run(); + } + + private class SolutionRenamer + { + private readonly List _entries; + private readonly string _companyNamePlaceHolder; + private readonly string _projectNamePlaceHolder; + + private readonly string _companyName; + private readonly string _projectName; + + public SolutionRenamer(List entries, string companyNamePlaceHolder, string projectNamePlaceHolder, string companyName, string projectName) + { + if (string.IsNullOrWhiteSpace(companyName)) + { + companyName = null; + } + + if (companyNamePlaceHolder == null && companyName != null) + { + throw new UserFriendlyException($"Can not set {nameof(companyName)} if {nameof(companyNamePlaceHolder)} is null."); + } + + _entries = entries; + + _companyNamePlaceHolder = companyNamePlaceHolder; + _projectNamePlaceHolder = projectNamePlaceHolder ?? throw new ArgumentNullException(nameof(projectNamePlaceHolder)); + + _companyName = companyName; + _projectName = projectName ?? throw new ArgumentNullException(nameof(projectName)); + } + + public void Run() + { + if (_companyNamePlaceHolder != null && _companyName != null) + { + RenameDirectoryRecursively(_companyNamePlaceHolder, _companyName); + RenameAllFiles(_companyNamePlaceHolder, _companyName); + ReplaceContent(_companyNamePlaceHolder, _companyName); + } + else if (_companyNamePlaceHolder != null) + { + RenameDirectoryRecursively(_companyNamePlaceHolder + "." + _projectNamePlaceHolder, _projectNamePlaceHolder); + RenameAllFiles(_companyNamePlaceHolder + "." + _projectNamePlaceHolder, _projectNamePlaceHolder); + ReplaceContent(_companyNamePlaceHolder + "." + _projectNamePlaceHolder, _projectNamePlaceHolder); + } + + RenameDirectoryRecursively(_projectNamePlaceHolder, _projectName); + RenameAllFiles(_projectNamePlaceHolder, _projectName); + ReplaceContent(_projectNamePlaceHolder, _projectName); + } + + private void RenameDirectoryRecursively(string placeHolder, string name) + { + foreach (var entry in _entries.Where(e => e.IsDirectory)) + { + if (entry.Name.Contains(placeHolder)) + { + entry.SetName(entry.Name.Replace(placeHolder, name)); + } + } + } + + private void RenameAllFiles(string placeHolder, string name) + { + foreach (var entry in _entries.Where(e => !e.IsDirectory)) + { + if (entry.Name.Contains(placeHolder)) + { + entry.SetName(entry.Name.Replace(placeHolder, name)); + } + } + } + + private void ReplaceContent(string placeHolder, string name) + { + foreach (var entry in _entries.Where(e => !e.IsDirectory)) + { + if (entry.Content.Length < placeHolder.Length) + { + continue; + } + + if (entry.IsBinaryFile) + { + continue; + } + + var newContent = entry.Content.Replace(placeHolder, name); + if (newContent != entry.Content) + { + entry.SetContent(newContent); + } + } + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs new file mode 100644 index 0000000000..64e1b44c11 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs @@ -0,0 +1,80 @@ +using System; +using Volo.Abp.SolutionTemplating.Files; + +namespace Volo.Abp.SolutionTemplating.Building.Steps +{ + public class SwitchEntityFrameworkCoreToMongoDbStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + ChangeProjectReference(context); + ChangeWebModuleUsage(context); + ChangeConnectionString(context); + } + + private void ChangeProjectReference(ProjectBuildContext context) + { + var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj"); + + file.NormalizeLineEndings(); + + var lines = file.GetLines(); + for (var i = 0; i < lines.Length; i++) + { + if (lines[i].Contains("ProjectReference") && lines[i].Contains("MyCompanyName.MyProjectName.EntityFrameworkCore")) + { + lines[i] = lines[i].Replace("EntityFrameworkCore", "MongoDB"); + file.SetLines(lines); + return; + } + } + + throw new ApplicationException("Could not find the EntityFrameworkCore reference in the MyCompanyName.MyProjectName.Web.csproj!"); + } + + private void ChangeWebModuleUsage(ProjectBuildContext context) + { + var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs"); + + file.NormalizeLineEndings(); + + file.RemoveTemplateCodeIfNot("EntityFrameworkCore"); + + var lines = file.GetLines(); + + for (var i = 0; i < lines.Length; i++) + { + if (lines[i].Contains("using MyCompanyName.MyProjectName.EntityFrameworkCore")) + { + lines[i] = "using MyCompanyName.MyProjectName.MongoDb;"; + } + else if (lines[i].Contains("MyProjectNameEntityFrameworkCoreModule")) + { + lines[i] = lines[i].Replace("MyProjectNameEntityFrameworkCoreModule", "MyProjectNameMongoDbModule"); + } + } + + file.SetLines(lines); + } + + private void ChangeConnectionString(ProjectBuildContext context) + { + var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/appsettings.json"); + + file.NormalizeLineEndings(); + + var lines = file.GetLines(); + for (var i = 0; i < lines.Length; i++) + { + if (lines[i].Contains("Default") && lines[i].Contains("Database")) + { + lines[i] = " \"Default\": \"mongodb://localhost:27017|MyProjectName\""; + file.SetLines(lines); + return; + } + } + + throw new ApplicationException("Could not find the 'Default' connection string in appsettings.json file!"); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs new file mode 100644 index 0000000000..e35e11d441 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs @@ -0,0 +1,19 @@ +using Volo.Abp.SolutionTemplating.Files; + +namespace Volo.Abp.SolutionTemplating.Building.Steps +{ + public class TemplateCodeDeleteStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + foreach (var file in context.Files) + { + if (file.Name.EndsWith(".cs")) //TODO: Why only cs! + { + file.RemoveTemplateCode(); + file.RemoveTemplateCodeMarkers(); + } + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs new file mode 100644 index 0000000000..0bdccd3d00 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Abp.SolutionTemplating.Building +{ + public abstract class TemplateInfo + { + public string Name { get; set; } + + public GithubRepositoryInfo GithubRepository { get; } + + public string FilePath { get; set; } + + public string RootPathInZipFile { get; set; } + + public string Version { get; set; } + + protected TemplateInfo( + string name, + GithubRepositoryInfo githubRepository, + string rootPathInZipFile) + { + Name = name; + GithubRepository = githubRepository; + RootPathInZipFile = rootPathInZipFile; + } + + public virtual IEnumerable GetCustomSteps(ProjectBuildContext context) + { + return Array.Empty(); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/DownloadInfo.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/DownloadInfo.cs new file mode 100644 index 0000000000..0865e1175c --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/DownloadInfo.cs @@ -0,0 +1,37 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.SolutionTemplating +{ + [Table("Downloads")] + public class DownloadInfo : CreationAuditedAggregateRoot + { + [Required] + [StringLength(128)] + public string ProjectName { get; set; } + + [Required] + [StringLength(42)] + public string TemplateName { get; set; } + + [Required] + public DatabaseProvider DatabaseProvider { get; set; } + + [Required] + [StringLength(20)] + public string Version { get; set; } + + public int CreationDuration { get; set; } + + public DownloadInfo(string projectName, string templateName, DatabaseProvider databaseProvider, string version, int creationDuration) + { + ProjectName = projectName; + TemplateName = templateName; + DatabaseProvider = databaseProvider; + Version = version; + CreationDuration = creationDuration; + } + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntry.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntry.cs new file mode 100644 index 0000000000..7f808ad4cf --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntry.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Volo.Abp.SolutionTemplating.Files +{ + public class FileEntry + { + private static string[] BinaryFileExtensions = { + ".exe", ".dll", ".bin", + ".suo", ".obj", ".pdb", + ".png", "jpg", "jpeg", ".ico" + ,".woff", ".woff2", ".eot", ".svg", ".ttf" + }; + + public string Name { get; private set; } + + public bool IsDirectory { get; } + + public Encoding Encoding { get; } + + public byte[] Bytes { get; private set; } + + public string Content { get; private set; } + + public bool IsBinaryFile { get; private set; } + + public FileEntry(string name, byte[] bytes, bool isDirectory) + { + Name = name; + Bytes = bytes; + IsDirectory = isDirectory; + + Encoding = CalculateEncoding(); + Content = Encoding.GetString(bytes); + IsBinaryFile = CalculateIsBinaryFile(); + } + + public void SetContent(string fileContent) + { + Content = fileContent; + Bytes = Encoding.GetBytes(fileContent); + } + + public string[] GetLines() + { + return Content.Split(new[] { Environment.NewLine, "\n" }, StringSplitOptions.None); + } + + public void SetLines(IEnumerable lines) + { + SetContent(lines.JoinAsString(Environment.NewLine)); + } + + public void SetName(string fileName) + { + Name = fileName; + IsBinaryFile = CalculateIsBinaryFile(); + } + + public void NormalizeLineEndings() + { + if (Content.IsNullOrEmpty()) + { + return; + } + + SetContent(Content.NormalizeLineEndings()); + } + + public override string ToString() + { + var str = new StringBuilder(Name); + + if (IsDirectory) + { + str.Append(" [DIR]"); + } + + str.Append($" [{Bytes.Length}]"); + + return str.ToString(); + } + + private Encoding CalculateEncoding() + { + if (Bytes.IsNullOrEmpty()) + { + return Encoding.ASCII; + } + + if (Bytes[0] == 0x2b && Bytes[1] == 0x2f && Bytes[2] == 0x76) + { + return Encoding.UTF7; + } + + if (Bytes[0] == 0xef && Bytes[1] == 0xbb && Bytes[2] == 0xbf) + { + return Encoding.UTF8; + } + + if (Bytes[0] == 0xff && Bytes[1] == 0xfe) + { + return Encoding.Unicode; //UTF-16LE + } + + if (Bytes[0] == 0xfe && Bytes[1] == 0xff) + { + return Encoding.BigEndianUnicode; //UTF-16BE + } + + if (Bytes[0] == 0 && Bytes[1] == 0 && Bytes[2] == 0xfe && Bytes[3] == 0xff) + { + return Encoding.UTF32; + } + + return Encoding.UTF8; + } + + private bool CalculateIsBinaryFile() + { + return BinaryFileExtensions.Any(ext => Name.EndsWith(ext)); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs new file mode 100644 index 0000000000..999e8a9353 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; + +namespace Volo.Abp.SolutionTemplating.Files +{ + public static class FileEntryExtensions + { + public static void RemoveTemplateCode(this FileEntry file) + { + RemoveMarkedTemplateCode(file, ""); + } + + public static void RemoveTemplateCodeIf(this FileEntry file, string condition) + { + RemoveByCondition(file, "IF", condition); + } + + public static void RemoveTemplateCodeIfNot(this FileEntry file, string condition) + { + RemoveByCondition(file, "IF-NOT", condition); + } + + public static void RemoveTemplateCodeMarkers(this FileEntry file) + { + file.NormalizeLineEndings(); + + var lines = file.GetLines(); + var newLines = new List(); + + for (int i = 0; i < lines.Length; i++) + { + if (lines[i].Contains("")) + { + //TODO: What if we use inline like: some-code + //TODO: This logic skips the code in that case. Should handle it + ++i; + } + + if (i < lines.Length) + { + newLines.Add(lines[i]); + } + } + + file.SetLines(newLines); + } + + private static void RemoveByCondition(this FileEntry file, string conditionName, string condition) + { + RemoveMarkedTemplateCode(file, $""); + } + + private static void RemoveMarkedTemplateCode(this FileEntry file, string beginMark) + { + file.NormalizeLineEndings(); + + var lines = file.GetLines(); + var newLines = new List(); + + for (int i = 0; i < lines.Length; i++) + { + if (lines[i].Contains(beginMark)) + { + while (!lines[i].Contains("") && i < lines.Length) + { + ++i; + } + + ++i; + } + + if (i < lines.Length) + { + newLines.Add(lines[i]); + } + } + + file.SetLines(newLines); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs new file mode 100644 index 0000000000..17b7b757ba --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace Volo.Abp.SolutionTemplating.Files +{ + public class FileEntryList : List + { + public FileEntryList(IEnumerable entries) + : base(entries) + { + + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs new file mode 100644 index 0000000000..01acdf297b --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs @@ -0,0 +1,24 @@ +using System; +using Ionic.Zip; + +namespace Volo.Abp.SolutionTemplating.Files +{ + public static class FileEntryListExtensions + { + public static void CopyToZipFile(this FileEntryList fileEntryList, ZipFile zipFile) + { + foreach (var entry in fileEntryList) + { + try + { + zipFile.AddEntry(entry.Name, entry.Bytes); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubManager.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubManager.cs new file mode 100644 index 0000000000..fbe0801ffd --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubManager.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Newtonsoft.Json; +using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.Threading; + +namespace Volo.Abp.SolutionTemplating.Github +{ + public class GithubManager + { + private static readonly object LockObject = new object(); + + public string GetVersion(ProjectBuildContext context) + { + if (context.Request.Version.StartsWith("Branch:", StringComparison.OrdinalIgnoreCase)) + { + //TODO: Should not cache branch files! + return context.Request.Version.Substring("Branch:".Length); + } + + var url = "https://api.github.com/repos/" + context.Template.GithubRepository.RepositoryNameWithOrganization + "/releases"; + + using (var client = new System.Net.Http.HttpClient()) + { + var credentials = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:", context.Template.GithubRepository.AccessToken); + credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials)); + + client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); + client.Timeout = TimeSpan.FromMinutes(30); + + client.DefaultRequestHeaders.UserAgent.ParseAdd("MyAgent/1.0"); + var releases = JsonConvert.DeserializeObject>(client.GetStringAsync(url).Result); + + if (context.Request.Version == StandardVersions.LatestUnstable) + { + return releases.FirstOrDefault(r => !r.IsPrerelease)?.Name; + } + + return releases.FirstOrDefault()?.Name; + } + } + + public void DownloadIfNotExist(ProjectBuildContext context) + { + using (var client = new System.Net.Http.HttpClient()) + { + if (File.Exists(context.Template.FilePath)) + { + return; + } + + lock (LockObject) + { + if (File.Exists(context.Template.FilePath)) + { + return; + } + + var downloadUrl = "https://github.com/" + context.Template.GithubRepository.RepositoryNameWithOrganization + "/archive/" + context.Template.Version + ".zip"; + + var credentials = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:", context.Template.GithubRepository.AccessToken); + credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials)); + + client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); + client.Timeout = TimeSpan.FromMinutes(30); + + var fileContents = AsyncHelper.RunSync(() => client.GetByteArrayAsync(downloadUrl)); + + File.WriteAllBytes(context.Template.FilePath, fileContents); + } + } + } + + //public string GetExistingVersion(ProjectBuildContext context) + //{ + // var directoryInfo = new DirectoryInfo(templateRootPath); + // var existingFileName = directoryInfo.GetFiles().FirstOrDefault(f => f.Name.StartsWith(repositoryName))?.Name; + // var latestVersion = ""; + + // if (existingFileName != null) + // { + // var pFrom = existingFileName.IndexOf(repositoryName + "-", StringComparison.Ordinal) + (repositoryName + "-").Length; + // var pTo = existingFileName.LastIndexOf(".zip", StringComparison.Ordinal); + + // latestVersion = existingFileName.Substring(pFrom, pTo - pFrom); + // } + + // return latestVersion; + //} + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs new file mode 100644 index 0000000000..4e5ea612fe --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs @@ -0,0 +1,21 @@ +using System; +using Newtonsoft.Json; + +namespace Volo.Abp.SolutionTemplating.Github +{ + [JsonObject] + public class GithubRelease + { + [JsonProperty("id")] + public int Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("prerelease")] + public bool IsPrerelease { get; set; } + + [JsonProperty("published_at")] + public DateTime PublishTime { get; set; } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs new file mode 100644 index 0000000000..77628e9767 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs @@ -0,0 +1,15 @@ +namespace Volo.Abp.SolutionTemplating +{ + public class SolutionBuildResult + { + public byte[] ZipContent { get; } + + public string ProjectName { get; } + + public SolutionBuildResult(byte[] zipContent, string projectName) + { + ZipContent = zipContent; + ProjectName = projectName; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuilder.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuilder.cs new file mode 100644 index 0000000000..736ffad678 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuilder.cs @@ -0,0 +1,64 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.SolutionTemplating +{ + public class SolutionBuilder : ITransientDependency + { + private readonly IHostingEnvironment _hostingEnvironment; + private readonly IRepository _downloadRepository; + + public SolutionBuilder( + IHostingEnvironment hostingEnvironment, + IRepository downloadRepository) + { + _hostingEnvironment = hostingEnvironment; + _downloadRepository = downloadRepository; + } + + public async Task BuildAsync( + TemplateInfo template, + string companyAndProjectName, + DatabaseProvider databaseProvider, + string version, + bool replaceLocalReferencesToNuget) + { + var stopwatch = Stopwatch.StartNew(); + + var templateRootPath = Path.Combine(_hostingEnvironment.ContentRootPath, "TemplateFiles"); //TODO: To another folder that is not in the deployment folder! + var solutionName = SolutionName.Parse(companyAndProjectName); + + var context = new ProjectBuildContext( + template, + new ProjectBuildRequest( + solutionName, + databaseProvider, + version + ), + templateRootPath + ); + + ProjectBuildPipelineBuilder.Build(context).Execute(context); + + stopwatch.Stop(); + + await _downloadRepository.InsertAsync( + new DownloadInfo( + solutionName.FullName, + template.Name, + databaseProvider, + context.Template.Version, + Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds) + ) + ); + + return new SolutionBuildResult(context.Result.ZipContent, solutionName.ProjectName); + } + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionName.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionName.cs new file mode 100644 index 0000000000..63ec52a432 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionName.cs @@ -0,0 +1,50 @@ +using System; + +namespace Volo.Abp.SolutionTemplating +{ + public class SolutionName + { + public string FullName { get; } + + public string CompanyName { get; } + + public string ProjectName { get; } + + private SolutionName(string fullName, string companyName, string projectName) + { + FullName = fullName; + CompanyName = companyName; + ProjectName = projectName; + } + + public static SolutionName Parse(string fullName) + { + if (fullName.Length < 1) + { + throw new UserFriendlyException("Solution name is not valid. It should be 1 character length at minimum."); + } + + string companyName = null; + var projectName = fullName; + + if (fullName.Contains(".")) + { + var lastDotIndex = fullName.LastIndexOf(".", StringComparison.OrdinalIgnoreCase); + companyName = fullName.Substring(0, lastDotIndex); + projectName = fullName.Substring(lastDotIndex + 1); + + if (companyName.Length < 1) + { + throw new UserFriendlyException("Solution name is not valid. Company name should be 1 character length at minimum."); + } + + if (projectName.Length < 1) + { + throw new UserFriendlyException("Solution name is not valid. Project name should be 1 character length at minimum."); + } + } + + return new SolutionName(fullName, companyName, projectName); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/StandardVersions.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/StandardVersions.cs new file mode 100644 index 0000000000..df7b8b2e39 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/StandardVersions.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.SolutionTemplating +{ + public static class StandardVersions + { + public const string LatestStable = "LatestStable"; + + public const string LatestUnstable = "LatestUnstable"; + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs new file mode 100644 index 0000000000..e4e5290194 --- /dev/null +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Ionic.Zip; +using Volo.Abp.SolutionTemplating.Files; + +namespace Volo.Abp.SolutionTemplating.Zipping +{ + public static class ZipFileExtensions + { + public static byte[] GetBytes(this ZipFile zipFile) + { + using (var ms = new MemoryStream()) + { + zipFile.Save(ms); + return ms.ToArray(); + } + } + + public static FileEntryList ToFileEntryList(this ZipFile zipFile, string rootFolder = null) + { + var zipEntries = zipFile.Entries; + + if (rootFolder != null) + { + zipEntries = zipEntries.Where(entry => entry.FileName.StartsWith(rootFolder)).ToList(); + } + + var fileEntries = new List(); + + foreach (var zipEntry in zipEntries) + { + using (var entryStream = zipEntry.OpenReader()) + { + var fileName = zipEntry.FileName; + + if (rootFolder != null) + { + fileName = fileName.RemovePreFix(rootFolder); + } + + if (fileName.IsNullOrEmpty()) + { + continue; + } + + fileName = fileName.EnsureStartsWith('/'); + + fileEntries.Add(new FileEntry(fileName, entryStream.GetAllBytes(), zipEntry.IsDirectory)); + } + } + + return new FileEntryList(fileEntries); + } + } +} diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs index a4862789f2..8036760f6a 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs @@ -56,7 +56,7 @@ namespace Volo.Abp public virtual void Dispose() { - + //TODO: Shutdown if not done before? } protected virtual void SetServiceProvider(IServiceProvider serviceProvider) diff --git a/framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj b/framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj new file mode 100644 index 0000000000..915cb58607 --- /dev/null +++ b/framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp2.2 + latest + + + + + + + + + + diff --git a/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestBase.cs b/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestBase.cs new file mode 100644 index 0000000000..6f6393b7ae --- /dev/null +++ b/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestBase.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Cli +{ + public class AbpCliTestBase : AbpIntegratedTest + { + + } +} \ No newline at end of file diff --git a/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestModule.cs b/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestModule.cs new file mode 100644 index 0000000000..8c2101052b --- /dev/null +++ b/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/AbpCliTestModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Modularity; + +namespace Volo.Abp.Cli +{ + [DependsOn( + typeof(AbpTestBaseModule), + typeof(AbpCliModule) + )] + public class AbpCliTestModule : AbpModule + { + + } +} diff --git a/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs b/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs new file mode 100644 index 0000000000..c8d31990cf --- /dev/null +++ b/framework/test/Volo.Abp.Cli.Tests/Volo/Abp/Cli/CommandLineArgumentParser_Tests.cs @@ -0,0 +1,68 @@ +using Shouldly; +using System.Linq; +using Volo.Abp.Cli.Args; +using Xunit; + +namespace Volo.Abp.Cli +{ + public class CommandLineArgumentParser_Tests : AbpCliTestBase + { + private readonly ICommandLineArgumentParser _commandLineArgumentParser; + + public CommandLineArgumentParser_Tests() + { + _commandLineArgumentParser = GetRequiredService(); + } + + [Theory] + [InlineData(null)] + [InlineData(new object[] { new string[0] })] + public void Should_Parse_Empty_Arguments(string[] args) + { + var commandLineArgs = _commandLineArgumentParser.Parse(args); + commandLineArgs.Command.ShouldBeNull(); + commandLineArgs.Target.ShouldBeNull(); + commandLineArgs.Options.Any().ShouldBeFalse(); + } + + [Fact] + public void Should_Work_With_Only_Command() + { + var commandLineArgs = _commandLineArgumentParser.Parse(new[] { "mycommand" }); + commandLineArgs.Command.ShouldBe("mycommand"); + commandLineArgs.Target.ShouldBeNull(); + commandLineArgs.Options.Any().ShouldBeFalse(); + } + + [Fact] + public void Should_Work_With_Command_And_Target() + { + var commandLineArgs = _commandLineArgumentParser.Parse(new[] { "mycommand", "mytarget" }); + commandLineArgs.Command.ShouldBe("mycommand"); + commandLineArgs.Target.ShouldBe("mytarget"); + commandLineArgs.Options.Any().ShouldBeFalse(); + } + + [Fact] + public void Should_Work_With_Command_And_Target_And_Options() + { + var commandLineArgs = _commandLineArgumentParser.Parse(new[] + { + "mycommand", "mytarget", "-a", "value1", "-b", "--optionC", "value2" + }); + + commandLineArgs.Command.ShouldBe("mycommand"); + commandLineArgs.Target.ShouldBe("mytarget"); + commandLineArgs.Options.Any().ShouldBeTrue(); + + commandLineArgs.Options.ShouldContainKey("a"); + commandLineArgs.Options["a"].ShouldBe("value1"); + + commandLineArgs.Options.ShouldContainKey("b"); + commandLineArgs.Options["b"].ShouldBeNull(); + + commandLineArgs.Options.ShouldContainKey("optionC"); + commandLineArgs.Options["optionC"].ShouldBe("value2"); + } + } +} From 3fa617b092cb14232e6c618a98fef87448f09b6b Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 18 Apr 2019 18:49:32 +0300 Subject: [PATCH 02/10] Fix namespaces --- .../Volo/Abp/Cli/Args/CommandLineArgs.cs | 3 +- .../Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs | 21 ++++++++---- .../Volo/Abp/Cli/Commands/CommandSelector.cs | 12 ++++--- .../Volo/Abp/Cli/Commands/ICommandSelector.cs | 7 ++-- .../Volo/Abp/Cli/Commands/IConsoleCommand.cs | 5 +-- .../Volo/Abp/Cli/Commands/MainHelpCommand.cs | 13 +++---- .../Abp/Cli/Commands/NewProjectCommand.cs | 34 +++++++++++++++---- 7 files changed, 63 insertions(+), 32 deletions(-) diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs index 27108a76c4..624c96afe5 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs @@ -1,9 +1,8 @@ using System.Linq; using System.Text; using JetBrains.Annotations; -using Volo.Abp.Cli.Args; -namespace Volo.Abp.Cli +namespace Volo.Abp.Cli.Args { public class CommandLineArgs { diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs index 6c51b0cd30..d76216b300 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs @@ -1,6 +1,8 @@ -using System; +using Microsoft.Extensions.DependencyInjection; +using System; using System.Threading.Tasks; using Volo.Abp.Cli.Args; +using Volo.Abp.Cli.Commands; using Volo.Abp.DependencyInjection; namespace Volo.Abp.Cli @@ -9,21 +11,28 @@ namespace Volo.Abp.Cli { protected ICommandLineArgumentParser CommandLineArgumentParser { get; } protected ICommandSelector CommandSelector { get; } + public IHybridServiceScopeFactory ServiceScopeFactory { get; } public CliService( - ICommandLineArgumentParser commandLineArgumentParser, - ICommandSelector commandSelector) + ICommandLineArgumentParser commandLineArgumentParser, + ICommandSelector commandSelector, + IHybridServiceScopeFactory serviceScopeFactory) { CommandLineArgumentParser = commandLineArgumentParser; CommandSelector = commandSelector; + ServiceScopeFactory = serviceScopeFactory; } public async Task RunAsync(string[] args) { var commandLineArgs = CommandLineArgumentParser.Parse(args); - var command = CommandSelector.Select(commandLineArgs); - await command.ExecuteAsync(); - Console.WriteLine(commandLineArgs); + var commandType = CommandSelector.Select(commandLineArgs); + + using (var scope = ServiceScopeFactory.CreateScope()) + { + var command = (IConsoleCommand)scope.ServiceProvider.GetRequiredService(commandType); + await command.ExecuteAsync(commandLineArgs); + } } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs index c5d410f400..32268540a7 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs @@ -1,20 +1,22 @@ -using Volo.Abp.DependencyInjection; +using System; +using Volo.Abp.Cli.Args; +using Volo.Abp.DependencyInjection; -namespace Volo.Abp.Cli +namespace Volo.Abp.Cli.Commands { public class CommandSelector : ICommandSelector, ITransientDependency { - public IConsoleCommand Select(CommandLineArgs commandLineArgs) + public Type Select(CommandLineArgs commandLineArgs) { //TODO: Create options to define commands //TODO: Get from dependency injection instead of new? if (commandLineArgs.Command == "new") { - return new NewProjectCommand(commandLineArgs); + return typeof(NewProjectCommand); } - return new MainHelpCommand(commandLineArgs); + return typeof(MainHelpCommand); } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs index 86d2f1d2f0..507f8ab452 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs @@ -1,7 +1,10 @@ -namespace Volo.Abp.Cli +using System; +using Volo.Abp.Cli.Args; + +namespace Volo.Abp.Cli.Commands { public interface ICommandSelector { - IConsoleCommand Select(CommandLineArgs commandLineArgs); + Type Select(CommandLineArgs commandLineArgs); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs index a3e822a160..2b1129aab2 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs @@ -1,9 +1,10 @@ using System.Threading.Tasks; +using Volo.Abp.Cli.Args; -namespace Volo.Abp.Cli +namespace Volo.Abp.Cli.Commands { public interface IConsoleCommand { - Task ExecuteAsync(); + Task ExecuteAsync(CommandLineArgs commandLineArgs); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs index 5bb1894229..d06dcade91 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs @@ -1,16 +1,13 @@ using System; using System.Threading.Tasks; +using Volo.Abp.Cli.Args; +using Volo.Abp.DependencyInjection; -namespace Volo.Abp.Cli +namespace Volo.Abp.Cli.Commands { - public class MainHelpCommand : IConsoleCommand + public class MainHelpCommand : ITransientDependency { - public MainHelpCommand(CommandLineArgs commandLineArgs) - { - - } - - public Task ExecuteAsync() + public Task ExecuteAsync(CommandLineArgs commandLineArgs) { Console.WriteLine("*********** ABP CLI ****************"); Console.WriteLine(); diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs index 5ef068e5ae..92ce6fc6f7 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs @@ -1,21 +1,41 @@ using System; using System.Threading.Tasks; +using Volo.Abp.Cli.Args; +using Volo.Abp.DependencyInjection; +using Volo.Abp.SolutionTemplating; +using Volo.Abp.SolutionTemplating.Building; -namespace Volo.Abp.Cli +namespace Volo.Abp.Cli.Commands { - public class NewProjectCommand : IConsoleCommand + public class NewProjectCommand : IConsoleCommand, ITransientDependency { - protected CommandLineArgs CommandLineArgs { get; } + protected SolutionBuilder SolutionBuilder { get; } - public NewProjectCommand(CommandLineArgs commandLineArgs) + public NewProjectCommand(SolutionBuilder solutionBuilder) { - CommandLineArgs = commandLineArgs; + SolutionBuilder = solutionBuilder; } - public Task ExecuteAsync() + public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { + if (commandLineArgs.Target == null) + { + Console.WriteLine("Project name is missing."); + Console.WriteLine("Usage:"); + Console.WriteLine(" abp new "); + Console.WriteLine("Example:"); + Console.WriteLine(" abp new Acme.BookStore"); + } + Console.WriteLine("TODO: Create new project"); - return Task.CompletedTask; + + //await SolutionBuilder.BuildAsync( + // null, + // commandLineArgs.Target, + // DatabaseProvider.EntityFrameworkCore, + // "...", + // true + //); } } } \ No newline at end of file From 859a001a037ef60df9c1237ae89087adbd3590a0 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 19 Apr 2019 16:30:59 +0300 Subject: [PATCH 03/10] Update NewProjectCommand.cs --- .../Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs index 92ce6fc6f7..b3051ea700 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs @@ -20,14 +20,16 @@ namespace Volo.Abp.Cli.Commands { if (commandLineArgs.Target == null) { - Console.WriteLine("Project name is missing."); + Console.WriteLine("Solution name is missing."); Console.WriteLine("Usage:"); Console.WriteLine(" abp new "); Console.WriteLine("Example:"); Console.WriteLine(" abp new Acme.BookStore"); + return; } - Console.WriteLine("TODO: Create new project"); + Console.WriteLine("Creating a new solution"); + Console.WriteLine("Solution name: " + commandLineArgs.Target); //await SolutionBuilder.BuildAsync( // null, From e45caa5b7fee096a76ad61ac04b8edae67003e21 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 3 May 2019 09:11:08 +0300 Subject: [PATCH 04/10] Create Volo.Abp.Cli.Core package. --- framework/Volo.Abp.sln | 9 ++++++- .../Volo.Abp.Cli.Core.csproj | 25 +++++++++++++++++++ .../Volo/Abp/Cli/AbpCliCoreModule.cs | 15 +++++++++++ .../Volo/Abp/Cli/Args/CommandLineArgs.cs | 0 .../Abp/Cli/Args/CommandLineArgumentParser.cs | 0 .../Volo/Abp/Cli/Args/CommandLineOptions.cs | 0 .../Cli/Args/ICommandLineArgumentParser.cs | 0 .../Volo/Abp/Cli/CliService.cs | 1 - .../Volo/Abp/Cli/Commands/CommandSelector.cs | 0 .../Volo/Abp/Cli/Commands/ICommandSelector.cs | 0 .../Volo/Abp/Cli/Commands/IConsoleCommand.cs | 0 .../Volo/Abp/Cli/Commands/MainHelpCommand.cs | 0 .../Abp/Cli/Commands/NewProjectCommand.cs | 0 .../Building/DatabaseProvider.cs | 0 .../Building/GithubRepositoryInfo.cs | 0 .../Building/ProjectBuildContext.cs | 0 .../Building/ProjectBuildContextExtensions.cs | 0 .../Building/ProjectBuildPipeline.cs | 0 .../Building/ProjectBuildPipelineBuilder.cs | 0 .../Building/ProjectBuildPipelineStep.cs | 0 .../Building/ProjectBuildRequest.cs | 0 .../Building/ProjectResult.cs | 0 .../Steps/CreateProjectResultZipStep.cs | 0 .../Building/Steps/FileEntryListReadStep.cs | 0 .../Building/Steps/GithubDownloadStep.cs | 0 .../Steps/NugetReferenceReplaceStep.cs | 0 .../Steps/RemoveProjectFromSolutionStep.cs | 0 .../Building/Steps/SolutionRenameStep.cs | 0 .../SwitchEntityFrameworkCoreToMongoDbStep.cs | 0 .../Building/Steps/TemplateCodeDeleteStep.cs | 0 .../Building/TemplateInfo.cs | 0 .../Abp/SolutionTemplating/DownloadInfo.cs | 0 .../Abp/SolutionTemplating/Files/FileEntry.cs | 0 .../Files/FileEntryExtensions.cs | 0 .../SolutionTemplating/Files/FileEntryList.cs | 0 .../Files/FileEntryListExtensions.cs | 0 .../Github/GithubManager.cs | 0 .../Github/GithubRelease.cs | 0 .../SolutionTemplating/SolutionBuildResult.cs | 0 .../Abp/SolutionTemplating/SolutionBuilder.cs | 0 .../Abp/SolutionTemplating/SolutionName.cs | 0 .../SolutionTemplating/StandardVersions.cs | 0 .../Zipping/ZipFileExtensions.cs | 0 .../src/Volo.Abp.Cli/Volo.Abp.Cli.csproj | 9 +------ .../Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs | 5 ++-- .../Volo.Abp.Cli.Tests.csproj | 2 +- nupkg/common.ps1 | 1 + 47 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Args/CommandLineArgs.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Args/CommandLineOptions.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/CliService.cs (98%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Commands/CommandSelector.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Commands/ICommandSelector.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Commands/IConsoleCommand.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Commands/MainHelpCommand.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/Cli/Commands/NewProjectCommand.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/DownloadInfo.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Files/FileEntry.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Github/GithubManager.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/SolutionBuilder.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/SolutionName.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/StandardVersions.cs (100%) rename framework/src/{Volo.Abp.Cli => Volo.Abp.Cli.Core}/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs (100%) diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index e1af7720f9..41eb7f1aeb 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -224,10 +224,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.FluentValidation", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.FluentValidation.Tests", "test\Volo.Abp.FluentValidation.Tests\Volo.Abp.FluentValidation.Tests.csproj", "{E9E1714F-7ED2-4BD1-BA4A-BA06E398288A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Cli.Tests", "test\Volo.Abp.Cli.Tests\Volo.Abp.Cli.Tests.csproj", "{92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Cli.Tests", "test\Volo.Abp.Cli.Tests\Volo.Abp.Cli.Tests.csproj", "{92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.EntityFrameworkCore.Sqlite", "src\Volo.Abp.EntityFrameworkCore.Sqlite\Volo.Abp.EntityFrameworkCore.Sqlite.csproj", "{58CF8957-5045-4F81-884D-72DF48F721CC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Cli.Core", "src\Volo.Abp.Cli.Core\Volo.Abp.Cli.Core.csproj", "{3DA9923E-048E-4FE7-9748-3A0194F5D196}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -678,6 +680,10 @@ Global {58CF8957-5045-4F81-884D-72DF48F721CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {58CF8957-5045-4F81-884D-72DF48F721CC}.Release|Any CPU.ActiveCfg = Release|Any CPU {58CF8957-5045-4F81-884D-72DF48F721CC}.Release|Any CPU.Build.0 = Release|Any CPU + {3DA9923E-048E-4FE7-9748-3A0194F5D196}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DA9923E-048E-4FE7-9748-3A0194F5D196}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DA9923E-048E-4FE7-9748-3A0194F5D196}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DA9923E-048E-4FE7-9748-3A0194F5D196}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -794,6 +800,7 @@ Global {E9E1714F-7ED2-4BD1-BA4A-BA06E398288A} = {447C8A77-E5F0-4538-8687-7383196D04EA} {92B70EFF-C1B1-4D1D-8BCE-D116908FC6FF} = {447C8A77-E5F0-4538-8687-7383196D04EA} {58CF8957-5045-4F81-884D-72DF48F721CC} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {3DA9923E-048E-4FE7-9748-3A0194F5D196} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj new file mode 100644 index 0000000000..459d95089a --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj @@ -0,0 +1,25 @@ + + + + + + netstandard2.0 + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + false + false + false + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs new file mode 100644 index 0000000000..e56c95ff27 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs @@ -0,0 +1,15 @@ +using Volo.Abp.Domain; +using Volo.Abp.Json; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Cli +{ + [DependsOn( + typeof(AbpDddDomainModule), + typeof(AbpJsonModule) + )] + public class AbpCliCoreModule : AbpModule + { + + } +} diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgs.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgs.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineOptions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineOptions.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineOptions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineOptions.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/ICommandLineArgumentParser.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs similarity index 98% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs index d76216b300..50108567e6 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.DependencyInjection; -using System; using System.Threading.Tasks; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Commands; diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ICommandSelector.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ICommandSelector.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/IConsoleCommand.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/IConsoleCommand.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/MainHelpCommand.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/MainHelpCommand.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/DownloadInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/DownloadInfo.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/DownloadInfo.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/DownloadInfo.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntry.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntry.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntry.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntry.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubManager.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubManager.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubManager.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubManager.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuilder.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionBuilder.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuilder.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionName.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionName.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/SolutionName.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionName.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/StandardVersions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/StandardVersions.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/StandardVersions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/StandardVersions.cs diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs similarity index 100% rename from framework/src/Volo.Abp.Cli/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs diff --git a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj index fb8b3b9e19..f2f9424512 100644 --- a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj +++ b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj @@ -11,14 +11,7 @@ - - - - - - - - + diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs index 0b891e1299..523dd6c813 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs @@ -1,10 +1,9 @@ -using Volo.Abp.Domain; -using Volo.Abp.Modularity; +using Volo.Abp.Modularity; namespace Volo.Abp.Cli { [DependsOn( - typeof(AbpDddDomainModule) + typeof(AbpCliCoreModule) )] public class AbpCliModule : AbpModule { diff --git a/framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj b/framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj index 915cb58607..3f094594d0 100644 --- a/framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj +++ b/framework/test/Volo.Abp.Cli.Tests/Volo.Abp.Cli.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index 6ebae9a0b5..100bfe3b89 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -53,6 +53,7 @@ $projects = ( "framework/src/Volo.Abp.BackgroundWorkers", "framework/src/Volo.Abp.Caching", "framework/src/Volo.Abp.Castle.Core", + "framework/src/Volo.Abp.Cli.Core", "framework/src/Volo.Abp.Cli", "framework/src/Volo.Abp.Core", "framework/src/Volo.Abp.Data", From 9cd2f241026fad2634f8db03b90717d550f7af92 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 3 May 2019 12:04:24 +0300 Subject: [PATCH 05/10] New project creation for CLI --- .../Volo/Abp/Cli/Args/CommandLineOptions.cs | 28 +++++- .../Abp/Cli/Commands/NewProjectCommand.cs | 68 +++++++++++--- .../Abp/ProjectBuilding/AbpIoTemplateStore.cs | 16 ++++ .../Abp/ProjectBuilding/IProjectBuilder.cs | 10 ++ .../ProjectBuilding/ITemplateInfoProvider.cs | 11 +++ .../Abp/ProjectBuilding/ITemplateStore.cs | 9 ++ .../Abp/ProjectBuilding/ProjectBuildArgs.cs | 27 ++++++ .../Abp/ProjectBuilding/ProjectBuilder.cs | 52 ++++++++++ .../Volo/Abp/ProjectBuilding/TemplateFile.cs | 12 +++ .../ProjectBuilding/TemplateInfoProvider.cs | 48 ++++++++++ .../Templates/MvcApplicationTemplate.cs | 41 ++++++++ .../Templates/MvcModuleTemplate.cs | 9 ++ .../Templates/ServiceTemplate.cs | 9 ++ .../Building/DatabaseProvider.cs | 4 +- .../Building/ProjectBuildContext.cs | 25 +++-- .../Building/ProjectBuildPipelineBuilder.cs | 1 - .../Building/ProjectBuildRequest.cs | 23 ----- .../Building/Steps/FileEntryListReadStep.cs | 34 +------ .../Building/Steps/GithubDownloadStep.cs | 33 ------- .../Steps/NugetReferenceReplaceStep.cs | 2 +- .../Building/Steps/SolutionRenameStep.cs | 4 +- .../Building/TemplateInfo.cs | 18 ---- .../Github/GithubManager.cs | 94 ------------------- ...onBuildResult.cs => ProjectBuildResult.cs} | 4 +- .../Abp/SolutionTemplating/SolutionBuilder.cs | 64 ------------- 25 files changed, 351 insertions(+), 295 deletions(-) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateStore.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateFile.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubManager.cs rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/{SolutionBuildResult.cs => ProjectBuildResult.cs} (68%) delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuilder.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineOptions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineOptions.cs index 93f23fdd76..3e72d6e434 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineOptions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineOptions.cs @@ -1,9 +1,35 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using JetBrains.Annotations; namespace Volo.Abp.Cli.Args { public class CommandLineOptions : Dictionary { + [CanBeNull] + public string GetOrNull([NotNull] string name, params string[] alternativeNames) + { + Check.NotNullOrWhiteSpace(name, nameof(name)); + var value = this.GetOrDefault(name); + if (!value.IsNullOrWhiteSpace()) + { + return value; + } + + if (!alternativeNames.IsNullOrEmpty()) + { + foreach (var alternativeName in alternativeNames) + { + value = this.GetOrDefault(alternativeName); + if (!value.IsNullOrWhiteSpace()) + { + return value; + } + } + } + + return null; + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs index b3051ea700..b662bec85b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs @@ -1,43 +1,85 @@ using System; +using System.IO; using System.Threading.Tasks; +using Ionic.Zip; using Volo.Abp.Cli.Args; using Volo.Abp.DependencyInjection; +using Volo.Abp.ProjectBuilding; using Volo.Abp.SolutionTemplating; using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.SolutionTemplating.Zipping; namespace Volo.Abp.Cli.Commands { public class NewProjectCommand : IConsoleCommand, ITransientDependency { - protected SolutionBuilder SolutionBuilder { get; } + protected ProjectBuilder ProjectBuilder { get; } - public NewProjectCommand(SolutionBuilder solutionBuilder) + public NewProjectCommand(ProjectBuilder projectBuilder) { - SolutionBuilder = solutionBuilder; + ProjectBuilder = projectBuilder; } public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { if (commandLineArgs.Target == null) { - Console.WriteLine("Solution name is missing."); + Console.WriteLine("Project name is missing."); Console.WriteLine("Usage:"); - Console.WriteLine(" abp new "); - Console.WriteLine("Example:"); + Console.WriteLine(" abp new [-t ]"); + Console.WriteLine("Examples:"); Console.WriteLine(" abp new Acme.BookStore"); + Console.WriteLine(" abp new Acme.BookStore mvc"); return; } Console.WriteLine("Creating a new solution"); Console.WriteLine("Solution name: " + commandLineArgs.Target); - //await SolutionBuilder.BuildAsync( - // null, - // commandLineArgs.Target, - // DatabaseProvider.EntityFrameworkCore, - // "...", - // true - //); + var result = await ProjectBuilder.BuildAsync( + new ProjectBuildArgs( + SolutionName.Parse(commandLineArgs.Target), + GetDatabaseProviderOrNull(commandLineArgs), + commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long) + ) + ); + + using (var templateFileStream = new MemoryStream(result.ZipContent)) + { + using (var templateZipFile = ZipFile.Read(templateFileStream)) + { + templateZipFile.ExtractAll(Directory.GetCurrentDirectory(), ExtractExistingFileAction.Throw); + } + } + } + + protected virtual DatabaseProvider GetDatabaseProviderOrNull(CommandLineArgs commandLineArgs) + { + var optionValue = commandLineArgs.Options.GetOrNull(Options.DatabaseProvider.Short, Options.DatabaseProvider.Long); + switch (optionValue) + { + case "ef": + return DatabaseProvider.EntityFrameworkCore; + case "mongodb": + return DatabaseProvider.MongoDb; + default: + return DatabaseProvider.NotSpecified; + } + } + + public static class Options + { + public static class Template + { + public const string Short = "t"; + public const string Long = "template"; + } + + public static class DatabaseProvider + { + public const string Short = "d"; + public const string Long = "databaseProvider"; + } } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs new file mode 100644 index 0000000000..c8c36b967d --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs @@ -0,0 +1,16 @@ +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.ProjectBuilding +{ + public class AbpIoTemplateStore : ITemplateStore, ITransientDependency + { + public async Task GetAsync(string templateName, string version) + { + return new TemplateFile( + File.ReadAllBytes("C:\\Temp\\abp-templates\\" + version + "\\" + templateName + ".zip") + ); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs new file mode 100644 index 0000000000..3011516061 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; +using Volo.Abp.SolutionTemplating; + +namespace Volo.Abp.ProjectBuilding +{ + public interface IProjectBuilder + { + Task BuildAsync(ProjectBuildArgs args); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs new file mode 100644 index 0000000000..ad8dbbe874 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs @@ -0,0 +1,11 @@ +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.ProjectBuilding +{ + public interface ITemplateInfoProvider + { + TemplateInfo GetDefault(); + + TemplateInfo Get(string name); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateStore.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateStore.cs new file mode 100644 index 0000000000..f09faa8603 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateStore.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Volo.Abp.ProjectBuilding +{ + public interface ITemplateStore + { + Task GetAsync(string templateInfoName, string version); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs new file mode 100644 index 0000000000..5ca1a0ad99 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs @@ -0,0 +1,27 @@ +using JetBrains.Annotations; +using Volo.Abp.SolutionTemplating; +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.ProjectBuilding +{ + public class ProjectBuildArgs + { + [NotNull] + public SolutionName SolutionName { get; } + + [CanBeNull] + public string TemplateName { get; set; } + + public DatabaseProvider DatabaseProvider { get; } + + public ProjectBuildArgs( + [NotNull] SolutionName solutionName, + DatabaseProvider databaseProvider = DatabaseProvider.NotSpecified, + [CanBeNull] string templateName = null) + { + DatabaseProvider = databaseProvider; + TemplateName = templateName; + SolutionName = Check.NotNull(solutionName, nameof(solutionName)); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs new file mode 100644 index 0000000000..ee13db6e3f --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.SolutionTemplating; +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.ProjectBuilding +{ + public class ProjectBuilder : IProjectBuilder, ITransientDependency + { + protected ITemplateStore TemplateStore { get; } + protected ITemplateInfoProvider TemplateInfoProvider { get; } + + public ProjectBuilder(ITemplateStore templateStore, ITemplateInfoProvider templateInfoProvider) + { + TemplateStore = templateStore; + TemplateInfoProvider = templateInfoProvider; + } + + public async Task BuildAsync(ProjectBuildArgs args) + { + var version = "0.16.0"; //TODO: Should get from somewhere! + + var templateInfo = GetTemplateInfo(args); + + var templateFile = await TemplateStore.GetAsync(args.TemplateName, version); + + var context = new ProjectBuildContext( + templateInfo, + templateFile, + args, + version + ); + + ProjectBuildPipelineBuilder.Build(context).Execute(context); + + return new ProjectBuildResult(context.Result.ZipContent, args.SolutionName.ProjectName); + } + + private TemplateInfo GetTemplateInfo(ProjectBuildArgs args) + { + if (args.TemplateName.IsNullOrWhiteSpace()) + { + return TemplateInfoProvider.GetDefault(); + } + else + { + return TemplateInfoProvider.Get(args.TemplateName); + } + } + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateFile.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateFile.cs new file mode 100644 index 0000000000..d1f839e27b --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateFile.cs @@ -0,0 +1,12 @@ +namespace Volo.Abp.ProjectBuilding +{ + public class TemplateFile + { + public byte[] FileBytes { get; } + + public TemplateFile(byte[] fileBytes) + { + FileBytes = fileBytes; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs new file mode 100644 index 0000000000..d65937eab2 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs @@ -0,0 +1,48 @@ +using System; +using Volo.Abp.DependencyInjection; +using Volo.Abp.ProjectBuilding.Templates; +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.ProjectBuilding +{ + public class TemplateInfoProvider : ITemplateInfoProvider, ITransientDependency + { + public TemplateInfo GetDefault() + { + return Get(TemplateNames.Mvc); + } + + public TemplateInfo Get(string name) + { + switch (name) + { + case TemplateNames.Mvc: + return new MvcApplicationTemplate(); + case TemplateNames.MvcModule: + return new MvcModuleTemplate(); + case TemplateNames.Service: + return new ServiceTemplate(); + default: + throw new Exception("There is no template found with given name: " + name); + } + } + + public static class TemplateNames + { + /// + /// "mvc". + /// + public const string Mvc = "mvc"; + + /// + /// "mvcmodule". + /// + public const string MvcModule = "mvcmodule"; + + /// + /// "service". + /// + public const string Service = "service"; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs new file mode 100644 index 0000000000..7fe2fd7a0a --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.SolutionTemplating.Building.Steps; + +namespace Volo.Abp.ProjectBuilding.Templates +{ + public class MvcApplicationTemplate : TemplateInfo + { + public override IEnumerable GetCustomSteps(ProjectBuildContext context) + { + var steps = new List(); + SwitchDatabaseProvider(context, steps); + RemoveOtherDatabaseProviders(context, steps); + return steps; + } + + private static void SwitchDatabaseProvider(ProjectBuildContext context, List steps) + { + if (context.BuildArgs.DatabaseProvider == DatabaseProvider.MongoDb) + { + steps.Add(new SwitchEntityFrameworkCoreToMongoDbStep()); + } + } + + private static void RemoveOtherDatabaseProviders(ProjectBuildContext context, List steps) + { + if (context.BuildArgs.DatabaseProvider != DatabaseProvider.EntityFrameworkCore) + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Application.Tests", projectFolderPath: "test/MyCompanyName.MyProjectName.Application.Tests")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "test/MyCompanyName.MyProjectName.Web.Tests")); + } + + if (context.BuildArgs.DatabaseProvider != DatabaseProvider.MongoDb) + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB")); + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs new file mode 100644 index 0000000000..6549ce103c --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs @@ -0,0 +1,9 @@ +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.ProjectBuilding.Templates +{ + public class MvcModuleTemplate : TemplateInfo + { + + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs new file mode 100644 index 0000000000..7558891d34 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs @@ -0,0 +1,9 @@ +using Volo.Abp.SolutionTemplating.Building; + +namespace Volo.Abp.ProjectBuilding.Templates +{ + public class ServiceTemplate : TemplateInfo + { + + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs index 1e2e4efc00..e0e0f14e0b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs @@ -1,8 +1,8 @@ namespace Volo.Abp.SolutionTemplating.Building { - public enum DatabaseProvider : byte + public enum DatabaseProvider { - Irrelevant = 0, + NotSpecified = 0, EntityFrameworkCore = 1, MongoDb = 2 } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs index 297e7f056f..b620f6dc02 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs @@ -1,28 +1,37 @@ using JetBrains.Annotations; +using Volo.Abp.ProjectBuilding; using Volo.Abp.SolutionTemplating.Files; namespace Volo.Abp.SolutionTemplating.Building { public class ProjectBuildContext { - public ProjectBuildRequest Request { get; } + [NotNull] + public TemplateFile TemplateFile { get; } - public string TemplatesFolder { get; } + [NotNull] + public string Version { get; } + [NotNull] + public ProjectBuildArgs BuildArgs { get; } + + [NotNull] public TemplateInfo Template { get; } public FileEntryList Files { get; set; } public ProjectResult Result { get; set; } - public ProjectBuildContext( - [NotNull] TemplateInfo template, - ProjectBuildRequest request, - string templatesFolder) + public ProjectBuildContext([NotNull] TemplateInfo template, + [NotNull] TemplateFile templateFile, + [NotNull] ProjectBuildArgs buildArgs, + [NotNull] string version) { Template = Check.NotNull(template, nameof(template)); - Request = request; - TemplatesFolder = templatesFolder; + TemplateFile = Check.NotNull(templateFile, nameof(templateFile)); + BuildArgs = Check.NotNull(buildArgs, nameof(buildArgs)); + Version = Check.NotNullOrWhiteSpace(version, nameof(version)); + Result = new ProjectResult(); } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs index 41d760e4df..44062f9cee 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs @@ -8,7 +8,6 @@ namespace Volo.Abp.SolutionTemplating.Building { var pipeline = new ProjectBuildPipeline(); - pipeline.Steps.Add(new GithubDownloadStep()); pipeline.Steps.Add(new FileEntryListReadStep()); pipeline.Steps.AddRange(context.Template.GetCustomSteps(context)); pipeline.Steps.Add(new NugetReferenceReplaceStep()); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs deleted file mode 100644 index 4f4bec11b8..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildRequest.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Volo.Abp.SolutionTemplating.Building -{ - public class ProjectBuildRequest - { - public SolutionName SolutionName { get; } - - public DatabaseProvider DatabaseProvider { get; } - - public string Version { get; } - - public bool ReplaceLocalReferencesToNuget { get; set; } - - public ProjectBuildRequest( - SolutionName solutionName, - DatabaseProvider databaseProvider, - string version) - { - SolutionName = solutionName; - DatabaseProvider = databaseProvider; - Version = version; - } - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs index 62ec0d9f66..d1433725ec 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs @@ -9,25 +9,7 @@ namespace Volo.Abp.SolutionTemplating.Building.Steps { public override void Execute(ProjectBuildContext context) { - if (context.Template.RootPathInZipFile == null) - { - context.Files = GetEntriesFromZipFile(context.Template.FilePath); - return; - } - - var entryListCachePath = CreateCachePath(context); - - if (File.Exists(entryListCachePath)) - { - context.Files = GetEntriesFromZipFile(entryListCachePath); - return; - } - - context.Files = GetEntriesFromZipFile( - context.Template.FilePath, - context.Template.RootPathInZipFile); - - SaveCachedEntries(entryListCachePath, context.Files); + context.Files = GetEntriesFromZipFile(context.Template.FilePath); } private static FileEntryList GetEntriesFromZipFile(string filePath, string rootFolder = null) @@ -40,19 +22,5 @@ namespace Volo.Abp.SolutionTemplating.Building.Steps } } } - - private static void SaveCachedEntries(string filePath, FileEntryList entries) - { - using (var resultZipFile = new ZipFile()) - { - entries.CopyToZipFile(resultZipFile); - resultZipFile.Save(filePath); - } - } - - private string CreateCachePath(ProjectBuildContext context) - { - return context.Template.FilePath.Replace(".zip", "-filtered.zip"); - } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs deleted file mode 100644 index d34c67ec66..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/GithubDownloadStep.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.IO; -using Volo.Abp.SolutionTemplating.Github; - -namespace Volo.Abp.SolutionTemplating.Building.Steps -{ - public class GithubDownloadStep : ProjectBuildPipelineStep - { - public override void Execute(ProjectBuildContext context) - { - var githubManager = new GithubManager(); - - context.Template.Version = githubManager.GetVersion(context); - - context.Template.FilePath = Path.Combine( - context.TemplatesFolder, - $"{context.Template.Name}-{context.Template.Version}.zip" - ); - - context.Template.RootPathInZipFile = context.Template.GithubRepository.RepositoryName + "-" + context.Template.Version.RemovePreFix("v") + context.Template.RootPathInZipFile; - - try - { - githubManager.DownloadIfNotExist(context); - } - catch (Exception e) - { - throw e; //TODO: !!! - //var existingVersion = githubManager.GetExistingVersion(context); - } - } - } -} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs index 7336dbd397..460e174252 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs @@ -14,7 +14,7 @@ namespace Volo.Abp.SolutionTemplating.Building.Steps context.Files, "MyCompanyName", "MyProjectName", - context.Template.Version + context.Version ).Run(); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs index a45fabfd5b..43d7356a32 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs @@ -13,8 +13,8 @@ namespace Volo.Abp.SolutionTemplating.Building.Steps context.Files, "MyCompanyName", "MyProjectName", - context.Request.SolutionName.CompanyName, - context.Request.SolutionName.ProjectName + context.BuildArgs.SolutionName.CompanyName, + context.BuildArgs.SolutionName.ProjectName ).Run(); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs index 0bdccd3d00..1756402664 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs @@ -5,26 +5,8 @@ namespace Volo.Abp.SolutionTemplating.Building { public abstract class TemplateInfo { - public string Name { get; set; } - - public GithubRepositoryInfo GithubRepository { get; } - public string FilePath { get; set; } - public string RootPathInZipFile { get; set; } - - public string Version { get; set; } - - protected TemplateInfo( - string name, - GithubRepositoryInfo githubRepository, - string rootPathInZipFile) - { - Name = name; - GithubRepository = githubRepository; - RootPathInZipFile = rootPathInZipFile; - } - public virtual IEnumerable GetCustomSteps(ProjectBuildContext context) { return Array.Empty(); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubManager.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubManager.cs deleted file mode 100644 index fbe0801ffd..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubManager.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using Newtonsoft.Json; -using Volo.Abp.SolutionTemplating.Building; -using Volo.Abp.Threading; - -namespace Volo.Abp.SolutionTemplating.Github -{ - public class GithubManager - { - private static readonly object LockObject = new object(); - - public string GetVersion(ProjectBuildContext context) - { - if (context.Request.Version.StartsWith("Branch:", StringComparison.OrdinalIgnoreCase)) - { - //TODO: Should not cache branch files! - return context.Request.Version.Substring("Branch:".Length); - } - - var url = "https://api.github.com/repos/" + context.Template.GithubRepository.RepositoryNameWithOrganization + "/releases"; - - using (var client = new System.Net.Http.HttpClient()) - { - var credentials = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:", context.Template.GithubRepository.AccessToken); - credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials)); - - client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); - client.Timeout = TimeSpan.FromMinutes(30); - - client.DefaultRequestHeaders.UserAgent.ParseAdd("MyAgent/1.0"); - var releases = JsonConvert.DeserializeObject>(client.GetStringAsync(url).Result); - - if (context.Request.Version == StandardVersions.LatestUnstable) - { - return releases.FirstOrDefault(r => !r.IsPrerelease)?.Name; - } - - return releases.FirstOrDefault()?.Name; - } - } - - public void DownloadIfNotExist(ProjectBuildContext context) - { - using (var client = new System.Net.Http.HttpClient()) - { - if (File.Exists(context.Template.FilePath)) - { - return; - } - - lock (LockObject) - { - if (File.Exists(context.Template.FilePath)) - { - return; - } - - var downloadUrl = "https://github.com/" + context.Template.GithubRepository.RepositoryNameWithOrganization + "/archive/" + context.Template.Version + ".zip"; - - var credentials = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:", context.Template.GithubRepository.AccessToken); - credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credentials)); - - client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); - client.Timeout = TimeSpan.FromMinutes(30); - - var fileContents = AsyncHelper.RunSync(() => client.GetByteArrayAsync(downloadUrl)); - - File.WriteAllBytes(context.Template.FilePath, fileContents); - } - } - } - - //public string GetExistingVersion(ProjectBuildContext context) - //{ - // var directoryInfo = new DirectoryInfo(templateRootPath); - // var existingFileName = directoryInfo.GetFiles().FirstOrDefault(f => f.Name.StartsWith(repositoryName))?.Name; - // var latestVersion = ""; - - // if (existingFileName != null) - // { - // var pFrom = existingFileName.IndexOf(repositoryName + "-", StringComparison.Ordinal) + (repositoryName + "-").Length; - // var pTo = existingFileName.LastIndexOf(".zip", StringComparison.Ordinal); - - // latestVersion = existingFileName.Substring(pFrom, pTo - pFrom); - // } - - // return latestVersion; - //} - } -} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/ProjectBuildResult.cs similarity index 68% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/ProjectBuildResult.cs index 77628e9767..dd43e8b63e 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuildResult.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/ProjectBuildResult.cs @@ -1,12 +1,12 @@ namespace Volo.Abp.SolutionTemplating { - public class SolutionBuildResult + public class ProjectBuildResult { public byte[] ZipContent { get; } public string ProjectName { get; } - public SolutionBuildResult(byte[] zipContent, string projectName) + public ProjectBuildResult(byte[] zipContent, string projectName) { ZipContent = zipContent; ProjectName = projectName; diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuilder.cs deleted file mode 100644 index 736ffad678..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionBuilder.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Domain.Repositories; -using Volo.Abp.SolutionTemplating.Building; - -namespace Volo.Abp.SolutionTemplating -{ - public class SolutionBuilder : ITransientDependency - { - private readonly IHostingEnvironment _hostingEnvironment; - private readonly IRepository _downloadRepository; - - public SolutionBuilder( - IHostingEnvironment hostingEnvironment, - IRepository downloadRepository) - { - _hostingEnvironment = hostingEnvironment; - _downloadRepository = downloadRepository; - } - - public async Task BuildAsync( - TemplateInfo template, - string companyAndProjectName, - DatabaseProvider databaseProvider, - string version, - bool replaceLocalReferencesToNuget) - { - var stopwatch = Stopwatch.StartNew(); - - var templateRootPath = Path.Combine(_hostingEnvironment.ContentRootPath, "TemplateFiles"); //TODO: To another folder that is not in the deployment folder! - var solutionName = SolutionName.Parse(companyAndProjectName); - - var context = new ProjectBuildContext( - template, - new ProjectBuildRequest( - solutionName, - databaseProvider, - version - ), - templateRootPath - ); - - ProjectBuildPipelineBuilder.Build(context).Execute(context); - - stopwatch.Stop(); - - await _downloadRepository.InsertAsync( - new DownloadInfo( - solutionName.FullName, - template.Name, - databaseProvider, - context.Template.Version, - Convert.ToInt32(stopwatch.Elapsed.TotalMilliseconds) - ) - ); - - return new SolutionBuildResult(context.Result.ZipContent, solutionName.ProjectName); - } - } -} From e53279a6fb628f09552dc5dd7dc1e402581be69d Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 3 May 2019 15:21:19 +0300 Subject: [PATCH 06/10] Initial working version of new project creation with temporary code. --- .../Volo.Abp.Cli.Core.csproj | 2 ++ .../Volo/Abp/Cli/AbpCliCoreModule.cs | 8 ++++-- .../Volo/Abp/Cli/Commands/MainHelpCommand.cs | 2 +- .../Abp/Cli/Commands/NewProjectCommand.cs | 1 - .../Abp/ProjectBuilding/ProjectBuildArgs.cs | 2 +- .../Abp/ProjectBuilding/ProjectBuilder.cs | 10 +++++++ .../ProjectBuilding/TemplateInfoProvider.cs | 26 +++---------------- .../Templates/MvcApplicationTemplate.cs | 10 +++++++ .../Templates/MvcModuleTemplate.cs | 11 +++++++- .../Templates/ServiceTemplate.cs | 9 +++++++ .../Building/Steps/FileEntryListReadStep.cs | 10 +++---- .../Building/TemplateInfo.cs | 13 +++++++++- .../src/Volo.Abp.Cli/Volo.Abp.Cli.csproj | 4 +++ 13 files changed, 74 insertions(+), 34 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj index 459d95089a..07a488123c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj +++ b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj @@ -15,6 +15,8 @@ + + diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs index e56c95ff27..555fe14ca4 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Domain; +using System.Text; +using Volo.Abp.Domain; using Volo.Abp.Json; using Volo.Abp.Modularity; @@ -10,6 +11,9 @@ namespace Volo.Abp.Cli )] public class AbpCliCoreModule : AbpModule { - + public override void ConfigureServices(ServiceConfigurationContext context) + { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/MainHelpCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/MainHelpCommand.cs index d06dcade91..96f7132934 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/MainHelpCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/MainHelpCommand.cs @@ -5,7 +5,7 @@ using Volo.Abp.DependencyInjection; namespace Volo.Abp.Cli.Commands { - public class MainHelpCommand : ITransientDependency + public class MainHelpCommand : IConsoleCommand, ITransientDependency { public Task ExecuteAsync(CommandLineArgs commandLineArgs) { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs index b662bec85b..8addefbdde 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs @@ -7,7 +7,6 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.ProjectBuilding; using Volo.Abp.SolutionTemplating; using Volo.Abp.SolutionTemplating.Building; -using Volo.Abp.SolutionTemplating.Zipping; namespace Volo.Abp.Cli.Commands { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs index 5ca1a0ad99..34284ffafb 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs @@ -12,7 +12,7 @@ namespace Volo.Abp.ProjectBuilding [CanBeNull] public string TemplateName { get; set; } - public DatabaseProvider DatabaseProvider { get; } + public DatabaseProvider DatabaseProvider { get; set; } public ProjectBuildArgs( [NotNull] SolutionName solutionName, diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs index ee13db6e3f..cc0f91940b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs @@ -23,6 +23,16 @@ namespace Volo.Abp.ProjectBuilding var templateInfo = GetTemplateInfo(args); + args.TemplateName = templateInfo.Name; + + if (args.DatabaseProvider == DatabaseProvider.NotSpecified) + { + if (templateInfo.DefaultDatabaseProvider != DatabaseProvider.NotSpecified) + { + args.DatabaseProvider = templateInfo.DefaultDatabaseProvider; + } + } + var templateFile = await TemplateStore.GetAsync(args.TemplateName, version); var context = new ProjectBuildContext( diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs index d65937eab2..bfc5aec303 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs @@ -9,40 +9,22 @@ namespace Volo.Abp.ProjectBuilding { public TemplateInfo GetDefault() { - return Get(TemplateNames.Mvc); + return Get(MvcApplicationTemplate.TemplateName); } public TemplateInfo Get(string name) { switch (name) { - case TemplateNames.Mvc: + case MvcApplicationTemplate.TemplateName: return new MvcApplicationTemplate(); - case TemplateNames.MvcModule: + case MvcModuleTemplate.TemplateName: return new MvcModuleTemplate(); - case TemplateNames.Service: + case ServiceTemplate.TemplateName: return new ServiceTemplate(); default: throw new Exception("There is no template found with given name: " + name); } } - - public static class TemplateNames - { - /// - /// "mvc". - /// - public const string Mvc = "mvc"; - - /// - /// "mvcmodule". - /// - public const string MvcModule = "mvcmodule"; - - /// - /// "service". - /// - public const string Service = "service"; - } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs index 7fe2fd7a0a..3b8dd55f54 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs @@ -6,6 +6,16 @@ namespace Volo.Abp.ProjectBuilding.Templates { public class MvcApplicationTemplate : TemplateInfo { + /// + /// "mvc". + /// + public const string TemplateName = "mvc"; + + public MvcApplicationTemplate() + : base(TemplateName, DatabaseProvider.EntityFrameworkCore) + { + } + public override IEnumerable GetCustomSteps(ProjectBuildContext context) { var steps = new List(); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs index 6549ce103c..a4f436932b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs @@ -4,6 +4,15 @@ namespace Volo.Abp.ProjectBuilding.Templates { public class MvcModuleTemplate : TemplateInfo { - + /// + /// "mvcmodule". + /// + public const string TemplateName = "mvcmodule"; + + public MvcModuleTemplate() + : base(TemplateName) + { + + } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs index 7558891d34..ebbd9fa90a 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs @@ -4,6 +4,15 @@ namespace Volo.Abp.ProjectBuilding.Templates { public class ServiceTemplate : TemplateInfo { + /// + /// "service". + /// + public const string TemplateName = "service"; + public ServiceTemplate() + : base(TemplateName) + { + + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs index d1433725ec..794f169a26 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs @@ -9,16 +9,16 @@ namespace Volo.Abp.SolutionTemplating.Building.Steps { public override void Execute(ProjectBuildContext context) { - context.Files = GetEntriesFromZipFile(context.Template.FilePath); + context.Files = GetEntriesFromZipFile(context.TemplateFile.FileBytes); } - private static FileEntryList GetEntriesFromZipFile(string filePath, string rootFolder = null) + private static FileEntryList GetEntriesFromZipFile(byte[] fileBytes) { - using (var templateFileStream = File.OpenRead(filePath)) + using (var memoryStream = new MemoryStream(fileBytes)) { - using (var templateZipFile = ZipFile.Read(templateFileStream)) + using (var templateZipFile = ZipFile.Read(memoryStream)) { - return templateZipFile.ToFileEntryList(rootFolder); + return templateZipFile.ToFileEntryList(); } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs index 1756402664..0ef7d26a4f 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs @@ -1,11 +1,22 @@ using System; using System.Collections.Generic; +using JetBrains.Annotations; namespace Volo.Abp.SolutionTemplating.Building { public abstract class TemplateInfo { - public string FilePath { get; set; } + public string Name { get; } + + public DatabaseProvider DefaultDatabaseProvider { get; } + + protected TemplateInfo( + [NotNull] string name, + DatabaseProvider defaultDatabaseProvider = DatabaseProvider.NotSpecified) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); + DefaultDatabaseProvider = Check.NotNull(defaultDatabaseProvider, nameof(defaultDatabaseProvider)); + } public virtual IEnumerable GetCustomSteps(ProjectBuildContext context) { diff --git a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj index f2f9424512..9cdc913391 100644 --- a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj +++ b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj @@ -10,6 +10,10 @@ + + + + From f5f987189dc1b76d58f75c2693f334ac96268b16 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 3 May 2019 15:43:02 +0300 Subject: [PATCH 07/10] Get CLI & template version from the assembly. --- .../src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs | 9 ++++++++- .../Volo/Abp/ProjectBuilding/ProjectBuilder.cs | 5 +++-- .../System/Reflection/AbpAssemblyExtensions.cs | 12 ++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs index 50108567e6..1b65577f1d 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; +using System; +using System.Reflection; +using Microsoft.Extensions.DependencyInjection; using System.Threading.Tasks; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Commands; @@ -8,6 +10,8 @@ namespace Volo.Abp.Cli { public class CliService : ITransientDependency { + public static string Version => typeof(AbpCliCoreModule).Assembly.GetFileVersion(); + protected ICommandLineArgumentParser CommandLineArgumentParser { get; } protected ICommandSelector CommandSelector { get; } public IHybridServiceScopeFactory ServiceScopeFactory { get; } @@ -24,6 +28,9 @@ namespace Volo.Abp.Cli public async Task RunAsync(string[] args) { + Console.WriteLine("ABP CLI (abp.io)"); + Console.WriteLine("Version: " + Version); + var commandLineArgs = CommandLineArgumentParser.Parse(args); var commandType = CommandSelector.Select(commandLineArgs); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs index cc0f91940b..501d309845 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Volo.Abp.Cli; using Volo.Abp.DependencyInjection; using Volo.Abp.SolutionTemplating; using Volo.Abp.SolutionTemplating.Building; @@ -19,8 +20,6 @@ namespace Volo.Abp.ProjectBuilding public async Task BuildAsync(ProjectBuildArgs args) { - var version = "0.16.0"; //TODO: Should get from somewhere! - var templateInfo = GetTemplateInfo(args); args.TemplateName = templateInfo.Name; @@ -33,6 +32,8 @@ namespace Volo.Abp.ProjectBuilding } } + var version = CliService.Version; + var templateFile = await TemplateStore.GetAsync(args.TemplateName, version); var context = new ProjectBuildContext( diff --git a/framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs b/framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs new file mode 100644 index 0000000000..0e61770618 --- /dev/null +++ b/framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs @@ -0,0 +1,12 @@ +using System.Diagnostics; + +namespace System.Reflection +{ + public static class AbpAssemblyExtensions + { + public static string GetFileVersion(this Assembly assembly) + { + return FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion; + } + } +} From 37ce88c29e093c3b90dcbcdce93aefa7ebe944e1 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 3 May 2019 16:22:27 +0300 Subject: [PATCH 08/10] Added logging for CLI --- .../Volo.AbpWebSite.Web/publish-ignore.json | 1 + .../Volo/Abp/Cli/CliService.cs | 11 ++++-- .../Abp/Cli/Commands/NewProjectCommand.cs | 22 +++++++----- .../Abp/ProjectBuilding/AbpIoTemplateStore.cs | 36 ++++++++++++++++--- .../src/Volo.Abp.Cli/Volo.Abp.Cli.csproj | 5 +++ .../Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs | 6 ++-- .../src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs | 17 ++++++++- .../Volo/Abp/Modularity/ModuleManager.cs | 4 +-- 8 files changed, 83 insertions(+), 19 deletions(-) diff --git a/abp_io/src/Volo.AbpWebSite.Web/publish-ignore.json b/abp_io/src/Volo.AbpWebSite.Web/publish-ignore.json index 89e3176a69..c5e2fd7c51 100644 --- a/abp_io/src/Volo.AbpWebSite.Web/publish-ignore.json +++ b/abp_io/src/Volo.AbpWebSite.Web/publish-ignore.json @@ -3,6 +3,7 @@ "TemplateFiles/": {}, "Logs/": {}, "wwwroot/files/": {}, + "wwwroot/downloads/": {}, "appsettings.json": {}, "web.config": {} } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs index 1b65577f1d..502ab294e6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs @@ -2,9 +2,12 @@ using System.Reflection; using Microsoft.Extensions.DependencyInjection; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Commands; using Volo.Abp.DependencyInjection; +using Volo.Abp.ProjectBuilding; namespace Volo.Abp.Cli { @@ -12,6 +15,8 @@ namespace Volo.Abp.Cli { public static string Version => typeof(AbpCliCoreModule).Assembly.GetFileVersion(); + public ILogger Logger { get; set; } + protected ICommandLineArgumentParser CommandLineArgumentParser { get; } protected ICommandSelector CommandSelector { get; } public IHybridServiceScopeFactory ServiceScopeFactory { get; } @@ -24,12 +29,14 @@ namespace Volo.Abp.Cli CommandLineArgumentParser = commandLineArgumentParser; CommandSelector = commandSelector; ServiceScopeFactory = serviceScopeFactory; + + Logger = NullLogger.Instance; } public async Task RunAsync(string[] args) { - Console.WriteLine("ABP CLI (abp.io)"); - Console.WriteLine("Version: " + Version); + Logger.LogInformation("ABP CLI (abp.io)"); + Logger.LogInformation("Version: " + Version); var commandLineArgs = CommandLineArgumentParser.Parse(args); var commandType = CommandSelector.Select(commandLineArgs); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs index 8addefbdde..09fd578d85 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs @@ -2,6 +2,8 @@ using System.IO; using System.Threading.Tasks; using Ionic.Zip; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Cli.Args; using Volo.Abp.DependencyInjection; using Volo.Abp.ProjectBuilding; @@ -12,28 +14,32 @@ namespace Volo.Abp.Cli.Commands { public class NewProjectCommand : IConsoleCommand, ITransientDependency { + public ILogger Logger { get; set; } + protected ProjectBuilder ProjectBuilder { get; } public NewProjectCommand(ProjectBuilder projectBuilder) { ProjectBuilder = projectBuilder; + + Logger = NullLogger.Instance; } public async Task ExecuteAsync(CommandLineArgs commandLineArgs) { if (commandLineArgs.Target == null) { - Console.WriteLine("Project name is missing."); - Console.WriteLine("Usage:"); - Console.WriteLine(" abp new [-t ]"); - Console.WriteLine("Examples:"); - Console.WriteLine(" abp new Acme.BookStore"); - Console.WriteLine(" abp new Acme.BookStore mvc"); + Logger.LogWarning("Project name is missing."); + Logger.LogWarning("Usage:"); + Logger.LogWarning(" abp new [-t ]"); + Logger.LogWarning("Examples:"); + Logger.LogWarning(" abp new Acme.BookStore"); + Logger.LogWarning(" abp new Acme.BookStore mvc"); return; } - Console.WriteLine("Creating a new solution"); - Console.WriteLine("Solution name: " + commandLineArgs.Target); + Logger.LogInformation("Creating a new project..."); + Logger.LogInformation("Project name: " + commandLineArgs.Target); var result = await ProjectBuilder.BuildAsync( new ProjectBuildArgs( diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs index c8c36b967d..e81e7e414b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs @@ -1,16 +1,44 @@ -using System.IO; +using System; +using System.IO; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.DependencyInjection; +using Volo.Abp.IO; namespace Volo.Abp.ProjectBuilding { public class AbpIoTemplateStore : ITemplateStore, ITransientDependency { + public ILogger Logger { get; set; } + + public AbpIoTemplateStore() + { + Logger = NullLogger.Instance; + } + public async Task GetAsync(string templateName, string version) { - return new TemplateFile( - File.ReadAllBytes("C:\\Temp\\abp-templates\\" + version + "\\" + templateName + ".zip") - ); + var localCacheFolder = "C:\\Temp\\abp-template-cache\\" + version; + DirectoryHelper.CreateIfNotExists(localCacheFolder); + + var localCacheFile = Path.Combine(localCacheFolder, templateName + ".zip"); + if (File.Exists(localCacheFile)) + { + Logger.LogInformation("Using cached template: " + templateName + ", version: " + version); + return new TemplateFile(File.ReadAllBytes(localCacheFile)); + } + + Logger.LogInformation("Downloading template: " + templateName + ", version: " + version); + + using (var client = new System.Net.Http.HttpClient()) + { + client.Timeout = TimeSpan.FromMinutes(5); + var downloadUrl = "https://abp.io/downloads/templates/" + version + "/" + templateName + ".zip"; + var fileContents = await client.GetByteArrayAsync(downloadUrl); + File.WriteAllBytes(localCacheFile, fileContents); + return new TemplateFile(fileContents); + } } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj index 9cdc913391..4f0de79850 100644 --- a/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj +++ b/framework/src/Volo.Abp.Cli/Volo.Abp.Cli.csproj @@ -12,9 +12,14 @@ + + + + + diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs index 523dd6c813..339041ef8a 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/AbpCliModule.cs @@ -1,9 +1,11 @@ -using Volo.Abp.Modularity; +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; namespace Volo.Abp.Cli { [DependsOn( - typeof(AbpCliCoreModule) + typeof(AbpCliCoreModule), + typeof(AbpAutofacModule) )] public class AbpCliModule : AbpModule { diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs index c7f321a8e1..706dc91d47 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.DependencyInjection; +using Serilog; +using Serilog.Events; using Volo.Abp.Threading; namespace Volo.Abp.Cli @@ -7,7 +9,20 @@ namespace Volo.Abp.Cli { private static void Main(string[] args) { - using (var application = AbpApplicationFactory.Create()) + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .Enrich.FromLogContext() + //.WriteTo.File("Logs/logs.txt") //TODO: Write logs to a global path + .WriteTo.Console() + .CreateLogger(); + + using (var application = AbpApplicationFactory.Create( + options => + { + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + })) { application.Initialize(); diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleManager.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleManager.cs index d79ae0b843..934948dc03 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleManager.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/ModuleManager.cs @@ -42,12 +42,12 @@ namespace Volo.Abp.Modularity } } - _logger.LogInformation("Initialized all modules."); + _logger.LogInformation("Initialized all ABP modules."); } private void LogListOfModules() { - _logger.LogInformation("Loaded modules:"); + _logger.LogInformation("Loaded ABP modules:"); foreach (var module in _moduleContainer.Modules) { From e5579144595a457e06f87ad8540d1b28c387a319 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 3 May 2019 16:35:32 +0300 Subject: [PATCH 09/10] Use user data folder for template cache and logging. --- .../src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs | 13 +++++++++++++ .../Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs | 3 ++- framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs new file mode 100644 index 0000000000..b0296671b3 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs @@ -0,0 +1,13 @@ +using System; +using System.IO; + +namespace Volo.Abp.Cli +{ + public static class CliPaths + { + public static string TemplateCachePath => Path.Combine(AbpRootPath, "templates"); + public static string CliLogPath => Path.Combine(AbpRootPath, "cli", "logs"); + + private static readonly string AbpRootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".abp"); + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs index e81e7e414b..6f3956f604 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/AbpIoTemplateStore.cs @@ -3,6 +3,7 @@ using System.IO; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Volo.Abp.Cli; using Volo.Abp.DependencyInjection; using Volo.Abp.IO; @@ -19,7 +20,7 @@ namespace Volo.Abp.ProjectBuilding public async Task GetAsync(string templateName, string version) { - var localCacheFolder = "C:\\Temp\\abp-template-cache\\" + version; + var localCacheFolder = Path.Combine(CliPaths.TemplateCachePath, version); DirectoryHelper.CreateIfNotExists(localCacheFolder); var localCacheFile = Path.Combine(localCacheFolder, templateName + ".zip"); diff --git a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs index 706dc91d47..02759655ff 100644 --- a/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs +++ b/framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Serilog; using Serilog.Events; +using System.IO; using Volo.Abp.Threading; namespace Volo.Abp.Cli @@ -13,7 +14,7 @@ namespace Volo.Abp.Cli .MinimumLevel.Information() .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .Enrich.FromLogContext() - //.WriteTo.File("Logs/logs.txt") //TODO: Write logs to a global path + .WriteTo.File(Path.Combine(CliPaths.CliLogPath, "abp-cli-logs.txt")) .WriteTo.Console() .CreateLogger(); From 379a2e48ad7f78506e6fb80b0694b71bd9439bb4 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 3 May 2019 16:39:38 +0300 Subject: [PATCH 10/10] Move to a propert namespace. --- .../Volo/Abp/Cli/Commands/NewProjectCommand.cs | 5 +++-- .../Building/DatabaseProvider.cs | 2 +- .../Building/GithubRepositoryInfo.cs | 2 +- .../Building/ProjectBuildContext.cs | 5 ++--- .../Building/ProjectBuildContextExtensions.cs | 4 ++-- .../Building/ProjectBuildPipeline.cs | 2 +- .../Building/ProjectBuildPipelineBuilder.cs | 4 ++-- .../Building/ProjectBuildPipelineStep.cs | 2 +- .../Building/ProjectResult.cs | 2 +- .../Building/Steps/CreateProjectResultZipStep.cs | 6 +++--- .../Building/Steps/FileEntryListReadStep.cs | 6 +++--- .../Building/Steps/NugetReferenceReplaceStep.cs | 4 ++-- .../Building/Steps/RemoveProjectFromSolutionStep.cs | 2 +- .../Building/Steps/SolutionRenameStep.cs | 4 ++-- .../Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs | 4 ++-- .../Building/Steps/TemplateCodeDeleteStep.cs | 4 ++-- .../Building/TemplateInfo.cs | 2 +- .../DownloadInfo.cs | 4 ++-- .../Files/FileEntry.cs | 2 +- .../Files/FileEntryExtensions.cs | 2 +- .../Files/FileEntryList.cs | 2 +- .../Files/FileEntryListExtensions.cs | 2 +- .../Github/GithubRelease.cs | 2 +- .../Volo/Abp/ProjectBuilding/IProjectBuilder.cs | 1 - .../Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs | 2 +- .../Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs | 3 +-- .../ProjectBuildResult.cs | 2 +- .../Volo/Abp/ProjectBuilding/ProjectBuilder.cs | 3 +-- .../SolutionName.cs | 2 +- .../Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs | 2 +- .../ProjectBuilding/Templates/MvcApplicationTemplate.cs | 4 ++-- .../Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs | 2 +- .../Abp/ProjectBuilding/Templates/ServiceTemplate.cs | 2 +- .../Zipping/ZipFileExtensions.cs | 4 ++-- .../Volo/Abp/SolutionTemplating/StandardVersions.cs | 9 --------- 35 files changed, 49 insertions(+), 61 deletions(-) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/DatabaseProvider.cs (71%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/GithubRepositoryInfo.cs (94%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/ProjectBuildContext.cs (89%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/ProjectBuildContextExtensions.cs (83%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/ProjectBuildPipeline.cs (90%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/ProjectBuildPipelineBuilder.cs (86%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/ProjectBuildPipelineStep.cs (72%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/ProjectResult.cs (64%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/Steps/CreateProjectResultZipStep.cs (80%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/Steps/FileEntryListReadStep.cs (82%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/Steps/NugetReferenceReplaceStep.cs (97%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/Steps/RemoveProjectFromSolutionStep.cs (97%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/Steps/SolutionRenameStep.cs (97%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs (96%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/Steps/TemplateCodeDeleteStep.cs (82%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Building/TemplateInfo.cs (94%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/DownloadInfo.cs (92%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Files/FileEntry.cs (98%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Files/FileEntryExtensions.cs (98%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Files/FileEntryList.cs (83%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Files/FileEntryListExtensions.cs (92%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Github/GithubRelease.cs (90%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/ProjectBuildResult.cs (87%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/SolutionName.cs (97%) rename framework/src/Volo.Abp.Cli.Core/Volo/Abp/{SolutionTemplating => ProjectBuilding}/Zipping/ZipFileExtensions.cs (94%) delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/StandardVersions.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs index 09fd578d85..a1e69d14ca 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewProjectCommand.cs @@ -7,8 +7,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Cli.Args; using Volo.Abp.DependencyInjection; using Volo.Abp.ProjectBuilding; -using Volo.Abp.SolutionTemplating; -using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.ProjectBuilding.Building; namespace Volo.Abp.Cli.Commands { @@ -56,6 +55,8 @@ namespace Volo.Abp.Cli.Commands templateZipFile.ExtractAll(Directory.GetCurrentDirectory(), ExtractExistingFileAction.Throw); } } + + Logger.LogInformation($"Successfully created the project '{commandLineArgs.Target}'"); } protected virtual DatabaseProvider GetDatabaseProviderOrNull(CommandLineArgs commandLineArgs) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/DatabaseProvider.cs similarity index 71% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/DatabaseProvider.cs index e0e0f14e0b..0352bed89c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/DatabaseProvider.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/DatabaseProvider.cs @@ -1,4 +1,4 @@ -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public enum DatabaseProvider { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/GithubRepositoryInfo.cs similarity index 94% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/GithubRepositoryInfo.cs index f9d8812076..7a7277f8a4 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/GithubRepositoryInfo.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/GithubRepositoryInfo.cs @@ -1,6 +1,6 @@ using System; -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public class GithubRepositoryInfo { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildContext.cs similarity index 89% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildContext.cs index b620f6dc02..7e16a377c6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContext.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildContext.cs @@ -1,8 +1,7 @@ using JetBrains.Annotations; -using Volo.Abp.ProjectBuilding; -using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.ProjectBuilding.Files; -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public class ProjectBuildContext { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildContextExtensions.cs similarity index 83% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildContextExtensions.cs index 7178a24238..b4623e6744 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildContextExtensions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildContextExtensions.cs @@ -1,8 +1,8 @@ using System; using System.Linq; -using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.ProjectBuilding.Files; -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public static class ProjectBuildContextExtensions { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipeline.cs similarity index 90% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipeline.cs index 3e2e617517..c4afe2aab6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipeline.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipeline.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public class ProjectBuildPipeline { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipelineBuilder.cs similarity index 86% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipelineBuilder.cs index 44062f9cee..35ea1bfe39 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipelineBuilder.cs @@ -1,6 +1,6 @@ -using Volo.Abp.SolutionTemplating.Building.Steps; +using Volo.Abp.ProjectBuilding.Building.Steps; -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public static class ProjectBuildPipelineBuilder { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipelineStep.cs similarity index 72% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipelineStep.cs index d6ec90325f..3080224ed2 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectBuildPipelineStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectBuildPipelineStep.cs @@ -1,4 +1,4 @@ -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public abstract class ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectResult.cs similarity index 64% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectResult.cs index 3afc3e1a17..19230adfb5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/ProjectResult.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/ProjectResult.cs @@ -1,4 +1,4 @@ -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public class ProjectResult { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/CreateProjectResultZipStep.cs similarity index 80% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/CreateProjectResultZipStep.cs index 88f2558e58..a2b468effd 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/CreateProjectResultZipStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/CreateProjectResultZipStep.cs @@ -1,8 +1,8 @@ using Ionic.Zip; -using Volo.Abp.SolutionTemplating.Files; -using Volo.Abp.SolutionTemplating.Zipping; +using Volo.Abp.ProjectBuilding.Files; +using Volo.Abp.ProjectBuilding.Zipping; -namespace Volo.Abp.SolutionTemplating.Building.Steps +namespace Volo.Abp.ProjectBuilding.Building.Steps { public class CreateProjectResultZipStep : ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/FileEntryListReadStep.cs similarity index 82% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/FileEntryListReadStep.cs index 794f169a26..22f1d8840f 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/FileEntryListReadStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/FileEntryListReadStep.cs @@ -1,9 +1,9 @@ using System.IO; using Ionic.Zip; -using Volo.Abp.SolutionTemplating.Files; -using Volo.Abp.SolutionTemplating.Zipping; +using Volo.Abp.ProjectBuilding.Files; +using Volo.Abp.ProjectBuilding.Zipping; -namespace Volo.Abp.SolutionTemplating.Building.Steps +namespace Volo.Abp.ProjectBuilding.Building.Steps { public class FileEntryListReadStep : ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/NugetReferenceReplaceStep.cs similarity index 97% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/NugetReferenceReplaceStep.cs index 460e174252..3d41c682dc 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/NugetReferenceReplaceStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/NugetReferenceReplaceStep.cs @@ -2,9 +2,9 @@ using System.IO; using System.Linq; using HtmlAgilityPack; -using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.ProjectBuilding.Files; -namespace Volo.Abp.SolutionTemplating.Building.Steps +namespace Volo.Abp.ProjectBuilding.Building.Steps { public class NugetReferenceReplaceStep : ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/RemoveProjectFromSolutionStep.cs similarity index 97% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/RemoveProjectFromSolutionStep.cs index 7130b7ae1e..c956e4b4ab 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/RemoveProjectFromSolutionStep.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace Volo.Abp.SolutionTemplating.Building.Steps +namespace Volo.Abp.ProjectBuilding.Building.Steps { public class RemoveProjectFromSolutionStep : ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/SolutionRenameStep.cs similarity index 97% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/SolutionRenameStep.cs index 43d7356a32..20f2810633 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SolutionRenameStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/SolutionRenameStep.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.ProjectBuilding.Files; -namespace Volo.Abp.SolutionTemplating.Building.Steps +namespace Volo.Abp.ProjectBuilding.Building.Steps { public class SolutionRenameStep : ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs similarity index 96% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs index 64e1b44c11..6b77808f55 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs @@ -1,7 +1,7 @@ using System; -using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.ProjectBuilding.Files; -namespace Volo.Abp.SolutionTemplating.Building.Steps +namespace Volo.Abp.ProjectBuilding.Building.Steps { public class SwitchEntityFrameworkCoreToMongoDbStep : ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/TemplateCodeDeleteStep.cs similarity index 82% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/TemplateCodeDeleteStep.cs index e35e11d441..aa3990905a 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/Steps/TemplateCodeDeleteStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/Steps/TemplateCodeDeleteStep.cs @@ -1,6 +1,6 @@ -using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.ProjectBuilding.Files; -namespace Volo.Abp.SolutionTemplating.Building.Steps +namespace Volo.Abp.ProjectBuilding.Building.Steps { public class TemplateCodeDeleteStep : ProjectBuildPipelineStep { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/TemplateInfo.cs similarity index 94% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/TemplateInfo.cs index 0ef7d26a4f..c85d1d571c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Building/TemplateInfo.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Building/TemplateInfo.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using JetBrains.Annotations; -namespace Volo.Abp.SolutionTemplating.Building +namespace Volo.Abp.ProjectBuilding.Building { public abstract class TemplateInfo { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/DownloadInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/DownloadInfo.cs similarity index 92% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/DownloadInfo.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/DownloadInfo.cs index 0865e1175c..9d07f6e022 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/DownloadInfo.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/DownloadInfo.cs @@ -1,9 +1,9 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.ProjectBuilding.Building; -namespace Volo.Abp.SolutionTemplating +namespace Volo.Abp.ProjectBuilding { [Table("Downloads")] public class DownloadInfo : CreationAuditedAggregateRoot diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntry.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntry.cs similarity index 98% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntry.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntry.cs index 7f808ad4cf..5dd67846d2 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntry.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntry.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace Volo.Abp.SolutionTemplating.Files +namespace Volo.Abp.ProjectBuilding.Files { public class FileEntry { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryExtensions.cs similarity index 98% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryExtensions.cs index 999e8a9353..19bf75456c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryExtensions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryExtensions.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Volo.Abp.SolutionTemplating.Files +namespace Volo.Abp.ProjectBuilding.Files { public static class FileEntryExtensions { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryList.cs similarity index 83% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryList.cs index 17b7b757ba..34543e31fa 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryList.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryList.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Volo.Abp.SolutionTemplating.Files +namespace Volo.Abp.ProjectBuilding.Files { public class FileEntryList : List { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryListExtensions.cs similarity index 92% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryListExtensions.cs index 01acdf297b..1a1a47c1c6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Files/FileEntryListExtensions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Files/FileEntryListExtensions.cs @@ -1,7 +1,7 @@ using System; using Ionic.Zip; -namespace Volo.Abp.SolutionTemplating.Files +namespace Volo.Abp.ProjectBuilding.Files { public static class FileEntryListExtensions { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Github/GithubRelease.cs similarity index 90% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Github/GithubRelease.cs index 4e5ea612fe..449f9a43d5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Github/GithubRelease.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Github/GithubRelease.cs @@ -1,7 +1,7 @@ using System; using Newtonsoft.Json; -namespace Volo.Abp.SolutionTemplating.Github +namespace Volo.Abp.ProjectBuilding.Github { [JsonObject] public class GithubRelease diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs index 3011516061..c037442711 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/IProjectBuilder.cs @@ -1,5 +1,4 @@ using System.Threading.Tasks; -using Volo.Abp.SolutionTemplating; namespace Volo.Abp.ProjectBuilding { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs index ad8dbbe874..789e11b341 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ITemplateInfoProvider.cs @@ -1,4 +1,4 @@ -using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.ProjectBuilding.Building; namespace Volo.Abp.ProjectBuilding { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs index 34284ffafb..fffeb87a6c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildArgs.cs @@ -1,6 +1,5 @@ using JetBrains.Annotations; -using Volo.Abp.SolutionTemplating; -using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.ProjectBuilding.Building; namespace Volo.Abp.ProjectBuilding { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/ProjectBuildResult.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildResult.cs similarity index 87% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/ProjectBuildResult.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildResult.cs index dd43e8b63e..2acf036ddc 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/ProjectBuildResult.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuildResult.cs @@ -1,4 +1,4 @@ -namespace Volo.Abp.SolutionTemplating +namespace Volo.Abp.ProjectBuilding { public class ProjectBuildResult { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs index 501d309845..3a5c7a6b8a 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs @@ -2,8 +2,7 @@ using System.Threading.Tasks; using Volo.Abp.Cli; using Volo.Abp.DependencyInjection; -using Volo.Abp.SolutionTemplating; -using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.ProjectBuilding.Building; namespace Volo.Abp.ProjectBuilding { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionName.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/SolutionName.cs similarity index 97% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionName.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/SolutionName.cs index 63ec52a432..0e274f5ceb 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/SolutionName.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/SolutionName.cs @@ -1,6 +1,6 @@ using System; -namespace Volo.Abp.SolutionTemplating +namespace Volo.Abp.ProjectBuilding { public class SolutionName { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs index bfc5aec303..e386bd7ef1 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/TemplateInfoProvider.cs @@ -1,7 +1,7 @@ using System; using Volo.Abp.DependencyInjection; +using Volo.Abp.ProjectBuilding.Building; using Volo.Abp.ProjectBuilding.Templates; -using Volo.Abp.SolutionTemplating.Building; namespace Volo.Abp.ProjectBuilding { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs index 3b8dd55f54..581fe9fcb5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcApplicationTemplate.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using Volo.Abp.SolutionTemplating.Building; -using Volo.Abp.SolutionTemplating.Building.Steps; +using Volo.Abp.ProjectBuilding.Building; +using Volo.Abp.ProjectBuilding.Building.Steps; namespace Volo.Abp.ProjectBuilding.Templates { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs index a4f436932b..d2831d32b0 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/MvcModuleTemplate.cs @@ -1,4 +1,4 @@ -using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.ProjectBuilding.Building; namespace Volo.Abp.ProjectBuilding.Templates { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs index ebbd9fa90a..4b547eead0 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Templates/ServiceTemplate.cs @@ -1,4 +1,4 @@ -using Volo.Abp.SolutionTemplating.Building; +using Volo.Abp.ProjectBuilding.Building; namespace Volo.Abp.ProjectBuilding.Templates { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Zipping/ZipFileExtensions.cs similarity index 94% rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Zipping/ZipFileExtensions.cs index e4e5290194..97536bd6ea 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/Zipping/ZipFileExtensions.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/Zipping/ZipFileExtensions.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Ionic.Zip; -using Volo.Abp.SolutionTemplating.Files; +using Volo.Abp.ProjectBuilding.Files; -namespace Volo.Abp.SolutionTemplating.Zipping +namespace Volo.Abp.ProjectBuilding.Zipping { public static class ZipFileExtensions { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/StandardVersions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/StandardVersions.cs deleted file mode 100644 index df7b8b2e39..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/SolutionTemplating/StandardVersions.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Volo.Abp.SolutionTemplating -{ - public static class StandardVersions - { - public const string LatestStable = "LatestStable"; - - public const string LatestUnstable = "LatestUnstable"; - } -}