diff --git a/build/Scripts/CreateModuleManifest.ps1 b/build/Scripts/CreateModuleManifest.ps1 index 7f5b26a..740983d 100644 --- a/build/Scripts/CreateModuleManifest.ps1 +++ b/build/Scripts/CreateModuleManifest.ps1 @@ -1,15 +1,18 @@ param ( - [string]$path, + [string]$powershellModuleFileLocation, [string]$guid, [string]$author, [string[]]$nestedModules, [string]$rootModule, [string[]]$cmdletsToExport, - [string]$manifestFileLocation + [string]$manifestFileLocation, + # not used for anything yet, but I should probably simplify the module locations as they get the output dir + # created in CopyOutputTask.cs + [string]$outputDir ) $manifestSplat = @{ - Path = "$path" + Path = "$powershellModuleFileLocation" GUID = "$guid" Author = "$author" NestedModules = @($nestedModules) diff --git a/build/Tasks/CopyOutputTask.cs b/build/Tasks/CopyOutputTask.cs index 175f82a..32caea6 100644 --- a/build/Tasks/CopyOutputTask.cs +++ b/build/Tasks/CopyOutputTask.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using Cake.Core.Diagnostics; using Cake.Core.IO; @@ -13,17 +14,20 @@ public class CopyOutputTask : FrostingTask public override void Run(BuildContext context) { var powershellModuleName = "PowershellModule"; + // TODO: probably don't create full file locations when I can pass the output dir in and have the script + // make the path var scriptParams = new { - Path = $"{context.PowershellModuleOutputDir}/{powershellModuleName}.psd1", + PowershellModuleFileLocation = $"{context.PowershellModuleOutputDir}/{powershellModuleName}.psd1", Guid = Guid.Parse("5cdf4635-edb0-428c-8d9b-92d0bcd47443"), Author = "Me", NestedModules = new[] { $"{powershellModuleName}.dll" }, RootModule = $"{powershellModuleName}.psm1", - CmdletsToExport = new[] { "Get-Calendar" }, - ManifestFileLocation = $"{context.PowershellModuleOutputDir}/{powershellModuleName}.psm1" + CmdletsToExport = GetExportedCmdlets(), + ManifestFileLocation = $"{context.PowershellModuleOutputDir}/{powershellModuleName}.psm1", + OutputLocation = context.PowershellModuleOutputDir, }; - + var psSettings = new PowershellSettings() { Arguments = new ProcessArgumentBuilder(), @@ -31,13 +35,14 @@ public class CopyOutputTask : FrostingTask // This feels a bit ugly/redundant seeing as I've defined the scriptParams above, but I'm leaving it as is // until I want to come back and clean this up properly - psSettings.Arguments.Append("path", ToPowershellSafeString(scriptParams.Path)); + psSettings.Arguments.Append("powershellModuleFileLocation", ToPowershellSafeString(scriptParams.PowershellModuleFileLocation)); psSettings.Arguments.Append("guid", ToPowershellSafeString(scriptParams.Guid.ToString())); psSettings.Arguments.Append("author", ToPowershellSafeString(scriptParams.Author)); psSettings.Arguments.Append("nestedModules", $"@({string.Join(",", scriptParams.NestedModules.Select(ToPowershellSafeString))})"); psSettings.Arguments.Append("rootModule", ToPowershellSafeString(scriptParams.RootModule)); psSettings.Arguments.Append("cmdletsToExport", $"@({string.Join(",", scriptParams.CmdletsToExport.Select(ToPowershellSafeString))})"); psSettings.Arguments.Append("manifestFileLocation", ToPowershellSafeString(scriptParams.ManifestFileLocation)); + psSettings.Arguments.Append("outputDir", ToPowershellSafeString(scriptParams.OutputLocation)); context.StartPowershellFile(context.CreateModuleManifestScript, psSettings); context.Log.Information($"Module output to: {context.PowershellModuleOutputDir.Path.MakeAbsolute(context.Environment)}"); @@ -46,4 +51,19 @@ public class CopyOutputTask : FrostingTask } private static string ToPowershellSafeString(string unescapedString) => $"'{unescapedString}'"; + + private static List GetExportedCmdlets() + { + return ["Get-Calendar", .. GetGitRepoRegistrationVerbs()]; + } + + private static List GetGitRepoRegistrationVerbs() + { + // TODO: I should make some reference file for these verbs and name but that'd pull in powershell dependencies + // to the build and I'd like to avoid that. + // This isn't great but commands are unlikely to change that frequently + string[] verbs = ["Get", "New", "Remove", "Show"]; + var commandName = "GitRepoRegistration"; + return [.. verbs.Select(x => $"{x}-{commandName}")]; + } } \ No newline at end of file