Skip to content
Merged
Show file tree
Hide file tree
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
Comment thread
timotheeguerin marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
parameters:
- name: npmrcPath
type: string
# When empty, defaults to the agent user's .npmrc ($HOME/.npmrc on
# Linux/macOS, %USERPROFILE%\.npmrc on Windows) so every subsequent
# npm / pnpm / npx call in the job inherits the registry + auth.
default: ""
- name: registryUrl
type: string
default: "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/"
- name: CustomCondition
type: string
default: succeeded()
- name: ServiceConnection
type: string
default: ""

steps:
- pwsh: |
$npmrcPath = '${{ parameters.npmrcPath }}'
if (-not $npmrcPath) { $npmrcPath = Join-Path $HOME '.npmrc' }

Write-Host "Creating .npmrc file $npmrcPath for registry ${{ parameters.registryUrl }}"
$parentFolder = Split-Path -Path $npmrcPath -Parent

if ($parentFolder -and -not (Test-Path $parentFolder)) {
Write-Host "Creating folder $parentFolder"
New-Item -Path $parentFolder -ItemType Directory | Out-Null
}

"registry=${{ parameters.registryUrl }}" | Out-File $npmrcPath
Write-Host "##vso[task.setvariable variable=resolvedNpmrcPath]$npmrcPath"
displayName: "Create .npmrc"
condition: ${{ parameters.CustomCondition }}

- task: npmAuthenticate@0
displayName: Authenticate .npmrc
condition: ${{ parameters.CustomCondition }}
inputs:
workingFile: $(resolvedNpmrcPath)
azureDevOpsServiceConnection: ${{ parameters.ServiceConnection }}
8 changes: 7 additions & 1 deletion eng/pipelines/templates/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ steps:
displayName: Install Node.js
retryCountOnTaskFailure: 3

- template: /eng/common/pipelines/templates/steps/create-authenticated-npmrc.yml

- task: Cache@2
inputs:
key: 'pnpm | "$(Agent.OS)" | pnpm-lock.yaml'
path: ${{ parameters.pnpmStorePath }}
displayName: Cache pnpm store
- script: npm install -g pnpm # Pnpm manage-package-manager-versions will respect packageManager field

- pwsh: |
$packageJson = Get-Content -Raw "$(Build.SourcesDirectory)/package.json" | ConvertFrom-Json
npm install -g $packageJson.packageManager # Pnpm manage-package-manager-versions will respect packageManager field
displayName: Install pnpm

- script: pnpm config set store-dir ${{ parameters.pnpmStorePath }}
displayName: Setup pnpm cache dir

Expand Down
Loading