Skip to content

Commit

Permalink
Refinement
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljurek committed Aug 24, 2023
1 parent be5ce46 commit 32a328c
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions eng/common/scripts/Update-DocsPackageMonikers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param(

. (Join-Path $PSScriptRoot common.ps1)

Set-StictMode -Version 3
Set-StrictMode -Version 3

function getPackageMetadata($moniker) {
$jsonFiles = Get-ChildItem -Path (Join-Path $DocRepoLocation "metadata/$moniker") -Filter *.json
Expand All @@ -18,14 +18,14 @@ function getPackageMetadata($moniker) {
$packageIdentity = &$GetPackageIdentity $packageMetadata
}

$metadata[$packageIdentity] = @{ File = $jsonFile; metadata = $packageMetadata }
$metadata[$packageIdentity] = @{ File = $jsonFile; Metadata = $packageMetadata }
}

return $metadata
}

function getPackageMetadataFileLocation($packageIdentity, $lookupTable) {
if ($lookupTable.ContainsKey[$packageIdentity]) {
if ($lookupTable.ContainsKey($packageIdentity)) {
return $lookupTable[$packageIdentity]['File']
}

Expand All @@ -41,8 +41,6 @@ $deprecatedPackages = (Get-CSVMetadata).Where({ $_.Support -eq 'deprecated' })

foreach ($package in $deprecatedPackages) {
$packageIdentity = $package.Package
$metadata = &$GetDocsMsMetadataForPackageFn -PackageInfo $packageMetadata

# TODO: Ensure this works
if (Test-Path "Function:$GetPackageIdentity") {
$packageIdentity = &$GetPackageIdentity $package
Expand All @@ -52,25 +50,36 @@ foreach ($package in $deprecatedPackages) {
-packageIdentity $packageIdentity `
-lookupTable $metadataLookup['preview']

$latestMetadataPath = getPackageMetadataFileLocation `
-packageIdentity $packageIdentity `
-lookupTable $metadataLookup['latest']
if ($previewMetadataPath) {
$metadata = &$GetDocsMsMetadataForPackageFn -PackageInfo $metadataLookup['preview'][$packageIdentity]['Metadata']

if ($previewMetadataPath) {
Write-Host "Package $packageIdentity is deprecated but has file in preview metadata folder. Moving to legacy."
Move-Item $previewMetadataPath "$DocRepoLocation/metadata/legacy/" -Force
Move-Item `
"$($metadata.PreviewReadMeLocation)/$($metadata.DocsMsReadMeName)-readme.md" `
"$DocRepoLocation/metadata/legacy/$($metadata.DocsMsReadMeName)-readme.md" `
-Force


if (Test-Path "$DocRepoLocation/$($metadata.PreviewReadMeLocation)/$($metadata.DocsMsReadMeName)-readme.md") {
Move-Item `
"$DocRepoLocation/$($metadata.PreviewReadMeLocation)/$($metadata.DocsMsReadMeName)-readme.md" `
"$DocRepoLocation/$($metadata.LegacyReadMeLocation)/" `
-Force
}

}

if ($latestMetadataPath) {
$latestMetadataPath = getPackageMetadataFileLocation `
-packageIdentity $packageIdentity `
-lookupTable $metadataLookup['latest']

if ($latestMetadataPath) {
$metadata = &$GetDocsMsMetadataForPackageFn -PackageInfo $metadataLookup['latest'][$packageIdentity]['Metadata']

Write-Host "Package $packageIdentity is deprecated but has file in latest metadata folder. Moving to legacy. (might overwrite preview version if it exists in metadata/legacy)"
Move-Item $latestMetadataPath "$DocRepoLocation/metadata/legacy/" -Force
Move-Item `
"$($metadata.LatestReadMeLocation)/$($metadata.DocsMsReadMeName)-readme.md" `
"$DocRepoLocation/metadata/legacy/$($metadata.DocsMsReadMeName)-readme.md" `
-Force
if (Test-Path "$DocRepoLocation/$($metadata.LatestReadMeLocation)/$($metadata.DocsMsReadMeName)-readme.md") {
Move-Item `
"$DocRepoLocation/$($metadata.LatestReadMeLocation)/$($metadata.DocsMsReadMeName)-readme.md" `
"$DocRepoLocation/$($metadata.LegacyReadMeLocation)/" `
-Force
}
}
}

0 comments on commit 32a328c

Please sign in to comment.