Public/New-specModule.ps1
Function New-specModule { <# .SYNOPSIS Automates the creation of a basic PowerShell module structure, including necessary files and configuration for Pester testing and PowerShell Gallery publishing. .DESCRIPTION This function streamlines the setup of a new PowerShell module by creating the following: * A root folder with standard subfolders ('Tests', module folder, 'en-US', 'Public', 'Private'). * A README.md file. * A Test.ps1 file with basic Pester configuration. * A Pester tests file (.tests.ps1). * An 'about_' help file. * A module manifest (.psd1) file. * A module loader (.psm1) file. * YAML configuration files for Pester testing and PowerShell Gallery publishing pipelines. .PARAMETER path Required. The base path where the module structure will be created. .PARAMETER Name Required. The name of the new module. .PARAMETER ShortDescription Required. A concise description of the module's functionality. .PARAMETER DevOpsPath Required. The relative path to the module folder within your DevOps repository. .EXAMPLE New-specModule -path C:\Dev\Modules -Name MyModule -ShortDescription "Provides data processing tools" -RelativePath "Modules" .NOTES Author: owen.heaume Version: 1.0.0 - Initial release 1.0.1 - Change 'DevopsPath' to 'RelativePath' #> [cmdletbinding()] param( [parameter (Mandatory)] [string]$path, [parameter (Mandatory)] [string]$Name, [parameter (Mandatory)] [string]$ShortDescription, [Parameter(Mandatory)] [string]$RelativePath ) Begin {} Process { # 1. Create the folder structure $paths = New-FolderStructure -Path $Path -Name $Name Write-Host '' # 2. Create the Pester YAML file New-PesterYamlFile -Path $Path -Name $Name -RelativePath $RelativePath Write-Host '' # 3. Create the PSGallery YAML file New-PSGalleryYamlFile -Path $Path -Name $Name -RelativePath $RelativePath Write-Host '' # 4. create the README.md file New-ReadMe -Path $paths.folderPath -Name $name Write-Host '' # 5. Create the Test.ps1 file New-TestFile -Path $paths.folderpath -Name $name Write-Host '' # 6. Create the Pester tests file New-PesterTestsFile -Path $paths.tests -Name $Name Write-Host '' # 7. Create the about file New-AboutFile -Path $paths.enus -Name $name -moduleShortDescription $ShortDescription Write-Host '' # 8. Create the module manifest psd1 file New-Psd1File -path $paths.module -name $name -moduleShortDescription $ShortDescription Write-Host '' #9. Create the module psm1 file New-Psm1File -path $paths.module -name $Name Write-Host '' } End { Write-Host "Module '$name' has been setup successfully" -ForegroundColor DarkGreen } } |