Merge pull request #14189 from abpframework/auto-merge/rel-6-0/1379

Merge branch dev with rel-6.0
pull/14193/head
Enis Necipoglu 3 years ago committed by GitHub
commit 762e78e8db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,11 +1,4 @@
using System.Collections.Generic;
using System.Security.Policy;
using Volo.Abp.Cli.ProjectBuilding.Templates.App;
using Volo.Abp.Cli.ProjectBuilding.Templates.Microservice;
using Volo.Abp.Cli.ProjectBuilding.Templates.Module;
using Volo.Abp.Cli.ProjectBuilding.Templates.MvcModule;
namespace Volo.Abp.Cli;
namespace Volo.Abp.Cli;
public static class CliConsts
{
@ -24,4 +17,9 @@ public static class CliConsts
public const string AppSettingsJsonFileName = "appsettings.json";
public const string AppSettingsSecretJsonFileName = "appsettings.secrets.json";
public static class MemoryKeys
{
public const string LatestCliVersionCheckDate = "LatestCliVersionCheckDate";
}
}

@ -10,6 +10,7 @@ public static class CliPaths
public static string Log => Path.Combine(AbpRootPath, "cli", "logs");
public static string Root => Path.Combine(AbpRootPath, "cli");
public static string AccessToken => Path.Combine(AbpRootPath, "cli", "access-token.bin");
public static string Memory => Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!, "memory.bin");
public static string Build => Path.Combine(AbpRootPath, "build");
public static string Lic => Path.Combine(Path.GetTempPath(), Encoding.ASCII.GetString(new byte[] { 65, 98, 112, 76, 105, 99, 101, 110, 115, 101, 46, 98, 105, 110 }));

@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using NuGet.Versioning;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@ -11,14 +12,17 @@ using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Memory;
using Volo.Abp.Cli.NuGet;
using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection;
using Volo.Abp.IO;
namespace Volo.Abp.Cli;
public class CliService : ITransientDependency
{
private readonly MemoryService _memoryService;
public ILogger<CliService> Logger { get; set; }
protected ICommandLineArgumentParser CommandLineArgumentParser { get; }
protected ICommandSelector CommandSelector { get; }
@ -31,8 +35,10 @@ public class CliService : ITransientDependency
ICommandSelector commandSelector,
IServiceScopeFactory serviceScopeFactory,
NuGetService nugetService,
ICmdHelper cmdHelper)
ICmdHelper cmdHelper,
MemoryService memoryService)
{
_memoryService = memoryService;
CommandLineArgumentParser = commandLineArgumentParser;
CommandSelector = commandSelector;
ServiceScopeFactory = serviceScopeFactory;
@ -164,6 +170,11 @@ public class CliService : ITransientDependency
private async Task CheckCliVersionAsync()
{
if (!await IsLatestVersionCheckExpiredAsync())
{
return;
}
var assembly = typeof(CliService).Assembly;
var toolPath = GetToolPath(assembly);
var currentCliVersion = await GetCurrentCliVersionInternalAsync(assembly);
@ -187,6 +198,27 @@ public class CliService : ITransientDependency
}
}
private async Task<bool> IsLatestVersionCheckExpiredAsync()
{
try
{
var latestTime = await _memoryService.GetAsync(CliConsts.MemoryKeys.LatestCliVersionCheckDate);
if (latestTime != null && DateTime.Now - DateTime.Parse(latestTime, CultureInfo.InvariantCulture) < TimeSpan.FromDays(1))
{
return false;
}
await _memoryService.SetAsync(CliConsts.MemoryKeys.LatestCliVersionCheckDate, DateTime.Now.ToString(CultureInfo.InvariantCulture));
return true;
}
catch (Exception)
{
return true;
}
}
private string GetToolPath(Assembly assembly)
{
if (!assembly.Location.Contains(".store"))

@ -39,13 +39,8 @@ public class GetSourceCommand : IConsoleCommand, ITransientDependency
}
var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long);
if (version != null)
{
Logger.LogInformation("Version: " + version);
}
var outputFolder = GetOutPutFolder(commandLineArgs);
Logger.LogInformation("Output folder: " + outputFolder);
var gitHubAbpLocalRepositoryPath = commandLineArgs.Options.GetOrNull(Options.GitHubAbpLocalRepositoryPath.Long);
if (gitHubAbpLocalRepositoryPath != null)

