Browse Source

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

Merge branch dev with rel-6.0
pull/14193/head
Enis Necipoglu 4 years ago
committed by GitHub
parent
commit
762e78e8db
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliConsts.cs
  2. 1
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs
  3. 34
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs
  4. 5
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs
  5. 3
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/SourceCodeDownloadService.cs
  6. 50
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Memory/MemoryService.cs
  7. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs
  8. 24
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs
  9. 4
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs
  10. 8
      modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs

14
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliConsts.cs

@ -1,11 +1,4 @@
using System.Collections.Generic; namespace Volo.Abp.Cli;
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;
public static class CliConsts public static class CliConsts
{ {
@ -24,4 +17,9 @@ public static class CliConsts
public const string AppSettingsJsonFileName = "appsettings.json"; public const string AppSettingsJsonFileName = "appsettings.json";
public const string AppSettingsSecretJsonFileName = "appsettings.secrets.json"; public const string AppSettingsSecretJsonFileName = "appsettings.secrets.json";
public static class MemoryKeys
{
public const string LatestCliVersionCheckDate = "LatestCliVersionCheckDate";
}
} }

1
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs

@ -10,6 +10,7 @@ public static class CliPaths
public static string Log => Path.Combine(AbpRootPath, "cli", "logs"); public static string Log => Path.Combine(AbpRootPath, "cli", "logs");
public static string Root => Path.Combine(AbpRootPath, "cli"); public static string Root => Path.Combine(AbpRootPath, "cli");
public static string AccessToken => Path.Combine(AbpRootPath, "cli", "access-token.bin"); 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 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 })); 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 }));

34
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs

@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using NuGet.Versioning; using NuGet.Versioning;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -11,14 +12,17 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Memory;
using Volo.Abp.Cli.NuGet; using Volo.Abp.Cli.NuGet;
using Volo.Abp.Cli.Utils; using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.IO;
namespace Volo.Abp.Cli; namespace Volo.Abp.Cli;
public class CliService : ITransientDependency public class CliService : ITransientDependency
{ {
private readonly MemoryService _memoryService;
public ILogger<CliService> Logger { get; set; } public ILogger<CliService> Logger { get; set; }
protected ICommandLineArgumentParser CommandLineArgumentParser { get; } protected ICommandLineArgumentParser CommandLineArgumentParser { get; }
protected ICommandSelector CommandSelector { get; } protected ICommandSelector CommandSelector { get; }
@ -31,8 +35,10 @@ public class CliService : ITransientDependency
ICommandSelector commandSelector, ICommandSelector commandSelector,
IServiceScopeFactory serviceScopeFactory, IServiceScopeFactory serviceScopeFactory,
NuGetService nugetService, NuGetService nugetService,
ICmdHelper cmdHelper) ICmdHelper cmdHelper,
MemoryService memoryService)
{ {
_memoryService = memoryService;
CommandLineArgumentParser = commandLineArgumentParser; CommandLineArgumentParser = commandLineArgumentParser;
CommandSelector = commandSelector; CommandSelector = commandSelector;
ServiceScopeFactory = serviceScopeFactory; ServiceScopeFactory = serviceScopeFactory;
@ -164,6 +170,11 @@ public class CliService : ITransientDependency
private async Task CheckCliVersionAsync() private async Task CheckCliVersionAsync()
{ {
if (!await IsLatestVersionCheckExpiredAsync())
{
return;
}
var assembly = typeof(CliService).Assembly; var assembly = typeof(CliService).Assembly;
var toolPath = GetToolPath(assembly); var toolPath = GetToolPath(assembly);
var currentCliVersion = await GetCurrentCliVersionInternalAsync(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) private string GetToolPath(Assembly assembly)
{ {
if (!assembly.Location.Contains(".store")) if (!assembly.Location.Contains(".store"))

5
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GetSourceCommand.cs

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

3
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/SourceCodeDownloadService.cs

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

50
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Memory/MemoryService.cs

@ -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)
);
}
}

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs

@ -205,7 +205,7 @@ public class AbpIoSourceCodeStore : ISourceCodeStore, ITransientDependency
private async Task<bool> IsVersionExists(string templateName, string version) 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 try
{ {

24
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs

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

4
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs

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

8
modules/cms-kit/src/Volo.CmsKit.Public.Web/Pages/Public/CmsKit/Blogs/Index.cshtml.cs

@ -25,11 +25,11 @@ public class IndexModel : CmsKitPublicPageModelBase
[BindProperty(SupportsGet = true)] [BindProperty(SupportsGet = true)]
public Guid? TagId { get; set; } 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 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; } protected IBlogPostPublicAppService BlogPostPublicAppService { get; }
@ -38,7 +38,7 @@ public class IndexModel : CmsKitPublicPageModelBase
BlogPostPublicAppService = blogPostPublicAppService; BlogPostPublicAppService = blogPostPublicAppService;
} }
public async Task OnGetAsync() public virtual async Task<IActionResult> OnGetAsync()
{ {
Blogs = await BlogPostPublicAppService.GetListAsync( Blogs = await BlogPostPublicAppService.GetListAsync(
BlogSlug, BlogSlug,
@ -54,5 +54,7 @@ public class IndexModel : CmsKitPublicPageModelBase
{ {
SelectedAuthor = await BlogPostPublicAppService.GetAuthorHasBlogPostAsync(AuthorId.Value); SelectedAuthor = await BlogPostPublicAppService.GetAuthorHasBlogPostAsync(AuthorId.Value);
} }
return Page();
} }
} }

Loading…
Cancel
Save