From e19518ea0aac72eeb8cf74d17eeaab16f3e10e73 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 9 Oct 2025 17:17:55 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 12396 (#6770) * Secure tsp-client usage by using pinned version from package-lock.json Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> * Use absolute path and remove try/finally blocks Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> * Keep original workingDirectory and use Push-Location for directory switching Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> * Resolve EmitterPackageJsonOutputPath to absolute path if relative Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> * Use workingDirectory instead of Push-Location/Pop-Location Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com> * Merge path resolution into tsp-client execution step Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: raych1 <20296335+raych1@users.noreply.github.com> Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com> --- .../templates/archetype-typespec-emitter.yml | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/eng/common/pipelines/templates/archetype-typespec-emitter.yml b/eng/common/pipelines/templates/archetype-typespec-emitter.yml index c359c3b1a..65f1bda9e 100644 --- a/eng/common/pipelines/templates/archetype-typespec-emitter.yml +++ b/eng/common/pipelines/templates/archetype-typespec-emitter.yml @@ -259,27 +259,34 @@ extends: displayName: Download pipeline artifacts - pwsh: | - npm install -g @azure-tools/typespec-client-generator-cli@latest + npm ci displayName: Install tsp-client + workingDirectory: $(Build.SourcesDirectory)/eng/common/tsp-client - pwsh: | + # Resolve EmitterPackageJsonOutputPath to absolute path if it's relative + $emitterPath = '${{ parameters.EmitterPackageJsonOutputPath }}' + if (-not [System.IO.Path]::IsPathRooted($emitterPath)) { + $emitterPath = Join-Path '$(Build.SourcesDirectory)' $emitterPath + } + Write-Host "Overrides location: $(buildArtifactsPath)/packages/overrides.json" + Write-Host "Resolved emitter package path: $emitterPath" if (Test-Path -Path '$(buildArtifactsPath)/packages/overrides.json') { Write-Host "Using overrides.json to generate emitter-package.json" - tsp-client generate-config-files ` - --package-json '$(buildArtifactsPath)/lock-files/package.json' ` - --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' ` - --overrides '$(buildArtifactsPath)/packages/overrides.json' + npm exec --no -- tsp-client generate-config-files ` + --package-json '$(buildArtifactsPath)/lock-files/package.json' ` + --emitter-package-json-path "$emitterPath" ` + --overrides '$(buildArtifactsPath)/packages/overrides.json' } else { Write-Host "No overrides.json found. Running tsp-client without overrides." - - tsp-client generate-config-files ` - --package-json '$(buildArtifactsPath)/lock-files/package.json' ` - --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' + npm exec --no -- tsp-client generate-config-files ` + --package-json '$(buildArtifactsPath)/lock-files/package.json' ` + --emitter-package-json-path "$emitterPath" } displayName: Generate emitter-package.json and emitter-package-lock files - workingDirectory: $(Build.SourcesDirectory) + workingDirectory: $(Build.SourcesDirectory)/eng/common/tsp-client - ${{ parameters.InitializationSteps }}