Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 4985 (Azure#32682)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

Co-authored-by: sima-zhu <[email protected]>
Co-authored-by: Sima Zhu <[email protected]>
Co-authored-by: Ben Broderick Phillips <[email protected]>
  • Loading branch information
4 people authored Dec 21, 2022
1 parent 3dc946e commit 61de559
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 33 deletions.
72 changes: 41 additions & 31 deletions eng/common/scripts/Helpers/Package-Helpers.ps1
Original file line number Diff line number Diff line change
@@ -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. <groupId>:<packageName> 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. <groupId>:<packageName> 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
}
2 changes: 1 addition & 1 deletion eng/common/scripts/Update-DocsMsMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Update-DocsMsPackages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @{}
Expand Down
1 change: 1 addition & 0 deletions eng/common/scripts/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 61de559

Please sign in to comment.