Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion tools/Utilities/PrePopulateAutorestCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ $extensions = @(
"@autorest/modelerfour@4.24.3"
)

# Force these installs onto the authenticated private feed. `npm install --prefix <dir>` does not
# reliably pick up the registry/auth from ~/.npmrc (it was observed hitting registry.npmjs.org
# directly, breaking CFSClean network isolation), so pass --userconfig and --registry explicitly,
# derived from the authenticated ~/.npmrc that install-tools.yml produced.
$npmFeedArgs = @()
$userNpmrc = Join-Path $env:USERPROFILE ".npmrc"
if (Test-Path $userNpmrc) {
$npmFeedArgs += @('--userconfig', $userNpmrc)
$regLine = Select-String -Path $userNpmrc -Pattern '^registry=' | Select-Object -First 1
if ($regLine) { $npmFeedArgs += @('--registry', ($regLine.Line -replace '^registry=', '').Trim()) }
}
else {
Write-Host "WARNING: ~/.npmrc not found; npm install may reach the public registry (CFSClean risk)."
}

foreach ($ext in $extensions) {
$parts = $ext -split '@(?=[^@]+$)' # split on last @
$pkg = $parts[0]
Expand All @@ -36,7 +51,8 @@ foreach ($ext in $extensions) {

New-Item -ItemType Directory -Force -Path $cacheDir | Out-Null
Write-Host "Pre-installing $ext into $cacheDir"
npm install $ext --prefix $cacheDir
npm install $ext --prefix $cacheDir @npmFeedArgs
if ($LASTEXITCODE -ne 0) { throw "Failed to pre-install $ext (exit $LASTEXITCODE)" }
Write-Host "Done: $ext"
}

Loading