mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
This pull request makes a targeted update to the release pipeline for
JavaScript packages. The main change is to the dependency configuration
for the documentation publishing stage, ensuring it now depends on the
correct package publishing step.
**Pipeline dependency update:**
* In `archetype-js-release.yml`, the `dependsOn` property for the
documentation publishing stage was updated to depend on
`PublishPackage_${{ replace(artifact.name, '-', '_') }}_To_DevFeed`
instead of the previous `PublishPackage_${{ replace(artifact.name, '-',
'_') }}`. This ensures that documentation is published only after the
package has been published to the development feed.
165 lines
5.0 KiB
PowerShell
165 lines
5.0 KiB
PowerShell
. "$PSScriptRoot/Docs-ToC.ps1"
|
|
|
|
# $SetDocsPackageOnboarding = "Set-${Language}-DocsPackageOnboarding"
|
|
function Set-javascript-DocsPackageOnboarding($moniker, $metadata, $docRepoLocation, $packageSourceOverride) {
|
|
$onboardingFile = GetOnboardingFile `
|
|
-docRepoLocation $docRepoLocation `
|
|
-moniker $moniker
|
|
|
|
$onboardingSpec = Get-Content $onboardingFile -Raw | ConvertFrom-Json -AsHashtable
|
|
|
|
$packagesToOnboard = @()
|
|
foreach ($package in $metadata) {
|
|
$packageSpec = [ordered]@{
|
|
name = Get-DocsMsPackageName `
|
|
-packageName $package.Name `
|
|
-packageVersion $package.Version
|
|
}
|
|
|
|
# $packageSourceOverride is irrelevant here as preview packages are
|
|
# published up to NPM directly as alpha versions. The version from the
|
|
# package metadata is sufficient.
|
|
|
|
# Merge properties from from overrides, duplicate keys will be overwritten
|
|
if ($package.ContainsKey('DocsCiConfigProperties')) {
|
|
$overrides = $package['DocsCiConfigProperties']
|
|
foreach ($key in $overrides.Keys) {
|
|
$packageSpec[$key] = $overrides[$key]
|
|
}
|
|
}
|
|
|
|
$packagesToOnboard += $packageSpec
|
|
}
|
|
|
|
$onboardingSpec['npm_package_sources'] = $packagesToOnboard
|
|
|
|
Set-Content `
|
|
-Path $onboardingFile `
|
|
-Value ($onboardingSpec | ConvertTo-Json -Depth 100)
|
|
}
|
|
|
|
function GetPackageInfoFromDocsMsConfig($packageName) {
|
|
if (!$packageName) {
|
|
throw "Package name must not be empty"
|
|
}
|
|
|
|
$name = $packageName
|
|
$version = ''
|
|
if ($packageName.IndexOf('@', 1) -ne -1) {
|
|
$secondAtIndex = $packageName.IndexOf('@', 1)
|
|
|
|
# "@azure/[email protected]" -> "@azure/package"
|
|
$name = $packageName.Substring(0, $secondAtIndex)
|
|
|
|
# "@azure/[email protected]" -> "1.2.3"
|
|
$version = $packageName.Substring($secondAtIndex + 1)
|
|
}
|
|
|
|
return @{
|
|
Name = $name
|
|
Version = $version
|
|
}
|
|
}
|
|
|
|
# $GetDocsPackagesAlreadyOnboarded = "Get-${Language}-DocsPackagesAlreadyOnboarded"
|
|
function Get-javascript-DocsPackagesAlreadyOnboarded($docRepoLocation, $moniker) {
|
|
$packageOnboardingFile = GetOnboardingFile `
|
|
-docRepoLocation $DocRepoLocation `
|
|
-moniker $moniker
|
|
|
|
$onboardedPackages = @{}
|
|
$onboardingSpec = ConvertFrom-Json (Get-Content $packageOnboardingFile -Raw)
|
|
foreach ($spec in $onboardingSpec.npm_package_sources) {
|
|
$packageInfo = GetPackageInfoFromDocsMsConfig $spec.name
|
|
$onboardedPackages[$packageInfo.Name] = $packageInfo
|
|
}
|
|
|
|
return $onboardedPackages
|
|
}
|
|
|
|
# "@azure/[email protected]" -> "@azure/package-name"
|
|
function Get-PackageNameFromDocsMsConfig($DocsConfigName) {
|
|
if ($DocsConfigName -match '^(?<pkgName>.+?)(?<pkgVersion>@.+)?$') {
|
|
return $Matches['pkgName']
|
|
}
|
|
LogWarning "Could not find package name in ($DocsConfigName)"
|
|
return ''
|
|
}
|
|
|
|
# Given the name of a package (possibly of the form "@azure/[email protected]")
|
|
# return a package name with the version specified in $packageVersion
|
|
# "@azure/[email protected]" "1.3.0" -> "@azure/[email protected]"
|
|
function Get-DocsMsPackageName($packageName, $packageVersion) {
|
|
return "$(Get-PackageNameFromDocsMsConfig $packageName)@$packageVersion"
|
|
}
|
|
|
|
# Defined in common.ps1 as:
|
|
# $ValidateDocsMsPackagesFn = "Validate-${Language}-DocMsPackages"
|
|
function Validate-javascript-DocMsPackages (
|
|
$PackageInfo,
|
|
$PackageInfos,
|
|
$DocRepoLocation,
|
|
$DocValidationImageId,
|
|
$PackageSourceOverride
|
|
) {
|
|
if (!$PackageInfos) {
|
|
$PackageInfos = @($PackageInfo)
|
|
}
|
|
|
|
$resolvedRegistry = if (![string]::IsNullOrWhiteSpace($PackageSourceOverride)) {
|
|
$PackageSourceOverride
|
|
}
|
|
else {
|
|
"https://registry.npmjs.org/"
|
|
}
|
|
|
|
$previousRegistry = $env:npm_config_registry
|
|
$previousUserConfig = $env:npm_config_userconfig
|
|
$env:npm_config_registry = $resolvedRegistry
|
|
|
|
try {
|
|
$allSucceeded = $true
|
|
$failedPackages = @()
|
|
|
|
foreach ($packageInfo in $PackageInfos) {
|
|
$outputLocation = New-Item `
|
|
-ItemType Directory `
|
|
-Path (Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()))
|
|
|
|
Write-Host "type2docfx `"$($packageInfo.Name)@$($packageInfo.Version)`" $outputLocation"
|
|
$output = & type2docfx "$($packageInfo.Name)@$($packageInfo.Version)" $outputLocation 2>&1 | Tee-Object -Variable output | Out-Host
|
|
if ($LASTEXITCODE) {
|
|
$allSucceeded = $false
|
|
$failedPackages += $packageInfo.Name
|
|
Write-Host "Package $($packageInfo.Name)@$($packageInfo.Version) failed validation"
|
|
$output | Write-Host
|
|
}
|
|
}
|
|
|
|
# Show failed packages at the end of the run
|
|
if ($failedPackages.Count -gt 0) {
|
|
Write-Host "Failed package: $($failedPackages.Count)"
|
|
foreach ($failedPackage in $failedPackages) {
|
|
Write-Host "Failed package: $failedPackage"
|
|
}
|
|
}
|
|
|
|
return $allSucceeded
|
|
}
|
|
finally {
|
|
if ($null -eq $previousRegistry) {
|
|
Remove-Item Env:npm_config_registry -ErrorAction SilentlyContinue
|
|
}
|
|
else {
|
|
$env:npm_config_registry = $previousRegistry
|
|
}
|
|
|
|
if ($null -eq $previousUserConfig) {
|
|
Remove-Item Env:npm_config_userconfig -ErrorAction SilentlyContinue
|
|
}
|
|
else {
|
|
$env:npm_config_userconfig = $previousUserConfig
|
|
}
|
|
}
|
|
}
|