diff --git a/eng/pipelines/apiview-review-gen-javascript.yml b/eng/pipelines/apiview-review-gen-javascript.yml new file mode 100644 index 000000000..88d2e8fd9 --- /dev/null +++ b/eng/pipelines/apiview-review-gen-javascript.yml @@ -0,0 +1,55 @@ +pr: none + +trigger: none + +pool: + name: azsdk-pool-mms-ubuntu-2004-general + vmImage: MMSUbuntu20.04 + +parameters: + - name: Reviews + type: string + default: '[{"ReviewID":"","RevisionID":"","FileID":"","FileName":""}]' + - name: APIViewURL + type: string + default: 'https://apiview.dev' + - name: StorageContainerUrl + type: string + default: '' +variables: + TypeScriptGeneratorDirectory: 'src/ts/ts-genapi' + NodeVersion: '16.x' + +jobs: +- job: CreateJSReviewCodeFile + displayName: 'Create JavaScript API review token file' + + variables: + - template: /eng/pipelines/templates/variables/globals.yml + + steps: + - task: NodeTool@0 + inputs: + versionSpec: $(NodeVersion) + displayName: "Use Node $(NodeVersion)" + + - script: | + npm install -g npm@8.16.0 + displayName: "Install npm 8.16.0" + + - script: | + npm install + workingDirectory: $(TypeScriptGeneratorDirectory) + displayName: "Install npm packages typescript generator" + + - script: | + npm run-script build + workingDirectory: $(TypeScriptGeneratorDirectory) + displayName: "Build typescript generator" + + - template: /eng/pipelines/templates/steps/apiview-review-gen.yml + parameters: + Reviews: ${{ parameters.Reviews }} + APIViewURL: ${{ parameters.APIViewURL }} + StorageContainerUrl: ${{ parameters.StorageContainerUrl }} + ApiviewGenScript: './Create-Apiview-Token-Javascript.ps1' \ No newline at end of file diff --git a/eng/scripts/Create-Apiview-Token-Javascript.ps1 b/eng/scripts/Create-Apiview-Token-Javascript.ps1 new file mode 100644 index 000000000..312a0ab1e --- /dev/null +++ b/eng/scripts/Create-Apiview-Token-Javascript.ps1 @@ -0,0 +1,17 @@ +[CmdletBinding()] +param ( + [Parameter(Mandatory = $true)] + [string]$SourcePath, + [Parameter(Mandatory = $true)] + [string]$OutPath +) + +Write-Host "Generating API review token file: $($SourcePath)" +$installedPath = npm ls @azure-tools/ts-genapi -p +$parserPath = Join-Path -Path $installedPath "export.js" + +$FileName = Split-Path -Leaf $SourcePath +$OutFileName = $FileName -replace ".api.json", "_js.json" +$OutFilePath = Join-Path -Path $OutPath $OutFileName +Write-Host "Converting api-extractor file $($SourcePath) to APIview code file $($OutFilePath)" +node $parserPath $SourcePath $OutFilePath \ No newline at end of file