feat: 完成abp-tool搭建

This commit is contained in:
橙子
2024-06-02 17:20:38 +08:00
parent d9c9db332c
commit 5df066999b
7 changed files with 41 additions and 14 deletions

View File

@@ -28,8 +28,8 @@ namespace Yi.Abp.Tool.Commands
> v: 查看yi-abp工具版本号
> help: 查看帮助列表,写下命令` yi-abp help <command> `
> new: 创建模板--(正在更新)
> new: 创建模块模板` yi-abp new <name> -t module -csf `
> new: 创建项目模板` yi-abp new <name> -csf `
""");
return Task.CompletedTask;
}

View File

@@ -31,34 +31,37 @@ namespace Yi.Abp.Tool.Commands
}
string name = args[1];
#region
options.TryGetValue("t", out var templateType);
var zipPath = string.Empty;
byte[] fileByteArray;
if (templateType == "module")
{
//代表模块生成
var fileByteArray = await _templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
fileByteArray = await _templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
{
Name = name,
});
zipPath = $"{id}.zip";
await File.WriteAllBytesAsync(zipPath, fileByteArray);
}
else
{
//暂未实现
throw new NotImplementedException("暂未实现");
//代表模块生成
var fileResult = await _templateGenService.CreateProjectAsync(new TemplateGenCreateInputDto
fileByteArray = await _templateGenService.CreateProjectAsync(new TemplateGenCreateInputDto
{
Name = name,
});
}
zipPath = $"{id}.zip";
await File.WriteAllBytesAsync(zipPath, fileByteArray);
#endregion
#region
//默认是当前目录
var unzipDirPath = "./";
//如果创建解决方案文件夹
if (templateType == "module"&&options.TryGetValue("csf", out _))
if (options.TryGetValue("csf", out _))
{
var moduleName = name.ToLower().Replace(".", "-");
@@ -69,12 +72,13 @@ namespace Yi.Abp.Tool.Commands
Directory.CreateDirectory(moduleName);
unzipDirPath = moduleName;
}
#endregion
ZipFile.ExtractToDirectory(zipPath, unzipDirPath);
//创建压缩包后删除临时目录
File.Delete(zipPath);
await Console.Out.WriteLineAsync("模块已生成!");
await Console.Out.WriteLineAsync("恭喜~模块已生成!");
}
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Yi.Abp.Tool;
using Yi.Abp.Tool.Application.Contracts;
@@ -25,6 +26,10 @@ class Program
{
await service.AddApplicationAsync<YiAbpToolModule>();
})
.ConfigureAppConfiguration(configurationBuilder =>
{
configurationBuilder.AddJsonFile("appsettings.json");
})
.UseAutofac()
.Build();
var commandSelector = host.Services.GetRequiredService<CommandSelector>();

View File

@@ -5,7 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.2.0</Version>
<Version>0.3.0</Version>
<Authors>橙子老哥</Authors>
<Description>yi-framework框架配套工具</Description>
<PackageProjectUrl>https://ccnetcore.com</PackageProjectUrl>
@@ -37,6 +37,9 @@
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="readme.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>

View File

@@ -1,4 +1,6 @@
using Yi.Abp.Tool.HttpApi.Client;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Http.Client;
using Yi.Abp.Tool.HttpApi.Client;
namespace Yi.Abp.Tool
{
@@ -6,5 +8,15 @@ namespace Yi.Abp.Tool
)]
public class YiAbpToolModule : AbpModule
{
public override void PostConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<AbpRemoteServiceOptions>(options =>
{
options.RemoteServices.Default =
new RemoteServiceConfiguration(configuration["YiAbpToolUrl"]);
});
}
}
}

View File

@@ -0,0 +1,3 @@
{
"YiAbpToolUrl": "https://ccnetcore.com:19002"
}