Browse Source

Added license code replace step.

pull/1768/head
Alper Ebicoglu 7 years ago
parent
commit
276a47295e
  1. 51
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
  2. 4
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs
  3. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/IApiKeyService.cs
  4. 7
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ProjectBuildPipelineBuilder.cs
  5. 23
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/LicenseCodeReplaceStep.cs
  6. 1
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenameStep.cs
  7. 13
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ProjectBuilder.cs

51
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs

@ -40,18 +40,29 @@ namespace Volo.Abp.Cli.Commands
Logger.LogInformation("Creating your project..."); Logger.LogInformation("Creating your project...");
Logger.LogInformation("Project name: " + commandLineArgs.Target); Logger.LogInformation("Project name: " + commandLineArgs.Target);
commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command); var template = commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long);
if (template != null)
{
Logger.LogInformation("Template: " + template);
}
var result = await ProjectBuilder.BuildAsync( var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long);
new ProjectBuildArgs( if (version != null)
SolutionName.Parse(commandLineArgs.Target), {
commandLineArgs.Options.GetOrNull(Options.Template.Short, Options.Template.Long), Logger.LogInformation("Version: " + version);
commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long), }
GetDatabaseProvider(commandLineArgs),
GetUiFramework(commandLineArgs), var databaseProvider = GetDatabaseProvider(commandLineArgs);
commandLineArgs.Options if (databaseProvider != DatabaseProvider.NotSpecified)
) {
); Logger.LogInformation("Database provider: " + databaseProvider);
}
var uiFramework = GetUiFramework(commandLineArgs);
if (uiFramework != UiFramework.NotSpecified)
{
Logger.LogInformation("UI Framework: " + uiFramework);
}
var outputFolder = commandLineArgs.Options.GetOrNull(Options.OutputFolder.Short, Options.OutputFolder.Long); var outputFolder = commandLineArgs.Options.GetOrNull(Options.OutputFolder.Short, Options.OutputFolder.Long);
if (outputFolder != null) if (outputFolder != null)
@ -68,6 +79,21 @@ namespace Volo.Abp.Cli.Commands
outputFolder = Directory.GetCurrentDirectory(); outputFolder = Directory.GetCurrentDirectory();
} }
Logger.LogInformation("Output folder: " + outputFolder);
commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command);
var result = await ProjectBuilder.BuildAsync(
new ProjectBuildArgs(
SolutionName.Parse(commandLineArgs.Target),
template,
version,
databaseProvider,
uiFramework,
commandLineArgs.Options
)
);
using (var templateFileStream = new MemoryStream(result.ZipContent)) using (var templateFileStream = new MemoryStream(result.ZipContent))
{ {
using (var zipInputStream = new ZipInputStream(templateFileStream)) using (var zipInputStream = new ZipInputStream(templateFileStream))
@ -101,8 +127,7 @@ namespace Volo.Abp.Cli.Commands
} }
} }
Logger.LogInformation($"Successfully created the project '{commandLineArgs.Target}'"); Logger.LogInformation($"'{commandLineArgs.Target}' has been successfully created to '{outputFolder}'");
Logger.LogInformation($"The output folder is: '{outputFolder}'");
} }
public string GetUsageInfo() public string GetUsageInfo()

4
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.Cli.Licensing
protected IJsonSerializer JsonSerializer { get; } protected IJsonSerializer JsonSerializer { get; }
public async Task<string> GetApiKeyOrNullAsync() public async Task<DeveloperApiKeyResult> GetApiKeyOrNullAsync()
{ {
using (var client = new CliHttpClient()) using (var client = new CliHttpClient())
{ {
@ -29,7 +29,7 @@ namespace Volo.Abp.Cli.Licensing
} }
var responseContent = await response.Content.ReadAsStringAsync(); var responseContent = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<DeveloperApiKeyResult>(responseContent).ApiKey; return JsonSerializer.Deserialize<DeveloperApiKeyResult>(responseContent);
} }
} }
} }

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/IApiKeyService.cs

@ -5,6 +5,6 @@ namespace Volo.Abp.Cli.Licensing
{ {
public interface IApiKeyService public interface IApiKeyService
{ {
Task<string> GetApiKeyOrNullAsync(); Task<DeveloperApiKeyResult> GetApiKeyOrNullAsync();
} }
} }

7
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ProjectBuildPipelineBuilder.cs

@ -1,4 +1,5 @@
using Volo.Abp.Cli.ProjectBuilding.Building.Steps; using Volo.Abp.Cli.ProjectBuilding.Building.Steps;
using Volo.Abp.Cli.ProjectBuilding.Templates.App;
namespace Volo.Abp.Cli.ProjectBuilding.Building namespace Volo.Abp.Cli.ProjectBuilding.Building
{ {
@ -19,6 +20,12 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building
pipeline.Steps.Add(new TemplateCodeDeleteStep()); pipeline.Steps.Add(new TemplateCodeDeleteStep());
pipeline.Steps.Add(new SolutionRenameStep()); pipeline.Steps.Add(new SolutionRenameStep());
if (context.Template.Name == AppProTemplate.TemplateName)
{
pipeline.Steps.Add(new LicenseCodeReplaceStep());
}
pipeline.Steps.Add(new CreateProjectResultZipStep()); pipeline.Steps.Add(new CreateProjectResultZipStep());
return pipeline; return pipeline;

23
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/LicenseCodeReplaceStep.cs

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp.Cli.ProjectBuilding.Files;
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
{
public class LicenseCodeReplaceStep : ProjectBuildPipelineStep
{
public override void Execute(ProjectBuildContext context)
{
var licenseCode = context.BuildArgs.ExtraProperties.GetOrDefault("license-code");
var appSettingsJsonFiles = context.Files.Where(f =>
f.Name.EndsWith("appsettings.json", StringComparison.OrdinalIgnoreCase));
foreach (var appSettingsJson in appSettingsJsonFiles)
{
appSettingsJson.ReplaceText(@"<LICENSE_CODE/>", licenseCode);
}
}
}
}

1
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenameStep.cs

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Volo.Abp.Cli.ProjectBuilding.Files; using Volo.Abp.Cli.ProjectBuilding.Files;
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps

13
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ProjectBuilder.cs

@ -53,10 +53,15 @@ namespace Volo.Abp.Cli.ProjectBuilding
args.Version args.Version
); );
var apiKey = await ApiKeyService.GetApiKeyOrNullAsync(); var apiKeyResult = await ApiKeyService.GetApiKeyOrNullAsync();
if (apiKey != null) if (apiKeyResult?.ApiKey != null)
{ {
args.ExtraProperties["api-key"] = apiKey; args.ExtraProperties["api-key"] = apiKeyResult.ApiKey;
}
if (apiKeyResult?.LicenseCode != null)
{
args.ExtraProperties["license-code"] = apiKeyResult.LicenseCode;
} }
var context = new ProjectBuildContext( var context = new ProjectBuildContext(
@ -69,7 +74,7 @@ namespace Volo.Abp.Cli.ProjectBuilding
if (!templateInfo.DocumentUrl.IsNullOrEmpty()) if (!templateInfo.DocumentUrl.IsNullOrEmpty())
{ {
Logger.LogInformation("Check out the documents: " + templateInfo.DocumentUrl); Logger.LogInformation("Check out the documents at " + templateInfo.DocumentUrl);
} }
// Exclude unwanted or known options. // Exclude unwanted or known options.

Loading…
Cancel
Save