Browse Source

feat: 添加模板项目和Cli项目

pull/126/head
wangjun 3 years ago
parent
commit
2db39732a5
  1. 2
      .github/workflows/docker-image.yml
  2. 2
      .github/workflows/nuget.yml
  3. 3
      aspnet-core/Directory.Build.Microsoft.targets
  4. 1
      aspnet-core/Directory.Build.Volo.targets
  5. 2
      aspnet-core/Directory.Build.targets
  6. 14
      aspnet-core/Lion.AbpPro.sln
  7. 22
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/GlobalUsings.cs
  8. 19
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Github/ILionAbpProManager.cs
  9. 68
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Github/LionAbpProManager.cs
  10. 33
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs
  11. 43
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs
  12. 20
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/ISourceCodeManager.cs
  13. 80
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeContext.cs
  14. 135
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs
  15. 26
      aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/TemplateFile.cs
  16. 13
      aspnet-core/frameworks/test/Lion.AbpPro.Core.Cli.Tests/Lion/AbpPro/Core/Cli/LionAbpProCoreCliTestBase.cs
  17. 24
      aspnet-core/frameworks/test/Lion.AbpPro.Core.Cli.Tests/Lion/AbpPro/Core/Cli/LionAbpProCoreCliTestBaseModule.cs
  18. 39
      aspnet-core/frameworks/test/Lion.AbpPro.Core.Cli.Tests/Lion/AbpPro/Core/Cli/LionAbpProManagerTests.cs
  19. 2
      aspnet-core/global.json
  20. 2
      docs/content/about/6.0-7.0.md

2
.github/workflows/docker-image.yml

@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Dotnet 7.0.102 - name: Install Dotnet 7.0.304
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: 7.0.x dotnet-version: 7.0.x

2
.github/workflows/nuget.yml

@ -12,7 +12,7 @@ jobs:
- name: Install Dotnet 7.x - name: Install Dotnet 7.x
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: 7.0.102 dotnet-version: 7.0.304
include-prerelease: True include-prerelease: True
- name: Setting Version - name: Setting Version
id: vars id: vars

3
aspnet-core/Directory.Build.Microsoft.targets

@ -1,7 +1,6 @@
<Project> <Project>
<ItemGroup> <ItemGroup>
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="7.0.2"/> <PackageReference Update="Microsoft.Extensions.DependencyModel" Version="7.0.2"/>
<PackageReference Update="Microsoft.Extensions.Http" Version="7.0.2"/>
<PackageReference Update="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.2"/> <PackageReference Update="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.2"/>
<PackageReference Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.2"/> <PackageReference Update="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.2"/>
<PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2"/> <PackageReference Update="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2"/>
@ -14,6 +13,8 @@
<PackageReference Update="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.2"/> <PackageReference Update="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.2"/>
<PackageReference Update="Microsoft.Extensions.Hosting" Version="7.0.0" /> <PackageReference Update="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Update="Microsoft.Extensions.Http" Version="7.0.0"/>
<PackageReference Update="Microsoft.AspNetCore.Mvc.Core" Version="2.2.0"/> <PackageReference Update="Microsoft.AspNetCore.Mvc.Core" Version="2.2.0"/>
<PackageReference Update="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0"/> <PackageReference Update="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0"/>

1
aspnet-core/Directory.Build.Volo.targets

@ -1,6 +1,7 @@
<Project> <Project>
<ItemGroup> <ItemGroup>
<PackageReference Update="Volo.Abp.Autofac" Version="7.2.2"/> <PackageReference Update="Volo.Abp.Autofac" Version="7.2.2"/>
<PackageReference Update="Volo.Abp.Threading" Version="7.2.2"/>
<PackageReference Update="Volo.Abp.Json" Version="7.2.2"/> <PackageReference Update="Volo.Abp.Json" Version="7.2.2"/>
<PackageReference Update="Volo.Abp.Validation" Version="7.2.2"/> <PackageReference Update="Volo.Abp.Validation" Version="7.2.2"/>
<PackageReference Update="Volo.Abp.Ddd.Domain" Version="7.2.2"/> <PackageReference Update="Volo.Abp.Ddd.Domain" Version="7.2.2"/>

