Public/New-DevConfig.ps1
|
function New-DevConfig { <# .SYNOPSIS Creates a DevXToolkit project configuration. .DESCRIPTION Writes a .devconfig.json file at the requested path. An existing file is preserved. .PARAMETER Path Project directory that receives .devconfig.json. .EXAMPLE New-DevConfig -Path C:\projects\demo #> [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter()] [string]$Path = (Get-Location).Path ) $ConfigPath = Join-Path $Path ".devconfig.json" if (Test-Path $ConfigPath) { Write-Verbose ".devconfig.json already exists; skipping" return } if (-not $PSCmdlet.ShouldProcess($ConfigPath, 'Create development configuration')) { return } $Config = @{ projectName = Split-Path $Path -Leaf created = (Get-Date).ToString("o") version = "1.0" tools = @{ prettier = $true markdownlint = $true analyzer = $true } } $content = $Config | ConvertTo-Json -Depth 5 Set-DtFileContent -Path $ConfigPath -Content $content -Confirm:$false | Out-Null Write-Information "Created .devconfig.json" -InformationAction Continue } |