Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs/Service Level Readme] Fix DirectoryPath logic #6281

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions eng/common/scripts/Service-Level-Readme-Automation.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<#
.SYNOPSIS
The script is to generate service level readme if it is missing.
The script is to generate service level readme if it is missing.
For exist ones, we do 2 things here:
1. Generate the client but not import to the existing service level readme.
2. Update the metadata of service level readme

.DESCRIPTION
Given a doc repo location, and the credential for fetching the ms.author.
Given a doc repo location, and the credential for fetching the ms.author.
Generate missing service level readme and updating metadata of the existing ones.

.PARAMETER DocRepoLocation
Expand Down Expand Up @@ -53,9 +53,9 @@ $fullMetadata = Get-CSVMetadata
$monikers = @("latest", "preview")
foreach($moniker in $monikers) {
# The onboarded packages return is key-value pair, which key is the package index, and value is the package info from {metadata}.json
# E.g.
# E.g.
# Key as: @azure/storage-blob
# Value as:
# Value as:
# {
# "Name": "@azure/storage-blob",
# "Version": "12.10.0-beta.1",
Expand All @@ -73,22 +73,38 @@ foreach($moniker in $monikers) {
$onboardedPackages = &$GetOnboardedDocsMsPackagesForMonikerFn `
-DocRepoLocation $DocRepoLocation -moniker $moniker
$csvMetadata = @()

foreach($metadataEntry in $fullMetadata) {
if ($metadataEntry.Package -and $metadataEntry.Hide -ne 'true') {
$pkgKey = GetPackageKey $metadataEntry
if($onboardedPackages.ContainsKey($pkgKey)) {
if ($onboardedPackages[$pkgKey] -and $onboardedPackages[$pkgKey].DirectoryPath) {
if (!($metadataEntry.PSObject.Members.Name -contains "DirectoryPath")) {
Add-Member -InputObject $metadataEntry `
-MemberType NoteProperty `
-Name DirectoryPath `
-Value $onboardedPackages[$pkgKey].DirectoryPath
}
}

if (!$onboardedPackages.ContainsKey($pkgKey)) {
continue
}

$package = $onboardedPackages[$pkgKey]

if (!$package) {
danieljurek marked this conversation as resolved.
Show resolved Hide resolved
$csvMetadata += $metadataEntry
continue
}

# If the metadata JSON entry has a DirectoryPath, but the CSV entry
# does not, add the DirectoryPath to the CSV entry
if (($package.PSObject.Members.Name -contains 'DirectoryPath') `
-and !($metadataEntry.PSObject.Members.Name -contains "DirectoryPath") ) {

Add-Member -InputObject $metadataEntry `
-MemberType NoteProperty `
-Name DirectoryPath `
-Value $package.DirectoryPath
}

$csvMetadata += $metadataEntry

}
}

$packagesForService = @{}
$allPackages = GetPackageLookup $csvMetadata
foreach ($metadataKey in $allPackages.Keys) {
Expand Down
7 changes: 7 additions & 0 deletions eng/common/scripts/Verify-RequiredDocsJsonMembers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ function Test-RequiredDocsJsonMembers($moniker) {
$script:FoundError = $true
}

if ($fileObject.PSObject.Members.Name -contains 'DirectoryPath') {
danieljurek marked this conversation as resolved.
Show resolved Hide resolved
if (!$fileObject.DirectoryPath) {
Write-Host "$path has a null or empty DirectoryPath member. If the DirectoryPath is unknown please remove the 'DirectoryPath' entry from the file."
$script:FoundError = $true
}
}

if ($Language -eq "java") {
if ($fileObject.PSObject.Members.Name -contains "Group")
{
Expand Down