Skip to content
Open
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
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
# --------------------------------
# cspell:ignore tdnf
FROM mcr.microsoft.com/devcontainers/javascript-node:24 AS builder

# Optional: Override npm registry for CFS compliance.
# pnpm 11+ requires PNPM_CONFIG_REGISTRY (ignores NPM_CONFIG_REGISTRY).
ARG NPM_REGISTRY=https://registry.npmjs.org/
ENV PNPM_CONFIG_REGISTRY=${NPM_REGISTRY}
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}

Comment on lines +7 to +12
COPY . /app

# Upgrade all packages per https://eng.ms/docs/more/containers-secure-supply-chain/updating.
Expand All @@ -24,6 +31,10 @@ RUN pnpm pack
# --------------------------------
FROM mcr.microsoft.com/azurelinux/base/nodejs:24

# Inherit registry setting for final stage
ARG NPM_REGISTRY=https://registry.npmjs.org/
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}

COPY --from=builder /app/packages/compiler/*.tgz /tmp/compiler.tgz

RUN npm install -g /tmp/compiler.tgz && rm /tmp/compiler.tgz
Expand Down
3 changes: 3 additions & 0 deletions eng/tsp-core/pipelines/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ extends:
displayName: Build and publish
variables:
imageName: "azsdkengsys.azurecr.io/typespec"
# Default to Azure SDK public feed; override with pipeline variable for CFS compliance
npmRegistry: $[coalesce(variables['NPM_REGISTRY'], 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/')]
pool:
name: $(LINUXPOOL)
image: $(LINUXVMIMAGE)
Expand All @@ -100,6 +102,7 @@ extends:

- script: |
docker build -f ./docker/Dockerfile \
--build-arg NPM_REGISTRY="$(npmRegistry)" \
-t $(imageName):latest \
.
displayName: "Build"
Expand Down
8 changes: 6 additions & 2 deletions packages/http-client-csharp/eng/pipeline/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ extends:
# to avoid running out of disk space on the root partition during generation
TMPDIR: $(Agent.TempDirectory)
NUGET_PACKAGES: $(Agent.TempDirectory)/nuget
# Set cache for both npm and pnpm (pnpm 11+ ignores npm_config_* prefix)
npm_config_cache: $(Agent.TempDirectory)/npm-cache
pnpm_config_store_dir: $(Agent.TempDirectory)/pnpm-store
steps:
- checkout: self

Expand Down Expand Up @@ -198,10 +200,12 @@ extends:
-PackageJsonPath '$(Build.SourcesDirectory)/packages/http-client-csharp/package.json'

- pwsh: |
# Set force for both npm and pnpm (pnpm 11+ ignores npm_config_* prefix)
Write-Host "##vso[task.setvariable variable=npm_config_force]true"
Write-Host "##vso[task.setvariable variable=pnpm_config_force]true"
Write-Host "##vso[task.setvariable variable=TSPCLIENT_FORCE_INSTALL]true"
Write-Host "Set npm --force and TSPCLIENT_FORCE_INSTALL for TypeSpec Next"
displayName: Configure npm for TypeSpec Next
Write-Host "Set npm/pnpm --force and TSPCLIENT_FORCE_INSTALL for TypeSpec Next"
displayName: Configure npm/pnpm for TypeSpec Next
condition: ${{ parameters.UseTypeSpecNext }}

- task: UseDotNet@2
Expand Down
3 changes: 2 additions & 1 deletion packages/http-client-csharp/eng/scripts/RegenPreview.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,8 @@ try {
Write-Host "Configuring npm registry for tsp-client (temporary .env)..." -ForegroundColor Gray
$sdkEnvFile = Join-Path $sdkRepoPath ".env"
$originalSdkEnv = if (Test-Path $sdkEnvFile) { Get-Content $sdkEnvFile -Raw } else { $null }
Set-Content $sdkEnvFile "npm_config_registry=$artifactFeedRegistry`n" -Encoding utf8 -NoNewline
# Set both npm and pnpm registry env vars (pnpm 11+ ignores npm_config_* prefix)
Set-Content $sdkEnvFile "npm_config_registry=$artifactFeedRegistry`npnpm_config_registry=$artifactFeedRegistry`n" -Encoding utf8 -NoNewline

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use pnpm when running this script. It's primarily used locally. Do we need this change here? If so, do we need to add some delimiter between the 2 registry values ?

Write-Host " Wrote $sdkEnvFile" -ForegroundColor Green
Write-Host ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,20 @@ try {
$configFilesOutputDir = Join-Path $tempDir "eng"
$emitterPackageJsonPath = Join-Path $configFilesOutputDir "http-client-csharp-emitter-package.json"

# Set NPM_CONFIG_USERCONFIG to point to our .npmrc so tsp-client's internal npm install
# can resolve packages from Azure Artifacts. tsp-client creates a temp directory for
# npm install, so a project-level .npmrc in the eng directory won't be found.
# Set NPM_CONFIG_USERCONFIG and PNPM_CONFIG_USERCONFIG to point to our .npmrc so
# tsp-client's internal npm/pnpm install can resolve packages from Azure Artifacts.
# tsp-client creates a temp directory for install, so a project-level .npmrc won't be found.
# Note: pnpm 11+ ignores npm_config_* prefix, so we set both.
$sourceNpmrcPath = Join-Path $PSScriptRoot "../../.npmrc"
$previousNpmConfigUserconfig = $env:NPM_CONFIG_USERCONFIG

$previousPnpmConfigUserconfig = $env:PNPM_CONFIG_USERCONFIG

if (Test-Path $sourceNpmrcPath) {
$resolvedNpmrcPath = (Resolve-Path $sourceNpmrcPath).Path
Write-Host "Setting NPM_CONFIG_USERCONFIG to use .npmrc for tsp-client package resolution..."
Write-Host "Setting NPM_CONFIG_USERCONFIG and PNPM_CONFIG_USERCONFIG to use .npmrc for tsp-client package resolution..."
Write-Host " Source .npmrc: $resolvedNpmrcPath"
$env:NPM_CONFIG_USERCONFIG = $resolvedNpmrcPath
$env:PNPM_CONFIG_USERCONFIG = $resolvedNpmrcPath

Write-Host "npm registry for tsp-client:"
npm config get registry
Expand Down Expand Up @@ -445,8 +448,9 @@ try {
}
Write-Host "Successfully generated emitter-package.json files"
} finally {
# Restore previous NPM_CONFIG_USERCONFIG
# Restore previous NPM_CONFIG_USERCONFIG and PNPM_CONFIG_USERCONFIG
$env:NPM_CONFIG_USERCONFIG = $previousNpmConfigUserconfig
$env:PNPM_CONFIG_USERCONFIG = $previousPnpmConfigUserconfig
}
} else {
Write-Warning "TypeSpecSourcePackageJsonPath not provided or file doesn't exist. Skipping emitter-package.json generation."
Expand Down
Loading