diff --git a/src/VirtoCommerce.Build/Build.cs b/src/VirtoCommerce.Build/Build.cs index 79a3d2e..a1b30c4 100644 --- a/src/VirtoCommerce.Build/Build.cs +++ b/src/VirtoCommerce.Build/Build.cs @@ -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 { diff --git a/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs b/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs index 69c057a..1a56255 100644 --- a/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs +++ b/src/VirtoCommerce.Build/Cloud/Build.SaaS.cs @@ -54,6 +54,8 @@ internal partial class Build [Parameter("App Project Name")] public string AppProject { get; set; } [Parameter("Cloud Environment Name")] public string EnvironmentName { get; set; } + [Parameter("Organization name", Name = "Organization")] public string SaaSOrganizationName { get; set; } + public Target WaitFor => _ => _ .Executes(async () => { @@ -125,7 +127,8 @@ internal partial class Build .Executes(async () => { var cloudClient = new VirtoCloudClient(CloudUrl, CloudToken); - var env = await cloudClient.GetEnvironment(EnvironmentName); + var env = await cloudClient.GetEnvironment(EnvironmentName, SaaSOrganizationName); + var envHelmParameters = env.Helm.Parameters; foreach (var parameter in HelmParameters) { diff --git a/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs b/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs index cef30e9..36169c9 100644 --- a/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs +++ b/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs @@ -51,12 +51,13 @@ public async Task UpdateEnvironmentAsync(CloudEnvironment environment) } } - public async Task GetEnvironment(string environmentName) + public async Task GetEnvironment(string environmentName, string orgName = null) { + var relativeUri = string.IsNullOrWhiteSpace(orgName) ? $"api/saas/environments/{environmentName}" : $"api/saas/environments/{orgName}/{environmentName}"; var response = await _client.SendAsync(new HttpRequestMessage { Method = HttpMethod.Get, - RequestUri = new Uri($"api/saas/environments/{environmentName}", UriKind.Relative) + RequestUri = new Uri(relativeUri, UriKind.Relative) }); if (!response.IsSuccessStatusCode) { diff --git a/src/VirtoCommerce.Build/PlatformTools/Azure/AzureUniversalPackagesModuleInstaller.cs b/src/VirtoCommerce.Build/PlatformTools/Azure/AzureUniversalPackagesModuleInstaller.cs index c2350ea..397909b 100644 --- a/src/VirtoCommerce.Build/PlatformTools/Azure/AzureUniversalPackagesModuleInstaller.cs +++ b/src/VirtoCommerce.Build/PlatformTools/Azure/AzureUniversalPackagesModuleInstaller.cs @@ -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); diff --git a/src/VirtoCommerce.Build/PlatformTools/GithubManager.cs b/src/VirtoCommerce.Build/PlatformTools/GithubManager.cs index 688ed8b..2b0ba4c 100644 --- a/src/VirtoCommerce.Build/PlatformTools/GithubManager.cs +++ b/src/VirtoCommerce.Build/PlatformTools/GithubManager.cs @@ -55,7 +55,9 @@ public static Tuple 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(groups[1].Value, groups[2].Value); + const int repoOwnerGroupIndex = 1; + const int repoNameGroupIndex = 2; + return new Tuple(groups[repoOwnerGroupIndex].Value, groups[repoNameGroupIndex].Value); } public static Task GetModuleRelease(string token, string moduleRepo, string releaseTag) diff --git a/src/VirtoCommerce.Build/PlatformTools/LocalCatalog.cs b/src/VirtoCommerce.Build/PlatformTools/LocalCatalog.cs index 27e00f6..33748ec 100644 --- a/src/VirtoCommerce.Build/PlatformTools/LocalCatalog.cs +++ b/src/VirtoCommerce.Build/PlatformTools/LocalCatalog.cs @@ -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; @@ -32,10 +32,14 @@ public LocalCatalog(IOptions 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(); @@ -156,24 +160,26 @@ private IDictionary 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); } } } diff --git a/src/VirtoCommerce.Build/PlatformTools/ModuleSourceConverter.cs b/src/VirtoCommerce.Build/PlatformTools/ModuleSourceConverter.cs index 7712b41..2ef5d2d 100644 --- a/src/VirtoCommerce.Build/PlatformTools/ModuleSourceConverter.cs +++ b/src/VirtoCommerce.Build/PlatformTools/ModuleSourceConverter.cs @@ -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); } } diff --git a/src/VirtoCommerce.Build/Utils/ArtifactPacker.cs b/src/VirtoCommerce.Build/Utils/ArtifactPacker.cs index 967680b..da5efdd 100644 --- a/src/VirtoCommerce.Build/Utils/ArtifactPacker.cs +++ b/src/VirtoCommerce.Build/Utils/ArtifactPacker.cs @@ -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 { @@ -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 ignoreList, IEnumerable keepList, string[] moduleContentFolders) + public static void CompressModule(string sourceDirectory, string outputZipPath, string moduleId, string moduleManifestPath, string webProjectDirectory, IEnumerable ignoreList, IEnumerable keepList, string[] moduleContentFolders) { FileSystemTasks.CopyFileToDirectory(moduleManifestPath, sourceDirectory, FileExistsPolicy.Overwrite);