Skip to content

Commit

Permalink
VCI-629: Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro committed Aug 22, 2023
1 parent 742bc45 commit 8a7ee75
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/VirtoCommerce.Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ private void CompressExecuteMethod()
keepFiles = TextTasks.ReadAllLines(ModuleKeepFile).ToArray();
}

ArtifactPacker.CompressModuleAsync(ModuleOutputDirectory, ZipFilePath, ModuleManifest.Id, ModuleManifestFile, WebProject.Directory, ignoredFiles, keepFiles, _moduleContentFolders);
ArtifactPacker.CompressModule(ModuleOutputDirectory, ZipFilePath, ModuleManifest.Id, ModuleManifestFile, WebProject.Directory, ignoredFiles, keepFiles, _moduleContentFolders);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ protected override Task InnerInstall(ModuleSource source)

var zipPath = Directory.GetFiles(moduleDestination).FirstOrDefault(p => p.EndsWith(".zip"));
if (zipPath == null)
{
Assert.Fail($"Can't download {module.Id} - {module.Version}");
}

Log.Information($"Extracting {zipPath}");
ZipFile.ExtractToDirectory(zipPath, moduleDestination);
Expand Down
4 changes: 3 additions & 1 deletion src/VirtoCommerce.Build/PlatformTools/GithubManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public static Tuple<string, string> GetRepoFromUrl(string url)
var regex = new Regex(@"http[s]{0,1}:\/\/github.com\/([A-z0-9]*)\/([A-z0-9\-]*)\/", RegexOptions.IgnoreCase);
var match = regex.Match(url);
var groups = match.Groups;
return new Tuple<string, string>(groups[1].Value, groups[2].Value);
const int repoOwnerGroupIndex = 1;
const int repoNameGroupIndex = 2;
return new Tuple<string, string>(groups[repoOwnerGroupIndex].Value, groups[repoNameGroupIndex].Value);
}

public static Task<Release> GetModuleRelease(string token, string moduleRepo, string releaseTag)
Expand Down
40 changes: 23 additions & 17 deletions src/VirtoCommerce.Build/PlatformTools/LocalCatalog.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using VirtoCommerce.Platform.Core.Common;
using VirtoCommerce.Platform.Core.Exceptions;
using VirtoCommerce.Platform.Core.Modularity;
Expand Down Expand Up @@ -32,10 +32,14 @@ public LocalCatalog(IOptions<LocalStorageModuleCatalogOptions> options, IInterna
protected override void InnerLoad()
{
if (string.IsNullOrEmpty(_options.ProbingPath))
{
throw new InvalidOperationException("The ProbingPath cannot contain a null value or be empty");
}

if (string.IsNullOrEmpty(_options.DiscoveryPath))
{
throw new InvalidOperationException("The DiscoveryPath cannot contain a null value or be empty");

}

var manifests = GetModuleManifests();

Expand Down Expand Up @@ -156,24 +160,26 @@ private IDictionary<string, ModuleManifest> GetModuleManifests()
}
private void CopyAssemblies(string sourceParentPath, string targetDirectoryPath)
{
if (sourceParentPath != null)
if (sourceParentPath == null)
{
var sourceDirectoryPath = Path.Combine(sourceParentPath, "bin");
return;
}

var sourceDirectoryPath = Path.Combine(sourceParentPath, "bin");

if (Directory.Exists(sourceDirectoryPath))
if (Directory.Exists(sourceDirectoryPath))
{
foreach (var sourceFilePath in Directory.EnumerateFiles(sourceDirectoryPath, "*.*", SearchOption.AllDirectories))
{
foreach (var sourceFilePath in Directory.EnumerateFiles(sourceDirectoryPath, "*.*", SearchOption.AllDirectories))
// Copy all assembly related files except assemblies that are inlcuded in TPA list
if (IsAssemblyRelatedFile(sourceFilePath))
{
// Copy all assembly related files except assemblies that are inlcuded in TPA list
if (IsAssemblyRelatedFile(sourceFilePath))
{
// Copy localization resource files to related subfolders
var targetFilePath = Path.Combine(
IsLocalizationFile(sourceFilePath) ? Path.Combine(targetDirectoryPath, Path.GetFileName(Path.GetDirectoryName(sourceFilePath)))
: targetDirectoryPath,
Path.GetFileName(sourceFilePath));
CopyFile(sourceFilePath, targetFilePath);
}
// Copy localization resource files to related subfolders
var targetFilePath = Path.Combine(
IsLocalizationFile(sourceFilePath) ? Path.Combine(targetDirectoryPath, Path.GetFileName(Path.GetDirectoryName(sourceFilePath)))
: targetDirectoryPath,
Path.GetFileName(sourceFilePath));
CopyFile(sourceFilePath, targetFilePath);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public class ModuleSourceSpecifiedConcreteClassConverter : DefaultContractResolv
protected override JsonConverter ResolveContractConverter(Type objectType)
{
if (typeof(ModuleSource).IsAssignableFrom(objectType) && !objectType.IsAbstract)
{
return null; // pretend TableSortRuleConvert is not specified (thus avoiding a stack overflow)
}

return base.ResolveContractConverter(objectType);
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/VirtoCommerce.Build/Utils/ArtifactPacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using NuGet.Packaging;
using Nuke.Common.IO;
using Octokit;
using VirtoCommerce.Platform.Core.Modularity;

namespace Utils
{
Expand All @@ -20,7 +15,7 @@ public static void CompressPlatform(string sourceDirectory, string outputZipPath
CompressionTasks.CompressZip(sourceDirectory, outputZipPath);
}

public static void CompressModuleAsync(string sourceDirectory, string outputZipPath, string moduleId, string moduleManifestPath, string webProjectDirectory, IEnumerable<string> ignoreList, IEnumerable<string> keepList, string[] moduleContentFolders)
public static void CompressModule(string sourceDirectory, string outputZipPath, string moduleId, string moduleManifestPath, string webProjectDirectory, IEnumerable<string> ignoreList, IEnumerable<string> keepList, string[] moduleContentFolders)
{
FileSystemTasks.CopyFileToDirectory(moduleManifestPath, sourceDirectory,
FileExistsPolicy.Overwrite);
Expand Down

0 comments on commit 8a7ee75

Please sign in to comment.