microsoft/typespec

Public

mirrored fromhttps://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
efeedc42a9fb908c64751d97fea2ae3d7dfeb4ee

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

eng/emitters/scripts/Generate-APIView-CodeFile.ps1

42lines · modecode

1param (
2 [Parameter(mandatory = $true)]
3 $ArtifactPath,
4 $NpmDevopsFeedRegistry = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js@Local/npm/registry/"
5)
6
7Set-StrictMode -Version 3
8if (!(Test-Path -Path $ArtifactPath))
9{
10 Write-Error "Incorrect path to api-extractor artifacts. Path: $($ArtifactPath)"
11 exit 1
12}
13
14$apiviewParser = "@azure-tools/ts-genapi@2.0.11"
15Write-Host "Installing $($apiviewParser)"
16npm install $apiviewParser --registry $NpmDevopsFeedRegistry
17$installedPath = npm ls @azure-tools/ts-genapi -p
18if (!(Test-Path -Path $installedPath))
19{
20 Write-Host "@Azure-tools/ts-genapi is not installed to $($installedPath)"
21 exit 1
22}
23
24Write-Host "Setting working directory to $($installedPath)"
25Push-Location $installedPath
26try {
27 $apiFiles = @(Get-ChildItem -Path $ArtifactPath -Recurse -Filter "*.api.json")
28 foreach ($apiPkgFile in $apiFiles)
29 {
30 $apiFilePath = $apiPkgFile.FullName
31 $FileName = Split-Path -Leaf $apiFilePath
32 $OutDirectory = Split-Path -Path $apiFilePath
33 $OutFileName = "$($FileName.split('.')[0])_js.json"
34 $OutFilePath = Join-Path -Path $OutDirectory $OutFileName
35 Write-Host "Converting api-extractor file $($apiFilePath) to APIview code file $($OutFilePath)"
36 node ./dist/export.js $apiFilePath $OutFilePath
37 }
38}
39finally
40{
41 Pop-Location
42}
43