PwSh.Fw.BuildHelpers.psm1
<#
.SYNOPSIS Create a new project.yml file .DESCRIPTION Create an empty project.yml file at the location of your choice. Preferably in the root of your new project workspace. .PARAMETER Path Existing path to write project.yml file .PARAMETER PassThru If specified, return the content of the project object instead of the absolute location of the file .EXAMPLE $project = New-ProjectFile -PassThru .NOTES General notes #> function New-ProjectFile { [CmdletBinding()][OutputType([String], [boolean])]Param ( [Parameter(Mandatory = $true, ValueFromPipeLine = $true)][string]$Path, [switch]$PassThru ) Begin { # Write-EnterFunction } Process { $Project = [PSCustomObject]@{ Name = "name" Version = "1.0.0" Authors = @("you") Owner = "you" LicenseURL = "https//path/to/your/licence/file" Description = "short description of your project" ReleaseNotes = "" Copyright = "" Depends = @() } If (Test-Path $Path) { $Project | ConvertTo-Yaml | Set-Content $Path/project.yml -Encoding utf8 } else { Write-Error "'$Path' not found." return $false } if ($PassThru) { return $Project } else { return (Resolve-Path "$Path/project.yml").Path } } End { # Write-LeaveFunction } } <# .SYNOPSIS Test if a project is compliant with BuildHelpers modules .DESCRIPTION Check the completeness of a project to be used with BuildHelpers modules. .PARAMETER Path The root path of the project to test .EXAMPLE Test-ProjectStructure -Path c:\projects\myNewProject .NOTES General notes #> function Test-ProjectStructure { [CmdletBinding()][OutputType([boolean])]Param ( [Parameter(Mandatory = $true, ValueFromPipeLine = $true)][string]$Path ) Begin { # Write-EnterFunction } Process { $rc = $true if (Test-Path $Path -PathType Container) { Write-Host -ForegroundColor Green "[+] $Path exist" } else { Write-Host -ForegroundColor Red "[-] $Path does not exist" $rc = $false } foreach ($f in @('project.yml', 'CHANGELOG.md', 'README.md', 'LICENSE', 'VERSION')) { if (Test-Path $Path/$f -PathType Leaf) { Write-Host -ForegroundColor Green "[+] $Path/$f exist" } else { Write-Host -ForegroundColor Red "[-] $Path/$f does not exist" $rc = $false } } return $rc } End { # Write-LeaveFunction } } |