Skip to content

Commit bf04f3e

Browse files
committed
Updated plugin generation to automatically target current tool version.
1 parent fcc405f commit bf04f3e

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

src/SparkDevNetwork.Rock.DevTool/Commands/PluginCommands/NewCommand.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.CommandLine;
22
using System.CommandLine.Invocation;
33
using System.IO.Abstractions;
4-
using System.Text.RegularExpressions;
4+
using System.Reflection;
55

66
using Fluid;
77

@@ -362,7 +362,8 @@ private async Task CopyTemplateAsync( string sourceName, string[] destination )
362362
RockVersion = RockVersion,
363363
RockWebPath = RockWebPath,
364364
Copy = Copy ?? false,
365-
RestApiSupport = RestApiSupport ?? false
365+
RestApiSupport = RestApiSupport ?? false,
366+
ToolVersion = GetToolVersion()
366367
};
367368

368369
if ( options.RockWebPath is not null )
@@ -605,6 +606,21 @@ private ValidationResult VersionStringValidator( string? value )
605606
}
606607
}
607608

609+
/// <summary>
610+
/// Gets the tool version number. This is taken from the build version
611+
/// but excludes any build metadata (git commit).
612+
/// </summary>
613+
/// <returns>A string that represents the build number.</returns>
614+
private string GetToolVersion()
615+
{
616+
var currentVersionInfo = GetType()
617+
.Assembly
618+
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
619+
?.InformationalVersion ?? "0";
620+
621+
return currentVersionInfo.Split( '+' )[0];
622+
}
623+
608624
/// <summary>
609625
/// The merge fields that will be available when merging template source
610626
/// files.
@@ -651,5 +667,10 @@ private class TemplateMergeFields
651667
/// DLL project.
652668
/// </summary>
653669
public bool? RestApiSupport { get; set; }
670+
671+
/// <summary>
672+
/// The version number of the tool when the merge happens.
673+
/// </summary>
674+
public string? ToolVersion { get; set; }
654675
}
655676
}

src/SparkDevNetwork.Rock.DevTool/Templates/obsidian-project/package.json.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"@rockrms/obsidian-framework": "^{{ RockVersion }}"
1414
},
1515
"devDependencies": {
16-
"@sparkdevnetwork/eslint-config-rock-recommended": "^1.0.0",
17-
"@sparkdevnetwork/obsidian-build-tools": "^1.0.0",
16+
"@sparkdevnetwork/eslint-config-rock-recommended": "^{{ ToolVersion }}",
17+
"@sparkdevnetwork/obsidian-build-tools": "^{{ ToolVersion }}",
1818
"@types/jest": "^29.5.4",
1919
"@types/node": "^20.5.7",
2020
"@typescript-eslint/eslint-plugin": "^6.5.0",

src/SparkDevNetwork.Rock.DevTool/Templates/sdk-project/project.csproj.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="SparkDevNetwork.Rock.Build.Tasks" Version="1.0.0" />
15-
<PackageReference Include="SparkDevNetwork.Rock.Analyzers" Version="1.0.0" />
14+
<PackageReference Include="SparkDevNetwork.Rock.Build.Tasks" Version="{{ ToolVersion }}" />
15+
<PackageReference Include="SparkDevNetwork.Rock.Analyzers" Version="{{ ToolVersion }}" />
1616
<PackageReference Include="RockRMS.Rock" Version="{{ RockVersion }}" />{% if RestApiSupport == true %}
1717
<PackageReference Include="RockRMS.Rock.Rest" Version="{{ RockVersion }}" />
1818
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" />{% endif %}

0 commit comments

Comments
 (0)