Skip to content

Commit

Permalink
feat: add VitePress lint target (#104)
Browse files Browse the repository at this point in the history
Co-authored-by: Raphael Strotz <Xzelsius@users.noreply.github.com>
  • Loading branch information
Xzelsius and Xzelsius authored Oct 21, 2024
1 parent 2805c7e commit 91662bc
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
"ShipPublicApis",
"Test",
"VitePressBuild",
"VitePressInstall"
"VitePressInstall",
"VitePressLint"
]
},
"Verbosity": {
Expand Down
8 changes: 8 additions & 0 deletions nukebuild/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
using Ayaka.Nuke.PublicApi;
using Ayaka.Nuke.VitePress;
using Nuke.Common;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.Npm;

[DotNetVerbosityMapping]
partial class Build
Expand All @@ -35,6 +37,7 @@ partial class Build
ICanDotNetValidate,
ICanDotNetPush,
ICanVitePressInstall,
ICanVitePressLint,
ICanVitePressBuild,
ICanGitHubRelease,
ICanShipPublicApis
Expand Down Expand Up @@ -67,6 +70,11 @@ partial class Build
.Description("Publishes all NuGet packages in the Solution")
.DependsOn<IHaveDotNetPushTarget>();

// Customize the VitePress linting
Configure<NpmRunSettings> ICanVitePressLint.VitePressLintSettings
=> run => run
.SetCommand("lint:js");

Target Docs => target => target
.Description("Builds the Documentation")
.DependsOn<IHaveVitePressBuildTarget>();
Expand Down
5 changes: 5 additions & 0 deletions src/Ayaka.Nuke/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
#nullable enable
Ayaka.Nuke.VitePress.ICanVitePressLint
Ayaka.Nuke.VitePress.ICanVitePressLint.VitePressLintSettings.get -> Nuke.Common.Tooling.Configure<Nuke.Common.Tools.Npm.NpmRunSettings!>!
Ayaka.Nuke.VitePress.ICanVitePressLint.VitePressLintSettingsBase.get -> Nuke.Common.Tooling.Configure<Nuke.Common.Tools.Npm.NpmRunSettings!>!
Ayaka.Nuke.VitePress.IHaveVitePressLintTarget
Ayaka.Nuke.VitePress.IHaveVitePressLintTarget.VitePressLint.get -> Nuke.Common.Target!
1 change: 1 addition & 0 deletions src/Ayaka.Nuke/VitePress/ICanVitePressBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Configure<NpmRunSettings> VitePressBuildSettings
.Description("Builds the VitePress site")
.Unlisted()
.DependsOn<IHaveVitePressInstallTarget>()
.TryDependsOn<IHaveVitePressLintTarget>()
.Executes(() =>
{
_ = NpmTasks.NpmRun(
Expand Down
53 changes: 53 additions & 0 deletions src/Ayaka.Nuke/VitePress/ICanVitePressLint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Raphael Strotz. All rights reserved.

namespace Ayaka.Nuke.VitePress;

using global::Nuke.Common;
using global::Nuke.Common.Tooling;
using global::Nuke.Common.Tools.Npm;

/// <summary>
/// Provides a target for linting a VitePress site to the <see cref="INukeLint" />.
/// </summary>
public interface ICanVitePressLint
: ICan,
IHaveDocumentation,
IHaveVitePressInstallTarget,
IHaveVitePressLintTarget
{
/// <summary>
/// Gets the base settings for linting the VitePress site.
/// </summary>
[ExcludeFromCodeCoverage]
sealed Configure<NpmRunSettings> VitePressLintSettingsBase
=> run => run
.SetProcessWorkingDirectory(DocsDirectory)
.SetCommand("lint")
.SetProcessLogOutput(Verbosity == Verbosity.Verbose);

/// <summary>
/// Gets the additional settings for linting the VitePress site.
/// </summary>
/// <remarks>
/// Override this to provide additional settings for the <see cref="IHaveVitePressLintTarget.VitePressLint" />
/// target.
/// </remarks>
[ExcludeFromCodeCoverage]
Configure<NpmRunSettings> VitePressLintSettings
=> run => run;

/// <inheritdoc />
[ExcludeFromCodeCoverage]
Target IHaveVitePressLintTarget.VitePressLint => target => target
.Description("Lints the VitePress site")
.Unlisted()
.DependsOn<IHaveVitePressInstallTarget>()
.TryBefore<IHaveVitePressBuildTarget>()
.Executes(() =>
{
_ = NpmTasks.NpmRun(
npm => npm
.Apply(VitePressLintSettingsBase)
.Apply(VitePressLintSettings));
});
}
16 changes: 16 additions & 0 deletions src/Ayaka.Nuke/VitePress/IHaveVitePressLintTarget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Raphael Strotz. All rights reserved.

namespace Ayaka.Nuke.VitePress;

using global::Nuke.Common;

/// <summary>
/// Indicates that a <see cref="INukeBuild" /> has a target for linting a VitePress site.
/// </summary>
public interface IHaveVitePressLintTarget : IHave
{
/// <summary>
/// Gets the target for linting a VitePress site.
/// </summary>
Target VitePressLint { get; }
}

0 comments on commit 91662bc

Please sign in to comment.