Skip to content

Commit 18425c2

Browse files
authored
[Tools] Adding snippet generator and update script (#601)
* [Tools] Adding snippet generator and update script The focus of these changes is to add the snippet generator tool from the Azure development feed and a PowerShell script to update snippets.
1 parent e605a17 commit 18425c2

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

.config/dotnet-tools.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"Azure.Sdk.Tools.SnippetGenerator": {
6+
"version": "1.0.0-dev.20241213.1",
7+
"commands": [
8+
"snippet-generator"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

nuget.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
55
<clear />
66
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
7+
<add key="azure-sdk-dev-feed" value="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" />
78
</packageSources>
89
</configuration>

scripts/Update-Snippets.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[CmdletBinding()]
2+
param(
3+
[string]$Path
4+
)
5+
6+
# If this is not a real path, assume snippets should be refreshed in a relative
7+
# path to the OpenAI.csproj file from the git root.
8+
if (-not $Path) {
9+
$_gitRoot = git rev-parse --show-toplevel 2>$null
10+
11+
if ((-not $_gitRoot) -or ($LASTEXITCODE -ne 0)) {
12+
Write-Error "Could not determine the git root directory. Please specify the path to the project file."
13+
exit 1
14+
}
15+
16+
$Path = Join-Path -Path $_gitRoot -ChildPath '/src/OpenAI.csproj'
17+
$Path = (Resolve-Path -LiteralPath $Path).Path
18+
}
19+
20+
# Update snippets
21+
Write-Host "Updating snippets in $Path"
22+
23+
dotnet tool restore
24+
dotnet tool run snippet-generator -b $Path

0 commit comments

Comments
 (0)