|
| 1 | +using Cake.Core; |
| 2 | +using Cake.Core.Annotations; |
| 3 | +using Cake.Npm.DistTag; |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Text; |
| 7 | + |
| 8 | +namespace Cake.Npm |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Npm dist-tag aliases |
| 12 | + /// </summary> |
| 13 | + [CakeAliasCategory("Npm")] |
| 14 | + [CakeNamespaceImport("Cake.Npm")] |
| 15 | + public static class NpmDistTagsAliases |
| 16 | + { |
| 17 | + /// <summary> |
| 18 | + /// Run npm dist-tag commands with specific arguments |
| 19 | + /// </summary> |
| 20 | + /// <param name="context">The context.</param> |
| 21 | + /// /// <param name="settings">The settings.</param> |
| 22 | + [CakeMethodAlias] |
| 23 | + [CakeAliasCategory("DistTags")] |
| 24 | + public static void NpmDistTag(this ICakeContext context, NpmDistTagSettings settings) |
| 25 | + { |
| 26 | + if (context == null) throw new ArgumentNullException(nameof(context)); |
| 27 | + if (settings == null) throw new ArgumentNullException(nameof(settings)); |
| 28 | + |
| 29 | + new NpmDistTagRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log).RunDistTags(settings); |
| 30 | + } |
| 31 | + |
| 32 | + /// <summary> |
| 33 | + /// Run npm dist-tag commands with specific arguments paramtered with the configurator |
| 34 | + /// </summary> |
| 35 | + /// <param name="context">The context.</param> |
| 36 | + /// <param name="package">The package name</param> |
| 37 | + /// <param name="version">The package version</param> |
| 38 | + /// <param name="tag">The package tag</param> |
| 39 | + /// <param name="configurator">The configurator</param> |
| 40 | + [CakeMethodAlias] |
| 41 | + [CakeAliasCategory("DistTags")] |
| 42 | + public static void NpmDistTagRun(this ICakeContext context, string package, string version, string tag, Action<NpmDistTagSettings> configurator = null) |
| 43 | + { |
| 44 | + if (context == null) throw new ArgumentNullException(nameof(context)); |
| 45 | + if (string.IsNullOrEmpty(package)) throw new ArgumentNullException(nameof(package)); |
| 46 | + if (string.IsNullOrEmpty(version)) throw new ArgumentNullException(nameof(version)); |
| 47 | + if (string.IsNullOrEmpty(tag)) throw new ArgumentNullException(nameof(tag)); |
| 48 | + |
| 49 | + NpmDistTagSettings s = new NpmDistTagSettings() |
| 50 | + { |
| 51 | + Package = package, |
| 52 | + Version = version, |
| 53 | + Tag = tag, |
| 54 | + }; |
| 55 | + configurator?.Invoke(s); |
| 56 | + |
| 57 | + new NpmDistTagRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log).RunDistTags(s); |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments