forked from Azure/autorest.java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerate-TypeSpec.ps1
65 lines (50 loc) · 2 KB
/
Generate-TypeSpec.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Use case:
#
# The purpose of this script is to compact the steps required to regenerate TypeSpec into a single script.
#
# If 'com.azure.autorest.customization' tests fails, re-install 'customization-base'.
#
# Before running this script the 'tsp' profile must be built, 'mvn install -P local,tsp'.
#
# This script can only be ran from the root of the repository.
# Invokes the given expression and only writes the output of the expression if it failed.
param (
[int] $Parallelization = [Environment]::ProcessorCount
)
function invokeExpressionAndCaptureOutput([string]$expression) {
$output = Invoke-Expression $expression
if ($LASTEXITCODE -ne 0) {
$ExitCode = $LASTEXITCODE
Write-Host $output
exit $ExitCode
}
}
Write-Host "Changing directory to './typespec-extension'"
Push-Location ./typespec-extension
try {
Write-Host "Installing dependencies for TypeSpec Java ('npm ci')"
invokeExpressionAndCaptureOutput("npm ci")
Write-Host "Building TypeSpec Java ('npm run build')"
invokeExpressionAndCaptureOutput("npm run build")
Write-Host "Linting TypeSpec Java ('npm run lint')"
invokeExpressionAndCaptureOutput("npm run lint")
Write-Host "Checking TypeSpec Java format ('npm run check-format')"
invokeExpressionAndCaptureOutput("npm run check-format")
Write-Host "Packing TypeSpec Java ('npm pack')"
invokeExpressionAndCaptureOutput("npm pack")
Write-Host "Returning to root directory ('..')"
} finally {
Pop-Location
}
Write-Host "Installing TypeSpec ('npm install -g @typespec/compiler')"
invokeExpressionAndCaptureOutput("npm install -g @typespec/compiler")
Write-Host "Changing directory to './typespec-tests'"
Push-Location ./typespec-tests
try {
Write-Host "Generating code ('Generate.ps1' in './typespec-tests')"
invokeExpressionAndCaptureOutput("./Generate.ps1 -Parallelization $Parallelization")
Write-Host "Checking format of generated code ('npm run check-format')"
invokeExpressionAndCaptureOutput("npm run check-format")
} finally {
Pop-Location
}