Public/Invoke-MkProj.ps1

function Invoke-MkProj {
    <#
    .SYNOPSIS
    Creates a project skeleton in a new or existing directory.

    .DESCRIPTION
    Scaffolds a deterministic project structure with src, tests, docs, and config folders,
    plus .gitignore and README.md. Existing files are not overwritten unless -Force is used.

    .PARAMETER Name
    Name of the project folder to create or update.

    .PARAMETER Template
    Project template flavor. Supported values: default, webapp, lib.

    .PARAMETER Force
    Overwrites generated files if they already exist.

    .EXAMPLE
    mkproj -Name SampleApp -Template webapp
    #>

    [CmdletBinding(SupportsShouldProcess = $true)]
    [Alias('mkproj')]
    param(
        [Parameter(Mandatory = $true, Position = 0)]
        [string]$Name,

        [ValidateSet('default', 'webapp', 'lib')]
        [string]$Template = 'default',

        [switch]$Force
    )

    $projectRoot = Resolve-DtContainedPath -BasePath (Get-Location) -ChildName $Name

    if (-not $PSCmdlet.ShouldProcess($projectRoot, 'Scaffold project')) {
        return
    }

    if (-not (Test-Path -LiteralPath $projectRoot)) {
        New-DtDirectory -Path $projectRoot -Force:$Force -Confirm:$false | Out-Null
    }
    else {
        Write-Verbose "Project root already exists: $projectRoot"
    }

    foreach ($folder in @('src', 'tests', 'docs', 'config')) {
        $folderPath = Join-Path -Path $projectRoot -ChildPath $folder
        New-DtDirectory -Path $folderPath -Force:$Force -Confirm:$false | Out-Null
    }

    $gitignoreContent = @"
# Build outputs
bin/
obj/
dist/

# Environment
.env
.venv/
env/
node_modules/

# IDE
.vscode/
.idea/
"@


    $readmeDescription = switch ($Template) {
        'webapp' { 'Web application scaffold generated by DevXToolkit.' }
        'lib' { 'Library scaffold generated by DevXToolkit.' }
        default { 'Project scaffold generated by DevXToolkit.' }
    }

    $safeName = ConvertTo-DtSafeMarkdownText -Text $Name

    $readmeContent = @"
# $safeName

$readmeDescription

## Setup

TODO: Add setup instructions.

## Usage

TODO: Add usage examples.

## License

TODO: Add license details.
"@


    Set-DtFileContent -Path (Join-Path $projectRoot '.gitignore') -Content $gitignoreContent -Force:$Force -Confirm:$false | Out-Null
    Set-DtFileContent -Path (Join-Path $projectRoot 'README.md') -Content $readmeContent -Force:$Force -Confirm:$false | Out-Null

    Write-Verbose "Project scaffold completed at: $projectRoot"
    Get-Item -LiteralPath $projectRoot
}