From 4aaf449db10eeae9e778bbdb155a6a740c14bbd2 Mon Sep 17 00:00:00 2001
From: wangjun <510423039@qq.com>
Date: Sat, 17 Jun 2023 13:35:01 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dcli?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Readme.md | 11 +++++--
.../Lion/AbpPro/Cli/AbpCliOptions.cs | 4 +--
.../Lion/AbpPro/Cli/AbpProCliCoreModule.cs | 22 ++++++++-----
.../Lion/AbpPro/Cli/Commands/NewCommand.cs | 16 +++++-----
.../AbpPro/Cli/Options/LionAbpProOptions.cs | 5 +--
.../Cli/Options/LionAbpProTemplateOptions.cs | 5 +++
.../Cli/SourceCode/SourceCodeManager.cs | 31 ++++++++++++-------
.../Cli/Utils/DirectoryAndFileHelper.cs | 2 +-
.../Lion.AbpPro.Cli/Lion.AbpPro.Cli.csproj | 4 +--
9 files changed, 60 insertions(+), 40 deletions(-)
diff --git a/Readme.md b/Readme.md
index 47f09638f..c3b7a92ed 100644
--- a/Readme.md
+++ b/Readme.md
@@ -26,23 +26,28 @@ dotnet tool install Lion.AbpPro.Cli -g
- 生成源码版本
```bash
-lion.abp new abp-vnext-pro -c 公司名称 -p 项目名称 -v 版本号(可选)
+lion.abp new -t pro -c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录
```
- nuget包形式的网关基础版本
- abp自带的所有模块,pro的通知模块,数据字典模块 以及ocelot网关。
```bash
-lion.abp new abp-vnext-pro-basic -c 公司名称 -p 项目名称 -v 版本(可选)
+lion.abp new -t pro.all -c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录
```
- nuget包形式的基础版本
- abp自带的所有模块,pro的通知模块,数据字典模块 无ocelot网关
```bash
-lion.abp new abp-vnext-pro-basic-no-ocelot -c 公司名称 -p 项目名称 -v 版本(可选)
+lion.abp new -t pro.simplify -c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录
```
+- 模块
+
+```bash
+lion.abp new -t pro.module -c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录
+```
## ✨ 系统功能
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpCliOptions.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpCliOptions.cs
index 0eb00fa6f..f7cf87ae8 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpCliOptions.cs
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpCliOptions.cs
@@ -6,9 +6,9 @@ public class AbpCliOptions
///
- /// Default value: "abppro".
+ /// Default value: "lion.abp".
///
- public string ToolName { get; set; } = "abppro";
+ public string ToolName { get; set; } = "lion.abp";
public AbpCliOptions()
{
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs
index e9b9d275e..4d79924cc 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs
@@ -21,26 +21,34 @@ public override void ConfigureServices(ServiceConfigurationContext context)
options.Token = "abp-vnext-proghp_47vqiabp-vnext-provNkHKJguOJkdHvnxUabp-vnext-protij7Qbdn1Qy3fUabp-vnext-pro";
options.Templates = new List()
{
- new LionAbpProTemplateOptions("abp-vnext-pro", "abp.vnext.pro", "源码版本", true)
+ new LionAbpProTemplateOptions("abp-vnext-pro", "pro", "源码版本", true)
{
ExcludeFiles = "templates,docs,.github,LICENSE,Readme.md",
ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env",
+ OldCompanyName = "Lion",
+ OldProjectName = "AbpPro"
},
- new LionAbpProTemplateOptions("abp-vnext-pro-nuget-all", "abp.vnext.pro.nuget.all", "Nuget完整版本")
+ new LionAbpProTemplateOptions("abp-vnext-pro-nuget-all", "pro.all", "Nuget完整版本")
{
- ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-module,abp-vnext-pro-nuget-simplify,docs,.github,LICENSE,Readme.md",
+ //ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-module,abp-vnext-pro-nuget-simplify,docs,.github,LICENSE,Readme.md",
ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env",
+ OldCompanyName = "MyCompanyName",
+ OldProjectName = "MyProjectName"
},
- new LionAbpProTemplateOptions("abp-vnext-pro-nuget-simplify", "abp.vnext.pro.nuget.simplify", "Nuget简单版本")
+ new LionAbpProTemplateOptions("abp-vnext-pro-nuget-simplify", "pro.simplify", "Nuget简单版本")
{
- ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-module,abp-vnext-pro-nuget-all,docs,.github,LICENSE,Readme.md",
+ //ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-module,abp-vnext-pro-nuget-all,docs,.github,LICENSE,Readme.md",
ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env",
+ OldCompanyName = "MyCompanyName",
+ OldProjectName = "MyProjectName"
},
- new LionAbpProTemplateOptions("abp-vnext-pro-nuget-module", "abp.vnext.pro.nuget.module", "模块")
+ new LionAbpProTemplateOptions("abp-vnext-pro-nuget-module", "pro.module", "模块")
{
- ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-all,abp-vnext-pro-nuget-simplify,docs,.github,LICENSE,Readme.md",
+ //ExcludeFiles = "aspnet-core,vben28,abp-vnext-pro-nuget-all,abp-vnext-pro-nuget-simplify,docs,.github,LICENSE,Readme.md",
ReplaceSuffix = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env",
+ OldCompanyName = "MyCompanyName",
+ OldProjectName = "MyProjectName"
},
};
});
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Commands/NewCommand.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Commands/NewCommand.cs
index 42f379d87..6d58f611d 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Commands/NewCommand.cs
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Commands/NewCommand.cs
@@ -30,11 +30,7 @@ public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
#region 参数获取
- var context = new SourceCodeContext
- {
- OldCompanyName = _options.OldCompanyName,
- OldProjectName = _options.OldProjectName
- };
+ var context = new SourceCodeContext();
// 检查模板是否正确
var template = commandLineArgs.Options.GetOrNull(CommandOptions.Template.Short, CommandOptions.Template.Long);
if (template.IsNullOrWhiteSpace())
@@ -60,6 +56,8 @@ public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
context.IsSource = templateOptions.IsSource;
context.ExcludeFiles = templateOptions.ExcludeFiles;
context.ReplaceSuffix = templateOptions.ReplaceSuffix;
+ context.OldCompanyName = templateOptions.OldCompanyName;
+ context.OldProjectName = templateOptions.OldProjectName;
// if (commandLineArgs.Target.IsNullOrWhiteSpace())
// {
// GetUsageInfo();
@@ -138,13 +136,13 @@ public void GetUsageInfo()
public string GetShortDescription()
{
var message = Environment.NewLine;
- message += $" > lion.abp new abp-vnext-pro -c 公司名称 -p 项目名称 -v 版本(默认LastRelease)";
+ message += $" > lion.abp new -t pro -c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录";
message += Environment.NewLine;
- message += $" > lion.abp new abp-vnext-pro-basic -c 公司名称 -p 项目名称 -v 版本(默认LastRelease)";
+ message += $" > lion.abp new -t pro.all -c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录";
message += Environment.NewLine;
- message += $" > lion.abp new abp-vnext-pro-basic-no-ocelot -c 公司名称 -p 项目名称 -v 版本(默认LastRelease)";
+ message += $" > lion.abp new -t pro.simplify -c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录";
message += Environment.NewLine;
- message += $" > lion.abp new abp-vnext-pro-module -c 公司名称 -p 项目名称 -m 模块名称 -v 版本(默认LastRelease)";
+ message += $" > lion.abp new -t pro.module-c 公司名称 -p 项目名称 -v 版本(默认LastRelease) -o 默认当前控制台执行目录";
return message;
}
}
\ No newline at end of file
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs
index 9c80b8fe6..40fd5334f 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs
@@ -26,8 +26,5 @@ public class LionAbpProOptions
/// 模板信息
///
public List Templates { get; set; }
-
- public string OldCompanyName { get; set; }= "Lion";
-
- public string OldProjectName { get; set; } = "AbpPro";
+
}
\ No newline at end of file
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs
index c87a0b233..d96c01311 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs
@@ -40,4 +40,9 @@ public LionAbpProTemplateOptions(string key, string name, string description, bo
/// 是否源码版本
///
public bool IsSource { get; set; }
+
+
+ public string OldCompanyName { get; set; }
+
+ public string OldProjectName { get; set; }
}
\ No newline at end of file
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs
index 6a622f0f5..64efab0ad 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs
@@ -115,21 +115,28 @@ public void MoveTemplate(SourceCodeContext context)
public void ReplaceTemplates(SourceCodeContext context)
{
- ReplaceHelper.ReplaceTemplates(context.ExtractProjectPath, context.OldCompanyName, context.OldProjectName, context.CompanyName, context.ProjectName, context.ReplaceSuffix);
- if (context.IsSource)
+ try
{
- context.TemplateFolder = context.ExtractProjectPath;
+ ReplaceHelper.ReplaceTemplates(context.ExtractProjectPath, context.OldCompanyName, context.OldProjectName, context.CompanyName, context.ProjectName, context.ReplaceSuffix);
+ if (context.IsSource)
+ {
+ context.TemplateFolder = context.ExtractProjectPath;
+ }
+ else
+ {
+ // 获取本地源码地址
+ context.TemplateFolder = Path.Combine(context.ExtractProjectPath, "templates", context.TemplateKey);
+ }
+
+ context.OutputFolder = Path.Combine(context.OutputFolder, context.CompanyName + "." + context.ProjectName);
+ DirectoryHelper.DeleteIfExists(context.OutputFolder, true);
+ DirectoryAndFileHelper.CopyFolder(context.TemplateFolder, context.OutputFolder, context.ExcludeFiles);
+
+ _logger.LogInformation($"OutputFolder:{context.OutputFolder}");
}
- else
+ finally
{
- // 获取本地源码地址
- context.TemplateFolder = Path.Combine(context.ExtractProjectPath, _options.RepositoryId + "-" + context.TemplateFile.Version, "templates", context.TemplateKey);
+ DirectoryHelper.DeleteIfExists(context.ExtractProjectPath, true);
}
-
- context.OutputFolder = Path.Combine(context.OutputFolder, context.CompanyName + "." + context.ProjectName);
- DirectoryHelper.DeleteIfExists(context.OutputFolder, true);
- DirectoryAndFileHelper.CopyFolder(context.TemplateFolder, context.OutputFolder, context.ExcludeFiles);
- DirectoryHelper.DeleteIfExists(context.ExtractProjectPath, true);
- _logger.LogInformation($"OutputFolder:{context.OutputFolder}");
}
}
\ No newline at end of file
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/DirectoryAndFileHelper.cs b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/DirectoryAndFileHelper.cs
index 124b751f6..2b74f6a46 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/DirectoryAndFileHelper.cs
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/DirectoryAndFileHelper.cs
@@ -63,7 +63,7 @@ public static void CopyFolder(string sourceFolder, string destFolder, string exc
CopyFolder(folder, dest); //构建目标路径,递归复制文件
}
}
- catch (Exception)
+ catch
{
throw new UserFriendlyException("复制文件失败!");
}
diff --git a/aspnet-core/frameworks/src/Lion.AbpPro.Cli/Lion.AbpPro.Cli.csproj b/aspnet-core/frameworks/src/Lion.AbpPro.Cli/Lion.AbpPro.Cli.csproj
index e9288820e..8d9967e4d 100644
--- a/aspnet-core/frameworks/src/Lion.AbpPro.Cli/Lion.AbpPro.Cli.csproj
+++ b/aspnet-core/frameworks/src/Lion.AbpPro.Cli/Lion.AbpPro.Cli.csproj
@@ -4,8 +4,8 @@
Exe
net7.0
true
- abp-pro-cli
- abppro
+ Lion.AbpPro.Cli
+ lion.abp