Skip to content

Commit

Permalink
fix: 修复cli
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJunZzz committed Jun 17, 2023
1 parent d2fd30c commit 4aaf449
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 40 deletions.
11 changes: 8 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 默认当前控制台执行目录
```


## ✨ 系统功能
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<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"
},
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public LionAbpProTemplateOptions(string key, string name, string description, bo
/// 是否源码版本
/// </summary>
public bool IsSource { get; set; }


public string OldCompanyName { get; set; }

public string OldProjectName { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void CopyFolder(string sourceFolder, string destFolder, string exc
CopyFolder(folder, dest); //构建目标路径,递归复制文件
}
}
catch (Exception)
catch
{
throw new UserFriendlyException("复制文件失败!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down

0 comments on commit 4aaf449

Please sign in to comment.