diff --git a/doc/DataPlaneCodeGeneration/Autorest_DataPlane_Quickstart.md b/doc/DataPlaneCodeGeneration/Autorest_DataPlane_Quickstart.md index 34075c931439b..d5344ec691408 100644 --- a/doc/DataPlaneCodeGeneration/Autorest_DataPlane_Quickstart.md +++ b/doc/DataPlaneCodeGeneration/Autorest_DataPlane_Quickstart.md @@ -62,16 +62,16 @@ sdk\\\CHANGELOG.md We will use dotnet project template [Azure.Template](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template) to automatically create the project. -You can run `eng\scripts\automation\Invoke-DataPlaneGenerateSDKPackage.ps1` to generate the starting SDK client library package directly as following: +You can run `eng\scripts\automation\Invoke-AutorestDataPlaneGenerateSDKPackage.ps1` to generate the starting SDK client library package directly as following: ```powershell -eng/scripts/automation/Invoke-DataPlaneGenerateSDKPackage.ps1 -service -namespace Azure.. -sdkPath [-inputfiles ] [-readme ] [-securityScope ] [-securityHeaderName ] +eng/scripts/automation/Invoke-AutorestDataPlaneGenerateSDKPackage.ps1 -service -namespace Azure.. -sdkPath [-inputfiles ] [-readme ] [-securityScope ] [-securityHeaderName ] ``` e.g. ```powershell -pwsh /home/azure-sdk-for-net/eng/scripts/automation/Invoke-DataPlaneGenerateSDKPackage.ps1 -service webpubsub -namespace Azure.Messaging.WebPubSub -sdkPath /home/azure-sdk-for-net -inputfiles https://github.com/Azure/azure-rest-api-specs/blob/73a0fa453a93bdbe8885f87b9e4e9fef4f0452d0/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json -securityScope https://sample/.default +pwsh /home/azure-sdk-for-net/eng/scripts/automation/Invoke-AutorestDataPlaneGenerateSDKPackage.ps1 -service webpubsub -namespace Azure.Messaging.WebPubSub -sdkPath /home/azure-sdk-for-net -inputfiles https://github.com/Azure/azure-rest-api-specs/blob/73a0fa453a93bdbe8885f87b9e4e9fef4f0452d0/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json -securityScope https://sample/.default ``` **Note**: @@ -85,7 +85,7 @@ pwsh /home/azure-sdk-for-net/eng/scripts/automation/Invoke-DataPlaneGenerateSDKP - `-securityScope` designates the authentication scope to use if your library supports **Token Credential** authentication. - `-securityHeaderName` designates the key to use if your library supports **Azure Key Credential** authentication. -When you run the `eng\scripts\automation\Invoke-DataPlaneGenerateSDKPackage.ps1` script, it will: +When you run the `eng\scripts\automation\Invoke-AutorestDataPlaneGenerateSDKPackage.ps1` script, it will: - Create a project folder, install template files from `sdk/template/Azure.Template`, and create `.csproj` and `.sln` files for your new library. diff --git a/doc/DataPlaneCodeGeneration/AzureSDKPackage_Setup.md b/doc/DataPlaneCodeGeneration/AzureSDKPackage_Setup.md index 0ff56e4453934..77da0babb4630 100644 --- a/doc/DataPlaneCodeGeneration/AzureSDKPackage_Setup.md +++ b/doc/DataPlaneCodeGeneration/AzureSDKPackage_Setup.md @@ -17,8 +17,8 @@ sdk\\\.sln - `` - Should be the name of the shipping package, or an abbreviation that distinguishes the given shipping artifact for the given service. It will be `Azure..`, e.g. Azure.IoT.DeviceUpdate ## Create sdk package - -We will use the Azure SDK template [Azure.Template](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template) to create the initial project skeleton. + +We will use the Azure SDK template [Azure.Template](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/template/Azure.Template) to create the initial project skeleton for SDKs generated from TypeSpec. You can run `eng\scripts\automation\Invoke-TypeSpecDataPlaneGenerateSDKPackage.ps1` to generate the starting SDK client library package directly as following: @@ -26,7 +26,7 @@ You can run `eng\scripts\automation\Invoke-TypeSpecDataPlaneGenerateSDKPackage.p eng/scripts/automation/Invoke-TypeSpecDataPlaneGenerateSDKPackage.ps1 -sdkFolder -typespecSpecDirectory -commit [-repo ] [-additionalSubDirectories ] ``` -e.g. +e.g. Use git url ```powershell diff --git a/eng/codegen_to_sdk_config.json b/eng/codegen_to_sdk_config.json deleted file mode 100644 index f0d47d11d6229..0000000000000 --- a/eng/codegen_to_sdk_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "init": { - "initScript": { - "path": "./eng/scripts/automation/init.sh", - "logPrefix": "[DotNet]", - "stderr":{ - "storeAllLog": true - } - } - }, - "generateAndBuild": { - "generateAndBuildScript": { - "path": "./eng/scripts/automation/Invoke-GenerateAndBuild.ps1", - "script": "pwsh", - "logPrefix": "[DotNet-Generate]", - "stderr":{ - "storeLogByFilter": "[error|Error|Exception]" - } - } - }, - "mockTest": { - "mockTestScript": { - "path": "./eng/scripts/automation/Invoke-MockTest.ps1", - "script": "pwsh", - "logPrefix": "[GO-MockTest]", - "stderr":{ - "storeLogByFilter": "[error|Error|Exception]" - } - } - } -} \ No newline at end of file diff --git a/eng/scripts/automation/Invoke-DataPlaneGenerateSDKPackage.ps1 b/eng/scripts/automation/Invoke-AutorestDataPlaneGenerateSDKPackage.ps1 similarity index 83% rename from eng/scripts/automation/Invoke-DataPlaneGenerateSDKPackage.ps1 rename to eng/scripts/automation/Invoke-AutorestDataPlaneGenerateSDKPackage.ps1 index 1b83461dec106..a3f14e3907041 100644 --- a/eng/scripts/automation/Invoke-DataPlaneGenerateSDKPackage.ps1 +++ b/eng/scripts/automation/Invoke-AutorestDataPlaneGenerateSDKPackage.ps1 @@ -1,7 +1,7 @@ #Requires -Version 7.0 <# .SYNOPSIS -script for creating a getting started project in a branch of `azure-sdk-for-net` repo. +script for creating a getting started project in a branch of `azure-sdk-for-net` repo for SDKs generated from swagger. .PARAMETER service The Azure client service directory name. ie. purview. It equals to the name of the directory in the specification folder of the azure-rest-api-specs repo that contains the REST API definition file. @@ -13,7 +13,7 @@ The SDK package namespace. This value will also provide the name for the shipped The address of the root directory of sdk repo. e.g. /home/azure-sdk-for-net .PARAMETER inputfiles -The address of the Open API spec files, separated by semicolon if there is more than one file. +The address of the Open API spec files, separated by semicolon if there is more than one file. The Open API spec file can be local file, or the web address of the file in the `azure-rest-api-specs` repo. When pointing to a local file, make sure to use **absolute path**, i.e. /home/swagger/compute.json. When pointing to a file in the `azure-rest-api-specs` repo, make sure to include the commit id in the URI, i.e. `https://github.com/Azure/azure-rest-api-specs/blob/73a0fa453a93bdbe8885f87b9e4e9fef4f0452d0/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json`. This ensures that you can choose the time to upgrade to new swagger file versions. @@ -31,10 +31,10 @@ The key to use if your library supports **Azure Key Credential** authentication. .EXAMPLE Run script with default parameters. -Invoke-DataPlaneGenerateSDKPackage.ps1 -service -namespace Azure.. -sdkPath [-inputfiles ] [-readme ] [-securityScope ] [-securityHeaderName ] +Invoke-AutorestDataPlaneGenerateSDKPackage.ps1 -service -namespace Azure.. -sdkPath [-inputfiles ] [-readme ] [-securityScope ] [-securityHeaderName ] e.g. -Invoke-DataPlaneGenerateSDKPackage.ps1 -service webpubsub -namespace Azure.Messaging.WebPubSub -sdkPath /home/azure-sdk-for-net -inputfiles https://github.com/Azure/azure-rest-api-specs/blob/73a0fa453a93bdbe8885f87b9e4e9fef4f0452d0/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json -securityScope https://sample/.default +Invoke-AutorestDataPlaneGenerateSDKPackage.ps1 -service webpubsub -namespace Azure.Messaging.WebPubSub -sdkPath /home/azure-sdk-for-net -inputfiles https://github.com/Azure/azure-rest-api-specs/blob/73a0fa453a93bdbe8885f87b9e4e9fef4f0452d0/specification/webpubsub/data-plane/WebPubSub/stable/2021-10-01/webpubsub.json -securityScope https://sample/.default #> param ( diff --git a/eng/scripts/automation/Invoke-GenerateAndBuild.ps1 b/eng/scripts/automation/Invoke-GenerateAndBuild.ps1 deleted file mode 100644 index e40414a2adaae..0000000000000 --- a/eng/scripts/automation/Invoke-GenerateAndBuild.ps1 +++ /dev/null @@ -1,117 +0,0 @@ -#Requires -Version 7.0 -param ( - [string]$inputJsonFile, - [string]$outputJsonFile -) - -. (Join-Path $PSScriptRoot ".." ".." "common" "scripts" "Helpers" PSModule-Helpers.ps1) -. (Join-Path $PSScriptRoot GenerateAndBuildLib.ps1) - -$inputJson = Get-Content $inputJsonFile | Out-String | ConvertFrom-Json -$swaggerDir = $inputJson.specFolder -if($swaggerDir) { - $swaggerDir = Resolve-Path $swaggerDir -} -$swaggerDir = $swaggerDir -replace "\\", "/" -$readmeFile = $inputJson.relatedReadmeMdFile -$readmeFile = $readmeFile -replace "\\", "/" -$commitid = $inputJson.headSha -$repoHttpsUrl = $inputJson.repoHttpsUrl -$downloadUrlPrefix = $inputJson.installInstructionInput.downloadUrlPrefix -$autorestConfig = $inputJson.autorestConfig - -$autorestConfig = $inputJson.autorestConfig -$relatedTypeSpecProjectFolder = $inputJson.relatedTypeSpecProjectFolder - -$autorestConfigYaml = "" -if ($autorestConfig) { - $autorestConfig | Set-Content "config.md" - $autorestConfigYaml = Get-Content -Path .\config.md - $range = ($autorestConfigYaml | Select-String -Pattern '```').LineNumber - if ( $range.count -gt 1) { - $startNum = $range[0]; - $lines = $range[1] - $range[0] - 1 - $autorestConfigYaml = ($autorestConfigYaml | Select -Skip $startNum | Select -First $lines) |Out-String - } - Install-ModuleIfNotInstalled "powershell-yaml" "0.4.1" | Import-Module - $yml = ConvertFrom-YAML $autorestConfigYaml - $requires = $yml["require"] - if ($requires.Count -gt 0) { - $readmeFile = $requires[0] - } -} - -$generatedSDKPackages = New-Object 'Collections.Generic.List[System.Object]' - -# $service, $serviceType = Get-ResourceProviderFromReadme $readmeFile -$sdkPath = (Join-Path $PSScriptRoot .. .. ..) -$sdkPath = Resolve-Path $sdkPath -$sdkPath = $sdkPath -replace "\\", "/" - -if ($readmeFile) { - Write-Host "swaggerDir:$swaggerDir, readmeFile:$readmeFile" - - $readme = "" - if ($commitid -ne "") { - if ((-Not $readmeFile.Contains("specification")) -And $swaggerDir.Contains("specification")) - { - $readmeFile = "specification/$readmeFile" - } - if ($repoHttpsUrl -ne "") { - $readme = "$repoHttpsUrl/blob/$commitid/$readmeFile" - } else { - $readme = "https://github.com/$org/azure-rest-api-specs/blob/$commitid/$readmeFile" - } - } else { - $readme = (Join-Path $swaggerDir $readmeFile) - } - Invoke-GenerateAndBuildSDK -readmeAbsolutePath $readme -sdkRootPath $sdkPath -autorestConfigYaml "$autorestConfigYaml" -downloadUrlPrefix "$downloadUrlPrefix" -generatedSDKPackages $generatedSDKPackages -} - -# generate sdk from typespec file -if ($relatedTypeSpecProjectFolder) { - foreach ($typespecRelativeFolder in $relatedTypeSpecProjectFolder) { - $typespecFolder = Resolve-Path (Join-Path $swaggerDir $typespecRelativeFolder) - $processScript = Resolve-Path (Join-Path $sdkPath "eng/common/scripts" "TypeSpec-Project-Process.ps1") - $sdkProjectFolders = Get-ChildItem -Path (Join-Path $sdkPath "sdk") -Depth 1 -Directory | Select-Object -ExpandProperty FullName - - # Invoke Process script. SkipSyncAndGenerate only when it's not a new SDK project - $sdkProjectFolder = & $processScript $typespecFolder $commitid $repoHttpsUrl -SkipSyncAndGenerate - if ($LASTEXITCODE) { - # If Process script call fails, then return with failure to CI and don't need to call GeneratePackage - $generatedSDKPackages.Add(@{ - result = "failed"; - path=@(""); - }) - } else { - $relativeSdkPath = Resolve-Path $sdkProjectFolder -Relative - $specRepoRoot = $swaggerDir -replace "/specification", "" - if ($sdkProjectFolders -contains $sdkProjectFolder) { - # Existed SDK project case, needs to generate code - GeneratePackage ` - -projectFolder $sdkProjectFolder ` - -sdkRootPath $sdkPath ` - -path $relativeSdkPath ` - -downloadUrlPrefix $downloadUrlPrefix ` - -serviceType "data-plane" ` - -generatedSDKPackages $generatedSDKPackages ` - -specRepoRoot $specRepoRoot - } else { - # New SDK project case, code is already generated by emitter. So, skip code generation - GeneratePackage ` - -projectFolder $sdkProjectFolder ` - -sdkRootPath $sdkPath ` - -path $relativeSdkPath ` - -downloadUrlPrefix $downloadUrlPrefix ` - -serviceType "data-plane" ` - -skipGenerate ` - -generatedSDKPackages $generatedSDKPackages ` - -specRepoRoot $specRepoRoot - } - } - } -} -$outputJson = [PSCustomObject]@{ - packages = $generatedSDKPackages -} -$outputJson | ConvertTo-Json -depth 100 | Out-File $outputJsonFile \ No newline at end of file diff --git a/eng/scripts/automation/generate-and-build.sh b/eng/scripts/automation/generate-and-build.sh deleted file mode 100644 index f09d09222d339..0000000000000 --- a/eng/scripts/automation/generate-and-build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -if [ -z $1 ]; then - echo "Please input inputfile" - echo "Usage: generate-and-build.sh " - exit 1 -fi - -if [ -z $2 ]; then - echo "Please input outputfile" - echo "Usage: generate-and-build.sh " - exit 1 -fi - -pwsh eng/automation/Invoke-GenerateAndBuild.ps1 -inputJsonFile $1 -outputJsonFile $2 - -if [ "$?" != "0" ]; then - echo "Failed to generate code." - exit 1 -fi - -cat $2 \ No newline at end of file