@ -33,8 +33,7 @@ public class SourceCodeDownloadService : ITransientDependency
public async Task DownloadModuleAsync(string moduleName, string outputFolder, string version, string gitHubAbpLocalRepositoryPath, string gitHubVoloLocalRepositoryPath, AbpCommandLineOptions options)
{
Logger.LogInformation("Downloading source code of " + moduleName);
Logger.LogInformation("Version: " + (version ?? "Latest"));
Logger.LogInformation($"Downloading source code of {moduleName} (v{version ?? "Latest"})");
Logger.LogInformation("Output folder: " + outputFolder);
var result = await ModuleProjectBuilder.BuildAsync(

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.DependencyInjection;
using Volo.Abp.IO;
namespace Volo.Abp.Cli.Memory;
public class MemoryService : ITransientDependency
{
private const string KeyValueSeparator = "|||";
[ItemCanBeNull]
public async Task<string> GetAsync(string key)
{
if (!File.Exists(CliPaths.Memory))
{
return null;
}
return (await FileHelper.ReadAllTextAsync(CliPaths.Memory))
.Split(new[] { Environment.NewLine, "\n" }, StringSplitOptions.None)
.FirstOrDefault(x => x.StartsWith($"{key} "))?.Split(KeyValueSeparator).Last().Trim();
}
public async Task SetAsync(string key, string value)
{
if (!File.Exists(CliPaths.Memory))
{
File.WriteAllText(CliPaths.Memory,
$"{key} {KeyValueSeparator} {value}"
);
return;
}
var memoryContentLines = (await FileHelper.ReadAllTextAsync(CliPaths.Memory))
.Split(new[] { Environment.NewLine, "\n" }, StringSplitOptions.None)
.ToList();
memoryContentLines.RemoveAll(x => x.StartsWith(key));
memoryContentLines.Add($"{key} {KeyValueSeparator} {value}");
File.WriteAllText(CliPaths.Memory,
memoryContentLines.JoinAsString(Environment.NewLine)
);
}
}

@ -205,7 +205,7 @@ public class AbpIoSourceCodeStore : ISourceCodeStore, ITransientDependency
private async Task<bool> IsVersionExists(string templateName, string version)
{
var url = $"{CliUrls.WwwAbpIo}api/download/versions?includePreReleases=true";
var url = $"{CliUrls.WwwAbpIo}api/download/all-versions?includePreReleases=true";
try
{

@ -83,6 +83,24 @@ public class IdentityClientConfiguration : Dictionary<string, string>
get => this.GetOrDefault(nameof(CacheAbsoluteExpiration))?.To<int>() ?? 60 * 30;
set => this[nameof(CacheAbsoluteExpiration)] = value.ToString(CultureInfo.InvariantCulture);
}
/// <summary>
/// ValidateIssuerName.
/// Default: true.
/// </summary>
public bool ValidateIssuerName {
get => this.GetOrDefault(nameof(ValidateIssuerName))?.To<bool>() ?? true;
set => this[nameof(ValidateIssuerName)] = value.ToString().ToLowerInvariant();
}
/// <summary>
/// ValidateEndpoints.
/// Default: true.
/// </summary>
public bool ValidateEndpoints {
get => this.GetOrDefault(nameof(ValidateEndpoints))?.To<bool>() ?? true;
set => this[nameof(ValidateEndpoints)] = value.ToString().ToLowerInvariant();
}
public IdentityClientConfiguration()
{
@ -98,7 +116,9 @@ public class IdentityClientConfiguration : Dictionary<string, string>
string userName = null,
string userPassword = null,
bool requireHttps = true,
int cacheAbsoluteExpiration = 60 * 30)
int cacheAbsoluteExpiration = 60 * 30,
bool validateIssuerName = true,
bool validateEndpoints = true)
{
this[nameof(Authority)] = authority;
this[nameof(Scope)] = scope;
@ -109,5 +129,7 @@ public class IdentityClientConfiguration : Dictionary<string, string>
this[nameof(UserPassword)] = userPassword;
this[nameof(RequireHttps)] = requireHttps.ToString().ToLowerInvariant();
this[nameof(CacheAbsoluteExpiration)] = cacheAbsoluteExpiration.ToString(CultureInfo.InvariantCulture);
this[nameof(ValidateIssuerName)] = validateIssuerName.ToString().ToLowerInvariant();
this[nameof(ValidateEndpoints)] = validateEndpoints.ToString().ToLowerInvariant();
}
}

@ -127,7 +127,9 @@ public class IdentityModelAuthenticationService : IIdentityModelAuthenticationSe
Address = configuration.Authority,
Policy =
{
RequireHttps = configuration.RequireHttps
RequireHttps = configuration.RequireHttps,
ValidateIssuerName = configuration.ValidateIssuerName,
ValidateEndpoints = configuration.ValidateEndpoints
}
};
IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage?.Invoke(request);

@ -25,11 +25,11 @@ public class IndexModel : CmsKitPublicPageModelBase
[BindProperty(SupportsGet = true)]
public Guid? TagId { get; set; }
public PagedResultDto<BlogPostCommonDto> Blogs { get; private set; }
public PagedResultDto<BlogPostPublicDto> Blogs { get; protected set; }
public PagerModel PagerModel => new PagerModel(Blogs.TotalCount, Blogs.Items.Count, CurrentPage, PageSize, Request.Path.ToString());
public CmsUserDto SelectedAuthor { get; set; }
public CmsUserDto SelectedAuthor { get; protected set; }
protected IBlogPostPublicAppService BlogPostPublicAppService { get; }
@ -38,7 +38,7 @@ public class IndexModel : CmsKitPublicPageModelBase
BlogPostPublicAppService = blogPostPublicAppService;
}
public async Task OnGetAsync()
public virtual async Task<IActionResult> OnGetAsync()
{
Blogs = await BlogPostPublicAppService.GetListAsync(
BlogSlug,
@ -54,5 +54,7 @@ public class IndexModel : CmsKitPublicPageModelBase
{
SelectedAuthor = await BlogPostPublicAppService.GetAuthorHasBlogPostAsync(AuthorId.Value);
}
return Page();
}
}

Loading…
Cancel
Save