Public/Test-CCFolderStructure.ps1
|
function Test-CCFolderStructure { [CmdletBinding()] param( [Parameter(Mandatory)][string]$Path, [string]$Standard = 'core', [string]$Config ) $cfg = Get-CCRepoConfig -Path $Path -Standard $Standard -ConfigFile $Config $disabled = $cfg['disabled_checks'] ?? @() $results = @() # STRUCT-001: Source folder if ('STRUCT-001' -notin $disabled -and $cfg['structure_source']) { $srcPath = Join-Path $Path $cfg['structure_source'] $exists = Test-Path $srcPath $results += New-CCRepoCheckResult -CheckId 'STRUCT-001' -Category 'Folder Structure' ` -Item $cfg['structure_source'] ` -Status $(if ($exists) { 'Pass' } else { 'Fail' }) ` -Severity 'Error' ` -Message $(if ($exists) { "Source folder '$($cfg['structure_source'])' exists" } else { "Source folder '$($cfg['structure_source'])' is missing" }) ` -Standard $Standard ` -FixAvailable $true ` -FixAction "Create folder $($cfg['structure_source'])" } # STRUCT-002: Tests folder if ('STRUCT-002' -notin $disabled -and $cfg['structure_tests']) { $testsPath = Join-Path $Path $cfg['structure_tests'] $exists = Test-Path $testsPath $results += New-CCRepoCheckResult -CheckId 'STRUCT-002' -Category 'Folder Structure' ` -Item $cfg['structure_tests'] ` -Status $(if ($exists) { 'Pass' } else { 'Fail' }) ` -Severity 'Error' ` -Message $(if ($exists) { "Tests folder '$($cfg['structure_tests'])' exists" } else { "Tests folder '$($cfg['structure_tests'])' is missing" }) ` -Standard $Standard ` -FixAvailable $true ` -FixAction "Create folder $($cfg['structure_tests'])" } # STRUCT-003: Docs folder if ('STRUCT-003' -notin $disabled -and $cfg['structure_docs']) { $docsPath = Join-Path $Path $cfg['structure_docs'] $exists = Test-Path $docsPath $results += New-CCRepoCheckResult -CheckId 'STRUCT-003' -Category 'Folder Structure' ` -Item $cfg['structure_docs'] ` -Status $(if ($exists) { 'Pass' } else { 'Warning' }) ` -Severity 'Warning' ` -Message $(if ($exists) { "Docs folder '$($cfg['structure_docs'])' exists" } else { "Docs folder '$($cfg['structure_docs'])' is missing" }) ` -Standard $Standard ` -FixAvailable $true ` -FixAction "Create folder $($cfg['structure_docs'])" } # STRUCT-004: CI workflows if ('STRUCT-004' -notin $disabled -and $cfg['require_ci']) { $ciPath = Join-Path $Path '.github/workflows' $exists = Test-Path $ciPath $results += New-CCRepoCheckResult -CheckId 'STRUCT-004' -Category 'Folder Structure' ` -Item '.github/workflows/' ` -Status $(if ($exists) { 'Pass' } else { 'Fail' }) ` -Severity 'Error' ` -Message $(if ($exists) { "CI workflows folder exists" } else { "CI workflows folder (.github/workflows/) is missing" }) ` -Standard $Standard ` -FixAvailable $true ` -FixAction "Create .github/workflows/" } $results } |