Public/Get-PCProjectVersion.ps1

<#
.SYNOPSIS
    Gets the current version of a project.
.DESCRIPTION
    Auto-detects the project ecosystem and reads the version from its native file.
    Supports PowerShell (.psd1), .NET (.csproj), Node.js (package.json),
    Python (pyproject.toml), and git tags as fallback.
.PARAMETER Path
    Project directory. Defaults to current directory.
.EXAMPLE
    Get-PCProjectVersion
    # Returns version info for the project in the current directory
.EXAMPLE
    Get-PCProjectVersion -Path C:\repos\MyModule
    # Returns version info for a specific project
.OUTPUTS
    [PSCustomObject] with Version, Parsed, ProjectType, and File properties.
#>

function Get-PCProjectVersion {
    [CmdletBinding()]
    [OutputType([PSCustomObject])]
    param(
        [Parameter()]
        [string]$Path = (Get-Location).Path
    )

    Write-Verbose "Detecting project type in: $Path"
    $projectType = Get-ProjectType -Path $Path

    if ($projectType.Type -eq 'Unknown') {
        throw "No recognized project type found in '$Path'. Supported: .psd1, .csproj, package.json, pyproject.toml, git tags"
    }

    Write-Verbose "Detected: $($projectType.Description) ($($projectType.FileName))"
    return Read-ProjectVersion -Path $Path -ProjectType $projectType
}