forked from Azure/autorest.java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Generate-TypeSpec.ps1
59 lines (45 loc) · 1.83 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
# Use case:
#
# The purpose of this script is to compact the steps required to regenerate TypeSpec into a single script.
#
# 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.
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'"
try {
Push-Location ./typespec-extension
Write-Host "Installing dependencies for TypeSpec Java ('npm install')"
invokeExpressionAndCaptureOutput("npm install")
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")
try {
Write-Host "Changing directory to './typespec-tests'"
Push-Location ./typespec-tests
Write-Host "Generating code ('Generate.ps1' in './typespec-tests')"
invokeExpressionAndCaptureOutput("./Generate.ps1")
Write-Host "Checking format of generated code ('npm run check-format')"
invokeExpressionAndCaptureOutput("npm run check-format")
} finally {
Pop-Location
}