2
aspnet-core/Directory.Build.targets

@ -83,7 +83,7 @@
<PackageReference Update="Polly" Version="7.2.3"/> <PackageReference Update="Polly" Version="7.2.3"/>
<PackageReference Update="Confluent.Kafka" Version="1.8.2.0"/> <PackageReference Update="Confluent.Kafka" Version="1.8.2.0"/>
<PackageReference Update="Octokit" Version="2.0.0" />
<!-- Idenity 一下三个包升级到最新版导致鉴权不通过--> <!-- Idenity 一下三个包升级到最新版导致鉴权不通过-->
<PackageReference Update="Microsoft.IdentityModel.Tokens" Version="6.10.0"/> <PackageReference Update="Microsoft.IdentityModel.Tokens" Version="6.10.0"/>

14
aspnet-core/Lion.AbpPro.sln

@ -242,6 +242,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.LanguageManagem
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.CAP.EntityFrameworkCore", "frameworks\src\Lion.AbpPro.CAP.EntityFrameworkCore\Lion.AbpPro.CAP.EntityFrameworkCore.csproj", "{68C902A2-A604-4F3A-879D-37941C00C7A9}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.CAP.EntityFrameworkCore", "frameworks\src\Lion.AbpPro.CAP.EntityFrameworkCore\Lion.AbpPro.CAP.EntityFrameworkCore.csproj", "{68C902A2-A604-4F3A-879D-37941C00C7A9}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.Cli.Core", "frameworks\src\Lion.AbpPro.Cli.Core\Lion.AbpPro.Cli.Core.csproj", "{8D5BD955-FFDC-4895-927F-624C42B64A92}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.Cli", "frameworks\src\Lion.AbpPro.Cli\Lion.AbpPro.Cli.csproj", "{B7A68103-D527-421F-8247-5D169A7F8931}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -588,6 +592,14 @@ Global
{68C902A2-A604-4F3A-879D-37941C00C7A9}.Debug|Any CPU.Build.0 = Debug|Any CPU {68C902A2-A604-4F3A-879D-37941C00C7A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68C902A2-A604-4F3A-879D-37941C00C7A9}.Release|Any CPU.ActiveCfg = Release|Any CPU {68C902A2-A604-4F3A-879D-37941C00C7A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68C902A2-A604-4F3A-879D-37941C00C7A9}.Release|Any CPU.Build.0 = Release|Any CPU {68C902A2-A604-4F3A-879D-37941C00C7A9}.Release|Any CPU.Build.0 = Release|Any CPU
{8D5BD955-FFDC-4895-927F-624C42B64A92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D5BD955-FFDC-4895-927F-624C42B64A92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D5BD955-FFDC-4895-927F-624C42B64A92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D5BD955-FFDC-4895-927F-624C42B64A92}.Release|Any CPU.Build.0 = Release|Any CPU
{B7A68103-D527-421F-8247-5D169A7F8931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7A68103-D527-421F-8247-5D169A7F8931}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7A68103-D527-421F-8247-5D169A7F8931}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7A68103-D527-421F-8247-5D169A7F8931}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -703,6 +715,8 @@ Global
{E5994C85-C1C2-44F3-BF10-3277CA6CF2C9} = {3FE23400-A323-46ED-A7F4-30BFF8916D64} {E5994C85-C1C2-44F3-BF10-3277CA6CF2C9} = {3FE23400-A323-46ED-A7F4-30BFF8916D64}
{15852D6F-4110-4B98-B89D-5747777E8908} = {3FE23400-A323-46ED-A7F4-30BFF8916D64} {15852D6F-4110-4B98-B89D-5747777E8908} = {3FE23400-A323-46ED-A7F4-30BFF8916D64}
{68C902A2-A604-4F3A-879D-37941C00C7A9} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} {68C902A2-A604-4F3A-879D-37941C00C7A9} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
{8D5BD955-FFDC-4895-927F-624C42B64A92} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
{B7A68103-D527-421F-8247-5D169A7F8931} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}

