Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js apiview parser build pipeline #3847

Merged
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
6 changes: 3 additions & 3 deletions .azure-pipelines/apiview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trigger:
- src/dotnet/APIView
- src/java/apiview-java-processor
- src/swift
- src/ts/ts-genapi
- tools/apiview/parsers/js-api-parser

pr:
branches:
Expand All @@ -26,7 +26,7 @@ pr:
- src/dotnet/APIView
- src/java/apiview-java-processor
- src/swift
- src/ts/ts-genapi
- tools/apiview/parsers/js-api-parser

variables:
DotNetRuntimeVersion: '3.1.x'
Expand All @@ -36,7 +36,7 @@ variables:
TestProjectPath: 'src/dotnet/APIView/**/*Tests.csproj'
NodeVersion: '12.x'
BuildConfiguration: 'Release'
TypeScriptGeneratorDirectory: 'src/ts/ts-genapi'
TypeScriptGeneratorDirectory: 'tools/apiview/parsers/js-api-parser'
GoParserPackagePath: 'src/go'
GoVersion: '1.18'
NugetSecurityAnalysisWarningLevel: 'none'
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/APIView/APIViewWeb/APIViewWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<JavaProcessor>..\..\..\java\apiview-java-processor\target\apiview-java-processor-1.27.0.jar</JavaProcessor>
<PythonProcessor>..\..\..\..\packages\python-packages\api-stub-generator\dist\api_stub_generator-0.1.0-py3-none-any.whl</PythonProcessor>
<GoProcessor>..\..\..\go\apiviewgo.exe</GoProcessor>
<JavaScriptProcessor>..\..\..\ts\ts-genapi\</JavaScriptProcessor>
<JavaScriptProcessor>..\..\..\..\tools\apiview\parsers\js-api-parser\</JavaScriptProcessor>
<TypeScriptToolsVersion>latest</TypeScriptToolsVersion>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/dotnet/APIView/APIViewWeb/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Core of the APIView tool is the web app developed using ASP.Net and TypeScript.
| C | https://github.com/Azure/azure-sdk-tools/blob/main/src/dotnet/APIView/APIViewWeb/Languages/CLanguageService.cs |
| C++ | https://github.com/Azure/azure-sdk-tools/blob/main/src/dotnet/APIView/APIViewWeb/Languages/CppLanguageService.cs |
| Java | https://github.com/Azure/azure-sdk-tools/tree/main/src/java/apiview-java-processor |
| JS/TS | https://github.com/Azure/azure-sdk-tools/tree/main/src/ts/ts-genapi |
| JS/TS | https://github.com/Azure/azure-sdk-tools/tree/main/tools/apiview/parsers/js-api-parser |
| Python | https://github.com/Azure/azure-sdk-tools/tree/main/packages/python-packages/api-stub-generator |
| Go | https://github.com/Azure/azure-sdk-tools/tree/main/src/go |
| Swift | https://github.com/Azure/azure-sdk-tools/tree/main/src/swift |
Expand Down Expand Up @@ -180,10 +180,10 @@ Happy coding!!!!
- Start Visual Studio debug run and create a new review as per the instructions in [APIView README.md](https://github.com/Azure/azure-sdk-tools/blob/main/src/dotnet/APIView/APIViewWeb/README.md)

#### JS/TS
- Got to <azure-sdk-tools repo root>/src/ts/ts-genapi
- Got to <azure-sdk-tools repo root>/tools/apiview/parsers/js-api-parser
- run `npm install`
- run `npm run-script build`
- Copy compiled `index.js` to following location within local code repo <azure-sdk-tools root directory>/artifacts/bin/APIVIewWeb/Debug/<.NetVersion>/
- Copy compiled `export.js` to following location within local code repo <azure-sdk-tools root directory>/artifacts/bin/APIVIewWeb/Debug/<.NetVersion>/
- Start Visual Studio debug run and create a new review as per the instructions in [APIView README.md](https://github.com/Azure/azure-sdk-tools/blob/main/src/dotnet/APIView/APIViewWeb/README.md)


Expand Down
20 changes: 0 additions & 20 deletions src/ts/ts-genapi/package.json

This file was deleted.

100 changes: 100 additions & 0 deletions tools/apiview/parsers/js-api-parser/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file.
trigger:
branches:
include:
- main
- feature/*
- release/*
- hotfix/*
paths:
include:
- tools/apiview/parsers/js-api-parserts-genapi

pr:
branches:
include:
- main
- feature/*
- release/*
- hotfix/*
paths:
include:
- tools/apiview/parsers/js-api-parserts-genapi

variables:
NodeVersion: '16.x'
TypeScriptGeneratorDirectory: 'tools/apiview/parsers/js-api-parserts-genapi'
ArtifactName: 'apiview'
FeedRegistry: 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/'

stages:
- stage: 'Build'
jobs:
- job: 'Build'

pool:
name: azsdk-pool-mms-ubuntu-2004-general
vmImage: MMSUbuntu20.04

steps:
- task: NodeTool@0
inputs:
versionSpec: '$(NodeVersion)'
displayName: 'Use NodeJS $(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"

- pwsh: |
npm pack $(TypeScriptGeneratorDirectory)
Copy-Item ./*.tgz $(Build.ArtifactStagingDirectory)
displayName: "Pack typescript generator"

- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: $(ArtifactName)

- ${{if and(eq(variables['Build.Reason'], 'Manual'), eq(variables['System.TeamProject'], 'internal'))}}:
- stage: 'Release'
dependsOn: Build
condition: Succeeded()
jobs:
- job: PublishPackage
displayName: 'Publish ts-genapi package to devops feed'
pool:
name: azsdk-pool-mms-ubuntu-2004-general
vmImage: MMSUbuntu20.04
steps:
- checkout: none
- download: current

- pwsh: |
$detectedPackageName=Get-ChildItem $(Pipeline.Workspace)/$(ArtifactName)/*.tgz
Write-Host "Detected package name: $detectedPackageName"
$registry="$(FeedRegistry)"
$regAuth=$registry.replace("https:","")
$npmReg = $regAuth.replace("registry/","");
$env:NPM_TOKEN="$(azure-sdk-devops-npm-token)"
Write-Host "Publishing to $($regAuth)"
npm config set $regAuth`:username=azure-sdk
npm config set $regAuth`:_password=`$`{NPM_TOKEN`}
npm config set $regAuth`:email=not_set
npm config set $npmReg`:username=azure-sdk
npm config set $npmReg`:_password=`$`{NPM_TOKEN`}
npm config set $npmReg`:email=not_set
Write-Host "Publishing package"
Write-Host "npm publish $detectedPackageName --registry=$registry --always-auth=true"
npm publish $detectedPackageName --registry=$registry --always-auth=true
displayName: Publish package
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ var apiViewFile: IApiViewFile = {
Name: name,
Navigation: navigation,
Tokens: builder.tokens,
PackageName: apiModel.packages[0].name
PackageName: apiModel.packages[0].name,
VersionString: "1.0.3",
Language: "JavaScript"
}

writeFile(process.argv[3], JSON.stringify(apiViewFile), err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export declare interface IApiViewFile {
Tokens: IApiViewToken[];
Navigation: IApiViewNavItem[];
PackageName: string;
VersionString: string;
Language: string;
}

export declare interface IApiViewToken {
Expand Down
21 changes: 21 additions & 0 deletions tools/apiview/parsers/js-api-parser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@azure-tools/ts-genapi",
"version": "1.0.3",
"description": "",
"main": "index.js",
"publishConfig":{"registry":"https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry/"},
"dependencies": {
"@microsoft/api-extractor-model": "^7.22.2",
"js-tokens": "^6.0.0"
},
"devDependencies": {
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
},
"scripts": {
"build": "tsc -p ."
},
"keywords": [],
"author": "azure-sdk",
"license": "MIT"
}
19 changes: 19 additions & 0 deletions tools/apiview/parsers/js-api-parser/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Overview

This application tokenises a Javascript project into a format useful for JavaScript API reviews. JavaScript API review parser is used by APIView system and CI pipelines to convert a JSON output file created by `api-extracor` to JSON token file intepreted by APIView to create and present review in APIView system.

## Building

1. Go to project directory `<repo root>/tools/apiview/parsers/js-api-parser` and Install npm packages.
`npm install
2. Run `npm run-script build`

## How To Use

Run API extractor step on JS project to create json output file. This step is integrated within build commend for all Azure SDK projects in azure-sdk-for-js monorepo. So running build step is good enough to create input file for APIvIew parser. You can see a JSON file created in temp directory within package root directory once build step is completed succesfully for the package.

Run `node ./export.js <Path to api-extractor JSON output> <Path to apiviewFile>

For e.g.

`node .\export.js C:\git\azure-sdk-for-js\sdk\core\core-client\temp\core-client.api.json C:\git\azure-sdk-for-js\sdk\core\core-client\temp\apiview.json`
3 changes: 3 additions & 0 deletions tools/apiview/parsers/js-api-parser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"include": ["*.ts"]
}