Skip to content

Commit 81cb027

Browse files
azure-sdksima-zhubenbp
authored
Sync eng/common directory with azure-sdk-tools for PR 4985 (Azure#33150)
* 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]>
1 parent 691c8c0 commit 81cb027

File tree

4 files changed

+44
-33
lines changed

4 files changed

+44
-33
lines changed
+41-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
function GetPackageKey($pkg) {
2-
$pkgKey = $pkg.Package
3-
$groupId = $null
4-
5-
if ($pkg.PSObject.Members.Name -contains "GroupId") {
6-
$groupId = $pkg.GroupId
7-
}
8-
9-
if ($groupId) {
10-
$pkgKey = "${groupId}:${pkgKey}"
11-
}
12-
13-
return $pkgKey
2+
$pkgKey = $pkg.Package
3+
$groupId = $null
4+
5+
if ($pkg.PSObject.Members.Name -contains "GroupId") {
6+
$groupId = $pkg.GroupId
147
}
8+
9+
if ($groupId) {
10+
$pkgKey = "${groupId}:${pkgKey}"
11+
}
12+
13+
return $pkgKey
14+
}
1515

16-
# Different language needs a different way to index the package. Build a map in convienice to lookup the package.
17-
# E.g. <groupId>:<packageName> is the package key in java.
18-
function GetPackageLookup($packageList) {
19-
$packageLookup = @{}
20-
21-
foreach ($pkg in $packageList) {
22-
$pkgKey = GetPackageKey $pkg
23-
24-
# We want to prefer updating non-hidden packages but if there is only
25-
# a hidden entry then we will return that
26-
if (!$packageLookup.ContainsKey($pkgKey) -or $packageLookup[$pkgKey].Hide -eq "true") {
27-
$packageLookup[$pkgKey] = $pkg
28-
}
29-
else {
30-
# Warn if there are more then one non-hidden package
31-
if ($pkg.Hide -ne "true") {
32-
Write-Host "Found more than one package entry for $($pkg.Package) selecting the first non-hidden one."
33-
}
16+
# Different language needs a different way to index the package. Build a map in convienice to lookup the package.
17+
# E.g. <groupId>:<packageName> is the package key in java.
18+
function GetPackageLookup($packageList) {
19+
$packageLookup = @{}
20+
21+
foreach ($pkg in $packageList) {
22+
$pkgKey = GetPackageKey $pkg
23+
24+
# We want to prefer updating non-hidden packages but if there is only
25+
# a hidden entry then we will return that
26+
if (!$packageLookup.ContainsKey($pkgKey) -or $packageLookup[$pkgKey].Hide -eq "true") {
27+
$packageLookup[$pkgKey] = $pkg
28+
}
29+
else {
30+
# Warn if there are more then one non-hidden package
31+
if ($pkg.Hide -ne "true") {
32+
Write-Host "Found more than one package entry for $($pkg.Package) selecting the first non-hidden one."
3433
}
3534
}
36-
return $packageLookup
3735
}
36+
return $packageLookup
37+
}
38+
39+
# For deprecated packages, add "(deprecated)" besides of display name.
40+
function GetDocsTocDisplayName($pkg) {
41+
$displayName = $pkg.DisplayName
42+
if ('deprecated' -eq $pkg.Support) {
43+
LogWarning "The pkg $($pkg.Package) is deprecated. Adding 'deprecated' beside the display name."
44+
$displayName += " (deprecated)"
45+
}
46+
return $displayName
47+
}

eng/common/scripts/Update-DocsMsMetadata.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function GetAdjustedReadmeContent($ReadmeContent, $PackageInfo, $PackageMetadata
8181
# The $PackageMetadata could be $null if there is no associated metadata entry
8282
# based on how the metadata CSV is filtered
8383
$service = $PackageInfo.ServiceDirectory.ToLower()
84-
if ($PackageMetadata -and $PackageMetadata.MSDocService) {
84+
if ($PackageMetadata -and $PackageMetadata.MSDocService -and 'placeholder' -ine $PackageMetadata.MSDocService) {
8585
# Use MSDocService in csv metadata to override the service directory
8686
# TODO: Use taxonomy for service name -- https://github.com/Azure/azure-sdk-tools/issues/1442
8787
$service = $PackageMetadata.MSDocService

eng/common/scripts/Update-DocsMsPackages.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function GetDocsMetadataForMoniker($moniker) {
8080
}
8181
function GetDocsMetadata() {
8282
# Read metadata from CSV
83-
$csvMetadata = (Get-CSVMetadata).Where({ $_.New -eq 'true' -and $_.Hide -ne 'true' })
83+
$csvMetadata = (Get-CSVMetadata).Where({ ($_.New -eq 'true' -or $_.MSDocService -ne '') -and $_.Hide -ne 'true'})
8484

8585
# Read metadata from docs repo
8686
$metadataByPackage = @{}

eng/common/scripts/common.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts"
1515
. (Join-Path $EngCommonScriptsDir Invoke-DevOpsAPI.ps1)
1616
. (Join-Path $EngCommonScriptsDir artifact-metadata-parsing.ps1)
1717
. (Join-Path $EngCommonScriptsDir "Helpers" git-helpers.ps1)
18+
. (Join-Path $EngCommonScriptsDir "Helpers" Package-Helpers.ps1)
1819

1920
# Setting expected from common languages settings
2021
$Language = "Unknown"

0 commit comments

Comments
 (0)