Public/New-OSDStageRepository.ps1

function New-OSDStageRepository {
    [CmdletBinding(SupportsShouldProcess)]
    param(
        [Parameter(Mandatory, Position=0)]
        [string]$Path
    )

    $appsPath = Join-Path $Path 'Packages'
    $catalogPath = Join-Path $Path 'catalog.json'

    $approved = $PSCmdlet.ShouldProcess($Path, 'Create OSDStage repository structure')
    if ($approved) {
        New-Item -ItemType Directory -Path $appsPath -Force -ErrorAction Stop | Out-Null

        if (-not (Test-Path -LiteralPath $catalogPath -PathType Leaf)) {
            [ordered]@{
                SchemaVersion = 2
                GeneratedAt   = (Get-Date).ToUniversalTime().ToString('o')
                Packages  = @()
            } |
                ConvertTo-Json -Depth 20 |
                Set-Content -LiteralPath $catalogPath -Encoding UTF8 -ErrorAction Stop
        }
    }

    $result = [pscustomobject]@{
        PSTypeName = 'OSDStage.Repository'
        Path       = $Path
        Catalog    = $catalogPath
        PackagesPath   = $appsPath
    }
    if (-not $approved) { $result.PSObject.TypeNames.Insert(0, 'OSDStage.RepositoryPlan') }
    $result
}