Skip to content

Commit

Permalink
VCI-960: update dependencies (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
krankenbro authored Feb 6, 2025
1 parent 3b06c7f commit c42e0ea
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 108 deletions.
61 changes: 16 additions & 45 deletions src/VirtoCommerce.Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected override void OnTargetFailed(string target)
.SetConfiguration(Configuration)
.SetFilter(TestsFilter)
.SetNoBuild(true)
.SetProcessLogOutput(true)
.SetProcessOutputLogging(true)
.SetResultsDirectory(outPath)
.SetDataCollector("XPlat Code Coverage");

Expand All @@ -379,7 +379,7 @@ protected override void OnTargetFailed(string target)
Assert.Fail("No Coverage Report found");
}

FileSystemTasks.MoveFile(sonarCoverageReportPath, CoverageReportPath, FileExistsPolicy.Overwrite);
sonarCoverageReportPath.Move(CoverageReportPath, ExistsPolicy.FileOverwrite);
}
else
{
Expand All @@ -393,10 +393,10 @@ protected override void OnTargetFailed(string target)
.Executes(() =>
{
var packages = ArtifactsDirectory.GlobFiles("*.nupkg", "*.snupkg").OrderBy(p => p.ToString());

DotNetLogger = CustomDotnetLogger;


DotNetNuGetPush(settings => settings
.SetProcessLogger(CustomDotnetLogger)
.SetSource(Source)
.SetApiKey(ApiKey)
.SetSkipDuplicate(true)
Expand All @@ -420,7 +420,6 @@ protected override void OnTargetFailed(string target)
public Target StartRelease => _ => _
.Executes(() =>
{
GitTasks.GitLogger = GitLogger;
var disableApproval = Environment.GetEnvironmentVariable("VCBUILD_DISABLE_RELEASE_APPROVAL");

if (disableApproval.IsNullOrEmpty() && !Force)
Expand Down Expand Up @@ -484,7 +483,7 @@ protected override void OnTargetFailed(string target)
GitTasks.Git("add Directory.Build.props");
}

GitTasks.Git($"commit -m \"{CustomVersionPrefix}\"");
GitTasks.Git($"commit -m \"{CustomVersionPrefix}\"", logger: GitLogger);
GitTasks.Git("push origin dev");
//remove release branch
GitTasks.Git($"branch -d {currentBranch}");
Expand All @@ -506,7 +505,7 @@ protected override void OnTargetFailed(string target)
ChangeProjectVersion(CustomVersionPrefix);
var manifestPath = IsModule ? RootDirectory.GetRelativePathTo(ModuleManifestFile) : "";
GitTasks.Git($"add Directory.Build.props {manifestPath}");
GitTasks.Git($"commit -m \"{CustomVersionPrefix}\"");
GitTasks.Git($"commit -m \"{CustomVersionPrefix}\"", logger: GitLogger);
GitTasks.Git($"push -u origin {hotfixBranchName}");
});

Expand Down Expand Up @@ -590,8 +589,6 @@ private static void WebPackBuildMethod(Project webProject)
.Before(UpdateManifest)
.Executes(() =>
{
GitTasks.GitLogger = GitLogger;

if (!ModulesLocalDirectory.DirectoryExists())
{
GitTasks.Git($"clone {ModulesRepository.HttpsUrl} {ModulesLocalDirectory}");
Expand Down Expand Up @@ -673,8 +670,7 @@ private static void UpdateManifestBody(ModuleManifest manifest, string modulePac
.After(UpdateManifest)
.Executes(() =>
{
GitTasks.GitLogger = GitLogger;
GitTasks.Git($"commit -am \"{ModuleManifest.Id} {ReleaseVersion}\"", ModulesLocalDirectory);
GitTasks.Git($"commit -am \"{ModuleManifest.Id} {ReleaseVersion}\"", ModulesLocalDirectory, logger: GitLogger);
GitTasks.Git("push origin HEAD:master -f", ModulesLocalDirectory);
});

Expand Down Expand Up @@ -759,48 +755,23 @@ private static void UpdateManifestBody(ModuleManifest manifest, string modulePac
.SetPullRequestBase(SonarPRBase ?? Environment.GetEnvironmentVariable("CHANGE_TARGET"))
.SetPullRequestBranch(SonarPRBranch ?? Environment.GetEnvironmentVariable("CHANGE_TITLE"))
.SetPullRequestKey(SonarPRNumber ?? Environment.GetEnvironmentVariable("CHANGE_ID"))
.SetProcessArgumentConfigurator(args =>
{
args = AddSonarPRProvider(args);
args = AddSonarPRGithubRepo(args);

return args;
}))
.AddProcessAdditionalArguments($"/d:sonar.pullrequest.provider={SonarPRProvider}",
$"/d:sonar.pullrequest.github.repository={SonarGithubRepo}"))
.When(!PullRequest, cc => cc
.SetBranchName(branchName)
.SetProcessArgumentConfigurator(args => AddSonarBranchTarget(args, branchName, branchNameTarget))
.AddProcessAdditionalArguments(GetSonarBranchTarget(branchName, branchNameTarget))
)
);
});

private static Arguments AddSonarBranchTarget(Arguments args, string branchName, string branchNameTarget)
private static string GetSonarBranchTarget(string branchName, string branchNameTarget)
{
var result = string.Empty;
if (!_sonarLongLiveBranches.Contains(branchName))
{
args = args.Add($"/d:\"sonar.branch.target={branchNameTarget}\"");
}

return args;
}

private static Arguments AddSonarPRGithubRepo(Arguments args)
{
if (!string.IsNullOrEmpty(SonarGithubRepo))
{
args = args.Add("/d:sonar.pullrequest.github.repository={value}", SonarGithubRepo);
result = $"/d:sonar.branch.target={branchNameTarget}";
}

return args;
}

private static Arguments AddSonarPRProvider(Arguments args)
{
if (!string.IsNullOrEmpty(SonarPRProvider))
{
args = args.Add($"/d:sonar.pullrequest.provider={SonarPRProvider}");
}

return args;
return result;
}

public Target SonarQubeEnd => _ => _
Expand All @@ -818,10 +789,10 @@ private static Arguments AddSonarPRProvider(Arguments args)
.Replace("netcoreapp3.0", "net5.0");
var sonarScannerShRightPath = Directory.GetParent(sonarScannerShPath)?.Parent?.FullName ?? string.Empty;
var tmpFile = TemporaryDirectory / sonarScript;
FileSystemTasks.MoveFile(sonarScannerShPath, tmpFile);
sonarScannerShPath.ToAbsolutePath().Move(tmpFile, ExistsPolicy.FileOverwrite);
sonarScannerShRightPath.ToAbsolutePath().DeleteDirectory();
var sonarScriptDestinationPath = Path.Combine(sonarScannerShRightPath, sonarScript);
FileSystemTasks.MoveFile(tmpFile, sonarScriptDestinationPath);
tmpFile.Move(sonarScriptDestinationPath);
Log.Information($"{sonarScript} path: {sonarScriptDestinationPath}");
var chmod = ToolResolver.GetPathTool("chmod");
chmod.Invoke($"+x {sonarScriptDestinationPath}");
Expand Down
11 changes: 6 additions & 5 deletions src/VirtoCommerce.Build/Cloud/Build.SaaS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Cloud.Client;
using Cloud.Models;
using Extensions;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand Down Expand Up @@ -216,7 +217,7 @@ private static void CopyModules(AbsolutePath modulesPath, AbsolutePath modulesSo
var moduleDestinationPath = Path.Combine(modulesPath, moduleDirectoryName);
if (!webProjects.Any())
{
FileSystemTasks.CopyDirectoryRecursively(directory, moduleDestinationPath, DirectoryExistsPolicy.Merge, FileExistsPolicy.OverwriteIfNewer);
directory.ToAbsolutePath().Copy(moduleDestinationPath, ExistsPolicy.MergeAndOverwriteIfNewer);
}
else
{
Expand All @@ -240,11 +241,11 @@ private static void CopyModules(AbsolutePath modulesPath, AbsolutePath modulesSo
{
var contentDestination = Path.Combine(moduleDestinationPath, contentDirectory);
var contentSource = Path.Combine(webProject.Directory, contentDirectory);
FileSystemTasks.CopyDirectoryRecursively(contentSource, contentDestination, DirectoryExistsPolicy.Merge, FileExistsPolicy.OverwriteIfNewer);
contentSource.ToAbsolutePath().Copy(contentDestination, ExistsPolicy.MergeAndOverwriteIfNewer);
}

var moduleManifestPath = webProject.Directory / "module.manifest";
FileSystemTasks.CopyFileToDirectory(moduleManifestPath, moduleDestinationPath, FileExistsPolicy.OverwriteIfNewer);
moduleManifestPath.CopyToDirectory(moduleDestinationPath, ExistsPolicy.FileOverwriteIfNewer);
}
}
}
Expand All @@ -270,12 +271,12 @@ private static void CopyPlatformDirectory(AbsolutePath platformDirectory, Absolu
foreach (var dir in directories)
{
var dirName = Path.GetFileName(dir);
FileSystemTasks.CopyDirectoryRecursively(dir, Path.Combine(platformDirectory, dirName), DirectoryExistsPolicy.Merge, FileExistsPolicy.OverwriteIfNewer);
dir.ToAbsolutePath().Copy(Path.Combine(platformDirectory, dirName), ExistsPolicy.MergeAndOverwriteIfNewer);
}

foreach (var file in files)
{
FileSystemTasks.CopyFileToDirectory(file, platformDirectory);
file.ToAbsolutePath().CopyToDirectory(platformDirectory);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/VirtoCommerce.Build/Docker/Build.Docker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Nuke.Common;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.Docker;
using Nuke.Common.Utilities;
using Nuke.Common.Utilities.Collections;
Expand Down Expand Up @@ -57,12 +58,11 @@ private static string[] DockerImageFullName
.OnlyWhenDynamic(() => DockerCredentialsPassed)
.Executes(() =>
{
DockerTasks.DockerLogger = (_, m) => Log.Debug(m);

var settings = new DockerLoginSettings()
.SetServer(DockerRegistryUrl)
.SetUsername(DockerUsername)
.SetPassword(DockerPassword);
.SetPassword(DockerPassword)
.SetProcessLogger((_, m) => Log.Debug(m));
DockerTasks.DockerLogin(settings);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal partial class Build
.OnlyWhenDynamic(() => ThereAreCustomApps)
.Executes(() =>
{
if (WebProject != null && ModuleManifest.Apps.Any())
if (WebProject != null && ModuleManifest.Apps.Length > 0)
{
foreach (var app in ModuleManifest.Apps)
{
Expand All @@ -31,14 +31,11 @@ internal partial class Build
continue;
}


var chmod = ToolResolver.GetPathTool("yarn");
chmod.Invoke("install", WebProject.Directory / "App");
chmod.Invoke("build", WebProject.Directory / "App");
FileSystemTasks.CopyDirectoryRecursively(WebProject.Directory / "App" / "dist",
WebProject.Directory / "Content" / app.Id,
DirectoryExistsPolicy.Merge,
FileExistsPolicy.Overwrite);
var sourceDirectory = WebProject.Directory / "App" / "dist";
sourceDirectory.Copy(WebProject.Directory / "Content" / app.Id, ExistsPolicy.MergeAndOverwrite);
}
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/VirtoCommerce.Build/PlatformTools/Build.PackageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private static async Task InstallPlatformAsync(string platformVersion, string pl
if (File.Exists(AppsettingsPath))
{
tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
FileSystemTasks.MoveFile(AppsettingsPath, tempFile, FileExistsPolicy.Overwrite);
AppsettingsPath.Move(tempFile, ExistsPolicy.FileOverwrite);
}

platformZip.UncompressTo(RootDirectory);
Expand All @@ -326,7 +326,7 @@ private static async Task InstallPlatformAsync(string platformVersion, string pl
.Append(DateTime.Now.ToString("MMddyyHHmmss"))
.Append(".bak");
AbsolutePath destinationSettingsPath = !Force ? AppsettingsPath : Path.Join(Path.GetDirectoryName(AppsettingsPath), bakFileName.ToString());
FileSystemTasks.MoveFile(tempFile, destinationSettingsPath, FileExistsPolicy.Overwrite);
tempFile.ToAbsolutePath().Move(destinationSettingsPath, ExistsPolicy.FileOverwrite);

if (Force)
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Threading.Tasks;
using Extensions;
using Nuke.Common.IO;
using Nuke.Common.Tooling;
using PlatformTools.Modules;
using VirtoCommerce.Platform.Core.Modularity;

namespace PlatformTools.Modules.Azure
Expand All @@ -32,20 +32,21 @@ protected override Task InnerInstall(ModuleSource source, IProgress<ProgressMess
Directory.CreateDirectory(moduleDestination);
moduleDestination.CreateOrCleanDirectory();
var azPath = ToolPathResolver.GetPathExecutable("az");
var azToolSettings = new AzureCliToolSettings()
.AddProcessEnvironmentVariable("AZURE_DEVOPS_EXT_PAT", token)
.SetProcessToolPath(azPath)
.SetProcessArgumentConfigurator(c => c
.Add("artifacts universal download")
.Add("--organization \"{0}\"", artifacts.Organization)
.Add("--project \"{0}\"", artifacts.Project)
.Add("--feed {0}", artifacts.Feed)
.Add("--name {0}", module.Id)
.Add("--path \"{0}\"", moduleDestination)
.Add("--scope {0}", "project")
.Add("--version {0}", module.Version)
);
ProcessTasks.StartProcess(azToolSettings).AssertZeroExitCode();
var arguments = new string[]
{
"artifacts universal download",
$"--organization \"{artifacts.Organization}\"",
$"--project \"{artifacts.Project}\"",
$"--feed {artifacts.Feed}",
$"--name {module.Id}",
$"--path \"{moduleDestination}\"",
"--scope project",
$"--version {module.Version}"
};

var envVars = new Dictionary<string, string>() { { "AZURE_DEVOPS_EXT_PAT", token } };

ProcessTasks.StartProcess(azPath, arguments: string.Join(' ', arguments), environmentVariables: envVars).AssertZeroExitCode();

var zipPath = Directory.GetFiles(moduleDestination).FirstOrDefault(p => p.EndsWith(".zip"));
if (zipPath == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Net.Http;

namespace PlatformTools.Modules
{
class CustomHttpClientFactory : IHttpClientFactory
{
public HttpClient CreateClient(string name)
{
return new HttpClient();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public static async Task<ExternalModuleCatalog> GetCatalog(IOptions<ExternalModu
{
var platformRelease = await GithubManager.GetPlatformRelease();
PlatformVersion.CurrentVersion = SemanticVersion.Parse(platformRelease.TagName); // workaround to see all modules in the external catalog
var client = new ExternalModulesClient(options);
var client = new ExternalModulesClient(options, new CustomHttpClientFactory());
var logger = new LoggerFactory().CreateLogger<ExternalModuleCatalog>();
_catalog = new ExternalModuleCatalog(localCatalog, client, options, logger);
_catalog = new ExternalModuleCatalog(localCatalog, client, options, logger, Options.Create(new ModuleSequenceBoostOptions()));
_catalog.Load();
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/VirtoCommerce.Build/PlatformTools/Modules/LocalCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class LocalCatalog : LocalStorageModuleCatalog
private readonly ILogger<LocalStorageModuleCatalog> _logger;
private readonly IInternalDistributedLockService _distributedLockProvider;
private readonly string _discoveryPath;
public LocalCatalog(IOptions<LocalStorageModuleCatalogOptions> options, IInternalDistributedLockService distributedLockProvider, ILogger<LocalStorageModuleCatalog> logger) :
base(options, distributedLockProvider, logger)
public LocalCatalog(IOptions<LocalStorageModuleCatalogOptions> options, IInternalDistributedLockService distributedLockProvider, IFileCopyPolicy fileCopyPolicy, ILogger<LocalStorageModuleCatalog> logger, IOptions<ModuleSequenceBoostOptions> boostOptions) :
base(options, distributedLockProvider, fileCopyPolicy, logger, boostOptions)
{
_options = options.Value;
_logger = logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using VirtoCommerce.Platform.Core.Modularity;
using VirtoCommerce.Platform.DistributedLock;
using VirtoCommerce.Platform.Modules;
using VirtoCommerce.Platform.Modules.Local;

namespace PlatformTools.Modules
{
Expand All @@ -22,7 +23,9 @@ public static ILocalModuleCatalog GetCatalog(IOptions<LocalStorageModuleCatalogO
{
var logger = new LoggerFactory().CreateLogger<LocalStorageModuleCatalog>();
var distributedLock = new InternalNoLockService(new LoggerFactory().CreateLogger<InternalNoLockService>());
_catalog = new LocalCatalog(options, distributedLock, logger);
var fileMetadataProvider = new FileMetadataProvider(options);
var fileCopyPolicy = new FileCopyPolicy(fileMetadataProvider);
_catalog = new LocalCatalog(options, distributedLock, fileCopyPolicy, logger, Options.Create(new ModuleSequenceBoostOptions()));
_catalog.Load();
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static Task SetupModuleFromArchive(string src, string moduleDestination)
private static Task SetupModuleFromDirectory(string src, string moduleDestination)
{
var absolutePath = src.ToAbsolutePath();
FileSystemTasks.CopyDirectoryRecursively(absolutePath, moduleDestination.ToAbsolutePath(), DirectoryExistsPolicy.Merge, FileExistsPolicy.OverwriteIfNewer);
absolutePath.Copy(moduleDestination.ToAbsolutePath(), ExistsPolicy.MergeAndOverwriteIfNewer);
return Task.CompletedTask;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static async Task<ModuleInstaller> GetModuleInstaller(string discoveryPat
var extCatalogOptions = ExtModuleCatalog.GetOptions(authToken, manifestUrls);
var localModuleCatalog = LocalModuleCatalog.GetCatalog(localCatalogOptions);
var externalModuleCatalog = await ExtModuleCatalog.GetCatalog(extCatalogOptions, localModuleCatalog);
var modulesClient = new ExternalModulesClient(extCatalogOptions);
var modulesClient = new ExternalModulesClient(extCatalogOptions, new CustomHttpClientFactory());
_moduleInstaller = new ModuleInstaller(externalModuleCatalog, modulesClient, fileManager, localCatalogOptions, fileSystem, zipFileWrapper);
}

Expand Down
Loading

0 comments on commit c42e0ea

Please sign in to comment.