Browse Source

fix: 修复cli

pull/126/head 7.2.2.4
wangjun 3 years ago
parent
commit
4aaf449db1
  1. 11
      Readme.md
  2. 4
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpCliOptions.cs
  3. 22
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs
  4. 16
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Commands/NewCommand.cs
  5. 5
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs
  6. 5
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs
  7. 31
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs
  8. 2
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/DirectoryAndFileHelper.cs
  9. 4
      aspnet-core/frameworks/src/Lion.AbpPro.Cli/Lion.AbpPro.Cli.csproj

11
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 默认当前控制台执行目录
```
## ✨ 系统功能

4
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpCliOptions.cs

@ -6,9 +6,9 @@ public class AbpCliOptions
/// <summary>
/// Default value: "abppro".
/// Default value: "lion.abp".
/// </summary>
public string ToolName { get; set; } = "abppro";
public string ToolName { get; set; } = "lion.abp";
public AbpCliOptions()
{

22
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs

@ -21,26 +21,34 @@ public class AbpProCliCoreModule : AbpModule
options.Token = "abp-vnext-proghp_47vqiabp-vnext-provNkHKJguOJkdHvnxUabp-vnext-protij7Qbdn1Qy3fUabp-vnext-pro";
options.Templates = new List<LionAbpProTemplateOptions>()
{
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"
},
};
});

16
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Commands/NewCommand.cs

@ -30,11 +30,7 @@ public class NewCommand : IConsoleCommand, ITransientDependency
{
#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 class NewCommand : IConsoleCommand, ITransientDependency
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 class NewCommand : IConsoleCommand, ITransientDependency
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;
}
}

5
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs

@ -26,8 +26,5 @@ public class LionAbpProOptions
/// 模板信息
/// </summary>
public List<LionAbpProTemplateOptions> Templates { get; set; }
public string OldCompanyName { get; set; }= "Lion";
public string OldProjectName { get; set; } = "AbpPro";
}

5
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs

@ -40,4 +40,9 @@ public class LionAbpProTemplateOptions
/// 是否源码版本
/// </summary>
public bool IsSource { get; set; }
public string OldCompanyName { get; set; }
public string OldProjectName { get; set; }
}

31
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs

@ -115,21 +115,28 @@ public class SourceCodeManager : ITransientDependency, ISourceCodeManager
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}");
}
}

2
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Utils/DirectoryAndFileHelper.cs

@ -63,7 +63,7 @@ public static class DirectoryAndFileHelper
CopyFolder(folder, dest); //构建目标路径,递归复制文件
}
}
catch (Exception)
catch
{
throw new UserFriendlyException("复制文件失败!");
}

4
aspnet-core/frameworks/src/Lion.AbpPro.Cli/Lion.AbpPro.Cli.csproj

@ -4,8 +4,8 @@
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<PackAsTool>true</PackAsTool>
<PackageId>abp-pro-cli</PackageId>
<ToolCommandName>abppro</ToolCommandName>
<PackageId>Lion.AbpPro.Cli</PackageId>
<ToolCommandName>lion.abp</ToolCommandName>
<RootNamespace />
</PropertyGroup>

Loading…
Cancel
Save