From f67c92f7f052ca535911b78f22da3a67d1bb647a Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 20 Dec 2019 09:57:43 +0300 Subject: [PATCH 1/3] chore(core): remove old route handling method --- .../packages/core/src/lib/plugins/config.plugin.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts b/npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts index bcd226c941..a07b613b44 100644 --- a/npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts +++ b/npm/ng-packs/packages/core/src/lib/plugins/config.plugin.ts @@ -50,14 +50,7 @@ export class ConfigPlugin implements NgxsPlugin { } function transformRoutes(routes: Routes = [], wrappers: ABP.FullRoute[] = []): any { - // TODO: remove in v1 - const oldAbpRoutes: ABP.FullRoute[] = routes - .filter(route => { - return snq(() => route.data.routes.routes.find(r => r.path === route.path), false); - }) - .reduce((acc, val) => [...acc, ...val.data.routes.routes], []); - // tslint:disable-next-line: deprecation - const abpRoutes = [...getAbpRoutes(), ...oldAbpRoutes]; + const abpRoutes = [...getAbpRoutes()]; wrappers = abpRoutes.filter(ar => ar.wrapper); const transformed = [] as ABP.FullRoute[]; @@ -89,8 +82,7 @@ function transformRoutes(routes: Routes = [], wrappers: ABP.FullRoute[] = []): a function setUrls(routes: ABP.FullRoute[], parentUrl?: string): ABP.FullRoute[] { if (parentUrl) { - // this if block using for only recursive call - + // recursive block return routes.map(route => ({ ...route, url: `${parentUrl}/${route.path}`, From f0e275a0c854977c5ebdfb30f2013d45f0824305 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Fri, 20 Dec 2019 11:59:50 +0300 Subject: [PATCH 2/3] add Poly to Abp.Cli.Core and use it GetApiKeyOrNullAsync method. --- .../Volo.Abp.Cli.Core.csproj | 2 + .../Volo/Abp/Cli/Commands/SuiteCommand.cs | 16 +++++++- .../Abp/Cli/Licensing/AbpIoApiKeyService.cs | 40 ++++++++++++++++--- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj index 46f3d32d6a..37a9f54748 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj +++ b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj @@ -19,6 +19,8 @@ + + diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs index d2913a0090..fe29b281a7 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SuiteCommand.cs @@ -60,6 +60,12 @@ namespace Volo.Abp.Cli.Commands private async Task InstallSuiteAsync() { var nugetIndexUrl = await GetNuGetIndexUrlAsync(); + + if (nugetIndexUrl == null) + { + return; + } + var result = CmdHelper.RunCmd("dotnet tool install " + SuitePackageName + " --add-source " + nugetIndexUrl + " -g"); if (result == 0) @@ -72,6 +78,12 @@ namespace Volo.Abp.Cli.Commands private async Task UpdateSuiteAsync() { var nugetIndexUrl = await GetNuGetIndexUrlAsync(); + + if (nugetIndexUrl == null) + { + return; + } + CmdHelper.RunCmd("dotnet tool update " + SuitePackageName + " --add-source " + nugetIndexUrl + " -g"); } @@ -101,8 +113,8 @@ namespace Volo.Abp.Cli.Commands private async Task GetNuGetIndexUrlAsync() { var apiKeyResult = await _apiKeyService.GetApiKeyOrNullAsync(); - if (apiKeyResult == null || - string.IsNullOrEmpty(apiKeyResult.ApiKey)) + + if (apiKeyResult == null || string.IsNullOrEmpty(apiKeyResult.ApiKey)) { Logger.LogError("Couldn't retrieve your NuGet API key!"); Logger.LogWarning(File.Exists(CliPaths.AccessToken) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs index c8f221b73c..1b9539d012 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs @@ -1,5 +1,12 @@ using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Http; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Polly; +using Polly.Extensions.Http; using Volo.Abp.Cli.Http; using Volo.Abp.Cli.ProjectBuilding; using Volo.Abp.DependencyInjection; @@ -10,22 +17,45 @@ namespace Volo.Abp.Cli.Licensing public class AbpIoApiKeyService : IApiKeyService, ITransientDependency { protected IJsonSerializer JsonSerializer { get; } - protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; } + private readonly ILogger _logger; - public AbpIoApiKeyService(IJsonSerializer jsonSerializer, IRemoteServiceExceptionHandler remoteServiceExceptionHandler) + public AbpIoApiKeyService(IJsonSerializer jsonSerializer, IRemoteServiceExceptionHandler remoteServiceExceptionHandler, ILogger logger) { JsonSerializer = jsonSerializer; RemoteServiceExceptionHandler = remoteServiceExceptionHandler; + _logger = logger; } public async Task GetApiKeyOrNullAsync() { using (var client = new CliHttpClient()) { - var url = $"{CliUrls.WwwAbpIo}api/license/api-key"; - - var response = await client.GetAsync(url); + var response = await HttpPolicyExtensions + .HandleTransientHttpError() + .OrResult(msg => !msg.IsSuccessStatusCode) + .WaitAndRetryAsync(new[] + { + TimeSpan.FromSeconds(1), + TimeSpan.FromSeconds(3), + TimeSpan.FromSeconds(7) + }, + (responseMessage, timeSpan, retryCount, context) => + { + if (responseMessage.Exception != null) + { + _logger.LogWarning( + $"{retryCount}. request attempt failed with an error: \"{responseMessage.Exception.Message}\". " + + $"Waiting {timeSpan.TotalSeconds} secs for the next try..."); + } + else if (responseMessage.Result != null) + { + _logger.LogWarning( + $"{retryCount}. request attempt failed with {responseMessage.Result.StatusCode}-{responseMessage.Result.ReasonPhrase}. " + + $"Waiting {timeSpan.TotalSeconds} secs for the next try..."); + } + }) + .ExecuteAsync(async () => await client.GetAsync($"{CliUrls.WwwAbpIo}api/license/api-key")); if (!response.IsSuccessStatusCode) { From 1a5273e4d821334cedc22ae981fadb4cf166c21a Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Fri, 20 Dec 2019 16:17:59 +0300 Subject: [PATCH 3/3] chore: update labeler action --- .github/labeler.yml | 3 +++ .github/workflows/labeler.yml | 21 ++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 738b727317..2dded9549b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,4 +1,7 @@ ui-angular: + - npm/ng-packs/* - npm/ng-packs/**/* + - templates/app/angular/* - templates/app/angular/**/* + - templates/module/angular/* - templates/module/angular/**/* diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index e70e966d4a..2796d177d1 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,17 +1,12 @@ -name: "Pull Request Labeler" +name: Pull request labeler on: - pull_request: - paths: - - npm/ng-packs/**/* - - templates/app/angular/**/* - - templates/module/angular/**/* - branches: - - master - - dev + schedule: + - cron: '0 */1 * * *' jobs: labeler: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - - uses: actions/labeler@v2 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" + - uses: paulfantom/periodic-labeler@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: ${{ github.repository }}