Skip to content

Commit 1c2e8c4

Browse files
Updates to Language Settings file (Azure#12589)
* Add Update-javascript-CIConfig * Add Update-javascript-CIConfig * Switch from using BuildNumber to BuildID for test versions
1 parent 279f6bf commit 1c2e8c4

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

eng/pipelines/templates/stages/archetype-js-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ stages:
3838
pwsh: true
3939
workingDirectory: $(Build.SourcesDirectory)
4040
filePath: eng/scripts/SetTestPipelineVersion.ps1
41-
arguments: '-BuildNumber $(Build.BuildNumber)'
41+
arguments: '-BuildID $(Build.BuildId)'
4242
- template: /eng/common/pipelines/templates/steps/verify-changelog.yml
4343
parameters:
4444
PackageName: ${{artifact.name}}

eng/pipelines/templates/steps/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ steps:
1212
pwsh: true
1313
workingDirectory: $(Build.SourcesDirectory)
1414
filePath: eng/scripts/SetTestPipelineVersion.ps1
15-
arguments: '-BuildNumber $(Build.BuildNumber)'
15+
arguments: '-BuildID $(Build.BuildId)'
1616

1717
- pwsh: |
1818
$folder = "${{parameters.ServiceDirectory}}"

eng/scripts/Language-Settings.ps1

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ function Publish-javascript-GithubIODocs ($DocLocation, $PublicArtifactLocation)
119119
$parsedPackage = Get-javascript-PackageInfoFromPackageFile $pkgs[0] $PublicArtifactLocation
120120
$PkgName = $parsedPackage.PackageId.Replace("@", "").Replace("/", "-")
121121
}
122-
else{
122+
else
123+
{
123124
Write-Host "Package info is not available from artifact. Assuming package is in default scope @azure."
124125
}
125126
Write-Host "Uploading Doc for $($PkgName) Version:- $($DocVersion)..."
@@ -144,3 +145,57 @@ function Get-javascript-GithubIoDocIndex()
144145
# Generate yml/md toc files and build site.
145146
GenerateDocfxTocContent -tocContent $tocContent -lang "JavaScript"
146147
}
148+
149+
# Updates a js CI configuration json.
150+
# For "latest", we simply set a target package name
151+
# For "preview", we add @next to the target package name
152+
function Update-javascript-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId = $null)
153+
{
154+
$pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo)
155+
156+
if (-not (Test-Path $pkgJsonLoc))
157+
{
158+
Write-Error "Unable to locate package json at location $pkgJsonLoc, exiting."
159+
exit(1)
160+
}
161+
162+
$allJson = Get-Content $pkgJsonLoc | ConvertFrom-Json
163+
164+
$visibleInCI = @{}
165+
166+
for ($i = 0; $i -lt $allJson.npm_package_sources.Length; $i++)
167+
{
168+
$pkgDef = $allJson.npm_package_sources[$i]
169+
$accessor = ($pkgDef.name).Replace("`@next", "")
170+
$visibleInCI[$accessor] = $i
171+
}
172+
173+
foreach ($releasingPkg in $pkgs)
174+
{
175+
$name = $releasingPkg.PackageId
176+
177+
if ($releasingPkg.IsPrerelease)
178+
{
179+
$name += "`@next"
180+
}
181+
182+
if ($visibleInCI.ContainsKey($releasingPkg.PackageId))
183+
{
184+
$packagesIndex = $visibleInCI[$releasingPkg.PackageId]
185+
$existingPackageDef = $allJson.npm_package_sources[$packagesIndex]
186+
$existingPackageDef.name = $name
187+
}
188+
else
189+
{
190+
$newItem = New-Object PSObject -Property @{
191+
name = $name
192+
}
193+
194+
if ($newItem) { $allJson.npm_package_sources += $newItem }
195+
}
196+
}
197+
198+
$jsonContent = $allJson | ConvertTo-Json -Depth 10 | ForEach-Object { $_ -replace "(?m) (?<=^(?: )*)", " " }
199+
200+
Set-Content -Path $pkgJsonLoc -Value $jsonContent
201+
}

eng/scripts/SetTestPipelineVersion.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
param (
55
[Parameter(mandatory = $true)]
6-
$BuildNumber
6+
$BuildID
77
)
88

99
. "${PSScriptRoot}\..\common\scripts\common.ps1"
@@ -24,7 +24,7 @@ LogDebug "Last Published Version $($semVarsSorted[0])"
2424

2525
$newVersion = [AzureEngSemanticVersion]::ParseVersionString($semVarsSorted[0])
2626
$newVersion.PrereleaseLabel = "beta"
27-
$newVersion.PrereleaseNumber = $BuildNumber
27+
$newVersion.PrereleaseNumber = $BuildID
2828

2929
$packageFileContent = Get-Content -Path $templatePackageFile | ConvertFrom-Json
3030
LogDebug "Version in Source $($packageFileContent.version)"

0 commit comments

Comments
 (0)