From 37196e62502952ebbac992782d78176bd54fff13 Mon Sep 17 00:00:00 2001 From: Matthias Koch Date: Thu, 16 Mar 2023 01:29:45 +0100 Subject: [PATCH] Refactor to CompressionExtensions usages --- build/Build.ReleaseImage.cs | 3 +-- source/Nuke.Common.Tests/CompressionTasksTest.cs | 6 +++--- source/Nuke.Components/IReportCoverage.cs | 10 +++------- source/Nuke.Components/ISignPackages.cs | 9 ++++----- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/build/Build.ReleaseImage.cs b/build/Build.ReleaseImage.cs index 5f4fbd961..736b73559 100644 --- a/build/Build.ReleaseImage.cs +++ b/build/Build.ReleaseImage.cs @@ -16,7 +16,6 @@ using SixLabors.ImageSharp.Drawing.Processing; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; -using static Nuke.Common.IO.CompressionTasks; using static Nuke.Common.IO.HttpTasks; partial class Build @@ -40,7 +39,7 @@ partial class Build .Executes(() => { FontDownloadUrls.ForEach(x => HttpDownloadFile(x, FontDirectory / new Uri(x).Segments.Last())); - FontArchives.ForEach(x => Uncompress(x, FontDirectory / Path.GetFileNameWithoutExtension(x))); + FontArchives.ForEach(x => x.UncompressTo(FontDirectory / x.NameWithoutExtension)); FontFiles.ForEach(x => FontCollection.Add(x)); FontCollection.Families.ForEach(x => Log.Information("Installed font {Font}", x.Name)); diff --git a/source/Nuke.Common.Tests/CompressionTasksTest.cs b/source/Nuke.Common.Tests/CompressionTasksTest.cs index 18318704e..9de527545 100644 --- a/source/Nuke.Common.Tests/CompressionTasksTest.cs +++ b/source/Nuke.Common.Tests/CompressionTasksTest.cs @@ -31,15 +31,15 @@ public void Test(string archiveFile) RootFile.WriteAllText("root", eofLineBreak: false); NestedFile.WriteAllText("nested", eofLineBreak: false); - var archive = Path.Combine(TestTempDirectory, archiveFile); - CompressionTasks.Compress(TestTempDirectory, archive); + var archive = TestTempDirectory / archiveFile; + TestTempDirectory.CompressTo(archive); File.Exists(archive).Should().BeTrue(); File.Delete(RootFile); File.Delete(NestedFile); Directory.GetFiles(TestTempDirectory, "*").Should().HaveCount(1); - CompressionTasks.Uncompress(archive, TestTempDirectory); + archive.UncompressTo(TestTempDirectory); File.Exists(RootFile).Should().BeTrue(); File.ReadAllText(RootFile).Should().Be("root"); File.Exists(NestedFile).Should().BeTrue(); diff --git a/source/Nuke.Components/IReportCoverage.cs b/source/Nuke.Components/IReportCoverage.cs index cd505b414..9885de7af 100644 --- a/source/Nuke.Components/IReportCoverage.cs +++ b/source/Nuke.Components/IReportCoverage.cs @@ -13,7 +13,6 @@ using Nuke.Common.Tools.Codecov; using Nuke.Common.Tools.ReportGenerator; using Nuke.Common.Utilities.Collections; -using static Nuke.Common.IO.CompressionTasks; using static Nuke.Common.Tools.Codecov.CodecovTasks; using static Nuke.Common.Tools.ReportGenerator.ReportGeneratorTasks; @@ -26,8 +25,8 @@ public interface IReportCoverage : ITest, IHazReports, IHazGitRepository bool ReportToCodecov { get; } [Parameter] [Secret] string CodecovToken => TryGetValue(() => CodecovToken); - string CoverageReportDirectory => ReportDirectory / "coverage-report"; - string CoverageReportArchive => Path.ChangeExtension(CoverageReportDirectory, ".zip"); + AbsolutePath CoverageReportDirectory => ReportDirectory / "coverage-report"; + AbsolutePath CoverageReportArchive => CoverageReportDirectory.WithExtension("zip"); Target ReportCoverage => _ => _ .DependsOn(Test) @@ -50,10 +49,7 @@ public interface IReportCoverage : ITest, IHazReports, IHazGitRepository .Apply(ReportGeneratorSettingsBase) .Apply(ReportGeneratorSettings)); - CompressZip( - directory: CoverageReportDirectory, - archiveFile: CoverageReportArchive, - fileMode: FileMode.Create); + CoverageReportDirectory.ZipTo(CoverageReportArchive, fileMode: FileMode.Create); } UploadCoverageData(); diff --git a/source/Nuke.Components/ISignPackages.cs b/source/Nuke.Components/ISignPackages.cs index c41908805..0cd0b4528 100644 --- a/source/Nuke.Components/ISignPackages.cs +++ b/source/Nuke.Components/ISignPackages.cs @@ -11,7 +11,6 @@ using Nuke.Common.CI.AppVeyor; using Nuke.Common.IO; using Nuke.Common.Utilities.Collections; -using static Nuke.Common.IO.CompressionTasks; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.SignPath.SignPathTasks; @@ -61,8 +60,8 @@ public interface ISignPackages : INukeBuild AbsolutePath SignPathTemporaryDirectory => TemporaryDirectory / "signpath"; AbsolutePath SignPathRequestDirectory => SignPathTemporaryDirectory / "signing-request"; AbsolutePath SignPathResponseDirectory => SignPathTemporaryDirectory / "signing-response"; - string SignPathRequestArchive => Path.ChangeExtension(SignPathRequestDirectory, ".zip"); - string SignPathResponseArchive => Path.ChangeExtension(SignPathResponseDirectory, ".zip"); + AbsolutePath SignPathRequestArchive => Path.ChangeExtension(SignPathRequestDirectory, ".zip"); + AbsolutePath SignPathResponseArchive => Path.ChangeExtension(SignPathResponseDirectory, ".zip"); IEnumerable SignPathPackages { get; } bool SignPathReplacePackages => true; @@ -81,7 +80,7 @@ public interface ISignPackages : INukeBuild { SignPathRequestDirectory.CreateOrCleanDirectory(); SignPathPackages.ForEach(x => CopyFileToDirectory(x, SignPathRequestDirectory)); - CompressZip(SignPathRequestDirectory, SignPathRequestArchive); + SignPathRequestDirectory.ZipTo(SignPathRequestArchive); AppVeyor.PushArtifact(SignPathRequestArchive); @@ -106,7 +105,7 @@ await DownloadSignedArtifactFromUrl( ReportSummary(_ => _); } - UncompressZip(SignPathResponseArchive, SignPathResponseDirectory); + SignPathResponseArchive.UnZipTo(SignPathResponseDirectory); if (SignPathReplacePackages) {