Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 6222 (#36703)
Browse files Browse the repository at this point in the history
* Updated typespec common script

* Updated per the review comment

---------

Co-authored-by: raychen <[email protected]>
  • Loading branch information
azure-sdk and raych1 authored May 31, 2023
1 parent 50a4054 commit a92cd40
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions eng/common/scripts/TypeSpec-Project-Process.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ $repoRootPath = (Join-Path $PSScriptRoot .. .. ..)
$repoRootPath = Resolve-Path $repoRootPath
$repoRootPath = $repoRootPath -replace "\\", "/"
$tspConfigPath = Join-Path $repoRootPath 'tspconfig.yaml'
$tmpTspConfigPath = $tspConfigPath
# example url of tspconfig.yaml: https://github.com/Azure/azure-rest-api-specs-pr/blob/724ccc4d7ef7655c0b4d5c5ac4a5513f19bbef35/specification/containerservice/Fleet.Management/tspconfig.yaml
if ($TypeSpecProjectDirectory -match '^https://github.com/(?<repo>Azure/azure-rest-api-specs(-pr)?)/blob/(?<commit>[0-9a-f]{40})/(?<path>.*)/tspconfig.yaml$') {
try {
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "github.com", "raw.githubusercontent.com"
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "/blob/", "/"
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "https://github.com/(.*)/(tree|blob)", "https://raw.githubusercontent.com/`$1"
Invoke-WebRequest $TypeSpecProjectDirectory -OutFile $tspConfigPath -MaximumRetryCount 3
}
catch {
Expand All @@ -119,13 +119,25 @@ if ($TypeSpecProjectDirectory -match '^https://github.com/(?<repo>Azure/azure-re
$CommitHash = $Matches["commit"]
# TODO support the branch name in url then get the commithash from branch name
} else {
if ($TypeSpecProjectDirectory -match "^.*/(?<path>specification/.*)$") {
$TypeSpecProjectDirectory = $Matches["path"]
} else {
Write-Error "'$TypeSpecProjectDirectory' doesn't have 'specification' in path."
exit 1
}
$tspConfigPath = Join-Path $TypeSpecProjectDirectory "tspconfig.yaml"
if (!(Test-Path $tspConfigPath)) {
Write-Error "Failed to find tspconfig.yaml in '$TypeSpecProjectDirectory'"
exit 1
}
}

$tspConfigYaml = Get-Content $tspConfigPath -Raw | ConvertFrom-Yaml

# delete the tmporary tspconfig.yaml downloaded from github
if (Test-Path $tmpTspConfigPath) {
Remove-Item $tspConfigPath
}
# call CreateUpdate-TspLocation function
$sdkProjectFolder = CreateUpdate-TspLocation $tspConfigYaml $TypeSpecProjectDirectory $CommitHash $repo $repoRootPath

Expand Down

0 comments on commit a92cd40

Please sign in to comment.