techthoughts2 / Catesta

Catesta is a PowerShell module and vault project generator. It uses templates to rapidly scaffold test and build integration for a variety of CI/CD platforms.
https://www.catesta.dev/
MIT License
165 stars 20 forks source link

Add functionality for automating the substitution of public functions into the manifest #98

Open techthoughts2 opened 1 week ago

techthoughts2 commented 1 week ago

It has been suggested in both #69 and #97 that Catesta should automate the process of populating public functions into the .psd1 manifest.

One proposed solution is to add a build task for this:

#Updates the array for FunctionsToExport in the module manifest
Add-BuildTask UpdateFunctionsToExport -Before TestModuleManifest {
    Write-Build White '      Running module manifest update FuctionsToExport...'
    $publicFunctionPath = Join-Path -Path $script:ModuleSourcePath -ChildPath 'Public'
    $publicFunctions = Get-ChildItem -Path $publicFunctionPath -Filter '*.ps1' -Recurse
    Update-ModuleManifest -Path $script:ModuleManifestFile -FunctionsToExport $publicFunctions.BaseName
    Write-Build Green '      ...Module Manifest Update FunctionsToExport Complete!'
} #UpdateFunctionsToExport

I'd like some community feedback on this change. Are there situations where this would not be desirable?

SamErde commented 1 week ago

I like the idea of doing a check. If both are empty or a wildcard, then the task can add all found public functions or cmdlets. If a value is there already, leave it unchanged [unless an -AddFunctions or -ExportAll switch is used with the build script].

SQLCanuck commented 1 week ago

Personally, I feel some sort of automation for the FunctionsToExport is necessary. Be it by the above proposed solution or some variant. As the purpose of having the Public directory, is to easily automate what functions are included during a build process.