Skip to content

Commit

Permalink
Merge branch 'release/3.804.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vc-ci committed Aug 26, 2024
2 parents d02ea93 + 589f1fd commit 55d46cc
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Copyright>Copyright © VirtoCommerce 2011-2022</Copyright>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>3.803.0</VersionPrefix>
<VersionPrefix>3.804.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup>
Expand Down
24 changes: 18 additions & 6 deletions src/VirtoCommerce.Build/Cloud/Client/VirtoCloudClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -22,22 +25,29 @@ public VirtoCloudClient(string baseUrl, string token)

public async Task<string> UpdateEnvironmentAsync(string manifest, string appProject)
{
var content = new Dictionary<string, string>();
content.Add("manifest", manifest);
content.Add("appProject", appProject);
var content = new Dictionary<string, string>
{
{ "manifest", manifest },
{ "appProject", appProject }
};
var response = await _client.SendAsync(new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = new Uri("api/saas/environments/update", UriKind.Relative),
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)
Expand All @@ -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());
}
}

Expand Down
46 changes: 46 additions & 0 deletions src/VirtoCommerce.Build/Cloud/Models/VirtoCloudError.cs
Original file line number Diff line number Diff line change
@@ -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<string> 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<VirtoCloudError>(response);
var message = cloudError?.Message ?? response;
var errors = cloudError?.Errors ?? new List<string>();
return new VirtoCloudError {
Message = message,
Errors = errors
};
}
catch (JsonReaderException)
{
return new VirtoCloudError
{
Message = response
};
}
}
}
}
16 changes: 15 additions & 1 deletion src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit 55d46cc

Please sign in to comment.