@@ -36,14 +36,14 @@ function CreateUpdate-TspLocation([System.Object]$tspConfig, [string]$TypeSpecPr
36
36
# Create service-dir if not exist
37
37
$serviceDir = Join-Path $repoRoot $serviceDir
38
38
if (! (Test-Path - Path $serviceDir )) {
39
- New-Item - Path $serviceDir - ItemType Directory
39
+ New-Item - Path $serviceDir - ItemType Directory | Out-Null
40
40
Write-Host " created service folder $serviceDir "
41
41
}
42
42
43
43
# Create package-dir if not exist
44
44
$packageDir = Join-Path $serviceDir $packageDir
45
45
if (! (Test-Path - Path $packageDir )) {
46
- New-Item - Path $packageDir - ItemType Directory
46
+ New-Item - Path $packageDir - ItemType Directory | Out-Null
47
47
Write-Host " created package folder $packageDir "
48
48
}
49
49
@@ -59,11 +59,15 @@ function CreateUpdate-TspLocation([System.Object]$tspConfig, [string]$TypeSpecPr
59
59
60
60
# Update tsp-location.yaml
61
61
$tspLocationYaml [" commit" ] = $CommitHash
62
+ Write-Host " updated tsp-location.yaml commit to $CommitHash "
62
63
$tspLocationYaml [" repo" ] = $repo
64
+ Write-Host " updated tsp-location.yaml repo to $repo "
63
65
$tspLocationYaml [" directory" ] = $TypeSpecProjectDirectory
66
+ Write-Host " updated tsp-location.yaml directory to $TypeSpecProjectDirectory "
64
67
$tspLocationYaml [" additionalDirectories" ] = $additionalDirs
68
+ Write-Host " updated tsp-location.yaml additionalDirectories to $additionalDirs "
65
69
$tspLocationYaml | ConvertTo-Yaml | Out-File $tspLocationYamlPath
66
- Write-Host " updated tsp-location.yaml in $packageDir "
70
+ Write-Host " finished updating tsp-location.yaml in $packageDir "
67
71
return $packageDir
68
72
}
69
73
@@ -87,22 +91,13 @@ function Get-PackageDir([System.Object]$tspConfig) {
87
91
return $packageDir
88
92
}
89
93
90
- $repo = " "
91
- if ($RepoUrl ) {
92
- if ($RepoUrl -match " ^https://github.com/(?<repo>[^/]*/azure-rest-api-specs(-pr)?).*" ) {
93
- $repo = $Matches [" repo" ]
94
- }
95
- else {
96
- Write-Host " Parameter 'RepoUrl' has incorrect value: $RepoUrl . It should be similar like 'https://github.com/Azure/azure-rest-api-specs'"
97
- exit 1
98
- }
99
- }
100
-
101
94
$repoRootPath = (Join-Path $PSScriptRoot .. .. ..)
102
95
$repoRootPath = Resolve-Path $repoRootPath
103
96
$repoRootPath = $repoRootPath -replace " \\" , " /"
104
97
$tspConfigPath = Join-Path $repoRootPath ' tspconfig.yaml'
105
98
$tmpTspConfigPath = $tspConfigPath
99
+ $repo = " "
100
+ # remote url scenario
106
101
# example url of tspconfig.yaml: https://github.com/Azure/azure-rest-api-specs-pr/blob/724ccc4d7ef7655c0b4d5c5ac4a5513f19bbef35/specification/containerservice/Fleet.Management/tspconfig.yaml
107
102
if ($TypeSpecProjectDirectory -match ' ^https://github.com/(?<repo>Azure/azure-rest-api-specs(-pr)?)/blob/(?<commit>[0-9a-f]{40})/(?<path>.*)/tspconfig.yaml$' ) {
108
103
try {
@@ -119,15 +114,32 @@ if ($TypeSpecProjectDirectory -match '^https://github.com/(?<repo>Azure/azure-re
119
114
$CommitHash = $Matches [" commit" ]
120
115
# TODO support the branch name in url then get the commithash from branch name
121
116
} else {
117
+ # local path scenario
118
+ $tspConfigPath = Join-Path $TypeSpecProjectDirectory " tspconfig.yaml"
119
+ if (! (Test-Path $tspConfigPath )) {
120
+ Write-Error " Failed to find tspconfig.yaml in '$TypeSpecProjectDirectory '"
121
+ exit 1
122
+ }
123
+ $TypeSpecProjectDirectory = $TypeSpecProjectDirectory.Replace (" \" , " /" )
122
124
if ($TypeSpecProjectDirectory -match " ^.*/(?<path>specification/.*)$" ) {
123
125
$TypeSpecProjectDirectory = $Matches [" path" ]
124
126
} else {
125
- Write-Error " ' $TypeSpecProjectDirectory ' doesn't have 'specification' in path."
127
+ Write-Error " $TypeSpecProjectDirectory doesn't have 'specification' in path."
126
128
exit 1
127
129
}
128
- $tspConfigPath = Join-Path $TypeSpecProjectDirectory " tspconfig.yaml"
129
- if (! (Test-Path $tspConfigPath )) {
130
- Write-Error " Failed to find tspconfig.yaml in '$TypeSpecProjectDirectory '"
130
+ if (! $CommitHash ) {
131
+ Write-Error " Parameter of Commithash is not provided in the local path scenario."
132
+ exit 1
133
+ }
134
+ if (! $RepoUrl ) {
135
+ Write-Error " Parameter of RepoUrl:$RepoUrl is not provided in the local path scenario."
136
+ exit 1
137
+ }
138
+ if ($RepoUrl -match " ^https://github.com/(?<repo>[^/]*/azure-rest-api-specs(-pr)?).*" ) {
139
+ $repo = $Matches [" repo" ]
140
+ }
141
+ else {
142
+ Write-Error " Parameter 'RepoUrl' has incorrect value:$RepoUrl . It should be similar like 'https://github.com/Azure/azure-rest-api-specs'"
131
143
exit 1
132
144
}
133
145
}
@@ -142,6 +154,13 @@ if (Test-Path $tmpTspConfigPath) {
142
154
$sdkProjectFolder = CreateUpdate- TspLocation $tspConfigYaml $TypeSpecProjectDirectory $CommitHash $repo $repoRootPath
143
155
144
156
# call TypeSpec-Project-Sync.ps1
145
- & " $PSScriptRoot /TypeSpec-Project-Sync.ps1" $sdkProjectFolder
157
+ $syncScript = Join-Path $PSScriptRoot TypeSpec- Project- Sync.ps1
158
+ & $syncScript $sdkProjectFolder
159
+ if ($LASTEXITCODE ) { exit $LASTEXITCODE }
160
+
146
161
# call TypeSpec-Project-Generate.ps1
147
- & " $PSScriptRoot /TypeSpec-Project-Generate.ps1" $sdkProjectFolder
162
+ $generateScript = Join-Path $PSScriptRoot TypeSpec- Project- Generate.ps1
163
+ & $generateScript $sdkProjectFolder
164
+ if ($LASTEXITCODE ) { exit $LASTEXITCODE }
165
+
166
+ return $sdkProjectFolder
0 commit comments