feat: 完成模板从gitee上获取
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -269,6 +269,7 @@ dist
|
|||||||
/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.Production.json
|
/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.Production.json
|
||||||
/Yi.Abp.Net8/test/Yi.Abp.Test/appsettings.Development.json
|
/Yi.Abp.Net8/test/Yi.Abp.Test/appsettings.Development.json
|
||||||
/Yi.Abp.Net8/test/Yi.Abp.Test/appsettings.Production.json
|
/Yi.Abp.Net8/test/Yi.Abp.Test/appsettings.Production.json
|
||||||
|
/Yi.Abp.Net8/tool/Yi.Abp.Tool.Web/appsettings.Development.json
|
||||||
database_backup
|
database_backup
|
||||||
/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.Staging.json
|
/Yi.Abp.Net8/src/Yi.Abp.Web/appsettings.Staging.json
|
||||||
/Yi.Abp.Net8/src/Yi.Abp.Web/logs/
|
/Yi.Abp.Net8/src/Yi.Abp.Web/logs/
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ namespace Yi.Abp.Tool.Application.Contracts.Dtos
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模块类型
|
||||||
|
/// </summary>
|
||||||
|
public string ModuleSoure { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据库提供者
|
/// 数据库提供者
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ namespace Yi.Abp.Tool.Application.Contracts
|
|||||||
public interface ITemplateGenService: IApplicationService
|
public interface ITemplateGenService: IApplicationService
|
||||||
{
|
{
|
||||||
Task<byte[]> CreateModuleAsync(TemplateGenCreateInputDto moduleCreateInputDto);
|
Task<byte[]> CreateModuleAsync(TemplateGenCreateInputDto moduleCreateInputDto);
|
||||||
Task<byte[]> CreateProjectAsync(TemplateGenCreateInputDto moduleCreateInputDto);
|
Task<List<string>> GetAllTemplatesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ using Yi.Framework.Core.Helper;
|
|||||||
|
|
||||||
namespace Yi.Abp.Tool.Application
|
namespace Yi.Abp.Tool.Application
|
||||||
{
|
{
|
||||||
public class TemplateGenService : ApplicationService,ITemplateGenService
|
public class TemplateGenService : ApplicationService, ITemplateGenService
|
||||||
{
|
{
|
||||||
private readonly TemplateGenManager _templateGenManager;
|
private readonly TemplateGenManager _templateGenManager;
|
||||||
public TemplateGenService(TemplateGenManager templateGenManager) { _templateGenManager = templateGenManager; }
|
|
||||||
|
public TemplateGenService(TemplateGenManager templateGenManager)
|
||||||
|
{
|
||||||
|
_templateGenManager = templateGenManager;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载模块文件
|
/// 下载模块文件
|
||||||
@@ -29,8 +33,10 @@ namespace Yi.Abp.Tool.Application
|
|||||||
{
|
{
|
||||||
moduleCreateInputDto.SetNameReplace();
|
moduleCreateInputDto.SetNameReplace();
|
||||||
|
|
||||||
|
//模块类型,就是分支小写
|
||||||
var input = moduleCreateInputDto.Adapt<TemplateGenCreateDto>();
|
var input = moduleCreateInputDto.Adapt<TemplateGenCreateDto>();
|
||||||
input.SetTemplateFilePath(_templateGenManager._toolOptions.ModuleTemplateFilePath);
|
input.SetTemplateGiteeRef(moduleCreateInputDto.ModuleSoure);
|
||||||
|
|
||||||
var filePath = await _templateGenManager.CreateTemplateAsync(input);
|
var filePath = await _templateGenManager.CreateTemplateAsync(input);
|
||||||
|
|
||||||
////考虑从路径中获取
|
////考虑从路径中获取
|
||||||
@@ -39,22 +45,15 @@ namespace Yi.Abp.Tool.Application
|
|||||||
return await File.ReadAllBytesAsync(filePath);
|
return await File.ReadAllBytesAsync(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载模块文件
|
/// 获取全部模板列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<byte[]> CreateProjectAsync(TemplateGenCreateInputDto moduleCreateInputDto)
|
[HttpGet("template-gen/template")]
|
||||||
|
public async Task<List<string>> GetAllTemplatesAsync()
|
||||||
{
|
{
|
||||||
moduleCreateInputDto.SetNameReplace();
|
return await _templateGenManager.GetAllTemplatesAsync();
|
||||||
|
|
||||||
var input = moduleCreateInputDto.Adapt<TemplateGenCreateDto>();
|
|
||||||
input.SetTemplateFilePath(_templateGenManager._toolOptions.ProjectTemplateFilePath);
|
|
||||||
var filePath = await _templateGenManager.CreateTemplateAsync(input);
|
|
||||||
|
|
||||||
//考虑从路径中获取
|
|
||||||
// var fileContentType = MimeHelper.GetMimeMapping(Path.GetFileName(filePath));
|
|
||||||
//设置附件下载,下载名称
|
|
||||||
return await File.ReadAllBytesAsync(filePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,21 +9,19 @@ namespace Yi.Abp.Tool.Domain.Shared.Dtos
|
|||||||
{
|
{
|
||||||
public class TemplateGenCreateDto
|
public class TemplateGenCreateDto
|
||||||
{
|
{
|
||||||
public void SetTemplateFilePath(string templateFilePath)
|
public void SetTemplateGiteeRef(string moduleType)
|
||||||
{
|
{
|
||||||
this.TemplateFilePath = templateFilePath;
|
this.GiteeRef = moduleType.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 模板文件路径
|
|
||||||
/// </summary>
|
|
||||||
public string TemplateFilePath { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模块名称
|
/// 模块名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 模块所属gitee分支
|
||||||
|
/// </summary>
|
||||||
|
public string GiteeRef { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据库提供者
|
/// 数据库提供者
|
||||||
|
|||||||
@@ -8,17 +8,6 @@ namespace Yi.Abp.Tool.Domain.Shared.Options
|
|||||||
{
|
{
|
||||||
public class ToolOptions
|
public class ToolOptions
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 模块模板zip文件路径
|
|
||||||
/// </summary>
|
|
||||||
public string ModuleTemplateFilePath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 项目模板zip文件路径
|
|
||||||
/// </summary>
|
|
||||||
public string ProjectTemplateFilePath { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 临时文件目录
|
/// 临时文件目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -9,5 +9,8 @@
|
|||||||
<ProjectReference Include="..\..\framework\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
<ProjectReference Include="..\..\framework\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||||
<ProjectReference Include="..\..\framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj" />
|
<ProjectReference Include="..\..\framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Options\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
85
Yi.Abp.Net8/tool/Yi.Abp.Tool.Domain/GiteeManager.cs
Normal file
85
Yi.Abp.Net8/tool/Yi.Abp.Tool.Domain/GiteeManager.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using System.Net;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Yi.Abp.Tool.Domain;
|
||||||
|
|
||||||
|
public class GiteeManager : ITransientDependency
|
||||||
|
{
|
||||||
|
private readonly string _accessToken;
|
||||||
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
|
private const string GiteeHost = "https://gitee.com/api/v5";
|
||||||
|
private const string Owner = "ccnetcore";
|
||||||
|
private const string Repo = "yi-template";
|
||||||
|
|
||||||
|
public GiteeManager(IConfiguration configuration, IHttpClientFactory httpClientFactory)
|
||||||
|
{
|
||||||
|
_httpClientFactory = httpClientFactory;
|
||||||
|
_accessToken = configuration.GetValue<string>("GiteeAccession");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在当前分支
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<bool> IsExsitBranchAsync(string branch)
|
||||||
|
{
|
||||||
|
using var client = _httpClientFactory.CreateClient();
|
||||||
|
var response =
|
||||||
|
await client.GetAsync(
|
||||||
|
$"{GiteeHost}/repos/{Owner}/{Repo}/branches/{branch}?access_token={_accessToken}");
|
||||||
|
if (response.StatusCode == HttpStatusCode.NotFound)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有分支
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<string>> GetAllBranchAsync()
|
||||||
|
{
|
||||||
|
using var client = _httpClientFactory.CreateClient();
|
||||||
|
var response =
|
||||||
|
await client.GetAsync(
|
||||||
|
$"{GiteeHost}/repos/{Owner}/{Repo}/branches?access_token={_accessToken}&sort=name&direction=asc&page=1&per_page=100");
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
var result= await response.Content.ReadAsStringAsync();
|
||||||
|
JArray jsonArray= JArray.Parse(result);
|
||||||
|
// 创建一个列表来存储名字
|
||||||
|
List<string> names = new List<string>();
|
||||||
|
|
||||||
|
// 遍历每个对象,获取 name 字段
|
||||||
|
foreach (JObject obj in jsonArray)
|
||||||
|
{
|
||||||
|
// 获取 name 字段的值
|
||||||
|
string name = obj["name"]?.ToString();
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
names.Add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载仓库分支代码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="branch"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<Stream> DownLoadFileAsync(string branch)
|
||||||
|
{
|
||||||
|
using var client = _httpClientFactory.CreateClient();
|
||||||
|
var response =
|
||||||
|
await client.GetAsync(
|
||||||
|
$"{GiteeHost}/repos/{Owner}/{Repo}/zipball?access_token={_accessToken}&ref={branch}");
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
return await response.Content.ReadAsStreamAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,13 +13,19 @@ namespace Yi.Abp.Tool.Domain
|
|||||||
{
|
{
|
||||||
public class TemplateGenManager : ITransientDependency
|
public class TemplateGenManager : ITransientDependency
|
||||||
{
|
{
|
||||||
public readonly ToolOptions _toolOptions;
|
private readonly ToolOptions _toolOptions;
|
||||||
public TemplateGenManager(IOptionsMonitor<ToolOptions> toolOptions) { _toolOptions = toolOptions.CurrentValue; }
|
private readonly GiteeManager _giteeManager;
|
||||||
|
public TemplateGenManager(IOptionsMonitor<ToolOptions> toolOptions, GiteeManager giteeManager)
|
||||||
|
{
|
||||||
|
_giteeManager = giteeManager;
|
||||||
|
_toolOptions = toolOptions.CurrentValue;
|
||||||
|
}
|
||||||
public async Task<string> CreateTemplateAsync(TemplateGenCreateDto input)
|
public async Task<string> CreateTemplateAsync(TemplateGenCreateDto input)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(input.TemplateFilePath))
|
//这里判断gitee上是否有这个分支
|
||||||
|
if (await _giteeManager.IsExsitBranchAsync(input.GiteeRef))
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException($"模板路径无法找到,请检查,[{input.TemplateFilePath}]路径");
|
throw new UserFriendlyException($"Gitee分支未找到{input.GiteeRef},请检查,[{input.GiteeRef}]分支是否存在");
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(_toolOptions.TempDirPath))
|
if (string.IsNullOrEmpty(_toolOptions.TempDirPath))
|
||||||
{
|
{
|
||||||
@@ -33,8 +39,15 @@ namespace Yi.Abp.Tool.Domain
|
|||||||
Directory.CreateDirectory(tempFileDirPath);
|
Directory.CreateDirectory(tempFileDirPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//文件解压覆盖
|
//下载的模板存放文件路径
|
||||||
ZipFile.ExtractToDirectory(input.TemplateFilePath, tempFileDirPath, true);
|
var downloadFilePath = Path.Combine(_toolOptions.TempDirPath,"download" ,$"{id}.zip");
|
||||||
|
var gitSteam= await _giteeManager.DownLoadFileAsync(input.GiteeRef);
|
||||||
|
using (FileStream fileStream = new FileStream(downloadFilePath, FileMode.Create, FileAccess.Write))
|
||||||
|
{
|
||||||
|
await gitSteam.CopyToAsync(fileStream);
|
||||||
|
}
|
||||||
|
//文件解压覆盖,将刚刚下载的模板,解压即可
|
||||||
|
ZipFile.ExtractToDirectory(downloadFilePath, tempFileDirPath, true);
|
||||||
|
|
||||||
await ReplaceContentAsync(tempFileDirPath, input.ReplaceStrData);
|
await ReplaceContentAsync(tempFileDirPath, input.ReplaceStrData);
|
||||||
var tempFilePath = Path.Combine(_toolOptions.TempDirPath, $"{id}.zip");
|
var tempFilePath = Path.Combine(_toolOptions.TempDirPath, $"{id}.zip");
|
||||||
@@ -45,13 +58,22 @@ namespace Yi.Abp.Tool.Domain
|
|||||||
return tempFilePath;
|
return tempFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取全部模板列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<string>> GetAllTemplatesAsync()
|
||||||
|
{
|
||||||
|
return await _giteeManager.GetAllBranchAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 替换内容,key为要替换的内容,value为替换成的内容
|
/// 替换内容,key为要替换的内容,value为替换成的内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task ReplaceContentAsync(string rootDirectory, Dictionary<string, string> dic)
|
private async Task ReplaceContentAsync(string rootDirectory, Dictionary<string, string> dic)
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (var dicEntry in dic)
|
foreach (var dicEntry in dic)
|
||||||
{
|
{
|
||||||
await ReplaceInDirectory(rootDirectory, dicEntry.Key, dicEntry.Value);
|
await ReplaceInDirectory(rootDirectory, dicEntry.Key, dicEntry.Value);
|
||||||
@@ -110,5 +132,6 @@ namespace Yi.Abp.Tool.Domain
|
|||||||
return directoryPath;
|
return directoryPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Text.Json.Serialization.Metadata;
|
||||||
using System.Threading.RateLimiting;
|
using System.Threading.RateLimiting;
|
||||||
using Microsoft.AspNetCore.Cors;
|
using Microsoft.AspNetCore.Cors;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
@@ -12,6 +15,7 @@ using Yi.Abp.Tool.Application;
|
|||||||
using Yi.Framework.AspNetCore;
|
using Yi.Framework.AspNetCore;
|
||||||
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
|
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
|
||||||
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
|
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Yi.Framework.Core.Json;
|
||||||
|
|
||||||
namespace Yi.Abp.Tool.Web
|
namespace Yi.Abp.Tool.Web
|
||||||
{
|
{
|
||||||
@@ -41,15 +45,17 @@ namespace Yi.Abp.Tool.Web
|
|||||||
});
|
});
|
||||||
|
|
||||||
//设置api格式
|
//设置api格式
|
||||||
service.AddControllers().AddNewtonsoftJson(options =>
|
Configure<JsonOptions>(options =>
|
||||||
{
|
{
|
||||||
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
options.JsonSerializerOptions.TypeInfoResolver = new DefaultJsonTypeInfoResolver();
|
||||||
options.SerializerSettings.Converters.Add(new StringEnumConverter());
|
options.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
|
||||||
|
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Configure<AbpAntiForgeryOptions>(options =>
|
Configure<AbpAntiForgeryOptions>(options =>
|
||||||
{
|
{
|
||||||
options.AutoValidate = false;
|
options.AutoValidate = false;
|
||||||
@@ -81,7 +87,7 @@ namespace Yi.Abp.Tool.Web
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
service.AddHttpClient();
|
||||||
//速率限制
|
//速率限制
|
||||||
//每60秒限制100个请求,滑块添加,分6段
|
//每60秒限制100个请求,滑块添加,分6段
|
||||||
service.AddRateLimiter(_ =>
|
service.AddRateLimiter(_ =>
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"GiteeAccession": "8d9f05faec154475f121079579a0abf0"
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,6 @@
|
|||||||
"TempDirPath": "wwwroot/temp",
|
"TempDirPath": "wwwroot/temp",
|
||||||
"ModuleTemplateFilePath": "wwwroot/ModuleTemplate.zip",
|
"ModuleTemplateFilePath": "wwwroot/ModuleTemplate.zip",
|
||||||
"ProjectTemplateFilePath": "wwwroot/ProjectTemplate.zip"
|
"ProjectTemplateFilePath": "wwwroot/ProjectTemplate.zip"
|
||||||
}
|
},
|
||||||
|
"GiteeAccession": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,33 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
|
|
||||||
public void CommandLineApplication(CommandLineApplication application)
|
public void CommandLineApplication(CommandLineApplication application)
|
||||||
{
|
{
|
||||||
var templateTypeOption = application.Option("-t|--moduleType", "模板类型:`module`|`porject`",
|
var templateTypeOption = application.Option("-t|--template", "模板类型:`module`|`porject`",
|
||||||
CommandOptionType.SingleValue);
|
CommandOptionType.SingleValue);
|
||||||
var pathOption = application.Option("-p|--path", "创建路径", CommandOptionType.SingleValue);
|
var pathOption = application.Option("-p|--path", "创建路径", CommandOptionType.SingleValue);
|
||||||
var csfOption = application.Option("-csf", "是否创建解决方案文件夹", CommandOptionType.NoValue);
|
var csfOption = application.Option("-csf", "是否创建解决方案文件夹", CommandOptionType.NoValue);
|
||||||
|
|
||||||
|
var soureOption = application.Option("-s|--soure", "模板来源,gitee模板库分支名称: 默认值`defualt`",
|
||||||
|
CommandOptionType.SingleValue);
|
||||||
|
|
||||||
var moduleNameArgument = application.Argument("moduleName", "模块名", (_) => { });
|
var moduleNameArgument = application.Argument("moduleName", "模块名", (_) => { });
|
||||||
|
|
||||||
|
//子命令,new list
|
||||||
|
application.Command("list",(applicationlist) =>
|
||||||
|
{
|
||||||
|
applicationlist.OnExecute(() =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("正在远程搜索中...");
|
||||||
|
var list=_templateGenService.GetAllTemplatesAsync().Result;
|
||||||
|
var tip = $"""
|
||||||
|
全部模板包括:
|
||||||
|
模板名称
|
||||||
|
----------------
|
||||||
|
{list.JoinAsString("\n")}
|
||||||
|
""";
|
||||||
|
Console.WriteLine(tip);
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
application.OnExecute(() =>
|
application.OnExecute(() =>
|
||||||
{
|
{
|
||||||
@@ -41,6 +62,8 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
var zipPath = string.Empty;
|
var zipPath = string.Empty;
|
||||||
byte[] fileByteArray;
|
byte[] fileByteArray;
|
||||||
|
|
||||||
|
var soure= soureOption.HasValue() ? soureOption.Value() : "defualt";
|
||||||
|
|
||||||
var templateType = templateTypeOption.HasValue() ? templateTypeOption.Value() : "module";
|
var templateType = templateTypeOption.HasValue() ? templateTypeOption.Value() : "module";
|
||||||
if (templateType == "module")
|
if (templateType == "module")
|
||||||
{
|
{
|
||||||
@@ -48,12 +71,13 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
fileByteArray = (_templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
|
fileByteArray = (_templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
|
||||||
{
|
{
|
||||||
Name = moduleNameArgument.Value,
|
Name = moduleNameArgument.Value,
|
||||||
|
ModuleSoure = soure
|
||||||
}).Result);
|
}).Result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//代表模块生成
|
//还是代表模块生成
|
||||||
fileByteArray = _templateGenService.CreateProjectAsync(new TemplateGenCreateInputDto
|
fileByteArray = _templateGenService.CreateModuleAsync(new TemplateGenCreateInputDto
|
||||||
{
|
{
|
||||||
Name = moduleNameArgument.Value,
|
Name = moduleNameArgument.Value,
|
||||||
}).Result;
|
}).Result;
|
||||||
|
|||||||
@@ -13,13 +13,15 @@ class Program
|
|||||||
//args = ["-h"];
|
//args = ["-h"];
|
||||||
|
|
||||||
//版本
|
//版本
|
||||||
args = ["-v"];
|
// args = ["-v"];
|
||||||
|
|
||||||
//清理
|
//清理
|
||||||
// args = ["clear"];
|
// args = ["clear"];
|
||||||
|
|
||||||
//创建模块
|
//创建模块
|
||||||
//args = ["new","oooo", "-t","module","-p","D:\\temp","-csf"];
|
//args = ["new","oooo", "-t","module","-p","D:\\temp","-csf"];
|
||||||
|
//查看模板列表
|
||||||
|
args = ["new","list"];
|
||||||
|
|
||||||
//添加模块
|
//添加模块
|
||||||
//args = ["add-module", "kkk"];
|
//args = ["add-module", "kkk"];
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ namespace Yi.Abp.Tool
|
|||||||
Configure<AbpRemoteServiceOptions>(options =>
|
Configure<AbpRemoteServiceOptions>(options =>
|
||||||
{
|
{
|
||||||
options.RemoteServices.Default =
|
options.RemoteServices.Default =
|
||||||
new RemoteServiceConfiguration("https://ccnetcore.com:19009");
|
// new RemoteServiceConfiguration("https://ccnetcore.com:19009");
|
||||||
|
new RemoteServiceConfiguration("http://localhost:19002");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user