Skip to content

Commit 6c6b16d

Browse files
authored
Added a wrapper script for writer to generate sdk (#24267)
* Added a wrapper script for writer to generate sdk * output sdk repo root path * Set default value for typespec project folder.
1 parent 0cffd39 commit 6c6b16d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

eng/scripts/TypeSpec-Generate-Sdk.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter(Position = 0)]
4+
[ValidateNotNullOrEmpty()]
5+
[string] $SdkRepoRootDirectory,
6+
[Parameter(Position = 1)]
7+
[string] $TypeSpecProjectDirectory = ".", # A directory of `tspconfig.yaml` or a remoteUrl of `tspconfig.yaml`
8+
[Parameter(Position = 2)]
9+
[string] $CommitHash,
10+
[Parameter(Position = 3)]
11+
[string] $RepoUrl
12+
)
13+
14+
if ($TypeSpecProjectDirectory -contains ".") {
15+
$TypeSpecProjectDirectory = Resolve-Path $TypeSpecProjectDirectory
16+
}
17+
18+
try {
19+
Push-Location $SdkRepoRootDirectory
20+
$commonScript = Join-Path . "eng/common/scripts/TypeSpec-Project-Process.ps1"
21+
if (Test-Path $commonScript) {
22+
. $commonScript -TypeSpecProjectDirectory $TypeSpecProjectDirectory -CommitHash $CommitHash -RepoUrl $RepoUrl
23+
if ($LASTEXITCODE) {
24+
exit $LASTEXITCODE
25+
}
26+
}
27+
else {
28+
Write-Error "Cannot find $commonScript at $SdkRepoRootDirectory"
29+
}
30+
}
31+
finally {
32+
Pop-Location
33+
}
34+
35+
exit 0

0 commit comments

Comments
 (0)