Skip to content

Commit

Permalink
add Azure.Template as the content of template
Browse files Browse the repository at this point in the history
  • Loading branch information
chunyu3 committed May 6, 2022
1 parent 96df97d commit cb009d5
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 49 deletions.
27 changes: 18 additions & 9 deletions eng/scripts/automation/GenerateAndBuildLib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ function New-DataPlanePackageFolder() {
}
}

$serviceFolder = (Join-Path $sdkPath "sdk" $service)
if (!(Test-Path -Path $serviceFolder)) {
Write-Host "service folder does not exist! create the folder $serviceFolder"
New-Item -Path $serviceFolder -ItemType Directory
}
$projectFolder=(Join-Path $sdkPath "sdk" $service $namespace)
$ciymlFilePath =(Join-Path $sdkPath "sdk" $service $CI_YAML_FILE)
$apifolder = (Join-Path $projectFolder "api")
Expand All @@ -148,19 +153,22 @@ function New-DataPlanePackageFolder() {
Write-Error "Error: input file should not be empty."
exit 1
}
dotnet new -i $sdkPath/sdk/template/Azure.Template
dotnet new -i $sdkPath/sdk/template
Write-Host "Create project folder $projectFolder"
New-Item -Path $projectFolder -ItemType Directory
Push-Location $projectFolder
if (Test-Path -Path $projectFolder) {
Remove-Item -Path $projectFolder -ItemType Directory
}

Push-Location $serviceFolder
$namespaceArray = $namespace.Split(".")
if ( $namespaceArray.Count -lt 3) {
Write-Error "Error: invalid namespace name."
exit 1
}

$libraryName = $namespaceArray[-1]
$clientName = $namespaceArray[-1]
$groupName = $namespaceArray[1]
$dotnetNewCmd = "dotnet new azsdkdpg --libraryName $libraryName --groupName $groupName --force"
$dotnetNewCmd = "dotnet new azsdkdpg --name $namespace --clientName $clientName --groupName $groupName --serviceDirectory $service --force"
if ($inputfile -ne "") {
$dotnetNewCmd = $dotnetNewCmd + " --swagger '$inputfile'"
}
Expand All @@ -175,17 +183,18 @@ function New-DataPlanePackageFolder() {
if (Test-Path -Path $ciymlFilePath) {
Write-Host "ci.yml already exists. update it to include the new serviceDirectory."
Update-CIYmlFile -ciFilePath $ciymlFilePath -artifact $namespace
} else {
$dotnetNewCmd = $dotnetNewCmd + " --includeCI true"
}

# dotnet new azsdkdpg --libraryName $libraryName --swagger $inputfile --securityScopes $securityScope --securityHeaderName $securityHeaderName --includeCI true --force
$dotnetNewCmd = $dotnetNewCmd + " --includeCI false"
}
# dotnet new azsdkdpg --name $namespace --clientName $clientName --groupName $groupName --serviceDirectory $service --swagger $inputfile --securityScopes $securityScope --securityHeaderName $securityHeaderName --includeCI true --force
Write-Host "Invote dotnet new command: $dotnetNewCmd"
Invoke-Expression $dotnetNewCmd