22
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/GlobalUsings.cs

@ -0,0 +1,22 @@
// Global using directives
global using System.Diagnostics.CodeAnalysis;
global using System.Net;
global using System.Text;
global using ICSharpCode.SharpZipLib.Core;
global using ICSharpCode.SharpZipLib.Zip;
global using Lion.AbpPro.Cli.Args;
global using Lion.AbpPro.Cli.Github;
global using Lion.AbpPro.Cli.Options;
global using Lion.AbpPro.Cli.Replace;
global using Lion.AbpPro.Cli.Utils;
global using Lion.AbpPro.Cli.Zip;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Options;
global using Octokit;
global using Polly;
global using Polly.Retry;
global using Volo.Abp;
global using Volo.Abp.DependencyInjection;
global using Volo.Abp.IO;

19
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Github/ILionAbpProManager.cs

@ -0,0 +1,19 @@
namespace Lion.AbpPro.Cli.Github;
public interface ILionAbpProManager
{
/// <summary>
/// 获取最后一个版本
/// </summary>
Task<string> GetLatestSourceCodeVersionAsync();
/// <summary>
/// 检查版本是否存在
/// </summary>
Task<bool> CheckSourceCodeVersionAsync(string version);
/// <summary>
/// 下载源码
/// </summary>
Task<byte[]> DownloadAsync(string version,string outputPath);
}

68
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Github/LionAbpProManager.cs

@ -0,0 +1,68 @@
using Uri = System.Uri;
namespace Lion.AbpPro.Cli.Github;
public class LionAbpProManager : ITransientDependency, ILionAbpProManager
{
private readonly LionAbpProOptions _options;
private readonly IHttpClientFactory _httpClientFactory;
public LionAbpProManager(IOptions<LionAbpProOptions> options, IHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
_options = options.Value;
}
/// <summary>
/// 获取最后一个版本
/// </summary>
public async Task<string> GetLatestSourceCodeVersionAsync()
{
var github = new GitHubClient(new ProductHeaderValue(_options.RepositoryId))
{
// 匿名访问,api会限流,所以需要设置访问令牌
Credentials = new Credentials(_options.DecryptToken)
};
var release = await github.Repository.Release.GetLatest(_options.Owner, _options.RepositoryId);
return release?.TagName;
}
/// <summary>
/// 检查版本是否存在
/// </summary>
public async Task<bool> CheckSourceCodeVersionAsync(string version)
{
try
{
var github = new GitHubClient(new ProductHeaderValue(_options.RepositoryId))
{
// 匿名访问,api会限流,所以需要设置访问令牌
Credentials = new Credentials(_options.DecryptToken)
};
var release = await github.Repository.Release.Get(_options.Owner, _options.RepositoryId, version);
return release != null;
}
catch
{
return false;
}
}
/// <summary>
/// 下载源码
/// </summary>
public async Task<byte[]> DownloadAsync(string version, string outputPath)
{
var httpClient = _httpClientFactory.CreateClient();
var uri = new Uri($"https://github.com/{_options.Owner}/{_options.RepositoryId}/archive/refs/tags/{version}.zip");
var response = await httpClient.GetAsync(uri);
DirectoryHelper.CreateIfNotExists(CliPaths.TemplateCache);
var content = await response.Content.ReadAsByteArrayAsync();
response.Dispose();
File.Delete(outputPath);
await File.WriteAllBytesAsync(outputPath, content);
return content;
}
}

33
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProOptions.cs

