mirror of https://github.com/abpframework/abp.git
8 changed files with 110 additions and 2 deletions
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Cli.Http; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Json; |
|||
|
|||
namespace Volo.Abp.Cli.Licensing |
|||
{ |
|||
public class AbpIoApiKeyService : IApiKeyService, ITransientDependency |
|||
{ |
|||
public AbpIoApiKeyService(IJsonSerializer jsonSerializer) |
|||
{ |
|||
JsonSerializer = jsonSerializer; |
|||
} |
|||
|
|||
protected IJsonSerializer JsonSerializer { get; } |
|||
|
|||
public async Task<string> GetApiKeyOrNullAsync() |
|||
{ |
|||
using (var client = new CliHttpClient()) |
|||
{ |
|||
var url = $"{CliUrls.WwwAbpIo}api/license/api-key"; |
|||
|
|||
var response = await client.GetAsync(url); |
|||
|
|||
if (!response.IsSuccessStatusCode) |
|||
{ |
|||
throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'"); |
|||
} |
|||
|
|||
var responseContent = await response.Content.ReadAsStringAsync(); |
|||
return JsonSerializer.Deserialize<DeveloperApiKeyResult>(responseContent).ApiKey; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.Cli.Licensing |
|||
{ |
|||
public class DeveloperApiKeyResult |
|||
{ |
|||
public bool HasActiveLicense { get; set; } |
|||
public string OrganizationName { get; set; } |
|||
public string ApiKey { get; set; } |
|||
public DateTime LicenseEndTime { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System.Net; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Cli.Licensing |
|||
{ |
|||
public interface IApiKeyService |
|||
{ |
|||
Task<string> GetApiKeyOrNullAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Volo.Abp.Cli.ProjectBuilding.Building; |
|||
using Volo.Abp.Cli.ProjectBuilding.Files; |
|||
|
|||
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App |
|||
{ |
|||
public class UpdateNuGetConfigStep : ProjectBuildPipelineStep |
|||
{ |
|||
private readonly string _nugetConfigFilePath; |
|||
|
|||
public UpdateNuGetConfigStep(string nugetConfigFilePath) |
|||
{ |
|||
_nugetConfigFilePath = nugetConfigFilePath; |
|||
} |
|||
|
|||
public override void Execute(ProjectBuildContext context) |
|||
{ |
|||
var file = context.Files.FirstOrDefault(f => f.Name == _nugetConfigFilePath); |
|||
if (file == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var apiKey = context.BuildArgs.ExtraProperties.GetOrDefault("api-key"); |
|||
if (apiKey.IsNullOrEmpty()) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
file.ReplaceText("{api-key}", apiKey); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue