From 61de5593eaf65b862b6a97c5dc0b277d360c3dcd Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 21 Dec 2022 12:44:07 -0500 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 4985 (#32682) * Give the csv flexibility to onboard not new package to Docs.Ms * Use placeholder if the accurate msservice not decided yet * add deprecated message to display name * reformat * typo * Add package helper to common * typo again * Update eng/common/scripts/Helpers/Package-Helpers.ps1 Co-authored-by: Ben Broderick Phillips Co-authored-by: sima-zhu Co-authored-by: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Co-authored-by: Ben Broderick Phillips --- .../scripts/Helpers/Package-Helpers.ps1 | 72 +++++++++++-------- eng/common/scripts/Update-DocsMsMetadata.ps1 | 2 +- eng/common/scripts/Update-DocsMsPackages.ps1 | 2 +- eng/common/scripts/common.ps1 | 1 + 4 files changed, 44 insertions(+), 33 deletions(-) diff --git a/eng/common/scripts/Helpers/Package-Helpers.ps1 b/eng/common/scripts/Helpers/Package-Helpers.ps1 index 15a1f2ea8d463..3cc8adbb7e3d8 100644 --- a/eng/common/scripts/Helpers/Package-Helpers.ps1 +++ b/eng/common/scripts/Helpers/Package-Helpers.ps1 @@ -1,37 +1,47 @@ function GetPackageKey($pkg) { - $pkgKey = $pkg.Package - $groupId = $null - - if ($pkg.PSObject.Members.Name -contains "GroupId") { - $groupId = $pkg.GroupId - } - - if ($groupId) { - $pkgKey = "${groupId}:${pkgKey}" - } - - return $pkgKey + $pkgKey = $pkg.Package + $groupId = $null + + if ($pkg.PSObject.Members.Name -contains "GroupId") { + $groupId = $pkg.GroupId } + + if ($groupId) { + $pkgKey = "${groupId}:${pkgKey}" + } + + return $pkgKey +} - # Different language needs a different way to index the package. Build a map in convienice to lookup the package. - # E.g. : is the package key in java. - function GetPackageLookup($packageList) { - $packageLookup = @{} - - foreach ($pkg in $packageList) { - $pkgKey = GetPackageKey $pkg - - # We want to prefer updating non-hidden packages but if there is only - # a hidden entry then we will return that - if (!$packageLookup.ContainsKey($pkgKey) -or $packageLookup[$pkgKey].Hide -eq "true") { - $packageLookup[$pkgKey] = $pkg - } - else { - # Warn if there are more then one non-hidden package - if ($pkg.Hide -ne "true") { - Write-Host "Found more than one package entry for $($pkg.Package) selecting the first non-hidden one." - } +# Different language needs a different way to index the package. Build a map in convienice to lookup the package. +# E.g. : is the package key in java. +function GetPackageLookup($packageList) { + $packageLookup = @{} + + foreach ($pkg in $packageList) { + $pkgKey = GetPackageKey $pkg + + # We want to prefer updating non-hidden packages but if there is only + # a hidden entry then we will return that + if (!$packageLookup.ContainsKey($pkgKey) -or $packageLookup[$pkgKey].Hide -eq "true") { + $packageLookup[$pkgKey] = $pkg + } + else { + # Warn if there are more then one non-hidden package + if ($pkg.Hide -ne "true") { + Write-Host "Found more than one package entry for $($pkg.Package) selecting the first non-hidden one." } } - return $packageLookup } + return $packageLookup +} + +# For deprecated packages, add "(deprecated)" besides of display name. +function GetDocsTocDisplayName($pkg) { + $displayName = $pkg.DisplayName + if ('deprecated' -eq $pkg.Support) { + LogWarning "The pkg $($pkg.Package) is deprecated. Adding 'deprecated' beside the display name." + $displayName += " (deprecated)" + } + return $displayName +} \ No newline at end of file diff --git a/eng/common/scripts/Update-DocsMsMetadata.ps1 b/eng/common/scripts/Update-DocsMsMetadata.ps1 index b6b696758acb9..c51dc11851c0d 100644 --- a/eng/common/scripts/Update-DocsMsMetadata.ps1 +++ b/eng/common/scripts/Update-DocsMsMetadata.ps1 @@ -81,7 +81,7 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata # The $PackageMetadata could be $null if there is no associated metadata entry # based on how the metadata CSV is filtered $service = $PackageInfo.ServiceDirectory.ToLower() - if ($PackageMetadata -and $PackageMetadata.MSDocService) { + if ($PackageMetadata -and $PackageMetadata.MSDocService -and 'placeholder' -ine $PackageMetadata.MSDocService) { # Use MSDocService in csv metadata to override the service directory # TODO: Use taxonomy for service name -- https://github.com/Azure/azure-sdk-tools/issues/1442 $service = $PackageMetadata.MSDocService diff --git a/eng/common/scripts/Update-DocsMsPackages.ps1 b/eng/common/scripts/Update-DocsMsPackages.ps1 index ab7f54dcea25d..ccd531d3bd402 100644 --- a/eng/common/scripts/Update-DocsMsPackages.ps1 +++ b/eng/common/scripts/Update-DocsMsPackages.ps1 @@ -80,7 +80,7 @@ function GetDocsMetadataForMoniker($moniker) { } function GetDocsMetadata() { # Read metadata from CSV - $csvMetadata = (Get-CSVMetadata).Where({ $_.New -eq 'true' -and $_.Hide -ne 'true' }) + $csvMetadata = (Get-CSVMetadata).Where({ ($_.New -eq 'true' -or $_.MSDocService -ne '') -and $_.Hide -ne 'true'}) # Read metadata from docs repo $metadataByPackage = @{} diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index 1b77491fd374c..c78b1cfc2f1f0 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -15,6 +15,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts" . (Join-Path $EngCommonScriptsDir Invoke-DevOpsAPI.ps1) . (Join-Path $EngCommonScriptsDir artifact-metadata-parsing.ps1) . (Join-Path $EngCommonScriptsDir "Helpers" git-helpers.ps1) +. (Join-Path $EngCommonScriptsDir "Helpers" Package-Helpers.ps1) # Setting expected from common languages settings $Language = "Unknown"