$ErrorActionPreference = 'Stop' $root = Split-Path -Parent $PSScriptRoot $fe = Join-Path $root 'frontend' $be = Join-Path $root 'backend' function Remove-Path([string]$path) { if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path -Recurse -Force Write-Output ("REMOVED " + $path.Substring($root.Length + 1)) } } # frontend directories @( 'docs', 'backups', 'cloud-functions', 'outputs', 'test-results', 'tmp', 'scripts', 'rules' ) | ForEach-Object { Remove-Path (Join-Path $fe $_) } # frontend softzhu directory if present Get-ChildItem -LiteralPath $fe -Force -Directory | Where-Object { $_.Name -like '*软著*' -or $_.Name -eq '软著申报' } | ForEach-Object { Remove-Path $_.FullName } # frontend root clutter $keepExact = @( 'src', 'angular.json', 'package.json', 'package-lock.json', 'tsconfig.json', 'tsconfig.app.json', 'proxy.conf.json', 'README.md' ) Get-ChildItem -LiteralPath $fe -Force | ForEach-Object { $name = $_.Name if ($keepExact -contains $name) { return } $drop = $false if ($name.StartsWith('_')) { $drop = $true } elseif ($name -match '\.(md|docx|xlsx|ps1|txt|out|diff|js)$') { $drop = $true } elseif ($name -like 'echarts_*') { $drop = $true } elseif ($name -like 'cloud-function-*') { $drop = $true } elseif ($name -like 'patch-*') { $drop = $true } elseif ($name -match '^(ec\d+|safe|scan|usage|findec)(\.|$)') { $drop = $true } if ($drop) { Remove-Path $_.FullName } } # backend unrelated @( 'docs', 'scripts', 'rules', 'IMPLEMENTATION-SUMMARY.md' ) | ForEach-Object { Remove-Path (Join-Path $be $_) } # module docs/tests Get-ChildItem -Path (Join-Path $be 'modules') -Recurse -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -in @('docs','examples','__tests__','test','tests') } | ForEach-Object { Remove-Path $_.FullName } Get-ChildItem -Path (Join-Path $be 'modules') -Recurse -File -Filter '*.md' -ErrorAction SilentlyContinue | ForEach-Object { Remove-Path $_.FullName } Write-Output 'CLEANUP_DONE'