feat: 完成abp-tool搭建
This commit is contained in:
BIN
Yi.Abp.Net8/tool/Yi.Abp.Tool.Web/wwwroot/ProjectTemplate.zip
Normal file
BIN
Yi.Abp.Net8/tool/Yi.Abp.Tool.Web/wwwroot/ProjectTemplate.zip
Normal file
Binary file not shown.
@@ -28,8 +28,8 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
|
|
||||||
> v: 查看yi-abp工具版本号
|
> v: 查看yi-abp工具版本号
|
||||||
> help: 查看帮助列表,写下命令` yi-abp help <command> `
|
> help: 查看帮助列表,写下命令` yi-abp help <command> `
|
||||||
> new: 创建模板--(正在更新)
|
> new: 创建模块模板` yi-abp new <name> -t module -csf `
|
||||||
|
> new: 创建项目模板` yi-abp new <name> -csf `
|
||||||
""");
|
""");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,34 +31,37 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
}
|
}
|
||||||
string name = args[1];
|
string name = args[1];
|
||||||
|
|
||||||
|
#region 处理生成类型
|
||||||
|
|
||||||
options.TryGetValue("t", out var templateType);
|
options.TryGetValue("t", out var templateType);
|
||||||
var zipPath = string.Empty;
|
var zipPath = string.Empty;
|
||||||
|
byte[] fileByteArray;
|
||||||
if (templateType == "module")
|
if (templateType == "module")
|
||||||
{
|
{
|
||||||
//代表模块生成
|
//代表模块生成
|
||||||
var fileByteArray = await _templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
|
fileByteArray = await _templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
});
|
});
|
||||||
zipPath = $"{id}.zip";
|
|
||||||
await File.WriteAllBytesAsync(zipPath, fileByteArray);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//暂未实现
|
|
||||||
throw new NotImplementedException("暂未实现");
|
|
||||||
//代表模块生成
|
//代表模块生成
|
||||||
var fileResult = await _templateGenService.CreateProjectAsync(new TemplateGenCreateInputDto
|
fileByteArray = await _templateGenService.CreateProjectAsync(new TemplateGenCreateInputDto
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
zipPath = $"{id}.zip";
|
||||||
|
await File.WriteAllBytesAsync(zipPath, fileByteArray);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 处理解决方案文件夹
|
||||||
//默认是当前目录
|
//默认是当前目录
|
||||||
var unzipDirPath = "./";
|
var unzipDirPath = "./";
|
||||||
//如果创建解决方案文件夹
|
//如果创建解决方案文件夹
|
||||||
if (templateType == "module"&&options.TryGetValue("csf", out _))
|
if (options.TryGetValue("csf", out _))
|
||||||
{
|
{
|
||||||
var moduleName = name.ToLower().Replace(".", "-");
|
var moduleName = name.ToLower().Replace(".", "-");
|
||||||
|
|
||||||
@@ -69,12 +72,13 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
Directory.CreateDirectory(moduleName);
|
Directory.CreateDirectory(moduleName);
|
||||||
unzipDirPath = moduleName;
|
unzipDirPath = moduleName;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
ZipFile.ExtractToDirectory(zipPath, unzipDirPath);
|
ZipFile.ExtractToDirectory(zipPath, unzipDirPath);
|
||||||
//创建压缩包后删除临时目录
|
//创建压缩包后删除临时目录
|
||||||
File.Delete(zipPath);
|
File.Delete(zipPath);
|
||||||
|
|
||||||
|
|
||||||
await Console.Out.WriteLineAsync("模块已生成!");
|
await Console.Out.WriteLineAsync("恭喜~模块已生成!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Yi.Abp.Tool;
|
using Yi.Abp.Tool;
|
||||||
using Yi.Abp.Tool.Application.Contracts;
|
using Yi.Abp.Tool.Application.Contracts;
|
||||||
@@ -25,6 +26,10 @@ class Program
|
|||||||
{
|
{
|
||||||
await service.AddApplicationAsync<YiAbpToolModule>();
|
await service.AddApplicationAsync<YiAbpToolModule>();
|
||||||
})
|
})
|
||||||
|
.ConfigureAppConfiguration(configurationBuilder =>
|
||||||
|
{
|
||||||
|
configurationBuilder.AddJsonFile("appsettings.json");
|
||||||
|
})
|
||||||
.UseAutofac()
|
.UseAutofac()
|
||||||
.Build();
|
.Build();
|
||||||
var commandSelector = host.Services.GetRequiredService<CommandSelector>();
|
var commandSelector = host.Services.GetRequiredService<CommandSelector>();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.2.0</Version>
|
<Version>0.3.0</Version>
|
||||||
<Authors>橙子老哥</Authors>
|
<Authors>橙子老哥</Authors>
|
||||||
<Description>yi-framework框架配套工具</Description>
|
<Description>yi-framework框架配套工具</Description>
|
||||||
<PackageProjectUrl>https://ccnetcore.com</PackageProjectUrl>
|
<PackageProjectUrl>https://ccnetcore.com</PackageProjectUrl>
|
||||||
@@ -37,6 +37,9 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="readme.md">
|
<None Update="readme.md">
|
||||||
<Pack>True</Pack>
|
<Pack>True</Pack>
|
||||||
<PackagePath>\</PackagePath>
|
<PackagePath>\</PackagePath>
|
||||||
|
|||||||
@@ -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
|
namespace Yi.Abp.Tool
|
||||||
{
|
{
|
||||||
@@ -6,5 +8,15 @@ namespace Yi.Abp.Tool
|
|||||||
)]
|
)]
|
||||||
public class YiAbpToolModule : AbpModule
|
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"]);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
Yi.Abp.Net8/tool/Yi.Abp.Tool/appsettings.json
Normal file
3
Yi.Abp.Net8/tool/Yi.Abp.Tool/appsettings.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"YiAbpToolUrl": "https://ccnetcore.com:19002"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user