Skip to content

Commit 09f56ef

Browse files
fix: use artifact feed in local regen preview script (#11359)
1 parent 89f388c commit 09f56ef

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

packages/http-client-csharp/eng/scripts/RegenPreview.ps1

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ Import-Module "$PSScriptRoot\RegenPreview.psm1" -DisableNameChecking -Force
159159
# Resolve paths
160160
$packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..')
161161
$sdkRepoPath = Resolve-Path $SdkLibraryRepoPath -ErrorAction Stop
162+
# Azure SDK artifact feed used for all npm restores in this script.
163+
$artifactFeedRegistry = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/"
162164

163165
Write-Host "==================== LOCAL VALIDATION SCRIPT ====================" -ForegroundColor Cyan
164166

@@ -592,7 +594,7 @@ try {
592594
Push-Location $packageRoot
593595
try {
594596
Write-Host "Installing dependencies..." -ForegroundColor Gray
595-
Invoke "npm ci"
597+
Invoke "npm ci --registry $artifactFeedRegistry"
596598
if ($LASTEXITCODE -ne 0) {
597599
throw "Failed to install dependencies for unbranded generator"
598600
}
@@ -843,7 +845,7 @@ try {
843845
$tempDir = Join-Path $engFolder "temp-package-update"
844846
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
845847

846-
# Create a local .npmrc pointing at the public azure-sdk-for-js registry so that
848+
# Create a local .npmrc pointing at the Azure SDK artifact feed so that
847849
# installing the local package tarball does not require authentication.
848850
Set-Content (Join-Path $tempDir ".npmrc") "registry=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/`n" -Encoding utf8
849851

@@ -973,7 +975,7 @@ try {
973975
$sdkForNetEngFolder = Join-Path $sdkRepoPath "eng"
974976
Write-Host "Pre-installing tsp-client..." -ForegroundColor Gray
975977
$tspClientDir = Join-Path $sdkForNetEngFolder "common" "tsp-client"
976-
Invoke "npm ci --prefix $tspClientDir" $tspClientDir
978+
Invoke "npm ci --prefix $tspClientDir --registry $artifactFeedRegistry" $tspClientDir
977979
if ($LASTEXITCODE -ne 0) {
978980
throw "Failed to install tsp-client"
979981
}
@@ -990,18 +992,31 @@ try {
990992
if ($LASTEXITCODE -ne 0) {
991993
throw "Failed to build client plugin"
992994
}
995+
Write-Host " Client plugin ready" -ForegroundColor Green
996+
Write-Host ""
993997

994998
# Thread-safe collections for progress tracking
995999
$completed = [System.Collections.Concurrent.ConcurrentBag[int]]::new()
9961000
$totalCount = $libraries.Count
9971001

1002+
Write-Host "Configuring npm registry for tsp-client (temporary .env)..." -ForegroundColor Gray
1003+
$sdkEnvFile = Join-Path $sdkRepoPath ".env"
1004+
$originalSdkEnv = if (Test-Path $sdkEnvFile) { Get-Content $sdkEnvFile -Raw } else { $null }
1005+
Set-Content $sdkEnvFile "npm_config_registry=$artifactFeedRegistry`n" -Encoding utf8 -NoNewline
1006+
Write-Host " Wrote $sdkEnvFile" -ForegroundColor Green
1007+
Write-Host ""
1008+
1009+
try {
1010+
Write-Host "Dispatching $totalCount regeneration jobs ($throttleLimit at a time)..." -ForegroundColor Cyan
9981011
# Run regeneration in parallel
9991012
$results = $libraries | ForEach-Object -ThrottleLimit $throttleLimit -Parallel {
10001013
$library = $_
10011014
$azureSdkPath = $using:sdkRepoPath
10021015
$completedBag = $using:completed
10031016
$total = $using:totalCount
10041017

1018+
Write-Host " -> Starting $($library.Library) ($($library.Service))" -ForegroundColor DarkGray
1019+
10051020
# Determine build path (check for src subdirectory)
10061021
$libraryPath = Join-Path $azureSdkPath $library.Path
10071022
$srcPath = Join-Path $libraryPath "src"
@@ -1058,6 +1073,15 @@ try {
10581073
Output = if ($result.ContainsKey('Output')) { $result.Output } else { "" }
10591074
}
10601075
}
1076+
}
1077+
finally {
1078+
# Remove/restore the temporary .env used to redirect tsp-client's npm registry
1079+
if ($null -eq $originalSdkEnv) {
1080+
Remove-Item $sdkEnvFile -Force -ErrorAction SilentlyContinue
1081+
} else {
1082+
Set-Content $sdkEnvFile $originalSdkEnv -Encoding utf8 -NoNewline
1083+
}
1084+
}
10611085

10621086
# Generate final report
10631087
$scriptEndTime = Get-Date

packages/http-client-csharp/eng/scripts/RegenPreview.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ function Update-OpenAIGenerator {
580580
Write-Host "Installing dependencies..." -ForegroundColor Gray
581581
Push-Location $OpenAIRepoPath
582582
try {
583-
$npmOutput = Invoke "npm install" $OpenAIRepoPath
583+
$npmOutput = Invoke "npm install --registry https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/" $OpenAIRepoPath
584584
if ($LASTEXITCODE -ne 0) {
585585
Write-Host $npmOutput -ForegroundColor Red
586586
throw "npm install failed"

0 commit comments

Comments
 (0)