Skip to content

Instantly share code, notes, and snippets.

@ElbertCode
Created July 28, 2026 16:40
Show Gist options
  • Select an option

  • Save ElbertCode/adae98a74df10f1665cddd364e21e7c4 to your computer and use it in GitHub Desktop.

Select an option

Save ElbertCode/adae98a74df10f1665cddd364e21e7c4 to your computer and use it in GitHub Desktop.
Check package review dates
steps:
- powershell: |
$ErrorActionPreference = 'Stop'
$jsonPath = "$(Build.SourcesDirectory)\packages.json"
if (-not (Test-Path $jsonPath)) {
Write-Host "JSON file not found at '$jsonPath'. Skipping validation."
exit 0
}
$packages = Get-Content -Raw -Path $jsonPath | ConvertFrom-Json
$now = [datetime]::UtcNow
$threshold = $now.AddDays(-180)
foreach ($pkg in $packages) {
$id = $pkg.Id
if (-not ($pkg.PSObject.Properties.Name -contains 'reviewedAt') -or [string]::IsNullOrWhiteSpace($pkg.reviewedAt)) {
Write-Error "Package '$id' is missing 'reviewedAt'."
exit 1
}
try {
$reviewedAt = [datetime]::Parse($pkg.reviewedAt).ToUniversalTime()
} catch {
Write-Error "Package '$id' has invalid 'reviewedAt' value: '$($pkg.reviewedAt)'."
exit 1
}
if ($reviewedAt -lt $threshold) {
$daysOld = [math]::Floor(($now - $reviewedAt).TotalDays)
Write-Error "Package '$id' has 'reviewedAt' ($($pkg.reviewedAt)) older than 180 days (~$daysOld days)."
exit 1
}
}
Write-Host "All packages have valid 'reviewedAt' values within the last 180 days."
displayName: 'Validate package review dates'

Comments are disabled for this gist.