@ -0,0 +1,33 @@
namespace Lion.AbpPro.Cli.Options;
public class LionAbpProOptions
{
/// <summary>
/// 仓库拥有者
/// </summary>
public string Owner { get; set; }
/// <summary>
/// 仓库Id
/// </summary>
public string RepositoryId { get; set; }
/// <summary>
/// Github Token
/// </summary>
public string Token { get; set; }
/// <summary>
/// 解密 Github Token
/// </summary>
public string DecryptToken => Cryptography.TokenHelper.Decrypt(Token);
/// <summary>
/// 模板信息
/// </summary>
public List<LionAbpProTemplateOptions> Templates { get; set; }
public string OldCompanyName { get; set; }= "Lion";
public string OldProjectName { get; set; } = "AbpPro";
}

43
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/Options/LionAbpProTemplateOptions.cs

@ -0,0 +1,43 @@
namespace Lion.AbpPro.Cli.Options;
public class LionAbpProTemplateOptions
{
public LionAbpProTemplateOptions(string key, string name, string description, bool isSource = false)
{
Key = key;
Name = name;
Description = description;
IsSource = isSource;
}
/// <summary>
/// 模板key
/// 对应templates下文件夹名称
/// </summary>
public string Key { get; set; }
/// <summary>
/// cli -t 对应参数
/// </summary>
public string Name { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 需要替换的文件
/// </summary>
public string ReplaceSuffix { get; set; }
/// <summary>
/// 需要排除的文件
/// </summary>
public string ExcludeFiles { get; set; }
/// <summary>
/// 是否源码版本
/// </summary>
public bool IsSource { get; set; }
}

20
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/ISourceCodeManager.cs

@ -0,0 +1,20 @@
namespace Lion.AbpPro.Cli.SourceCode;
public interface ISourceCodeManager
{
/// <summary>
/// 获取源码
/// </summary>
/// <param name="version">版本</param>
Task<TemplateFile> GetAsync(string version);
/// <summary>
/// 解压
/// </summary>
void ExtractProjectZip(SourceCodeContext context);
/// <summary>
/// 替换
/// </summary>
void ReplaceTemplates(SourceCodeContext context);
}

80
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeContext.cs

@ -0,0 +1,80 @@
namespace Lion.AbpPro.Cli.SourceCode;
public class SourceCodeContext
{
/// <summary>
/// 模板信息
/// </summary>
public TemplateFile TemplateFile { get; set; }
/// <summary>
/// 需要替换的文件
/// </summary>
public string ReplaceSuffix { get; set; }
/// <summary>
/// 需要排除的文件
/// </summary>
public string ExcludeFiles { get; set; }
/// <summary>
/// 替换CompanyName
/// </summary>
public string OldCompanyName { get; set; }
/// <summary>
/// 替换ProjectName
/// </summary>
public string OldProjectName { get; set; }
/// <summary>
/// New CompanyName
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// New ProjectName
/// </summary>
public string ProjectName { get; set; }
/// <summary>
/// 输入文件夹
/// </summary>
public string OutputFolder { get; set; }
/// <summary>
/// 模板文件夹
/// </summary>
public string TemplateFolder { get; set; }
/// <summary>
/// 模板key
/// </summary>
public string TemplateKey { get; set; }
/// <summary>
/// 模板名称
/// </summary>
public string TemplateName { get; set; }
/// <summary>
/// 解压目录
/// </summary>
public string ExtractProjectPath { get; set; }
/// <summary>
/// 是否源码版本
/// </summary>
public bool IsSource { get; set; }
/// <summary>
/// 仓库拥有者
/// </summary>
public string Owner { get; set; }
/// <summary>
/// 仓库Id
/// </summary>
public string RepositoryId { get; set; }
/// <summary>
/// Github Token
/// </summary>
public string Token { get; set; }
}

135
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/SourceCodeManager.cs

@ -0,0 +1,135 @@
namespace Lion.AbpPro.Cli.SourceCode;
public class SourceCodeManager : ITransientDependency, ISourceCodeManager
{
private readonly ILogger<SourceCodeManager> _logger;
private readonly ILionAbpProManager _lionAbpProManager;
private readonly LionAbpProOptions _options;
public SourceCodeManager(ILogger<SourceCodeManager> logger, IOptions<Options.LionAbpProOptions> options, ILionAbpProManager lionAbpProManager)
{
_logger = logger;
_lionAbpProManager = lionAbpProManager;
_options = options.Value;
}
/// <summary>
/// 获取源码
/// </summary>
/// <param name="version">版本</param>
public async Task<TemplateFile> GetAsync(string version)
{
var latestVersion = await _lionAbpProManager.GetLatestSourceCodeVersionAsync();
if (version == null)
{
version = latestVersion ?? throw new Exception("请检查版本是否正确");
}
else
{
if (!await _lionAbpProManager.CheckSourceCodeVersionAsync(version))
{
throw new Exception("没有找到指定的版本: " + version);
}
}
var localCacheFile = Path.Combine(CliPaths.TemplateCache, _options.RepositoryId + "-" + version + ".zip");
_logger.LogInformation($"Lion AbpPro Version:{version}");
_logger.LogInformation($"模板生成中......");
if (!File.Exists(localCacheFile))
{
return new TemplateFile(version, localCacheFile, await _lionAbpProManager.DownloadAsync(version, localCacheFile));
}
else
{
return new TemplateFile(version, localCacheFile, await File.ReadAllBytesAsync(localCacheFile));
}
}
public void ExtractProjectZip(SourceCodeContext context)
{
using (var templateFileStream = new MemoryStream(context.TemplateFile.FileBytes))
{
using (var zipInputStream = new ZipInputStream(templateFileStream))
{
var zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
{
if (string.IsNullOrWhiteSpace(zipEntry.Name))
{
zipEntry = zipInputStream.GetNextEntry();
continue;
}
var fullZipToPath = Path.Combine(CliPaths.TemplateCache, zipEntry.Name);
var directoryName = Path.GetDirectoryName(fullZipToPath);
if (!string.IsNullOrEmpty(directoryName))
{
Directory.CreateDirectory(directoryName);
}
var fileName = Path.GetFileName(fullZipToPath);
if (fileName.Length == 0)
{
zipEntry = zipInputStream.GetNextEntry();
continue;
}
var buffer = new byte[4096]; // 4K is optimum
using (var streamWriter = File.Create(fullZipToPath))
{
StreamUtils.Copy(zipInputStream, streamWriter, buffer);
}
zipEntry = zipInputStream.GetNextEntry();
}
}
}
context.ExtractProjectPath = Path.Combine(CliPaths.TemplateCache, _options.RepositoryId + "-" + context.TemplateFile.Version);
}
public void MoveTemplate(SourceCodeContext context)
{
// var codePath= Path.Combine(context.OutputFolder, context.CompanyName + "." + context.ProjectName);
//
// DirectoryHelper.DeleteIfExists(codePath,true);
//
// if (context.IsSource)
// {
// context.TemplateFolder = Path.Combine(context.OutputFolder, _options.RepositoryId + "-" + context.TemplateFile.Version);
// }
// else
// {
// // 获取本地源码地址
// context.TemplateFolder = Path.Combine(context.OutputFolder, _options.RepositoryId + "-" + context.TemplateFile.Version, "templates", context.TemplateKey);
// }
//
// Directory.Move(context.TemplateFolder, codePath);
// context.OutputFolder = codePath;
DirectoryAndFileHelper.CopyFolder(context.ExtractProjectPath, context.OutputFolder, "docs");
}
public void ReplaceTemplates(SourceCodeContext context)
{
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, _options.RepositoryId + "-" + context.TemplateFile.Version, "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);
DirectoryHelper.DeleteIfExists(context.ExtractProjectPath, true);
_logger.LogInformation($"OutputFolder:{context.OutputFolder}");
}
}

26
aspnet-core/frameworks/src/Lion.AbpPro.Cli.Core/Lion/AbpPro/Cli/SourceCode/TemplateFile.cs

@ -0,0 +1,26 @@
namespace Lion.AbpPro.Cli.SourceCode;
public class TemplateFile
{
public TemplateFile(string version, string sourceCodePath, byte[] fileBytes)
{
Version = version;
SourceCodePath = sourceCodePath;
FileBytes = fileBytes;
}
/// <summary>
/// 模板文件字节流
/// </summary>
public byte[] FileBytes { get; }
/// <summary>
/// 版本
/// </summary>
public string Version { get; }
/// <summary>
/// 模板zip压缩包地址
/// </summary>
public string SourceCodePath { get; }
}

13
aspnet-core/frameworks/test/Lion.AbpPro.Core.Cli.Tests/Lion/AbpPro/Core/Cli/LionAbpProCoreCliTestBase.cs

@ -0,0 +1,13 @@
using Volo.Abp;
using Volo.Abp.Testing;
namespace Lion.AbpPro.Core.Cli
{
public abstract class LionAbpProCoreCliTestBase : AbpIntegratedTest<LionAbpProCoreCliTestBaseModule>
{
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
}
}

24
aspnet-core/frameworks/test/Lion.AbpPro.Core.Cli.Tests/Lion/AbpPro/Core/Cli/LionAbpProCoreCliTestBaseModule.cs

@ -0,0 +1,24 @@
using Lion.AbpPro.Cli;
using Volo.Abp;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;
using LionAbpProOptions = Lion.AbpPro.Cli.Options.LionAbpProOptions;
namespace Lion.AbpPro.Core.Cli
{
[DependsOn(typeof(AbpTestBaseModule),
typeof(AbpProCliCoreModule))]
public class LionAbpProCoreCliTestBaseModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<LionAbpProOptions>(options =>
{
options.Owner = "WangJunZzz";
options.RepositoryId = "abp-vnext-pro";
options.Token = "abp-vnext-proghp_47vqiabp-vnext-provNkHKJguOJkdHvnxUabp-vnext-protij7Qbdn1Qy3fUabp-vnext-pro";
});
}
}
}

