From e0099aa7ab24f508142840915b3e124c8af791ea Mon Sep 17 00:00:00 2001 From: vc-ci Date: Mon, 12 Aug 2024 12:19:32 +0000 Subject: [PATCH 1/3] 3.804.0 --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 6e307cf..291be8b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,7 +6,7 @@ Copyright © VirtoCommerce 2011-2022 - 3.803.0 + 3.804.0 $(VersionSuffix)-$(BuildNumber) From 5cab7a1e2f88b79eff5b890b865962008e45065c Mon Sep 17 00:00:00 2001 From: Alexander Morogov <42555001+krankenbro@users.noreply.github.com> Date: Wed, 21 Aug 2024 08:52:13 +0200 Subject: [PATCH 2/3] VCI-905: Add FileExists statement if PackageManifestPath is not default (#145) --- .../PlatformTools/Build.PackageManager.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs b/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs index 54242b7..8926a7f 100644 --- a/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs +++ b/src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs @@ -29,8 +29,22 @@ internal partial class Build [Parameter("Platform or Module version to install", Name = "Version")] public static string VersionToInstall { get; set; } + private const string _packageManifestPathDefaultValue = "./vc-package.json"; + private static string _packageManifestPath = _packageManifestPathDefaultValue; + [Parameter("vc-package.json path")] - public static string PackageManifestPath { get; set; } = "./vc-package.json"; + public static string PackageManifestPath + { + get { + if (_packageManifestPath != _packageManifestPathDefaultValue) + { + Assert.FileExists(_packageManifestPath.ToAbsolutePath()); + } + return _packageManifestPath; + } + + set => _packageManifestPath = value; + } [Parameter("Install params (install -module VirtoCommerce.Core:1.2.3)")] public static string[] Module { get; set; } From 589f1fdd5ee4c9a57140c1c90a3038dffcb1dfdb Mon Sep 17 00:00:00 2001 From: Alexander Morogov <42555001+krankenbro@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:09:36 +0200 Subject: [PATCH 3/3] VCI-907: Add the parsing of error messages from VirtoCloud (#146) --- .../Cloud/Client/VirtoCloudClient.cs | 24 +++++++--- .../Cloud/Models/VirtoCloudError.cs | 46 +++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 src/VirtoCommerce.Build/Cloud/Models/VirtoCloudError.cs diff --git a/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs b/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs index c937660..43ad886 100644 --- a/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs +++ b/src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs @@ -3,7 +3,10 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; +using Cloud.Models; +using Newtonsoft.Json; using Nuke.Common; +using Nuke.Common.IO; using Nuke.Common.Utilities; using VirtoCloud.Client.Model; @@ -22,9 +25,11 @@ public VirtoCloudClient(string baseUrl, string token) public async Task UpdateEnvironmentAsync(string manifest, string appProject) { - var content = new Dictionary(); - content.Add("manifest", manifest); - content.Add("appProject", appProject); + var content = new Dictionary + { + { "manifest", manifest }, + { "appProject", appProject } + }; var response = await _client.SendAsync(new HttpRequestMessage { Method = HttpMethod.Put, @@ -32,12 +37,17 @@ public async Task UpdateEnvironmentAsync(string manifest, string appProj Content = new FormUrlEncodedContent(content) }); + var responseContent = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { - Assert.Fail($"{response.ReasonPhrase}: {await response.Content.ReadAsStringAsync()}"); + var error = VirtoCloudError.FromStringResponse(responseContent); + Assert.Fail(error.GetErrorMessage()); } - return await response.Content.ReadAsStringAsync(); + Serilog.Log.Information(responseContent); + Serilog.Log.Information("Environment updated successfully"); + + return responseContent; } public async Task UpdateEnvironmentAsync(CloudEnvironment environment) @@ -47,7 +57,9 @@ public async Task UpdateEnvironmentAsync(CloudEnvironment environment) var response = await _client.PutAsync(new Uri("api/saas/environments", UriKind.Relative), content); if (!response.IsSuccessStatusCode) { - Assert.Fail($"{response.ReasonPhrase}: {await response.Content.ReadAsStringAsync()}"); + var responseContent = await response.Content.ReadAsStringAsync(); + var error = VirtoCloudError.FromStringResponse(responseContent); + Assert.Fail(error.GetErrorMessage()); } } diff --git a/src/VirtoCommerce.Build/Cloud/Models/VirtoCloudError.cs b/src/VirtoCommerce.Build/Cloud/Models/VirtoCloudError.cs new file mode 100644 index 0000000..a837c13 --- /dev/null +++ b/src/VirtoCommerce.Build/Cloud/Models/VirtoCloudError.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; +using Nuke.Common; + +namespace Cloud.Models +{ + public class VirtoCloudError + { + public string Message { get; set; } + public List Errors { get; set; } + + public string GetErrorMessage() + { + var message = Message; + if (Errors?.Count > 0) + { + message += Environment.NewLine + string.Join(Environment.NewLine, Errors); + } + + return message; + } + + public static VirtoCloudError FromStringResponse(string response) + { + try + { + var cloudError = JsonConvert.DeserializeObject(response); + var message = cloudError?.Message ?? response; + var errors = cloudError?.Errors ?? new List(); + return new VirtoCloudError { + Message = message, + Errors = errors + }; + } + catch (JsonReaderException) + { + return new VirtoCloudError + { + Message = response + }; + } + } + } +}