From a4c8ade15889f0d2d1258239e4ef633c84012de8 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 21 Mar 2025 09:27:52 -0700 Subject: [PATCH] Package Properties processing updates (#6477) Co-authored-by: James Suplizio --- eng/common/scripts/Package-Properties.ps1 | 26 ++++++++++++++----- .../scripts/Save-Package-Properties.ps1 | 11 +++++--- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/eng/common/scripts/Package-Properties.ps1 b/eng/common/scripts/Package-Properties.ps1 index 7b9bd0b5f..88d96daa5 100644 --- a/eng/common/scripts/Package-Properties.ps1 +++ b/eng/common/scripts/Package-Properties.ps1 @@ -26,8 +26,8 @@ class PackageProps { $this.Initialize($name, $version, $directoryPath, $serviceDirectory) } - PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "") { - $this.Initialize($name, $version, $directoryPath, $serviceDirectory, $group) + PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "", [string]$artifactName = "") { + $this.Initialize($name, $version, $directoryPath, $serviceDirectory, $group, $artifactName) } hidden [void]Initialize( @@ -70,20 +70,32 @@ class PackageProps { [string]$version, [string]$directoryPath, [string]$serviceDirectory, - [string]$group + [string]$group, + [string]$artifactName ) { - $this.Initialize($name, $version, $directoryPath, $serviceDirectory) $this.Group = $group + $this.ArtifactName = $artifactName + $this.Initialize($name, $version, $directoryPath, $serviceDirectory) } - hidden [PSCustomObject]ParseYmlForArtifact([string]$ymlPath) { $content = LoadFrom-Yaml $ymlPath if ($content) { $artifacts = GetValueSafelyFrom-Yaml $content @("extends", "parameters", "Artifacts") $artifactForCurrentPackage = $null - if ($artifacts) { - $artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName -or $_["name"] -eq $this.Name } + # If there's an artifactName match that to the name field from the yml + if ($this.ArtifactName) { + # Additionally, if there's a group, then the group and artifactName need to match the groupId and name in the yml + if ($this.Group) { + $artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName -and $_["groupId"] -eq $this.Group} + } else { + # just matching the artifactName + $artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName } + } + } else { + # This is the default, match the Name to the name field from the yml + $artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.Name } + } } # if we found an artifact for the current package, we should count this ci file as the source of the matrix for this package diff --git a/eng/common/scripts/Save-Package-Properties.ps1 b/eng/common/scripts/Save-Package-Properties.ps1 index 0257e73a1..0db23f276 100644 --- a/eng/common/scripts/Save-Package-Properties.ps1 +++ b/eng/common/scripts/Save-Package-Properties.ps1 @@ -141,12 +141,17 @@ foreach ($pkg in $allPackageProperties) Write-Host "Package Version: $($pkg.Version)" Write-Host "Package SDK Type: $($pkg.SdkType)" Write-Host "Artifact Name: $($pkg.ArtifactName)" + if (-not [System.String]::IsNullOrEmpty($pkg.Group)) { + Write-Host "GroupId: $($pkg.Group)" + } Write-Host "Release date: $($pkg.ReleaseStatus)" $configFilePrefix = $pkg.Name - if ($pkg.ArtifactName) - { - $configFilePrefix = $pkg.ArtifactName + # Any languages (like JS) which need to override the the packageInfo file name to be something + # other than the name just need to declare this function in their Language-Settings.ps1 return + # the desired string from there. + if (Test-Path "Function:Get-PackageInfoNameOverride") { + $configFilePrefix = Get-PackageInfoNameOverride $pkg } $outputPath = Join-Path -Path $outDirectory "$configFilePrefix.json"