$file = (Join-Path $projectFolder "src" $AUTOREST_CONFIG_FILE)
Update-AutorestConfigFile -autorestFilePath $file -readme $readme
Pop-Location
# dotnet sln
Push-Location $projectFolder
dotnet sln remove src\$namespace.csproj
dotnet sln add src\$namespace.csproj
dotnet sln remove tests\$namespace.Tests.csproj
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "project"
},
"sourceName": "Azure.Template",
"preferNameDirectory": true,
"preferNameDirectory": false,
"guids": [
"FAE04EC0-301F-11D3-BF4B-00C04F79EFBC",
"FC7B9325-C8EA-4740-AB3B-723EB6549AAD",
Expand All @@ -20,8 +20,8 @@
],
"sources": [
{
"source": "./",
"target": "./",
"source": "./Azure.Template",
"target": "./Azure.Template",
"modifiers": [
{
"exclude": [
Expand All @@ -41,44 +41,42 @@
]
},
{
"source": ".content/testResource",
"target": "../",
"condition": "(includeCI)"
},
{
"source": ".content/perf",
"target": "./perf"
},
{
"source": ".content/samples",
"target": "./samples"
},
{
"source": ".content/stress",
"target": "./stress"
},
{
"source": ".content/tests",
"target": "./tests"
"source": "./Azure.Template/.content",
"target": "./Azure.Template",
"modifiers": [
{
"exclude": [
"testResource/**/*",
"packageResource/**/*"
]
}
]
},
{
"source": ".content/src",
"target": "./src"
"source": "Azure.Template/.content/testResource",
"target": "./",
"condition": "(includeCI)"
},
{
"source": ".content/packageResource",
"target": "./"
"source": "Azure.Template/.content/packageResource",
"target": "./Azure.Template/"
}
],
"symbols": {
"serviceDirectory": {
"type": "parameter",
"datatype":"text",
"isRequired": true,
"description": "The Azure client serviceDirectory 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."
},
"groupName": {
"type": "parameter",
"datatype":"text",
"isRequired": true,
"description": "The Azure namespace group the service belongs to. e.g. IoT",
"replaces": "GroupName"
},
"libraryName": {
"clientName": {
"type": "parameter",
"datatype":"text",
"isRequired": true,
Expand Down Expand Up @@ -121,7 +119,7 @@
"datatype": "bool",
"isRequired": false,
"description": "The optional parameter specifies whether generate related pipline ci.yml and test-resources.json in parent folder.",
"defaultValue": "false"
"defaultValue": "true"
},
"perfSampleLink": {
"type": "parameter",
Expand Down Expand Up @@ -179,21 +177,46 @@
"defaultValue": "https://github.com/Azure/azure-sdk-for-net/main/sdk/template/Azure.Template/samples/Sample1_HelloWorldAsync.md",
"replaces": "AsyncSampleReadmeLink"
},
"ServiceName": {
"ClientNameCapitalCase": {
"type": "derived",
"datatype": "text",
"description": "Renames files containing 'Template'",
"valueSource": "libraryName",
"valueTransform": "ServiceShortNameForm",
"fileRename": "Template",
"valueSource": "ClientName",
"valueTransform": "firstUpperCase",
"replaces": "Template"
},
"ClientNameWithSuffix": {
"type": "generated",
"generator": "join",
"parameters": {
"symbols": [
{
"type": "ref",
"value": "ClientNameCapitalCase"
},
{
"type": "const",
"value": "Client"
}
],
"separator": ""
},
"description": "Renames files containing 'TemplateClient'",
"valueSource": "Cl",
"valueTransform": "ServiceShortNameForm",
"fileRename": "TemplateClient",
"replaces": "TemplateClient"
},
"ServiceNameLowercase": {
"type": "derived",
"datatype": "text",
"valueSource": "libraryName",
"valueTransform": "ServiceNameLowerForm",
"replaces": "template"
"valueSource": "serviceDirectory",
"valueTransform": "ServiceNameLowerForm"
},
"ServiceNameCapitalCase": {
"type": "derived",
"datatype": "text",
"valueSource": "serviceDirectory",
"valueTransform": "firstUpperCase"
},
"ServiceDirectoryPath": {
"type": "generated",
Expand All @@ -212,7 +235,29 @@
"separator": ""
},
"replaces": "sdk/template"
},
},
"PackageName": {
"type": "generated",
"generator": "join",
"parameters": {
"symbols": [
{
"type": "const",
"value": "Azure"
},
{
"type": "ref",
"value": "groupName"
},
{
"type": "ref",
"value": "ClientNameCapitalCase"
}
],
"separator": "."
},
"replaces": "Azure.Template"
},
"PackageSafeName": {
"type": "generated",
"generator": "join",
Expand All @@ -228,7 +273,7 @@
},
{
"type": "ref",
"value": "libraryName"
"value": "ClientNameCapitalCase"
}
],
"separator": ""
Expand All @@ -250,13 +295,67 @@
},
{
"type": "ref",
"value": "libraryName"
"value": "ClientName"
}
],
"separator": "_"
},
"replaces": "Azure_Template"
},
"projectFileName": {
"type": "generated",
"generator": "join",
"parameters": {
"symbols": [
{
"type": "ref",
"value": "PackageName"
},
{
"type": "const",
"value": "."
}
],
"separator": ""
},
"fileRename": "Azure.Template."
},
"YamlServiceDirectory": {
"type": "generated",
"generator": "join",
"parameters": {
"symbols": [
{
"type": "const",
"value": "ServiceDirectory: "
},
{
"type": "ref",
"value": "ServiceNameLowercase"
}
],
"separator": ""
},
"replaces": "ServiceDirectory: template"
},
"AzureResourceProviderNamespace": {
"type": "generated",
"generator": "join",
"parameters": {
"symbols": [
{
"type": "const",
"value": "Microsoft"
},
{
"type": "ref",
"value": "ServiceNameCapitalCase"
}
],
"separator": "."
},
"replaces": "Microsoft.Template"
},
"securityTypes": {
"type": "generated",
"generator": "switch",
Expand Down Expand Up @@ -343,6 +442,9 @@
}
},
"forms": {
"firstUpperCase": {
"identifier": "firstUpperCase"
},
"ServiceShortNameForm": {
"identifier": "replace",
"pattern": "^[mM]icrosoft\\.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public TemplateClient(string endpoint, Azure.Core.TokenCredential credential, Az
}
public partial class TemplateClientOptions : Azure.Core.ClientOptions
{
public TemplateClientOptions(Azure.Template.Generated.TemplateServiceClientOptions.ServiceVersion version = Azure.Template.Generated.TemplateServiceClientOptions.ServiceVersion.V1_0_0) { }
public TemplateClientOptions(Azure.Template.Generated.TemplateClientOptions.ServiceVersion version = Azure.Template.Generated.TemplateClientOptions.ServiceVersion.V1_0_0) { }
public enum ServiceVersion
{
V1_0_0 = 1,
Expand Down

0 comments on commit cb009d5

Please sign in to comment.