Public/Invoke-MkVenv.ps1
|
function Invoke-MkVenv { <# .SYNOPSIS Creates a minimal virtual environment scaffold. .DESCRIPTION Scaffolds a Python or Node environment layout with placeholder files only. This command does not create real virtual environments yet. .PARAMETER Type Environment type to scaffold. Supported values: Python, Node. .PARAMETER Force Overwrites generated files if they already exist. .EXAMPLE mkvenv -Type Python #> [CmdletBinding(SupportsShouldProcess = $true)] [Alias('mkvenv')] param( [Parameter(Mandatory = $true)] [ValidateSet('Python', 'Node')] [string]$Type, [switch]$Force ) $cwd = Get-Location if (-not $PSCmdlet.ShouldProcess($cwd.Path, "Scaffold $Type environment")) { return } switch ($Type) { 'Python' { $envDir = Join-Path -Path $cwd -ChildPath 'env' New-DtDirectory -Path $envDir -Force:$Force -Confirm:$false | Out-Null $requirementsPath = Join-Path -Path $cwd -ChildPath 'requirements.txt' $requirementsContent = "# TODO: Add Python package requirements" Set-DtFileContent -Path $requirementsPath -Content $requirementsContent -Force:$Force -Confirm:$false | Out-Null } 'Node' { $nodeEnvDir = Join-Path -Path $cwd -ChildPath 'node_env' New-DtDirectory -Path $nodeEnvDir -Force:$Force -Confirm:$false | Out-Null $packageJsonPath = Join-Path -Path $cwd -ChildPath 'package.json' $packageJsonObject = [ordered]@{ name = 'todo-project' version = '0.1.0' private = $true scripts = [ordered]@{ start = 'echo "TODO: define start script"' test = 'echo "TODO: define test script"' } } $packageJsonContent = $packageJsonObject | ConvertTo-Json -Depth 6 Set-DtFileContent -Path $packageJsonPath -Content $packageJsonContent -Force:$Force -Confirm:$false | Out-Null } } Write-Verbose "Virtual environment scaffold generated for $Type" } |