39
aspnet-core/frameworks/test/Lion.AbpPro.Core.Cli.Tests/Lion/AbpPro/Core/Cli/LionAbpProManagerTests.cs

@ -0,0 +1,39 @@
using Lion.AbpPro.Cli.Github;
using Shouldly;
using Xunit;
namespace Lion.AbpPro.Core.Cli;
public sealed class LionAbpProManagerTests : LionAbpProCoreCliTestBase
{
private readonly ILionAbpProManager _lionAbpProManager;
public LionAbpProManagerTests()
{
_lionAbpProManager = GetRequiredService<ILionAbpProManager>();
}
[Fact]
public async Task GetLatestSourceCodeVersionAsync()
{
var result= await _lionAbpProManager.GetLatestSourceCodeVersionAsync();
result.ShouldBe("7.2.2.3");
}
[Fact]
public async Task CheckSourceCodeVersionAsync()
{
var result= await _lionAbpProManager.CheckSourceCodeVersionAsync("7.2.2.3");
result.ShouldBe(true);
var result1= await _lionAbpProManager.CheckSourceCodeVersionAsync("1.2.2.3");
result1.ShouldBe(false);
}
[Fact]
public async Task DownloadAsync()
{
//await _lionAbpProManager.DownloadAsync("7.2.2.3");
}
}

2
aspnet-core/global.json

@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "7.0.102", "version": "7.0.304",
"rollForward": "latestFeature" "rollForward": "latestFeature"
} }
} }

2
docs/content/about/6.0-7.0.md

@ -7,7 +7,7 @@
```json ```json
{ {
"sdk": { "sdk": {
"version": "7.0.102", "version": "7.0.304",
"rollForward": "latestFeature" "rollForward": "latestFeature"
} }
} }

Loading…
Cancel
Save