Browse Source

feat: cli create 添加创建模块指令

main
wangjunzzz 2 months ago
parent
commit
5c89b96a85
  1. 9
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/AbpProCliCoreModule.cs
  2. 16
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Commands/CreateCommand.cs

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

@ -78,6 +78,15 @@ public class AbpProCliCoreModule : AbpModule
OldModuleName = "", OldModuleName = "",
}, },
new AbpProTemplateOptions("pro-module", "pro-module", "模块")
{
ExcludeFiles = "aspnet-core,vben28,abp-nuget,docs,.github,LICENSE,.idea,Lion.AbpPro.Cli.slnx,Lion.AbpPro.slnx.sln.DotSettings.user",
ReplaceSuffix = ".slnx,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env,Directory.Build.Lion.targets",
OldCompanyName = "MyCompanyName",
OldProjectName = "MyProjectName",
OldModuleName = "MyModuleName",
},
new AbpProTemplateOptions("pro-nuget-gateways", "pro-nuget", "商业版本nuget网关版本") new AbpProTemplateOptions("pro-nuget-gateways", "pro-nuget", "商业版本nuget网关版本")
{ {
ExcludeFiles = ".github,LICENSE,Readme.md,aspnet-core,.idea,MyCompanyName.MyProjectName.slnx,MyCompanyName.MyProjectName.slnx.DotSettings.user,Lion.AbpPro.Cli.sln", ExcludeFiles = ".github,LICENSE,Readme.md,aspnet-core,.idea,MyCompanyName.MyProjectName.slnx,MyCompanyName.MyProjectName.slnx.DotSettings.user,Lion.AbpPro.Cli.sln",

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

@ -68,7 +68,15 @@ public class CreateCommand : IConsoleCommand, ITransientDependency
GetUsageInfo(); GetUsageInfo();
return; return;
} }
//校验是否输入模块名称
var moduleName = commandLineArgs.Options.GetOrNull(CommandOptions.Module.Short, CommandOptions.Module.Long);
if (templateOptions.Key == "pro-module" && moduleName.IsNullOrWhiteSpace())
{
_logger.LogError("请输入公司名称lion.abp create -m 模块名称");
GetUsageInfo();
return;
}
var version = commandLineArgs.Options.GetOrNull(CommandOptions.Version.Short, CommandOptions.Version.Long); var version = commandLineArgs.Options.GetOrNull(CommandOptions.Version.Short, CommandOptions.Version.Long);
var output = commandLineArgs.Options.GetOrNull(CommandOptions.Output.Short, CommandOptions.Output.Long); var output = commandLineArgs.Options.GetOrNull(CommandOptions.Output.Short, CommandOptions.Output.Long);
@ -108,11 +116,11 @@ public class CreateCommand : IConsoleCommand, ITransientDependency
if (output.IsNullOrWhiteSpace()) if (output.IsNullOrWhiteSpace())
{ {
// 复制源码到输出目录 // 复制源码到输出目录
output = Path.Combine(CliPaths.Output, $"{companyName}{projectName}{version}"); output = Path.Combine(CliPaths.Output, $"{companyName}{projectName}-{moduleName}-{version}");
} }
else else
{ {
output = Path.Combine(output, $"{companyName}{projectName}{version}"); output = Path.Combine(output, $"{companyName}{projectName}-{moduleName}-{version}");
} }
@ -126,7 +134,7 @@ public class CreateCommand : IConsoleCommand, ITransientDependency
templateOptions.OldModuleName, templateOptions.OldModuleName,
companyName, companyName,
projectName, projectName,
string.Empty, moduleName,
templateOptions.ReplaceSuffix, templateOptions.ReplaceSuffix,
version, version,
true); true);

Loading…
Cancel
Save