Public/New-specFunction.ps1
Function New-specFunction { <# .SYNOPSIS Creates a comprehensive project structure with folders, a YAML pipeline, and basic files. .DESCRIPTION This function automates the creation of a standard project structure. It includes: * Root folder and a "src" subfolder * Azure DevOps YAML pipeline file (with Pester integration) * README.md file * Test.ps1 file (with Pester configuration) * Functions.ps1 file * Pester test file (.tests.ps1) .PARAMETER Path Required. The base path where the project structure will be created. .PARAMETER Name Required. The name of the project (used for folder and file names). .PARAMETER DevOpsPath Required. The DevOps path to the function, used within the YAML pipeline. .EXAMPLE New-specFunction -Path C:\Projects -Name NewProject -DevOpsPath "_GBL\Scripts" This creates the entire project structure under "C:\Projects\NewProject". .NOTES Author: owen.heaume Version: 1.0.0 - Initial release #> [CmdletBinding()] param ( [Parameter(Mandatory)] [string]$Path, [Parameter(Mandatory)] [string]$Name, [Parameter(Mandatory)] [string]$DevOpsPath ) Begin {} Process { # 1. Create the folder structure $paths = New-FolderStructure -Path $Path -Name $Name Write-Host "" # 2. Create the YAML file New-YamlFile -Path $Path -Name $Name -DevOpsPath $DevOpsPath Write-Host "" # 3. create the README.md file New-ReadMe -Path $paths.folderPath -Name $name Write-Host "" # 4. Create the Test.ps1 file New-TestFile -Path $paths.folderpath Write-Host "" # 5. Create the Functions.ps1 file New-FunctionsFile -Path $paths.src write-host "" # 6. Create the Pester tests file New-PesterTestsFile -Path $paths.src -Name $Name write-host "" } End { Write-Host "Function '$name' has been setup successfully" -ForegroundColor DarkGreen } } |