-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish api json file and enable api change detection #17837
Merged
praveenkuttappan
merged 6 commits into
Azure:main
from
praveenkuttappan:enable_api_change_detect
Sep 28, 2021
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1831a55
Publis api file
praveenkuttappan 9191988
Stage api review file to package artofact path and rename to include …
praveenkuttappan bb6b002
Fix error in yaml
praveenkuttappan ad7f609
Dummy change to verify api change detection
praveenkuttappan 9d72c84
Dummy change
praveenkuttappan 007d68d
Revert dummy change
praveenkuttappan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
param ( | ||
[Parameter(mandatory = $true)] | ||
$PackageInfoPath, | ||
[Parameter(mandatory = $true)] | ||
$StagingDirectory | ||
) | ||
|
||
if (!((Test-Path $PackageInfoPath) -and (Test-Path $StagingDirectory))) | ||
{ | ||
Write-Error "Invalid parameter values. Pleaes verify values for these parameters." | ||
exit 1 | ||
} | ||
|
||
foreach($pkg in (Get-ChildItem -Path $PackageInfoPath "*.json")) | ||
{ | ||
$info = Get-Content -Path $pkg.FullName | ConvertFrom-Json | ||
$apiFilePath = Join-Path $info.DirectoryPath "temp" | ||
if (Test-Path $apiFilePath) | ||
{ | ||
$apiFile = Get-ChildItem -Path $apiFilePath "*.api.json" | ||
if ($apiFile) | ||
{ | ||
if ($apiFile.Count -ne 1) | ||
{ | ||
# Unlikely, but handling to avoid any issue in the future if more than one api file is present here | ||
Write-Error "Detected more than one api extracted file in $apiFilePath" | ||
exit 1 | ||
} | ||
|
||
$pkgStagingDir = Join-Path $StagingDirectory $info.ArtifactName | ||
if (!(Test-Path $pkgStagingDir)) | ||
{ | ||
New-Item -Type Directory -Name $info.ArtifactName -Path $StagingDirectory > $null | ||
} | ||
$sourceFilePath = $apiFile[0].FullName | ||
$targetFilePath = "$($pkgStagingDir)/$($info.ArtifactName)_$($info.Version).api.json" | ||
Write-Host "Copying $($sourceFilePath) to $($targetFilePath)" | ||
Copy-Item $sourceFilePath $targetFilePath | ||
} | ||
else | ||
{ | ||
# Not an error is api-extractor is not cofigured/ required for a package | ||
Write-Host "API extracted file is not present for package $($info.Name)" | ||
} | ||
} | ||
else | ||
{ | ||
Write-Host "Directory $($apiFilePath) is not present in package root to search for api-extracted file" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this always give back a list? I know PS sometimes gives back a single object if there is only one in the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so. It was working when referring it directly without index also. I thought of adding this check to avoid any issue if we get any such scenario.