From cb2ebcd0a2e0520c8065a07c5b09471618bbf3fd Mon Sep 17 00:00:00 2001 From: Andri Wandres Date: Fri, 14 Jul 2023 11:02:02 +0200 Subject: [PATCH 01/20] feat(#152): add support for --allow-same-version --- .../BumpVersion/NpmBumpVersionToolTests.cs | 28 +++++++++++++++++++ .../BumpVersion/NpmBumpVersionSettings.cs | 10 +++++++ 2 files changed, 38 insertions(+) diff --git a/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs b/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs index 72c8aa2..8908f99 100644 --- a/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs +++ b/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs @@ -164,6 +164,34 @@ public void Should_Add_GitTagVersion_False_Switch() Assert.Equal("version 11.22.33 --git-tag-version=false", result.Args); } + [Fact] + public void Should_Add_AllowSameVersion_True_Switch() + { + // Given + fixture.Settings.WithVersion("11.22.33"); + fixture.Settings.AllowSameVersion = true; + + // When + var result = fixture.Run(); + + // Then + Assert.Equal("version 11.22.33 --allow-same-version=true", result.Args); + } + + [Fact] + public void Should_Add_AllowSameVersion_False_Switch() + { + // Given + fixture.Settings.WithVersion("11.22.33"); + fixture.Settings.AllowSameVersion = false; + + // When + var result = fixture.Run(); + + // Then + Assert.Equal("version 11.22.33 --allow-same-version=false", result.Args); + } + class ExtensionNullCheckData : IEnumerable { public IEnumerator GetEnumerator() diff --git a/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs b/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs index 590613e..5d03070 100644 --- a/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs +++ b/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs @@ -41,6 +41,12 @@ public NpmBumpVersionSettings() /// public bool? GitTagVersion { get; set; } + /// + /// Gets or sets the --allow-same-version option. + /// Prevents throwing an error when npm version is used to set the new version to the same value as the current version. + /// + public bool? AllowSameVersion { get; set; } + /// /// Evaluates the settings and writes them to . /// @@ -65,6 +71,10 @@ protected override void EvaluateCore(ProcessArgumentBuilder args) args.Append($"--git-tag-version={GitTagVersion.ToString().ToLowerInvariant()}"); } + if (AllowSameVersion.HasValue) + { + args.Append($"--allow-same-version={AllowSameVersion.ToString().ToLowerInvariant()}"); + } } } } From 318d61b8a5438c4612a40769483188a25013a459 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 30 Dec 2023 09:52:17 +0100 Subject: [PATCH 02/20] (GH-156) Multi-target .NET 6, .NET 7 & .NET 8 --- .appveyor.yml | 1 + nuspec/nuget/Cake.Npm.nuspec | 3 +++ src/Cake.Npm.Tests/Cake.Npm.Tests.csproj | 2 +- src/Cake.Npm/Cake.Npm.csproj | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index b8ddac5..18d59e1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -16,6 +16,7 @@ install: - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 5.0.408 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.411 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.305 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 8.0.100 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" - ps: dotnet --info diff --git a/nuspec/nuget/Cake.Npm.nuspec b/nuspec/nuget/Cake.Npm.nuspec index db45678..fc1e5c5 100644 --- a/nuspec/nuget/Cake.Npm.nuspec +++ b/nuspec/nuget/Cake.Npm.nuspec @@ -24,5 +24,8 @@ + + + diff --git a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj index bceda3a..616c61d 100644 --- a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj +++ b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0 + net6.0;net7.0;net8.0 false false false diff --git a/src/Cake.Npm/Cake.Npm.csproj b/src/Cake.Npm/Cake.Npm.csproj index 8cc82d0..c144e72 100644 --- a/src/Cake.Npm/Cake.Npm.csproj +++ b/src/Cake.Npm/Cake.Npm.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0 + net6.0;net7.0;net8.0 Cake.Npm Cake.Npm false From df3836f5ff0685db5e995b07ab12b7d86d4864df Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 17:48:30 +0100 Subject: [PATCH 03/20] Update to Cake 4.0 --- src/Cake.Npm.Tests/Cake.Npm.Tests.csproj | 4 ++-- src/Cake.Npm/Cake.Npm.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj index 616c61d..f9efd2f 100644 --- a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj +++ b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/Cake.Npm/Cake.Npm.csproj b/src/Cake.Npm/Cake.Npm.csproj index c144e72..f88f236 100644 --- a/src/Cake.Npm/Cake.Npm.csproj +++ b/src/Cake.Npm/Cake.Npm.csproj @@ -21,6 +21,6 @@ - + \ No newline at end of file From b1bc79b4e2676181115a7c9a21290c9ece82f5a6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 10 Feb 2024 16:50:56 +0000 Subject: [PATCH 04/20] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..5db72dd --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] +} From e02a09cb54b203548873ae3584e2d7a88006b2ae Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 17:53:04 +0100 Subject: [PATCH 05/20] Use Cake.Recipe preset --- renovate.json => .github/renovate.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename renovate.json => .github/renovate.json (61%) diff --git a/renovate.json b/.github/renovate.json similarity index 61% rename from renovate.json rename to .github/renovate.json index 5db72dd..ed2b5d8 100644 --- a/renovate.json +++ b/.github/renovate.json @@ -1,6 +1,6 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ - "config:recommended" + "github>cake-contrib/renovate-presets:cake-recipe" ] } From 5bb089644d4890f3b806de37fcdfed260bb11bfd Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 17:54:43 +0100 Subject: [PATCH 06/20] Disable semantic commits --- .github/renovate.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/renovate.json b/.github/renovate.json index ed2b5d8..dc1ae00 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,6 +1,7 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ - "github>cake-contrib/renovate-presets:cake-recipe" + "github>cake-contrib/renovate-presets:cake-recipe", + ":semanticCommitsDisabled" ] } From ea6f13dc1e1a0e29414f5fbe4b19509b8128054a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:11:15 +0000 Subject: [PATCH 07/20] Update dependency Cake.Recipe to v3.1.1 --- recipe.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe.cake b/recipe.cake index 762b0ca..b7e32b3 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:?package=Cake.Recipe&version=3.0.1 +#load nuget:?package=Cake.Recipe&version=3.1.1 //************************************************************************************************* // Settings From bd0479319643aa1031960d98022abd882b4a0c9a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:43:18 +0000 Subject: [PATCH 08/20] Update dependency Microsoft.NET.Test.Sdk to v17 --- src/Cake.Npm.Tests/Cake.Npm.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj index f9efd2f..141d6a7 100644 --- a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj +++ b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj @@ -12,7 +12,7 @@ - + From f223f048c0e8bf2a2578a0d67875f9d02f91beb9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:58:05 +0000 Subject: [PATCH 09/20] Update xunit-dotnet monorepo --- src/Cake.Npm.Tests/Cake.Npm.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj index 141d6a7..0af4885 100644 --- a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj +++ b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj @@ -14,8 +14,8 @@ - - + + From 7d72d29d0ad7553de67a79dde112cdfd0acef680 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:01:04 +0000 Subject: [PATCH 10/20] Update dependency Shouldly to v4 --- src/Cake.Npm.Tests/Cake.Npm.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj index 0af4885..d948178 100644 --- a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj +++ b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj @@ -13,7 +13,7 @@ - + From 10a8bb898c714010df78ce673339d5562ede7296 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 18:47:54 +0100 Subject: [PATCH 11/20] Fix comment for GitTagVersion --- src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs b/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs index 5d03070..27a3a81 100644 --- a/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs +++ b/src/Cake.Npm/BumpVersion/NpmBumpVersionSettings.cs @@ -37,7 +37,7 @@ public NpmBumpVersionSettings() /// /// Gets or sets the --git-tag-version option. - /// Tag the commit when using the npm version command. Setting this to true results in no commit being made at all. + /// Tag the commit when using the npm version command. Setting this to false results in no commit being made at all. /// public bool? GitTagVersion { get; set; } From 0b935608bcc4ee5e7c492791197ea4fdbb9670d2 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:06:53 +0100 Subject: [PATCH 12/20] Use char instead of string (CA1847) --- src/Cake.Npm/AddUser/NpmAddUserSettings.cs | 2 +- src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs | 2 +- src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs | 4 ++-- src/Cake.Npm/Prune/NpmPruneSettingsExtensions.cs | 2 +- src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cake.Npm/AddUser/NpmAddUserSettings.cs b/src/Cake.Npm/AddUser/NpmAddUserSettings.cs index 6df14b8..2ea664d 100644 --- a/src/Cake.Npm/AddUser/NpmAddUserSettings.cs +++ b/src/Cake.Npm/AddUser/NpmAddUserSettings.cs @@ -54,7 +54,7 @@ protected override void EvaluateCore(ProcessArgumentBuilder args) if (!string.IsNullOrWhiteSpace(Scope)) { - if (!Scope.StartsWith("@")) + if (!Scope.StartsWith('@')) { throw new ArgumentException("Scope should start with @", nameof(Scope)); } diff --git a/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs b/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs index 070e7ff..b66c175 100644 --- a/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs +++ b/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs @@ -47,7 +47,7 @@ public static NpmAddUserSettings ForScope(this NpmAddUserSettings settings, stri throw new ArgumentNullException(nameof(scope)); } - if (!scope.StartsWith("@")) + if (!scope.StartsWith('@')) { throw new ArgumentException("Scope should start with @", nameof(scope)); } diff --git a/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs b/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs index 67c87cb..14abbbb 100644 --- a/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs +++ b/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs @@ -279,7 +279,7 @@ public static NpmInstallSettings AddPackage(this NpmInstallSettings settings, st if (!string.IsNullOrWhiteSpace(versionOrTag)) { var versionOrTagValue = versionOrTag; - if (versionOrTagValue.Contains(" ")) + if (versionOrTagValue.Contains(' ')) { versionOrTagValue = versionOrTag.Quote(); } @@ -288,7 +288,7 @@ public static NpmInstallSettings AddPackage(this NpmInstallSettings settings, st if (!string.IsNullOrWhiteSpace(scope)) { - if (!scope.StartsWith("@")) + if (!scope.StartsWith('@')) { throw new ArgumentException("Scope should start with @", nameof(scope)); } diff --git a/src/Cake.Npm/Prune/NpmPruneSettingsExtensions.cs b/src/Cake.Npm/Prune/NpmPruneSettingsExtensions.cs index 995d8d0..4daec58 100644 --- a/src/Cake.Npm/Prune/NpmPruneSettingsExtensions.cs +++ b/src/Cake.Npm/Prune/NpmPruneSettingsExtensions.cs @@ -67,7 +67,7 @@ public static NpmPruneSettings AddPackage(this NpmPruneSettings settings, string var resolvedPackageName = packageName; if (!string.IsNullOrWhiteSpace(scope)) { - if (!scope.StartsWith("@")) + if (!scope.StartsWith('@')) { throw new ArgumentException("Scope should start with @", nameof(scope)); } diff --git a/src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs b/src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs index 4009a1a..78b39d1 100644 --- a/src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs +++ b/src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs @@ -51,7 +51,7 @@ public static NpmRebuildSettings AddScopedPackage(this NpmRebuildSettings settin if (!string.IsNullOrWhiteSpace(scope)) { - if (!scope.StartsWith("@")) + if (!scope.StartsWith('@')) { throw new ArgumentException("Scope should start with @", nameof(scope)); } From c971754602d1335901a2494f28de62af97af76aa Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:10:28 +0100 Subject: [PATCH 13/20] Simplify null check (IDE0016) --- .../AddUser/NpmAddUserSettingsExtensions.cs | 7 +------ src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs | 7 +------ .../Install/NpmInstallSettingsExtensions.cs | 7 +------ src/Cake.Npm/NpmSettingsExtensions.cs | 21 +++---------------- .../Publish/NpmPublishSettingsExtensions.cs | 7 +------ 5 files changed, 7 insertions(+), 42 deletions(-) diff --git a/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs b/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs index b66c175..abf1103 100644 --- a/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs +++ b/src/Cake.Npm/AddUser/NpmAddUserSettingsExtensions.cs @@ -20,12 +20,7 @@ public static NpmAddUserSettings ForRegistry(this NpmAddUserSettings settings, U throw new ArgumentNullException(nameof(settings)); } - if (registry == null) - { - throw new ArgumentNullException(nameof(registry)); - } - - settings.Registry = registry; + settings.Registry = registry ?? throw new ArgumentNullException(nameof(registry)); return settings; } diff --git a/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs b/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs index 72147f2..8813cd9 100644 --- a/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs +++ b/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs @@ -40,12 +40,7 @@ public static NpmCiSettings FromRegistry(this NpmCiSettings settings, Uri regist throw new ArgumentNullException(nameof(settings)); } - if (registry == null) - { - throw new ArgumentNullException(nameof(registry)); - } - - settings.Registry = registry; + settings.Registry = registry ?? throw new ArgumentNullException(nameof(registry)); return settings; } } diff --git a/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs b/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs index 14abbbb..6888bea 100644 --- a/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs +++ b/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs @@ -314,12 +314,7 @@ public static NpmInstallSettings FromRegistry(this NpmInstallSettings settings, throw new ArgumentNullException(nameof(settings)); } - if (registry == null) - { - throw new ArgumentNullException(nameof(registry)); - } - - settings.Registry = registry; + settings.Registry = registry ?? throw new ArgumentNullException(nameof(registry)); return settings; } } diff --git a/src/Cake.Npm/NpmSettingsExtensions.cs b/src/Cake.Npm/NpmSettingsExtensions.cs index 0510a01..7e9c957 100644 --- a/src/Cake.Npm/NpmSettingsExtensions.cs +++ b/src/Cake.Npm/NpmSettingsExtensions.cs @@ -39,12 +39,7 @@ public static NpmSettings FromPath(this NpmSettings settings, DirectoryPath path throw new ArgumentNullException(nameof(settings)); } - if (path == null) - { - throw new ArgumentNullException(nameof(path)); - } - - settings.WorkingDirectory = path; + settings.WorkingDirectory = path ?? throw new ArgumentNullException(nameof(path)); return settings; } @@ -62,12 +57,7 @@ public static NpmSettings SetRedirectedStandardErrorHandler(this NpmSettings set throw new ArgumentNullException(nameof(settings)); } - if (standardErrorAction == null) - { - throw new ArgumentNullException(nameof(standardErrorAction)); - } - - settings.StandardErrorAction = standardErrorAction; + settings.StandardErrorAction = standardErrorAction ?? throw new ArgumentNullException(nameof(standardErrorAction)); return settings; } @@ -85,12 +75,7 @@ public static NpmSettings SetRedirectedStandardOutputHandler(this NpmSettings se throw new ArgumentNullException(nameof(settings)); } - if (standardOutputAction == null) - { - throw new ArgumentNullException(nameof(standardOutputAction)); - } - - settings.StandardOutputAction = standardOutputAction; + settings.StandardOutputAction = standardOutputAction ?? throw new ArgumentNullException(nameof(standardOutputAction)); return settings; } diff --git a/src/Cake.Npm/Publish/NpmPublishSettingsExtensions.cs b/src/Cake.Npm/Publish/NpmPublishSettingsExtensions.cs index 2c068e5..40c9a62 100644 --- a/src/Cake.Npm/Publish/NpmPublishSettingsExtensions.cs +++ b/src/Cake.Npm/Publish/NpmPublishSettingsExtensions.cs @@ -86,12 +86,7 @@ public static NpmPublishSettings ToRegistry(this NpmPublishSettings settings, Ur throw new ArgumentNullException(nameof(settings)); } - if (registry == null) - { - throw new ArgumentNullException(nameof(registry)); - } - - settings.Registry = registry; + settings.Registry = registry ?? throw new ArgumentNullException(nameof(registry)); return settings; } From 0ebf493fb2ac902322e40c738be1de8b73124022 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:12:38 +0100 Subject: [PATCH 14/20] Simplify object initialization (IDE0017) --- src/Cake.Npm.Tests/AddUser/NpmAddUserTests.cs | 6 ++++-- src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs | 6 ++++-- src/Cake.Npm.Tests/Install/NpmInstallerTests.cs | 6 ++++-- src/Cake.Npm.Tests/Pack/NpmPackerTests.cs | 6 ++++-- src/Cake.Npm.Tests/Prune/NpmPruneRunnerTests.cs | 6 ++++-- src/Cake.Npm.Tests/RunScript/NpmScriptRunnerTests.cs | 6 ++++-- src/Cake.Npm.Tests/Set/NpmSetToolTests.cs | 6 ++++-- src/Cake.Npm.Tests/Update/NpmUpdateToolTests.cs | 6 ++++-- src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs | 6 ++++-- 9 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/Cake.Npm.Tests/AddUser/NpmAddUserTests.cs b/src/Cake.Npm.Tests/AddUser/NpmAddUserTests.cs index 52a0199..c5d0b02 100644 --- a/src/Cake.Npm.Tests/AddUser/NpmAddUserTests.cs +++ b/src/Cake.Npm.Tests/AddUser/NpmAddUserTests.cs @@ -23,8 +23,10 @@ public void Should_Redirect_Standard_Error() public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmAddUserFixture(); - fixture.Settings = null; + var fixture = new NpmAddUserFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs b/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs index 4d5c0c6..c5b9e1f 100644 --- a/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs +++ b/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs @@ -24,8 +24,10 @@ public void Should_Redirect_Standard_Error() public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmCiToolFixture(); - fixture.Settings = null; + var fixture = new NpmCiToolFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs b/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs index 9decfac..c852e8e 100644 --- a/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs +++ b/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs @@ -24,8 +24,10 @@ public void Should_Redirect_Standard_Error() public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmInstallerFixture(); - fixture.Settings = null; + var fixture = new NpmInstallerFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/Pack/NpmPackerTests.cs b/src/Cake.Npm.Tests/Pack/NpmPackerTests.cs index ff51208..d820f9b 100644 --- a/src/Cake.Npm.Tests/Pack/NpmPackerTests.cs +++ b/src/Cake.Npm.Tests/Pack/NpmPackerTests.cs @@ -22,8 +22,10 @@ public void Should_Redirect_Standard_Error() public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmPackerFixture(); - fixture.Settings = null; + var fixture = new NpmPackerFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/Prune/NpmPruneRunnerTests.cs b/src/Cake.Npm.Tests/Prune/NpmPruneRunnerTests.cs index c5009ab..0ab558e 100644 --- a/src/Cake.Npm.Tests/Prune/NpmPruneRunnerTests.cs +++ b/src/Cake.Npm.Tests/Prune/NpmPruneRunnerTests.cs @@ -13,8 +13,10 @@ public sealed class ThePruneMethod public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmPruneFixture(); - fixture.Settings = null; + var fixture = new NpmPruneFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/RunScript/NpmScriptRunnerTests.cs b/src/Cake.Npm.Tests/RunScript/NpmScriptRunnerTests.cs index dcefb97..1d0ae45 100644 --- a/src/Cake.Npm.Tests/RunScript/NpmScriptRunnerTests.cs +++ b/src/Cake.Npm.Tests/RunScript/NpmScriptRunnerTests.cs @@ -23,8 +23,10 @@ public void Should_Redirect_Standard_Error() public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmRunScriptFixture(); - fixture.Settings = null; + var fixture = new NpmRunScriptFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/Set/NpmSetToolTests.cs b/src/Cake.Npm.Tests/Set/NpmSetToolTests.cs index e30e047..3f02669 100644 --- a/src/Cake.Npm.Tests/Set/NpmSetToolTests.cs +++ b/src/Cake.Npm.Tests/Set/NpmSetToolTests.cs @@ -24,8 +24,10 @@ public void Should_Redirect_Standard_Error() public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmSetToolFixture(); - fixture.Settings = null; + var fixture = new NpmSetToolFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/Update/NpmUpdateToolTests.cs b/src/Cake.Npm.Tests/Update/NpmUpdateToolTests.cs index 0f8df5d..c8700a1 100644 --- a/src/Cake.Npm.Tests/Update/NpmUpdateToolTests.cs +++ b/src/Cake.Npm.Tests/Update/NpmUpdateToolTests.cs @@ -22,8 +22,10 @@ public void Should_Redirect_Standard_Error() public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmUpdateToolFixture(); - fixture.Settings = null; + var fixture = new NpmUpdateToolFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); diff --git a/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs b/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs index f1ec8b3..53a65c3 100644 --- a/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs +++ b/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs @@ -12,8 +12,10 @@ public sealed class TheVersionMethod public void Should_Throw_If_Settings_Are_Null() { // Given - var fixture = new NpmVersionToolFixture(); - fixture.Settings = null; + var fixture = new NpmVersionToolFixture + { + Settings = null + }; // When var result = Record.Exception(() => fixture.Run()); From 94286c14ca115f5ae8b6c8f1f3f21eaa26ec5943 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:13:19 +0100 Subject: [PATCH 15/20] Simplify collection initialization (IDE0028) --- .../NpmAddUserSettingsExtensionsTests.cs | 4 ++-- .../NpmInstallSettingsExtensionsTests.cs | 4 ++-- .../Prune/NpmPruneSettingsExtensionsTests.cs | 20 +++++++++---------- src/Cake.Npm/Install/NpmInstallSettings.cs | 2 +- src/Cake.Npm/Prune/NpmPruneSettings.cs | 2 +- src/Cake.Npm/Rebuild/NpmRebuildSettings.cs | 2 +- .../RunScript/NpmRunScriptSettings.cs | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Cake.Npm.Tests/AddUser/NpmAddUserSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/AddUser/NpmAddUserSettingsExtensionsTests.cs index 49fef3e..f45d738 100644 --- a/src/Cake.Npm.Tests/AddUser/NpmAddUserSettingsExtensionsTests.cs +++ b/src/Cake.Npm.Tests/AddUser/NpmAddUserSettingsExtensionsTests.cs @@ -14,7 +14,7 @@ public void Should_Throw_If_Settings_Are_Null() { // Given NpmAddUserSettings settings = null; - Uri registry = new Uri("https://myregistry.com"); + Uri registry = new("https://myregistry.com"); // When var result = Record.Exception(() => settings.ForRegistry(registry)); @@ -42,7 +42,7 @@ public void Should_Set_Registry() { // Given var settings = new NpmAddUserSettings(); - Uri registry = new Uri("https://myregistry.com"); + Uri registry = new("https://myregistry.com"); // When var result = settings.ForRegistry(registry); diff --git a/src/Cake.Npm.Tests/Install/NpmInstallSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/Install/NpmInstallSettingsExtensionsTests.cs index c83ffc1..00bb976 100644 --- a/src/Cake.Npm.Tests/Install/NpmInstallSettingsExtensionsTests.cs +++ b/src/Cake.Npm.Tests/Install/NpmInstallSettingsExtensionsTests.cs @@ -793,7 +793,7 @@ public void Should_Throw_If_Settings_Are_Null() { // Given NpmInstallSettings settings = null; - Uri registry = new Uri("https://myregistry.com"); + Uri registry = new("https://myregistry.com"); // When var result = Record.Exception(() => settings.FromRegistry(registry)); @@ -821,7 +821,7 @@ public void Should_Set_Registry() { // Given var settings = new NpmInstallSettings(); - Uri registry = new Uri("https://myregistry.com"); + Uri registry = new("https://myregistry.com"); // When var result = settings.FromRegistry(registry); diff --git a/src/Cake.Npm.Tests/Prune/NpmPruneSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/Prune/NpmPruneSettingsExtensionsTests.cs index 36ee49a..975f8f3 100644 --- a/src/Cake.Npm.Tests/Prune/NpmPruneSettingsExtensionsTests.cs +++ b/src/Cake.Npm.Tests/Prune/NpmPruneSettingsExtensionsTests.cs @@ -25,7 +25,7 @@ public void Should_Throw_If_Settings_Are_Null() public void Should_Set_Production_Flag_True_() { // Given - NpmPruneSettings settings = new NpmPruneSettings(); + NpmPruneSettings settings = new(); // When settings.ForProduction(); @@ -38,7 +38,7 @@ public void Should_Set_Production_Flag_True_() public void Should_Set_Production_Flag_False() { // Given - NpmPruneSettings settings = new NpmPruneSettings() { Production = true }; + NpmPruneSettings settings = new() { Production = true }; // When settings.ForProduction(false); @@ -69,7 +69,7 @@ public void Should_Throw_If_Settings_Are_Null() public void Should_Throw_If_PackageName_Is_Null_Or_Whitespace(string packageName) { // Given - NpmPruneSettings settings = new NpmPruneSettings(); + NpmPruneSettings settings = new(); // When var result = Record.Exception(() => settings.AddPackage(packageName)); @@ -82,7 +82,7 @@ public void Should_Throw_If_PackageName_Is_Null_Or_Whitespace(string packageName public void Should_Throw_If_Scope_Does_Not_Start_With_At_Symbol() { // Given - NpmPruneSettings settings = new NpmPruneSettings(); + NpmPruneSettings settings = new(); // When var result = Record.Exception(() => settings.AddPackage("test", "badscope")); @@ -95,7 +95,7 @@ public void Should_Throw_If_Scope_Does_Not_Start_With_At_Symbol() public void Should_Add_PackageName_To_Packages() { // Given - NpmPruneSettings settings = new NpmPruneSettings(); + NpmPruneSettings settings = new(); // When settings.AddPackage("test"); @@ -108,7 +108,7 @@ public void Should_Add_PackageName_To_Packages() public void Should_Add_PackageName_And_Scope_To_Packages() { // Given - NpmPruneSettings settings = new NpmPruneSettings(); + NpmPruneSettings settings = new(); // When settings.AddPackage("test", "@scope"); @@ -136,7 +136,7 @@ public void Should_Throw_If_Settings_Are_Null() public void Should_Set_DryRun_Flag_True_() { // Given - NpmPruneSettings settings = new NpmPruneSettings(); + NpmPruneSettings settings = new(); // When settings.DryRun(); @@ -149,7 +149,7 @@ public void Should_Set_DryRun_Flag_True_() public void Should_Set_DryRun_Flag_False() { // Given - NpmPruneSettings settings = new NpmPruneSettings() { DryRun = true }; + NpmPruneSettings settings = new() { DryRun = true }; // When settings.DryRun(false); @@ -177,7 +177,7 @@ public void Should_Throw_If_Settings_Are_Null() public void Should_Set_Json_Flag_True_() { // Given - NpmPruneSettings settings = new NpmPruneSettings(); + NpmPruneSettings settings = new(); // When settings.Json(); @@ -190,7 +190,7 @@ public void Should_Set_Json_Flag_True_() public void Should_Set_Json_Flag_False() { // Given - NpmPruneSettings settings = new NpmPruneSettings() { Json = true }; + NpmPruneSettings settings = new() { Json = true }; // When settings.Json(false); diff --git a/src/Cake.Npm/Install/NpmInstallSettings.cs b/src/Cake.Npm/Install/NpmInstallSettings.cs index 81860e7..25ef762 100644 --- a/src/Cake.Npm/Install/NpmInstallSettings.cs +++ b/src/Cake.Npm/Install/NpmInstallSettings.cs @@ -11,7 +11,7 @@ /// public class NpmInstallSettings : NpmSettings { - private readonly List _packages = new List(); + private readonly List _packages = new(); /// /// Initializes a new instance of the class. diff --git a/src/Cake.Npm/Prune/NpmPruneSettings.cs b/src/Cake.Npm/Prune/NpmPruneSettings.cs index 948ae4d..27e78dd 100644 --- a/src/Cake.Npm/Prune/NpmPruneSettings.cs +++ b/src/Cake.Npm/Prune/NpmPruneSettings.cs @@ -10,7 +10,7 @@ /// public class NpmPruneSettings : NpmSettings { - private readonly List _packages = new List(); + private readonly List _packages = new(); /// /// Initializes a new instance of the class. diff --git a/src/Cake.Npm/Rebuild/NpmRebuildSettings.cs b/src/Cake.Npm/Rebuild/NpmRebuildSettings.cs index c621873..6e9280b 100644 --- a/src/Cake.Npm/Rebuild/NpmRebuildSettings.cs +++ b/src/Cake.Npm/Rebuild/NpmRebuildSettings.cs @@ -9,7 +9,7 @@ /// public class NpmRebuildSettings : NpmSettings { - private readonly List _packages = new List(); + private readonly List _packages = new(); /// /// Initializes a new instance of the class. diff --git a/src/Cake.Npm/RunScript/NpmRunScriptSettings.cs b/src/Cake.Npm/RunScript/NpmRunScriptSettings.cs index 86f38ee..eb17a3d 100644 --- a/src/Cake.Npm/RunScript/NpmRunScriptSettings.cs +++ b/src/Cake.Npm/RunScript/NpmRunScriptSettings.cs @@ -11,7 +11,7 @@ /// public class NpmRunScriptSettings : NpmSettings { - private readonly List _arguments = new List(); + private readonly List _arguments = new(); /// /// Initializes a new instance of the class. From 749f0fa51fb0a95e39e28034f3289b37c06140ae Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:14:34 +0100 Subject: [PATCH 16/20] Make fields readonly (IDE0044) --- src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs | 2 +- src/Cake.Npm.Tests/ViewVersion/NpmViewVersionToolTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs b/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs index 8908f99..e24c0d2 100644 --- a/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs +++ b/src/Cake.Npm.Tests/BumpVersion/NpmBumpVersionToolTests.cs @@ -12,7 +12,7 @@ public class NpmBumpVersionToolTests { public sealed class TheBumpVersionMethod { - private NpmBumpVersionToolFixture fixture; + private readonly NpmBumpVersionToolFixture fixture; public TheBumpVersionMethod() { diff --git a/src/Cake.Npm.Tests/ViewVersion/NpmViewVersionToolTests.cs b/src/Cake.Npm.Tests/ViewVersion/NpmViewVersionToolTests.cs index 23adbda..ce664fa 100644 --- a/src/Cake.Npm.Tests/ViewVersion/NpmViewVersionToolTests.cs +++ b/src/Cake.Npm.Tests/ViewVersion/NpmViewVersionToolTests.cs @@ -10,7 +10,7 @@ public class NpmViewVersionToolTests { public sealed class TheViewVersionMethod { - private NpmViewVersionToolFixture fixture; + private readonly NpmViewVersionToolFixture fixture; public TheViewVersionMethod() { From 3f2502ca6d1082fe17b98eea9b81d992b1ce16f1 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:15:39 +0100 Subject: [PATCH 17/20] Replace unecessary variable assignment with discard (IDE0059) --- src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs b/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs index 53a65c3..b97507a 100644 --- a/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs +++ b/src/Cake.Npm.Tests/Version/NpmVersionToolTests.cs @@ -73,7 +73,7 @@ public void Should_Determine_Version_From_StandardOutput() fixture.ProcessRunner.Process.SetStandardOutput(versionInfo); // When - var result = fixture.Run(); + _ = fixture.Run(); // Then fixture.Version.ShouldBe("5.8.0"); @@ -94,7 +94,7 @@ public void Should_Determine_Version_From_StandardOutput_Scenarios(string standa fixture.ProcessRunner.Process.SetStandardOutput(output); // When - var result = fixture.Run(); + _ = fixture.Run(); // Then fixture.Version.ShouldBe(expectedVersion); From 8093a641b928fa208444930b99fe30d95714eb98 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:17:34 +0100 Subject: [PATCH 18/20] Use switch expression (IDE0066) --- src/Cake.Npm/NpmSettings.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Cake.Npm/NpmSettings.cs b/src/Cake.Npm/NpmSettings.cs index 41907a2..b5461d2 100644 --- a/src/Cake.Npm/NpmSettings.cs +++ b/src/Cake.Npm/NpmSettings.cs @@ -137,19 +137,14 @@ private void AppendLogLevel(ProcessArgumentBuilder args, NpmLogLevel logLevel) private static NpmLogLevel CakeToNpmLogLevelConverter(Verbosity cakeVerbosityLevel) { - switch (cakeVerbosityLevel) + return cakeVerbosityLevel switch { - case Verbosity.Quiet: - return NpmLogLevel.Silent; - case Verbosity.Minimal: - return NpmLogLevel.Warn; - case Verbosity.Verbose: - return NpmLogLevel.Info; - case Verbosity.Diagnostic: - return NpmLogLevel.Verbose; - default: - return NpmLogLevel.Default; - } + Verbosity.Quiet => NpmLogLevel.Silent, + Verbosity.Minimal => NpmLogLevel.Warn, + Verbosity.Verbose => NpmLogLevel.Info, + Verbosity.Diagnostic => NpmLogLevel.Verbose, + _ => NpmLogLevel.Default, + }; } } } From 6b1dfd5307a63e207428051318874bdf701f941a Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:18:58 +0100 Subject: [PATCH 19/20] Use local function (IDE0039) --- src/Cake.Npm.Tests/NpmSettingsExtensionsTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cake.Npm.Tests/NpmSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/NpmSettingsExtensionsTests.cs index e911af0..eb45e0e 100644 --- a/src/Cake.Npm.Tests/NpmSettingsExtensionsTests.cs +++ b/src/Cake.Npm.Tests/NpmSettingsExtensionsTests.cs @@ -91,7 +91,7 @@ public void Should_Set_StandardOutputAction() { // Given var settings = new NpmInstallSettings(); - Action action = x => { }; + static void action(string x) { } // When settings.SetRedirectedStandardOutputHandler(action); @@ -105,7 +105,7 @@ public void Should_Set_StandardErrorAction() { // Given var settings = new NpmInstallSettings(); - Action action = x => { }; + static void action(string x) { } // When settings.SetRedirectedStandardErrorHandler(action); From 3abcdb4cb0a26825a0c460e592355f71b7032b70 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 10 Feb 2024 19:25:53 +0100 Subject: [PATCH 20/20] Update release notes link --- nuspec/nuget/Cake.Npm.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuspec/nuget/Cake.Npm.nuspec b/nuspec/nuget/Cake.Npm.nuspec index fc1e5c5..a0c00cf 100644 --- a/nuspec/nuget/Cake.Npm.nuspec +++ b/nuspec/nuget/Cake.Npm.nuspec @@ -14,7 +14,7 @@ false cake npm cake-addin cake-build cake-contrib - https://github.com/cake-contrib/Cake.Npm/releases/tag/3.0.0 + https://github.com/cake-contrib/Cake.Npm/releases/tag/4.0.0