Browse Source

Studio: created SourceCodeDownloadStep (Basic)

pull/10363/head
Yunus Emre Kalkan 5 years ago
parent
commit
398bc74121
  1. 10
      studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingContext.cs
  2. 5
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs
  3. 35
      studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/SourceCodeDownloadStep.cs

10
studio/src/Volo.Abp.Studio.ModuleInstaller.Abstractions/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingContext.cs

@ -7,6 +7,10 @@ namespace Volo.Abp.Studio.ModuleInstalling
{
public class ModuleInstallingContext
{
public string ModuleName { get; set; }
public string TargetModule { get; set; }
public bool WithSourceCode { get; set; }
public bool AddToSolutionFile { get; set; }
@ -22,12 +26,16 @@ namespace Volo.Abp.Studio.ModuleInstalling
public IServiceProvider ServiceProvider { get; }
public ModuleInstallingContext(
string moduleName,
string targetModule,
bool withSourceCode,
bool addToSolutionFile,
string version,
Dictionary<string,string> options,
IServiceProvider serviceProvider)
{
ModuleName = moduleName;
TargetModule = targetModule;
WithSourceCode = withSourceCode;
AddToSolutionFile = addToSolutionFile;
Version = version;
@ -45,7 +53,7 @@ namespace Volo.Abp.Studio.ModuleInstalling
ReferenceModulePackages = referenceModulePackages;
}
public void SetTargetModulePackages([NotNull] List<PackageInfo> targetModulePackages)
{
Check.NotNull(targetModulePackages, nameof(targetModulePackages));

5
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/ModuleInstallingPipelineBuilderBase.cs

@ -8,6 +8,11 @@ namespace Volo.Abp.Studio.ModuleInstalling
{
var pipeline = new ModuleInstallingPipeline(context);
if (context.WithSourceCode)
{
pipeline.Steps.Add(new SourceCodeDownloadStep());
}
pipeline.Steps.Add(new PackageReferencingStep());
return pipeline;

35
studio/src/Volo.Abp.Studio.ModuleInstaller/Volo/Abp/Studio/ModuleInstalling/Steps/SourceCodeDownloadStep.cs

@ -0,0 +1,35 @@
using System.IO;
using System.IO.Compression;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.Studio.Nuget;
namespace Volo.Abp.Studio.ModuleInstalling.Steps
{
public class SourceCodeDownloadStep : ModuleInstallingPipelineStep
{
public override async Task ExecuteAsync(ModuleInstallingContext context)
{
var _nugetSourceCodeStoreManager = context.ServiceProvider.GetRequiredService<INugetSourceCodeStore>();
var sourceCodePackageName = $"{context.ModuleName}.SourceCode";
var zipFilePath = await _nugetSourceCodeStoreManager.GetCachedSourceCodeFilePathAsync(
sourceCodePackageName,
SourceCodeTypes.Module,
context.Version);
var targetFolder =
Path.Combine(Path.GetDirectoryName(context.TargetModule), "modules", context.ModuleName);
using (ZipArchive archive = ZipFile.OpenRead(zipFilePath))
{
foreach (var entry in archive.Entries)
{
entry.ExtractToFile(Path.Combine(targetFolder, entry.FullName));
}
}
}
}
}
Loading…
Cancel
Save