Skip to content

Commit

Permalink
Merge 26a67f7 into fcef40f
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljurek authored Apr 29, 2024
2 parents fcef40f + 26a67f7 commit b60b8bc
Showing 1 changed file with 0 additions and 160 deletions.
160 changes: 0 additions & 160 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -376,28 +376,6 @@ function Get-DocsCiConfig($configPath) {
return $output
}

function Get-DocsCiLine ($item) {
$line = ''
if ($item.Properties.Count) {
$propertyPairs = @()
foreach ($key in $item.Properties.Keys) {
$propertyPairs += "$key=$($item.Properties[$key])"
}
$packageProperties = $propertyPairs -join ';'

$line = "$($item.Id),[$packageProperties]$($item.Name)"
} else {
$line = "$($item.Id),$($item.Name)"
}

if ($item.Versions) {
$joinedVersions = $item.Versions -join ','
$line += ",$joinedVersions"
}

return $line
}

function EnsureCustomSource($package) {
# $PackageSourceOverride is a global variable provided in
# Update-DocsMsPackages.ps1. Its value can set a "customSource" property.
Expand Down Expand Up @@ -446,144 +424,6 @@ function EnsureCustomSource($package) {
return $package
}

$PackageExclusions = @{
}

function Update-dotnet-DocsMsPackages($DocsRepoLocation, $DocsMetadata) {

Write-Host "Excluded packages:"
foreach ($excludedPackage in $PackageExclusions.Keys) {
Write-Host " $excludedPackage - $($PackageExclusions[$excludedPackage])"
}

$FilteredMetadata = $DocsMetadata.Where({ !($PackageExclusions.ContainsKey($_.Package)) })

UpdateDocsMsPackages `
(Join-Path $DocsRepoLocation 'bundlepackages/azure-dotnet-preview.csv') `
'preview' `
$FilteredMetadata

UpdateDocsMsPackages `
(Join-Path $DocsRepoLocation 'bundlepackages/azure-dotnet.csv') `
'latest' `
$FilteredMetadata
}

function UpdateDocsMsPackages($DocConfigFile, $Mode, $DocsMetadata) {
Write-Host "Updating configuration: $DocConfigFile with mode: $Mode"
$packageConfig = Get-DocsCiConfig $DocConfigFile

$outputPackages = @()
foreach ($package in $packageConfig) {
# Do not filter by GA/Preview status because we want differentiate between
# tracked and non-tracked packages
$matchingPublishedPackageArray = $DocsMetadata.Where({ $_.Package -eq $package.Name })

# If this package does not match any published packages keep it in the list.
# This handles packages which are not tracked in metadata but still need to
# be built in Docs CI.
if ($matchingPublishedPackageArray.Count -eq 0) {
Write-Host "Keep non-tracked preview package: $($package.Name)"
$outputPackages += $package
continue
}

if ($matchingPublishedPackageArray.Count -gt 1) {
LogWarning "Found more than one matching published package in metadata for $($package.Name); only updating first entry"
}
$matchingPublishedPackage = $matchingPublishedPackageArray[0]

if ($Mode -eq 'preview' -and !$matchingPublishedPackage.VersionPreview.Trim()) {
# If we are in preview mode and the package does not have a superseding
# preview version, remove the package from the list.
Write-Host "Remove superseded preview package: $($package.Name)"
continue
}

if ($matchingPublishedPackage.Support -eq 'deprecated') {
if ($Mode -eq 'legacy') {

# Select the GA version, if none use the preview version
$updatedVersion = $matchingPublishedPackage.VersionGA.Trim()
if (!$updatedVersion) {
$updatedVersion = $matchingPublishedPackage.VersionPreview.Trim()
}
$package.Versions = @($updatedVersion)

Write-Host "Add deprecated package to legacy moniker: $($package.Name)"
$outputPackages += $package
} else {
Write-Host "Removing deprecated package: $($package.Name)"
}

continue
}

$updatedVersion = $matchingPublishedPackage.VersionGA.Trim()
if ($Mode -eq 'preview') {
$updatedVersion = $matchingPublishedPackage.VersionPreview.Trim()
}

if ($updatedVersion -ne $package.Versions[0]) {
Write-Host "Update tracked package: $($package.Name) to version $updatedVersion"
$package.Versions = @($updatedVersion)
$package = EnsureCustomSource $package
} else {
Write-Host "Keep tracked package: $($package.Name)"
}

$outputPackages += $package
}

$outputPackagesHash = @{}
foreach ($package in $outputPackages) {
$outputPackagesHash[$package.Name] = $true
}

$remainingPackages = @()
if ($Mode -eq 'preview') {
$remainingPackages = $DocsMetadata.Where({
$_.VersionPreview.Trim() -and !$outputPackagesHash.ContainsKey($_.Package)
})
} else {
$remainingPackages = $DocsMetadata.Where({
$_.VersionGA.Trim() -and !$outputPackagesHash.ContainsKey($_.Package)
})
}

# Add packages that exist in the metadata but are not onboarded in docs config
# TODO: tfm='netstandard2.0' is a temporary workaround for
# https://github.com/Azure/azure-sdk-for-net/issues/22494
$newPackageProperties = [ordered]@{ tfm = 'netstandard2.0' }
if ($Mode -eq 'preview') {
$newPackageProperties['isPrerelease'] = 'true'
}

foreach ($package in $remainingPackages) {
Write-Host "Add new package from metadata: $($package.Package)"
$versions = @($package.VersionGA.Trim())
if ($Mode -eq 'preview') {
$versions = @($package.VersionPreview.Trim())
}

$newPackage = [PSCustomObject]@{
Id = $package.Package.Replace('.', '').ToLower();
Name = $package.Package;
Properties = $newPackageProperties;
Versions = $versions
}
$newPackage = EnsureCustomSource $newPackage

$outputPackages += $newPackage
}

$outputLines = @()
foreach ($package in $outputPackages) {
$outputLines += Get-DocsCiLine $package
}
Set-Content -Path $DocConfigFile -Value $outputLines
}

function Get-dotnet-EmitterName() {
return "@azure-tools/typespec-csharp"
}
Expand Down

0 comments on commit b60b8bc

Please sign in to comment.