fixes save
This commit is contained in:
44
devops/scripts/fix-project-references.ps1
Normal file
44
devops/scripts/fix-project-references.ps1
Normal file
@@ -0,0 +1,44 @@
|
||||
# Fix project references in src/__Tests/** that point to wrong relative paths
|
||||
# Pattern: ../../<Module>/... should be ../../../<Module>/...
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$testsPath = "E:\dev\git.stella-ops.org\src\__Tests"
|
||||
|
||||
# Known module prefixes that exist at src/<Module>/
|
||||
$modules = @("Signals", "Scanner", "Concelier", "Scheduler", "Authority", "Attestor",
|
||||
"BinaryIndex", "EvidenceLocker", "Excititor", "ExportCenter", "Gateway",
|
||||
"Graph", "IssuerDirectory", "Notify", "Orchestrator", "Policy", "AirGap",
|
||||
"Provenance", "Replay", "RiskEngine", "SbomService", "Signer", "TaskRunner",
|
||||
"Telemetry", "TimelineIndexer", "Unknowns", "VexHub", "VexLens", "VulnExplorer",
|
||||
"Zastava", "Cli", "Aoc", "Web", "Bench", "Cryptography", "PacksRegistry",
|
||||
"Notifier", "Findings")
|
||||
|
||||
$fixedCount = 0
|
||||
|
||||
Get-ChildItem -Path $testsPath -Recurse -Filter "*.csproj" | ForEach-Object {
|
||||
$proj = $_
|
||||
$content = Get-Content $proj.FullName -Raw
|
||||
$originalContent = $content
|
||||
|
||||
foreach ($module in $modules) {
|
||||
# Fix ../../<Module>/ to ../../../<Module>/
|
||||
# But not ../../../<Module> (already correct)
|
||||
$pattern = "Include=`"../../$module/"
|
||||
$replacement = "Include=`"../../../$module/"
|
||||
|
||||
if ($content -match [regex]::Escape($pattern) -and $content -notmatch [regex]::Escape("Include=`"../../../$module/")) {
|
||||
$content = $content -replace [regex]::Escape($pattern), $replacement
|
||||
}
|
||||
}
|
||||
|
||||
# Fix __Libraries references that are one level short
|
||||
$content = $content -replace 'Include="../../__Libraries/', 'Include="../../../__Libraries/'
|
||||
|
||||
if ($content -ne $originalContent) {
|
||||
Set-Content -Path $proj.FullName -Value $content -NoNewline
|
||||
Write-Host "Fixed: $($proj.Name)" -ForegroundColor Green
|
||||
$fixedCount++
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "`nFixed $fixedCount projects" -ForegroundColor Cyan
|
||||
Reference in New Issue
Block a user