diff --git a/.appveyor.yml b/.appveyor.yml
index bd21071..2b5f541 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -27,5 +27,4 @@ branches:
# Build Cache #
#---------------------------------#
cache:
-- src\packages -> src\**\packages.config
- tools -> setup.cake
\ No newline at end of file
diff --git a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj
index 0a8cd5e..963199e 100644
--- a/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj
+++ b/src/Cake.Npm.Tests/Cake.Npm.Tests.csproj
@@ -12,10 +12,10 @@
-
+
-
-
+
+
diff --git a/src/Cake.Npm.Tests/Ci/NpmCiSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/Ci/NpmCiSettingsExtensionsTests.cs
new file mode 100644
index 0000000..8f02779
--- /dev/null
+++ b/src/Cake.Npm.Tests/Ci/NpmCiSettingsExtensionsTests.cs
@@ -0,0 +1,83 @@
+namespace Cake.Npm.Tests.Ci
+{
+ using Cake.Npm.Ci;
+ using Shouldly;
+ using System;
+ using Xunit;
+
+ public sealed class NpmUpdateSettingsExtensionsTests
+ {
+ public sealed class TheForProductionMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmCiSettings settings = null;
+
+ // When
+ var result = Record.Exception(() => settings.ForProduction());
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+ [Fact]
+ public void Should_Set_Production()
+ {
+ // Given
+ var settings = new NpmCiSettings();
+
+ // When
+ settings.ForProduction();
+
+ // Then
+ settings.Production.ShouldBe(true);
+ }
+ }
+
+ public sealed class TheFromRegistryMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmCiSettings settings = null;
+ var registry = new Uri("https://myregistry.com");
+
+ // When
+ var result = Record.Exception(() => settings.FromRegistry(registry));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Registry_Is_Null()
+ {
+ // Given
+ var settings = new NpmCiSettings();
+ Uri registry = null;
+
+ // When
+ var result = Record.Exception(() => settings.FromRegistry(registry));
+
+ // Then
+ result.IsArgumentNullException("registry");
+ }
+
+ [Fact]
+ public void Should_Set_Registry()
+ {
+ // Given
+ var settings = new NpmCiSettings();
+ var registry = new Uri("https://myregistry.com");
+
+ // When
+ var result = settings.FromRegistry(registry);
+
+ // Then
+ result.Registry.ShouldBe(registry);
+ }
+ }
+ }
+}
diff --git a/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs b/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs
index 2ee4de0..4d5c0c6 100644
--- a/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs
+++ b/src/Cake.Npm.Tests/Ci/NpmCiToolTests.cs
@@ -106,6 +106,20 @@ public void Should_Include_Production_Flag()
Assert.Equal("ci --production", result.Args);
}
- }
+
+ [Fact]
+ public void Should_Include_Registry_Args_If_Set()
+ {
+ // Given
+ var fixture = new NpmCiToolFixture();
+ fixture.Settings.FromRegistry(new Uri("https://myregistry/"));
+
+ // When
+ var result = fixture.Run();
+
+ // Then
+ Assert.Equal("ci --registry https://myregistry/", result.Args);
+ }
+ }
}
}
diff --git a/src/Cake.Npm.Tests/Install/NpmInstallerSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/Install/NpmInstallSettingsExtensionsTests.cs
similarity index 94%
rename from src/Cake.Npm.Tests/Install/NpmInstallerSettingsExtensionsTests.cs
rename to src/Cake.Npm.Tests/Install/NpmInstallSettingsExtensionsTests.cs
index 374f1a5..c83ffc1 100644
--- a/src/Cake.Npm.Tests/Install/NpmInstallerSettingsExtensionsTests.cs
+++ b/src/Cake.Npm.Tests/Install/NpmInstallSettingsExtensionsTests.cs
@@ -5,7 +5,7 @@
using Shouldly;
using Xunit;
- public sealed class NpmInstallSettingsExtensionsTests
+ public sealed class NpmRebuildSettingsExtensionsTests
{
public sealed class TheWithForceMethod
{
@@ -785,5 +785,50 @@ public void Should_Quote_If_Tag_Contains_WhiteSpace()
settings.Packages.ShouldContain(scope + "/" + packageName + "@\"" + tag + "\"");
}
}
+
+ public sealed class TheFromRegistryMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmInstallSettings settings = null;
+ Uri registry = new Uri("https://myregistry.com");
+
+ // When
+ var result = Record.Exception(() => settings.FromRegistry(registry));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Registry_Is_Null()
+ {
+ // Given
+ var settings = new NpmInstallSettings();
+ Uri registry = null;
+
+ // When
+ var result = Record.Exception(() => settings.FromRegistry(registry));
+
+ // Then
+ result.IsArgumentNullException("registry");
+ }
+
+ [Fact]
+ public void Should_Set_Registry()
+ {
+ // Given
+ var settings = new NpmInstallSettings();
+ Uri registry = new Uri("https://myregistry.com");
+
+ // When
+ var result = settings.FromRegistry(registry);
+
+ // Then
+ result.Registry.ShouldBe(registry);
+ }
+ }
}
}
diff --git a/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs b/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs
index bcf7557..9decfac 100644
--- a/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs
+++ b/src/Cake.Npm.Tests/Install/NpmInstallerTests.cs
@@ -218,11 +218,11 @@ public void Should_Add_PreferOffline_To_Arguments_If_Not_Null()
}
[Fact]
- public void Should_Add_Registry_To_Arguments_If_Not_Empty()
+ public void Should_Add_Registry_To_Arguments_If_Set()
{
// Given
var fixture = new NpmInstallerFixture();
- var registry = "http://exampleregistry.com";
+ var registry = new Uri("http://exampleregistry.com");
fixture.Settings.Registry = registry;
// When
@@ -233,11 +233,11 @@ public void Should_Add_Registry_To_Arguments_If_Not_Empty()
}
[Fact]
- public void Should_Not_Add_Registry_To_Arguments_If_Empty()
+ public void Should_Not_Add_Registry_To_Arguments_If_Not_Set()
{
// Given
var fixture = new NpmInstallerFixture();
- fixture.Settings.Registry = "";
+ fixture.Settings.Registry = null;
// When
var result = fixture.Run();
diff --git a/src/Cake.Npm.Tests/Rebuild/NpmRebuildSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/Rebuild/NpmRebuildSettingsExtensionsTests.cs
new file mode 100644
index 0000000..26eea64
--- /dev/null
+++ b/src/Cake.Npm.Tests/Rebuild/NpmRebuildSettingsExtensionsTests.cs
@@ -0,0 +1,211 @@
+namespace Cake.Npm.Tests.Rebuild
+{
+ using Cake.Npm.Rebuild;
+ using Shouldly;
+ using Xunit;
+
+ public sealed class NpmRebuildSettingsExtensionsTests
+ {
+ public sealed class TheAddPackageMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmRebuildSettings settings = null;
+
+ // When
+ var result = Record.Exception(() => settings.AddPackage("foo"));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Package_Is_Null()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+
+ // When
+ var result = Record.Exception(() => settings.AddPackage((string)null));
+
+ // Then
+ result.IsArgumentNullException("packageName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Package_Is_Empty()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+
+ // When
+ var result = Record.Exception(() => settings.AddPackage(string.Empty));
+
+ // Then
+ result.IsArgumentNullException("packageName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Package_Is_WhiteSpace()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+
+ // When
+ var result = Record.Exception(() => settings.AddPackage(" "));
+
+ // Then
+ result.IsArgumentNullException("packageName");
+ }
+
+ [Fact]
+ public void Should_Add_Package()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+ var packageName = "foo";
+
+ // When
+ settings.AddPackage(packageName);
+
+ // Then
+ settings.Packages.Count.ShouldBe(1);
+ settings.Packages.ShouldContain(packageName);
+ }
+ }
+
+ public sealed class TheAddScopedPackageMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmRebuildSettings settings = null;
+
+ // When
+ var result = Record.Exception(() => settings.AddScopedPackage("foo", "@bar"));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Package_Is_Null()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+
+ // When
+ var result = Record.Exception(() => settings.AddScopedPackage(null, "@bar"));
+
+ // Then
+ result.IsArgumentNullException("packageName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Package_Is_Empty()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+
+ // When
+ var result = Record.Exception(() => settings.AddScopedPackage(string.Empty, "@bar"));
+
+ // Then
+ result.IsArgumentNullException("packageName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Package_Is_WhiteSpace()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+
+ // When
+ var result = Record.Exception(() => settings.AddScopedPackage(" ", "@bar"));
+
+ // Then
+ result.IsArgumentNullException("packageName");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Scope_Does_Not_Start_With_At()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+
+ // When
+ var result = Record.Exception(() => settings.AddScopedPackage("foo", "bar"));
+
+ // Then
+ result.IsArgumentException("scope");
+ }
+
+ [Fact]
+ public void Should_Add_Package()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+ var packageName = "foo";
+ var scope = "@bar";
+
+ // When
+ settings.AddScopedPackage(packageName, scope);
+
+ // Then
+ settings.Packages.Count.ShouldBe(1);
+ settings.Packages.ShouldContain(scope + "/" + packageName);
+ }
+
+ [Fact]
+ public void Should_Add_Package_If_Scope_Is_Null()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+ var packageName = "foo";
+ string scope = null;
+
+ // When
+ settings.AddScopedPackage(packageName, scope);
+
+ // Then
+ settings.Packages.Count.ShouldBe(1);
+ settings.Packages.ShouldContain(packageName);
+ }
+
+ [Fact]
+ public void Should_Add_Package_If_Scope_Is_Empty()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+ var packageName = "foo";
+ var scope = string.Empty;
+
+ // When
+ settings.AddScopedPackage(packageName, scope);
+
+ // Then
+ settings.Packages.Count.ShouldBe(1);
+ settings.Packages.ShouldContain(packageName);
+ }
+
+ [Fact]
+ public void Should_Add_Package_If_Scope_Is_WhiteSpace()
+ {
+ // Given
+ var settings = new NpmRebuildSettings();
+ var packageName = "foo";
+ var scope = " ";
+
+ // When
+ settings.AddScopedPackage(packageName, scope);
+
+ // Then
+ settings.Packages.Count.ShouldBe(1);
+ settings.Packages.ShouldContain(packageName);
+ }
+ }
+ }
+}
diff --git a/src/Cake.Npm.Tests/Set/NpmSetSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/Set/NpmSetSettingsExtensionsTests.cs
new file mode 100644
index 0000000..25da441
--- /dev/null
+++ b/src/Cake.Npm.Tests/Set/NpmSetSettingsExtensionsTests.cs
@@ -0,0 +1,147 @@
+namespace Cake.Npm.Tests.Set
+{
+ using Cake.Npm.Set;
+ using Shouldly;
+ using Xunit;
+
+ public sealed class NpmSetSettingsExtensionsTests
+ {
+ public sealed class TheForKeyMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmSetSettings settings = null;
+
+ // When
+ var result = Record.Exception(() => settings.ForKey("foo"));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Key_Is_Null()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+
+ // When
+ var result = Record.Exception(() => settings.ForKey(null));
+
+ // Then
+ result.IsArgumentNullException("key");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Key_Is_Empty()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+
+ // When
+ var result = Record.Exception(() => settings.ForKey(string.Empty));
+
+ // Then
+ result.IsArgumentNullException("key");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Key_Is_WhiteSpace()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+
+ // When
+ var result = Record.Exception(() => settings.ForKey(" "));
+
+ // Then
+ result.IsArgumentNullException("key");
+ }
+
+ [Fact]
+ public void Should_Set_Key()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+ var key = "foo";
+
+ // When
+ settings.ForKey(key);
+
+ // Then
+ settings.Key.ShouldBe(key);
+ }
+ }
+
+ public sealed class TheWithValueMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmSetSettings settings = null;
+
+ // When
+ var result = Record.Exception(() => settings.WithValue("foo"));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Value_Is_Null()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+
+ // When
+ var result = Record.Exception(() => settings.WithValue(null));
+
+ // Then
+ result.IsArgumentNullException("value");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Value_Is_Empty()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+
+ // When
+ var result = Record.Exception(() => settings.WithValue(string.Empty));
+
+ // Then
+ result.IsArgumentNullException("value");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Value_Is_WhiteSpace()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+
+ // When
+ var result = Record.Exception(() => settings.WithValue(" "));
+
+ // Then
+ result.IsArgumentNullException("value");
+ }
+
+ [Fact]
+ public void Should_Set_Value()
+ {
+ // Given
+ var settings = new NpmSetSettings();
+ var value = "foo";
+
+ // When
+ settings.WithValue(value);
+
+ // Then
+ settings.Value.ShouldBe(value);
+ }
+ }
+ }
+}
diff --git a/src/Cake.Npm.Tests/Update/NpmUpdateSettingsExtensionsTests.cs b/src/Cake.Npm.Tests/Update/NpmUpdateSettingsExtensionsTests.cs
new file mode 100644
index 0000000..b26922d
--- /dev/null
+++ b/src/Cake.Npm.Tests/Update/NpmUpdateSettingsExtensionsTests.cs
@@ -0,0 +1,38 @@
+namespace Cake.Npm.Tests.Update
+{
+ using Cake.Npm.Update;
+ using Shouldly;
+ using Xunit;
+
+ public sealed class NpmUpdateSettingsExtensionsTests
+ {
+ public sealed class TheUpdateGlobalPackagesMethod
+ {
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ // Given
+ NpmUpdateSettings settings = null;
+
+ // When
+ var result = Record.Exception(() => settings.UpdateGlobalPackages());
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+
+ [Fact]
+ public void Should_Set_Global()
+ {
+ // Given
+ var settings = new NpmUpdateSettings();
+
+ // When
+ settings.UpdateGlobalPackages();
+
+ // Then
+ settings.Global.ShouldBe(true);
+ }
+ }
+ }
+}
diff --git a/src/Cake.Npm/Ci/NpmCiSettings.cs b/src/Cake.Npm/Ci/NpmCiSettings.cs
index 19e1103..16eecc0 100644
--- a/src/Cake.Npm/Ci/NpmCiSettings.cs
+++ b/src/Cake.Npm/Ci/NpmCiSettings.cs
@@ -1,5 +1,6 @@
using Cake.Core;
using Cake.Core.IO;
+using System;
namespace Cake.Npm.Ci
{
@@ -21,6 +22,12 @@ public NpmCiSettings()
///
public bool Production { get; set; }
+ ///
+ /// Gets or sets the registry where packages should be restored from.
+ /// Defaulted to whatever the NPM configuration is.
+ ///
+ public Uri Registry { get; set; }
+
///
protected override void EvaluateCore(ProcessArgumentBuilder args)
{
@@ -30,6 +37,11 @@ protected override void EvaluateCore(ProcessArgumentBuilder args)
{
args.Append("--production");
}
+
+ if (Registry != null)
+ {
+ args.AppendSwitch("--registry", Registry.ToString());
+ }
}
}
}
diff --git a/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs b/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs
index 6e9ae67..72147f2 100644
--- a/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs
+++ b/src/Cake.Npm/Ci/NpmCiSettingsExtensions.cs
@@ -26,5 +26,27 @@ public static NpmCiSettings ForProduction(this NpmCiSettings settings)
settings.Production = true;
return settings;
}
+
+ ///
+ /// Instructs npm to look for packages in the given registry.
+ ///
+ /// The settings.
+ /// The registry to look up packages from
+ /// The instance with set to .
+ public static NpmCiSettings FromRegistry(this NpmCiSettings settings, Uri registry)
+ {
+ if (settings == null)
+ {
+ throw new ArgumentNullException(nameof(settings));
+ }
+
+ if (registry == null)
+ {
+ throw new ArgumentNullException(nameof(registry));
+ }
+
+ settings.Registry = registry;
+ return settings;
+ }
}
}
diff --git a/src/Cake.Npm/Install/NpmInstallSettings.cs b/src/Cake.Npm/Install/NpmInstallSettings.cs
index b4d15c5..81860e7 100644
--- a/src/Cake.Npm/Install/NpmInstallSettings.cs
+++ b/src/Cake.Npm/Install/NpmInstallSettings.cs
@@ -51,7 +51,7 @@ public NpmInstallSettings()
///
/// Gets or sets a value indicating which registry we should point to. Defaulted to whatever the NPM configuration is.
///
- public string Registry { get; set; }
+ public Uri Registry { get; set; }
///
/// Gets or sets a value indicating whether or not to utilise the prefer offline flag, avoiding going to the internet for packages if possible.
@@ -86,9 +86,9 @@ protected override void EvaluateCore(ProcessArgumentBuilder args)
args.Append("--no-optional");
}
- if (!string.IsNullOrWhiteSpace(Registry))
+ if (Registry != null)
{
- args.Append($"--registry {Registry.ToLower()}");
+ args.AppendSwitch("--registry", Registry.ToString());
}
if (PreferOffline)
diff --git a/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs b/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs
index 09ca17b..67c87cb 100644
--- a/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs
+++ b/src/Cake.Npm/Install/NpmInstallSettingsExtensions.cs
@@ -300,5 +300,27 @@ public static NpmInstallSettings AddPackage(this NpmInstallSettings settings, st
settings.Packages.Add(resolvedPackageName);
return settings;
}
+
+ ///
+ /// Instructs npm to look for packages in the given registry.
+ ///
+ /// The settings.
+ /// The registry to look up packages from
+ /// The instance with set to .
+ public static NpmInstallSettings FromRegistry(this NpmInstallSettings settings, Uri registry)
+ {
+ if (settings == null)
+ {
+ throw new ArgumentNullException(nameof(settings));
+ }
+
+ if (registry == null)
+ {
+ throw new ArgumentNullException(nameof(registry));
+ }
+
+ settings.Registry = registry;
+ return settings;
+ }
}
}
diff --git a/src/Cake.Npm/NpmCiAliases.cs b/src/Cake.Npm/NpmCiAliases.cs
index 0c1bb5e..afc75ca 100644
--- a/src/Cake.Npm/NpmCiAliases.cs
+++ b/src/Cake.Npm/NpmCiAliases.cs
@@ -35,6 +35,38 @@ public static void NpmCi(this ICakeContext context)
context.NpmCi(new NpmCiSettings());
}
+ ///
+ /// Cis packages using the settings returned by a configurator.
+ ///
+ /// The context.
+ /// The settings configurator.
+ ///
+ /// Use specific log level ('npm ci')
+ ///
+ /// settings.WithLogLevel(NpmLogLevel.Verbose));
+ /// ]]>
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Ci")]
+ public static void NpmCi(this ICakeContext context, Action configurator)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (configurator == null)
+ {
+ throw new ArgumentNullException(nameof(configurator));
+ }
+
+ var settings = new NpmCiSettings();
+ configurator(settings);
+ context.NpmCi(settings);
+ }
+
///
/// Cis packages using the specified settings.
///
diff --git a/src/Cake.Npm/NpmSetAliases.cs b/src/Cake.Npm/NpmSetAliases.cs
index 70869f4..fac3968 100644
--- a/src/Cake.Npm/NpmSetAliases.cs
+++ b/src/Cake.Npm/NpmSetAliases.cs
@@ -43,6 +43,38 @@ public static void NpmSet(this ICakeContext context, string key, string value, b
});
}
+ ///
+ /// Sets an npm configuration setting returned by a configurator.
+ ///
+ /// The context.
+ /// The settings configurator.
+ ///
+ /// Use speSetfic log level ('npm Set')
+ ///
+ /// settings.ForKey("progress").WithValue("false"));
+ /// ]]>
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Set")]
+ public static void NpmSet(this ICakeContext context, Action configurator)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (configurator == null)
+ {
+ throw new ArgumentNullException(nameof(configurator));
+ }
+
+ var settings = new NpmSetSettings();
+ configurator(settings);
+ context.NpmSet(settings);
+ }
+
///
/// Sets an npm configuration setting.
///
diff --git a/src/Cake.Npm/NpmUpdateAliases.cs b/src/Cake.Npm/NpmUpdateAliases.cs
index 6ef192f..ec33397 100644
--- a/src/Cake.Npm/NpmUpdateAliases.cs
+++ b/src/Cake.Npm/NpmUpdateAliases.cs
@@ -36,7 +36,38 @@ public static void NpmUpdate(this ICakeContext context)
}
///
- /// Updates all packages for the project in the current working directory.
+ /// Updates all packages for the project using the settings returned by a configurator.
+ ///
+ /// The context.
+ /// The settings configurator.
+ ///
+ ///
+ /// settings.UpdateGlobalPackages());
+ /// ]]>
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory("Update")]
+ public static void NpmUpdate(this ICakeContext context, Action configurator)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ if (configurator == null)
+ {
+ throw new ArgumentNullException(nameof(configurator));
+ }
+
+ var settings = new NpmUpdateSettings();
+ configurator(settings);
+ context.NpmUpdate(settings);
+ }
+
+ ///
+ /// Updates all packages for the project using the specified settings.
///
/// The context.
/// The settings.
diff --git a/src/Cake.Npm/Publish/NpmPublishSettings.cs b/src/Cake.Npm/Publish/NpmPublishSettings.cs
index 109e681..8a120bd 100644
--- a/src/Cake.Npm/Publish/NpmPublishSettings.cs
+++ b/src/Cake.Npm/Publish/NpmPublishSettings.cs
@@ -37,6 +37,7 @@ public NpmPublishSettings()
///
/// Gets or sets the registry where the package should be published to.
+ /// Defaulted to whatever the NPM configuration is.
///
public Uri Registry { get; set; }
diff --git a/src/Cake.Npm/Rebuild/NpmRebuilSettingsExtensions.cs b/src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs
similarity index 97%
rename from src/Cake.Npm/Rebuild/NpmRebuilSettingsExtensions.cs
rename to src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs
index 723a38d..4009a1a 100644
--- a/src/Cake.Npm/Rebuild/NpmRebuilSettingsExtensions.cs
+++ b/src/Cake.Npm/Rebuild/NpmRebuildSettingsExtensions.cs
@@ -5,7 +5,7 @@ namespace Cake.Npm.Rebuild
///
/// Extensions for .
///
- public static class NpmRebuilSettingsExtensions
+ public static class NpmRebuildSettingsExtensions
{
///
/// Rebuild a package by name
diff --git a/src/Cake.Npm/Set/NpmSetSettings.cs b/src/Cake.Npm/Set/NpmSetSettings.cs
index 189982e..c2feadd 100644
--- a/src/Cake.Npm/Set/NpmSetSettings.cs
+++ b/src/Cake.Npm/Set/NpmSetSettings.cs
@@ -1,58 +1,58 @@
-using Cake.Core;
-using Cake.Core.IO;
+using Cake.Core;
+using Cake.Core.IO;
using System;
-namespace Cake.Npm.Set
-{
- ///
- /// Contains settings used by .
- ///
- public class NpmSetSettings : NpmSettings
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public NpmSetSettings()
- : base("set")
- {
- }
-
- ///
- /// The config key
- ///
- public string Key { get; set; }
-
- ///
- /// The config value
- ///
- public string Value { get; set; }
-
- ///
- /// Determines whether to set the config key value globally
- ///
- public bool Global { get; set; }
-
- ///
- protected override void EvaluateCore(ProcessArgumentBuilder args)
- {
- if (string.IsNullOrWhiteSpace(Key))
- {
- throw new ArgumentNullException(nameof(Key));
- }
-
- if (string.IsNullOrWhiteSpace(Value))
- {
- throw new ArgumentNullException(nameof(Value));
- }
-
- args.Append($"\"{Key}\"=\"{Value}\"");
-
- if (Global)
- {
- args.Append("-g");
- }
-
- base.EvaluateCore(args);
- }
- }
-}
+namespace Cake.Npm.Set
+{
+ ///
+ /// Contains settings used by .
+ ///
+ public class NpmSetSettings : NpmSettings
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public NpmSetSettings()
+ : base("set")
+ {
+ }
+
+ ///
+ /// The config key
+ ///
+ public string Key { get; set; }
+
+ ///
+ /// The config value
+ ///
+ public string Value { get; set; }
+
+ ///
+ /// Determines whether to set the config key value globally
+ ///
+ public bool Global { get; set; }
+
+ ///
+ protected override void EvaluateCore(ProcessArgumentBuilder args)
+ {
+ if (string.IsNullOrWhiteSpace(Key))
+ {
+ throw new ArgumentNullException(nameof(Key));
+ }
+
+ if (string.IsNullOrWhiteSpace(Value))
+ {
+ throw new ArgumentNullException(nameof(Value));
+ }
+
+ args.Append($"\"{Key}\"=\"{Value}\"");
+
+ if (Global)
+ {
+ args.Append("-g");
+ }
+
+ base.EvaluateCore(args);
+ }
+ }
+}
diff --git a/src/Cake.Npm/Set/NpmSetSettingsExtensions.cs b/src/Cake.Npm/Set/NpmSetSettingsExtensions.cs
new file mode 100644
index 0000000..5d01dbe
--- /dev/null
+++ b/src/Cake.Npm/Set/NpmSetSettingsExtensions.cs
@@ -0,0 +1,54 @@
+namespace Cake.Npm.Set
+{
+ using System;
+
+ ///
+ /// Extensions for .
+ ///
+ public static class NpmSetSettingsExtensions
+ {
+ ///
+ /// Defines the key which should be set.
+ ///
+ /// The settings.
+ /// Key which should be set.
+ /// The instance with set to .
+ public static NpmSetSettings ForKey(this NpmSetSettings settings, string key)
+ {
+ if (settings == null)
+ {
+ throw new ArgumentNullException(nameof(settings));
+ }
+
+ if (string.IsNullOrWhiteSpace(key))
+ {
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ settings.Key = key;
+ return settings;
+ }
+
+ ///
+ /// Defines the value which should be set.
+ ///
+ /// The settings.
+ /// Value which should be set.
+ /// The instance with set to .
+ public static NpmSetSettings WithValue(this NpmSetSettings settings, string value)
+ {
+ if (settings == null)
+ {
+ throw new ArgumentNullException(nameof(settings));
+ }
+
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+
+ settings.Value = value;
+ return settings;
+ }
+ }
+}
diff --git a/src/Cake.Npm/Update/NpmUpdateSettingsExtensions.cs b/src/Cake.Npm/Update/NpmUpdateSettingsExtensions.cs
index b633596..a9adcfa 100644
--- a/src/Cake.Npm/Update/NpmUpdateSettingsExtensions.cs
+++ b/src/Cake.Npm/Update/NpmUpdateSettingsExtensions.cs
@@ -1,9 +1,6 @@
-using Cake.Npm.Update;
-
-namespace Cake.Npm.Update
+namespace Cake.Npm.Update
{
using System;
- using Core;
///
/// Extensions for .
diff --git a/tools/packages.config b/tools/packages.config
index 747e13e..0501888 100644
--- a/tools/packages.config
+++ b/tools/packages.config
@@ -1,4 +1,4 @@
-
+