@@ -67,6 +67,15 @@ parameters:
6767 type : object
6868 default : []
6969
70+ # The path to the emitter package json file.
71+ - name : EmitterPackageJsonOutputPath
72+ type : string
73+ default : " eng/emitter-package.json"
74+
75+ # The relative path to the emitter package.
76+ - name : EmitterPackagePath
77+ type : string
78+
7079extends :
7180 template : /eng/pipelines/templates/stages/1es-redirect.yml
7281 parameters :
@@ -94,7 +103,17 @@ extends:
94103 inputs :
95104 pwsh : true
96105 filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Initialize-WorkingDirectory.ps1
97- arguments : -UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
106+ ${{ if parameters.BuildPrereleaseVersion }} :
107+ arguments : >
108+ -PrereleaseSuffix "-alpha.$(Build.BuildNumber)"
109+ -OutputDirectory "$(Build.ArtifactStagingDirectory)"
110+ -UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
111+ -EmitterPackagePath:${{ parameters.EmitterPackagePath }}
112+ ${{ else }} :
113+ arguments : >
114+ -OutputDirectory "$(Build.ArtifactStagingDirectory)"
115+ -UseTypeSpecNext:$${{ parameters.UseTypeSpecNext }}
116+ -EmitterPackagePath:${{ parameters.EmitterPackagePath }}
98117
99118 - task : PowerShell@2
100119 displayName : ' Run build script'
@@ -103,10 +122,9 @@ extends:
103122 pwsh : true
104123 filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Build-Emitter.ps1
105124 arguments : >
106- -BuildNumber "$(Build.BuildNumber)"
107- -OutputDirectory "$(Build.ArtifactStagingDirectory)"
125+ -OutputDirectory "$(Build.ArtifactStagingDirectory)/packages"
108126 -TargetNpmJsFeed:$${{ parameters.PublishPublic }}
109- -Prerelease:$$ {{ parameters.BuildPrereleaseVersion }}
127+ -EmitterPackagePath:$ {{ parameters.EmitterPackagePath }}
110128
111129 - pwsh : |
112130 $sourceBranch = '$(Build.SourceBranch)'
@@ -134,7 +152,7 @@ extends:
134152 # Publish stage
135153 # Responsible for publishing the packages in `build_artifacts/packages` and producing `emitter-package-lock.json`
136154 # Produces the artifact `publish_artifacts` which contains the following:
137- # emitter-package.json: Created using the package json from the build step.
155+ # emitter-package.json: Created using the package json from the build step.
138156 # emitter-package-lock.json: Created by calling `npm install` using `emitter-package.json`
139157 - ${{ if parameters.ShouldPublish }} :
140158 - stage : Publish
@@ -189,26 +207,30 @@ extends:
189207 ServiceEndpointUrl : https://api.esrp.microsoft.com
190208 MainPublisher : ESRPRELPACMANTEST
191209
192- - task : PowerShell@2
193- displayName : Create emitter-package.json
194- inputs :
195- pwsh : true
196- filePath : ./eng/common/scripts/typespec/New-EmitterPackageJson.ps1
197- arguments : >
198- -PackageJsonPath '$(buildArtifactsPath)/lock-files/package.json'
199- -OverridesPath '$(buildArtifactsPath)/overrides.json'
200- -OutputDirectory '$(Build.ArtifactStagingDirectory)'
201- workingDirectory : $(Build.SourcesDirectory)
210+ - pwsh : |
211+ npm install -g @azure-tools/typespec-client-generator-cli@latest
212+ displayName: Install tsp-client
202213
203- - task : PowerShell@2
204- displayName : Create emitter-package-lock.json
205- inputs :
206- pwsh : true
207- filePath : ./eng/common/scripts/typespec/New-EmitterPackageLock.ps1
208- arguments : >
209- -EmitterPackageJsonPath '$(Build.ArtifactStagingDirectory)/emitter-package.json'
210- -OutputDirectory '$(Build.ArtifactStagingDirectory)'
211- workingDirectory : $(Build.SourcesDirectory)
214+ - pwsh : |
215+ Write-Host "Overrides location: $(buildArtifactsPath)/packages/overrides.json"
216+
217+ if (Test-Path -Path '$(buildArtifactsPath)/packages/overrides.json') {
218+ Write-Host "Using overrides.json to generate emitter-package.json"
219+ tsp-client generate-config-files `
220+ --package-json '$(buildArtifactsPath)/lock-files/package.json' `
221+ --output-dir '$(Build.SourcesDirectory)' `
222+ --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' `
223+ --overrides '$(buildArtifactsPath)/packages/overrides.json'
224+ } else {
225+ Write-Host "No overrides.json found. Running tsp-client without overrides."
226+
227+ tsp-client generate-config-files `
228+ --package-json '$(buildArtifactsPath)/lock-files/package.json' `
229+ --output-dir '$(Build.SourcesDirectory)' `
230+ --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}'
231+ }
232+ displayName: Generate emitter-package.json and emitter-package-lock files
233+ workingDirectory: $(Build.SourcesDirectory)
212234
213235 - template : /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
214236 parameters :
@@ -240,11 +262,8 @@ extends:
240262 displayName : Download pipeline artifacts
241263
242264 - pwsh : |
243- Write-Host "Copying emitter-package.json to $(Build.SourcesDirectory)/eng"
244- Copy-Item $(publishArtifactsPath)/emitter-package.json $(Build.SourcesDirectory)/eng/ -Force
245-
246- Write-Host "Copying emitter-package-lock.json to $(Build.SourcesDirectory)/eng"
247- Copy-Item $(publishArtifactsPath)/emitter-package-lock.json $(Build.SourcesDirectory)/eng/ -Force
265+ Write-Host "Copying *emitter-package*.json to $(Build.SourcesDirectory)/eng"
266+ Copy-Item $(publishArtifactsPath)/*emitter-package*.json $(Build.SourcesDirectory)/eng/ -Force
248267 displayName: Copy emitter-package json files
249268
250269 - ${{ parameters.InitializationSteps }}
@@ -291,7 +310,7 @@ extends:
291310 Paths :
292311 - " /*"
293312 - " !SessionRecords"
294-
313+
295314 - download : current
296315 displayName : Download pipeline artifacts
297316
@@ -432,7 +451,9 @@ extends:
432451 inputs :
433452 pwsh : true
434453 filePath : $(Build.SourcesDirectory)/eng/scripts/typespec/Initialize-WorkingDirectory.ps1
435- arguments : -BuildArtifactsPath '$(buildArtifactsPath)'
454+ arguments : >
455+ -BuildArtifactsPath '$(buildArtifactsPath)/lock-files'
456+ -EmitterPackagePath: ${{ parameters.EmitterPackagePath }}
436457
437458 - task : PowerShell@2
438459 displayName : ' Run test script'
@@ -442,6 +463,7 @@ extends:
442463 arguments : >
443464 $(TestArguments)
444465 -OutputDirectory "$(Build.ArtifactStagingDirectory)"
466+ -EmitterPackagePath: ${{ parameters.EmitterPackagePath }}
445467
446468 - template : /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
447469 parameters :
0 commit comments