@autorest/powershell 4.0.0-dev.6 → 4.0.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +70 -60
- package/.rush/temp/shrinkwrap-deps.json +2 -2
- package/autorest-configuration-for-sdk.md +14 -2
- package/autorest-configuration.md +2 -1
- package/dist/cmdlets/class.d.ts +3 -0
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +157 -33
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/cmdlets/namespace.d.ts.map +1 -1
- package/dist/cmdlets/namespace.js +1 -0
- package/dist/cmdlets/namespace.js.map +1 -1
- package/dist/generators/psm1.js +1 -1
- package/dist/generators/script-cmdlet.js +1 -1
- package/dist/internal/powershell-declarations.d.ts +1 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +2 -1
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/internal/project.d.ts +10 -2
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +31 -14
- package/dist/internal/project.js.map +1 -1
- package/dist/llcsharp/clientruntime.d.ts +1 -0
- package/dist/llcsharp/clientruntime.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.js +1 -0
- package/dist/llcsharp/clientruntime.js.map +1 -1
- package/dist/llcsharp/code-model.d.ts +1 -0
- package/dist/llcsharp/code-model.d.ts.map +1 -1
- package/dist/llcsharp/csharp-declarations.d.ts +1 -0
- package/dist/llcsharp/csharp-declarations.d.ts.map +1 -1
- package/dist/llcsharp/csharp-declarations.js +2 -1
- package/dist/llcsharp/csharp-declarations.js.map +1 -1
- package/dist/llcsharp/model/model-class.d.ts.map +1 -1
- package/dist/llcsharp/model/model-class.js +27 -11
- package/dist/llcsharp/model/model-class.js.map +1 -1
- package/dist/llcsharp/operation/method.js +2 -1
- package/dist/llcsharp/operation/method.js.map +1 -1
- package/dist/llcsharp/schema/array.js +7 -7
- package/dist/llcsharp/schema/array.js.map +1 -1
- package/dist/llcsharp/schema/fixed-array.d.ts +42 -0
- package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -0
- package/dist/llcsharp/schema/fixed-array.js +251 -0
- package/dist/llcsharp/schema/fixed-array.js.map +1 -0
- package/dist/llcsharp/schema/schema-resolver.d.ts +1 -1
- package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
- package/dist/llcsharp/schema/schema-resolver.js +9 -2
- package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -1
- package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
- package/dist/plugins/cs-namer-v2.js +10 -7
- package/dist/plugins/cs-namer-v2.js.map +1 -1
- package/dist/plugins/plugin-create-inline-properties.js +1 -1
- package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
- package/dist/plugins/powershell-v2.d.ts.map +1 -1
- package/dist/plugins/powershell-v2.js +5 -10
- package/dist/plugins/powershell-v2.js.map +1 -1
- package/dist/plugins/sdk-create-inline-properties.d.ts +4 -0
- package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -0
- package/dist/plugins/sdk-create-inline-properties.js +552 -0
- package/dist/plugins/sdk-create-inline-properties.js.map +1 -0
- package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
- package/dist/plugins/sdk-cs-namer.js +186 -14
- package/dist/plugins/sdk-cs-namer.js.map +1 -1
- package/dist/plugins/sdk-cs-simplifier.d.ts +3 -0
- package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -0
- package/dist/plugins/sdk-cs-simplifier.js +154 -0
- package/dist/plugins/sdk-cs-simplifier.js.map +1 -0
- package/dist/plugins/sdk-generate.d.ts.map +1 -1
- package/dist/plugins/sdk-generate.js +49 -3
- package/dist/plugins/sdk-generate.js.map +1 -1
- package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
- package/dist/plugins/sdk-tweak-model.js +196 -37
- package/dist/plugins/sdk-tweak-model.js.map +1 -1
- package/dist/sdk/project.d.ts +1 -0
- package/dist/sdk/project.d.ts.map +1 -1
- package/dist/sdk/project.js +11 -0
- package/dist/sdk/project.js.map +1 -1
- package/dist/sdk/utility.d.ts +27 -0
- package/dist/sdk/utility.d.ts.map +1 -1
- package/dist/sdk/utility.js +402 -5
- package/dist/sdk/utility.js.map +1 -1
- package/dist/utils/SdkModel.d.ts.map +1 -1
- package/dist/utils/SdkModel.js.map +1 -1
- package/dist/utils/TrieNode.d.ts +10 -0
- package/dist/utils/TrieNode.d.ts.map +1 -0
- package/dist/utils/TrieNode.js +45 -0
- package/dist/utils/TrieNode.js.map +1 -0
- package/dist/utils/WrapComments.d.ts +2 -0
- package/dist/utils/WrapComments.d.ts.map +1 -0
- package/dist/utils/WrapComments.js +46 -0
- package/dist/utils/WrapComments.js.map +1 -0
- package/dist/utils/code-namer.d.ts +3 -0
- package/dist/utils/code-namer.d.ts.map +1 -0
- package/dist/utils/code-namer.js +38 -0
- package/dist/utils/code-namer.js.map +1 -0
- package/dist/utils/schema.d.ts +4 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +28 -1
- package/dist/utils/schema.js.map +1 -1
- package/package.json +1 -1
- package/resources/assets/build-module.ps1 +10 -2
- package/resources/assets/create-model-cmdlets.ps1 +51 -10
- package/resources/assets/custom/README.md +1 -1
- package/resources/assets/docs/README.md +1 -1
- package/resources/assets/exports/README.md +1 -1
- package/resources/assets/generate-portal-ux.ps1 +379 -0
- package/resources/assets/how-to.md +1 -1
- package/resources/assets/internal/README.md +1 -1
- package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +1 -1
- package/resources/assets/tools/Resources/docs/README.md +1 -1
- package/resources/assets/tools/Resources/how-to.md +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.nuspec +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psd1 +1 -1
- package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml +34 -34
- package/resources/modules/Az.Accounts/2.7.5/en-US/about_az.help.txt +1 -1
- package/resources/modules/Az.Accounts/2.7.5/package/services/metadata/core-properties/1aa0749a068a4238881858013f1a5b7f.psmdcp +1 -1
- package/resources/psruntime/BuildTime/Cmdlets/ExportFormatPs1xml.cs +3 -1
- package/resources/psruntime/BuildTime/PsAttributes.cs +12 -0
- package/resources/psruntime/BuildTime/PsExtensions.cs +7 -0
- package/resources/psruntime/TypeConverterExtensions.cs +50 -0
- package/resources/runtime/csharp/json/Nodes/Collections/XNodeArray.cs +5 -0
- package/resources/templates/azureMethod.ejs +3 -2
- package/resources/templates/azureMethodGroup.ejs +2 -1
- package/resources/templates/azureServiceClient.ejs +13 -4
- package/resources/templates/enum.ejs +73 -0
- package/resources/templates/exception.ejs +52 -0
- package/resources/templates/extensionMethod.ejs +22 -11
- package/resources/templates/extensions.ejs +4 -4
- package/resources/templates/longRunningOperationMethod.ejs +43 -0
- package/resources/templates/method.ejs +21 -2
- package/resources/templates/methodBodyRestCall.ejs +154 -20
- package/resources/templates/methodGroupInterface.ejs +28 -4
- package/resources/templates/model.ejs +133 -20
- package/resources/templates/page.ejs +40 -0
- package/resources/templates/serviceClientBody.ejs +12 -14
- package/resources/templates/serviceClientInterface.ejs +4 -3
- package/resources/templates/methodGroup.ejs +0 -7
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------------
|
|
2
|
+
${$project.pwshCommentHeader}
|
|
3
|
+
# ----------------------------------------------------------------------------------
|
|
4
|
+
param([switch]$Isolated)
|
|
5
|
+
$ErrorActionPreference = 'Stop'
|
|
6
|
+
|
|
7
|
+
$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
|
|
8
|
+
if(-not $Isolated) {
|
|
9
|
+
Write-Host -ForegroundColor Green 'Creating isolated process...'
|
|
10
|
+
& "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
$exportsFolder = Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.exportsFolder)}'
|
|
15
|
+
if(-not (Test-Path $exportsFolder)) {
|
|
16
|
+
Write-Error "Exports folder '$exportsFolder' was not found."
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$directories = Get-ChildItem -Directory -Path $exportsFolder
|
|
20
|
+
$hasProfiles = ($directories | Measure-Object).Count -gt 0
|
|
21
|
+
if(-not $hasProfiles) {
|
|
22
|
+
$directories = Get-Item -Path $exportsFolder
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
$docsFolder = Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.docsFolder)}'
|
|
26
|
+
if(Test-Path $docsFolder) {
|
|
27
|
+
$null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
|
|
28
|
+
}
|
|
29
|
+
$null = New-Item -ItemType Directory -Force -Path $docsFolder -ErrorAction SilentlyContinue
|
|
30
|
+
|
|
31
|
+
$moduleName = '${$project.moduleName}'
|
|
32
|
+
$rootModuleName = '${$project.rootModuleName}'
|
|
33
|
+
if ($rootModuleName -eq "")
|
|
34
|
+
{
|
|
35
|
+
$rootModuleName = $moduleName
|
|
36
|
+
}
|
|
37
|
+
$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot "./$moduleName.psd1")
|
|
38
|
+
$modulePath = $modulePsd1.FullName
|
|
39
|
+
|
|
40
|
+
# Load DLL to use build-time cmdlets
|
|
41
|
+
Import-Module -Name $modulePath
|
|
42
|
+
Import-Module -Name (Join-Path $PSScriptRoot "./bin/$moduleName.private.dll")
|
|
43
|
+
$instance = [${$project.serviceNamespace.moduleClass.declaration}]::Instance
|
|
44
|
+
# Module info is shared per profile
|
|
45
|
+
$moduleInfo = Get-Module -Name $moduleName
|
|
46
|
+
$parameterSetsInfo = Get-Module -Name "$moduleName.private"
|
|
47
|
+
|
|
48
|
+
$buildinFunctions = @("Export-CmdletSurface", "Export-ExampleStub", "Export-FormatPs1xml", "Export-HelpMarkdown", "Export-ModelSurface", "Export-ProxyCmdlet", "Export-Psd1", "Export-TestStub", "Get-CommonParameter", "Get-ModuleGuid", "Get-ScriptCmdlet")
|
|
49
|
+
|
|
50
|
+
function Test-FunctionSupported()
|
|
51
|
+
{
|
|
52
|
+
[CmdletBinding()]
|
|
53
|
+
Param (
|
|
54
|
+
[Parameter()]
|
|
55
|
+
[string]
|
|
56
|
+
$FunctionName
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
If ($buildinfunctions.Contains($FunctionName)) {
|
|
60
|
+
return $false
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
$cmdletName, $parameterSetName = $FunctionName.Split("_")
|
|
64
|
+
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity")) {
|
|
65
|
+
return $false
|
|
66
|
+
}
|
|
67
|
+
If ($cmdletName.StartsWith("New") -or $cmdletName.StartsWith("Set") -or $cmdletName.StartsWith("Update")) {
|
|
68
|
+
return $false
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
$parameterSetInfo = $parameterSetsInfo.ExportedCmdlets[$FunctionName]
|
|
72
|
+
foreach ($parameterInfo in $parameterSetInfo.Parameters.Values)
|
|
73
|
+
{
|
|
74
|
+
$category = (Get-ParameterAttribute -ParameterInfo $parameterInfo -AttributeName "CategoryAttribute").Categories
|
|
75
|
+
$invalideCategory = @('Query', 'Body')
|
|
76
|
+
if ($invalideCategory -contains $category)
|
|
77
|
+
{
|
|
78
|
+
return $false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$customFiles = Get-ChildItem -Path custom -Filter "$cmdletName.*"
|
|
83
|
+
if ($customFiles.Length -ne 0)
|
|
84
|
+
{
|
|
85
|
+
Write-Host -ForegroundColor Yellow "There are come custom files for $cmdletName, skip generate UX data for it."
|
|
86
|
+
return $false
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return $true
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function Get-MappedCmdletFromFunctionName()
|
|
93
|
+
{
|
|
94
|
+
[CmdletBinding()]
|
|
95
|
+
Param (
|
|
96
|
+
[Parameter()]
|
|
97
|
+
[string]
|
|
98
|
+
$FunctionName
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
$cmdletName, $parameterSetName = $FunctionName.Split("_")
|
|
102
|
+
|
|
103
|
+
return $cmdletName
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function Get-ParameterAttribute()
|
|
107
|
+
{
|
|
108
|
+
[CmdletBinding()]
|
|
109
|
+
Param (
|
|
110
|
+
[Parameter()]
|
|
111
|
+
[System.Management.Automation.ParameterMetadata]
|
|
112
|
+
$ParameterInfo,
|
|
113
|
+
[Parameter()]
|
|
114
|
+
[String]
|
|
115
|
+
$AttributeName
|
|
116
|
+
)
|
|
117
|
+
return $ParameterInfo.Attributes | Where-Object { $_.TypeId.Name -eq $AttributeName }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function Get-CmdletAttribute()
|
|
121
|
+
{
|
|
122
|
+
[CmdletBinding()]
|
|
123
|
+
Param (
|
|
124
|
+
[Parameter()]
|
|
125
|
+
[System.Management.Automation.CommandInfo]
|
|
126
|
+
$CmdletInfo,
|
|
127
|
+
[Parameter()]
|
|
128
|
+
[String]
|
|
129
|
+
$AttributeName
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
return $CmdletInfo.ImplementingType.GetTypeInfo().GetCustomAttributes([System.object], $true) | Where-Object { $_.TypeId.Name -eq $AttributeName }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function Get-CmdletDescription()
|
|
136
|
+
{
|
|
137
|
+
[CmdletBinding()]
|
|
138
|
+
Param (
|
|
139
|
+
[Parameter()]
|
|
140
|
+
[String]
|
|
141
|
+
$CmdletName
|
|
142
|
+
)
|
|
143
|
+
$helpInfo = Get-Help $CmdletName -Full
|
|
144
|
+
|
|
145
|
+
$description = $helpInfo.Description.Text
|
|
146
|
+
if ($null -eq $description)
|
|
147
|
+
{
|
|
148
|
+
return ""
|
|
149
|
+
}
|
|
150
|
+
return $description
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# Test whether the parameter is from swagger http path
|
|
154
|
+
function Test-ParameterFromSwagger()
|
|
155
|
+
{
|
|
156
|
+
[CmdletBinding()]
|
|
157
|
+
Param (
|
|
158
|
+
[Parameter()]
|
|
159
|
+
[System.Management.Automation.ParameterMetadata]
|
|
160
|
+
$ParameterInfo
|
|
161
|
+
)
|
|
162
|
+
$category = (Get-ParameterAttribute -ParameterInfo $ParameterInfo -AttributeName "CategoryAttribute").Categories
|
|
163
|
+
$doNotExport = Get-ParameterAttribute -ParameterInfo $ParameterInfo -AttributeName "DoNotExportAttribute"
|
|
164
|
+
if ($null -ne $doNotExport)
|
|
165
|
+
{
|
|
166
|
+
return $false
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
$valideCategory = @('Path')
|
|
170
|
+
if ($valideCategory -contains $category)
|
|
171
|
+
{
|
|
172
|
+
return $true
|
|
173
|
+
}
|
|
174
|
+
return $false
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function New-ExampleForParameterSet()
|
|
178
|
+
{
|
|
179
|
+
[CmdletBinding()]
|
|
180
|
+
Param (
|
|
181
|
+
[Parameter()]
|
|
182
|
+
[System.Management.Automation.CommandInfo]
|
|
183
|
+
$ParameterSetInfo
|
|
184
|
+
)
|
|
185
|
+
$parameters = $ParameterSetInfo.Parameters.Values | Where-Object { Test-ParameterFromSwagger $_ }
|
|
186
|
+
$result = @()
|
|
187
|
+
foreach ($parameter in $parameters)
|
|
188
|
+
{
|
|
189
|
+
$category = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "CategoryAttribute").Categories
|
|
190
|
+
$sourceName = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "InfoAttribute").SerializedName
|
|
191
|
+
$name = $parameter.Name
|
|
192
|
+
$result += [ordered]@{
|
|
193
|
+
name = "-$Name"
|
|
194
|
+
value = "[$category.$sourceName]"
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return $result
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function New-ParameterArrayInParameterSet()
|
|
202
|
+
{
|
|
203
|
+
[CmdletBinding()]
|
|
204
|
+
Param (
|
|
205
|
+
[Parameter()]
|
|
206
|
+
[System.Management.Automation.CommandInfo]
|
|
207
|
+
$ParameterSetInfo
|
|
208
|
+
)
|
|
209
|
+
$parameters = $ParameterSetInfo.Parameters.Values | Where-Object { Test-ParameterFromSwagger $_ }
|
|
210
|
+
$result = @()
|
|
211
|
+
foreach ($parameter in $parameters)
|
|
212
|
+
{
|
|
213
|
+
$isMandatory = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "ParameterAttribute").Mandatory
|
|
214
|
+
$parameterName = $parameter.Name
|
|
215
|
+
$parameterType = $parameter.ParameterType.ToString().Split('.')[1]
|
|
216
|
+
if ($parameter.SwitchParameter)
|
|
217
|
+
{
|
|
218
|
+
$parameterSignature = "-$parameterName"
|
|
219
|
+
}
|
|
220
|
+
else
|
|
221
|
+
{
|
|
222
|
+
$parameterSignature = "-$parameterName <$parameterType>"
|
|
223
|
+
}
|
|
224
|
+
if ($parameterName -eq "SubscriptionId")
|
|
225
|
+
{
|
|
226
|
+
$isMandatory = $false
|
|
227
|
+
}
|
|
228
|
+
if (-not $isMandatory)
|
|
229
|
+
{
|
|
230
|
+
$parameterSignature = "[$parameterSignature]"
|
|
231
|
+
}
|
|
232
|
+
$result += $parameterSignature
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return $result
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function New-MetadataForParameterSet()
|
|
239
|
+
{
|
|
240
|
+
[CmdletBinding()]
|
|
241
|
+
Param (
|
|
242
|
+
[Parameter()]
|
|
243
|
+
[System.Management.Automation.CommandInfo]
|
|
244
|
+
$ParameterSetInfo
|
|
245
|
+
)
|
|
246
|
+
$httpAttribute = Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "HttpPathAttribute"
|
|
247
|
+
$httpPath = $httpAttribute.Path
|
|
248
|
+
$apiVersion = $httpAttribute.ApiVersion
|
|
249
|
+
$provider = [System.Text.RegularExpressions.Regex]::New("/providers/([\w+\.]+)/").Match($httpPath).Groups[1].Value
|
|
250
|
+
$resourcePath = "/" + $httpPath.Split("$provider/")[1]
|
|
251
|
+
$resourceType = [System.Text.RegularExpressions.Regex]::New("/([\w]+)/\{\w+\}").Matches($resourcePath) | ForEach-Object {$_.groups[1].Value} | Join-String -Separator "/"
|
|
252
|
+
$cmdletName = Get-MappedCmdletFromFunctionName $ParameterSetInfo.Name
|
|
253
|
+
$description = (Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "DescriptionAttribute").Description
|
|
254
|
+
[object[]]$example = New-ExampleForParameterSet $ParameterSetInfo
|
|
255
|
+
[string[]]$signature = New-ParameterArrayInParameterSet $ParameterSetInfo
|
|
256
|
+
|
|
257
|
+
return @{
|
|
258
|
+
Path = $httpPath
|
|
259
|
+
Provider = $provider
|
|
260
|
+
ResourceType = $resourceType
|
|
261
|
+
ApiVersion = $apiVersion
|
|
262
|
+
CmdletName = $cmdletName
|
|
263
|
+
Description = $description
|
|
264
|
+
Example = $example
|
|
265
|
+
Signature = @{
|
|
266
|
+
parameters = $signature
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function Merge-WithExistCmdletMetadata()
|
|
272
|
+
{
|
|
273
|
+
[CmdletBinding()]
|
|
274
|
+
Param (
|
|
275
|
+
[Parameter()]
|
|
276
|
+
[System.Collections.Specialized.OrderedDictionary]
|
|
277
|
+
$ExistedCmdletInfo,
|
|
278
|
+
[Parameter()]
|
|
279
|
+
[Hashtable]
|
|
280
|
+
$ParameterSetMetadata
|
|
281
|
+
)
|
|
282
|
+
$ExistedCmdletInfo.help.parameterSets += $ParameterSetMetadata.Signature
|
|
283
|
+
$ExistedCmdletInfo.examples += [ordered]@{
|
|
284
|
+
description = $ParameterSetMetadata.Description
|
|
285
|
+
parameters = $ParameterSetMetadata.Example
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return $ExistedCmdletInfo
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function New-MetadataForCmdlet()
|
|
292
|
+
{
|
|
293
|
+
[CmdletBinding()]
|
|
294
|
+
Param (
|
|
295
|
+
[Parameter()]
|
|
296
|
+
[Hashtable]
|
|
297
|
+
$ParameterSetMetadata
|
|
298
|
+
)
|
|
299
|
+
$cmdletName = $ParameterSetMetadata.CmdletName
|
|
300
|
+
$description = Get-CmdletDescription $cmdletName
|
|
301
|
+
$result = [ordered]@{
|
|
302
|
+
name = $cmdletName
|
|
303
|
+
description = $description
|
|
304
|
+
path = $ParameterSetMetadata.Path
|
|
305
|
+
help = [ordered]@{
|
|
306
|
+
learnMore = [ordered]@{
|
|
307
|
+
url = "https://learn.microsoft.com/powershell/module/$rootModuleName/$cmdletName".ToLower()
|
|
308
|
+
}
|
|
309
|
+
parameterSets = @()
|
|
310
|
+
}
|
|
311
|
+
examples = @()
|
|
312
|
+
}
|
|
313
|
+
$result = Merge-WithExistCmdletMetadata -ExistedCmdletInfo $result -ParameterSetMetadata $ParameterSetMetadata
|
|
314
|
+
return $result
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-functionSupported($_) }
|
|
318
|
+
$resourceTypes = @{}
|
|
319
|
+
foreach ($parameterSetName in $parameterSets)
|
|
320
|
+
{
|
|
321
|
+
$cmdletInfo = $parameterSetsInfo.ExportedCommands[$parameterSetName]
|
|
322
|
+
$parameterSetMetadata = New-MetadataForParameterSet -ParameterSetInfo $cmdletInfo
|
|
323
|
+
$cmdletName = $parameterSetMetadata.CmdletName
|
|
324
|
+
if (-not ($moduleInfo.ExportedCommands.ContainsKey($cmdletName)))
|
|
325
|
+
{
|
|
326
|
+
continue
|
|
327
|
+
}
|
|
328
|
+
if ($resourceTypes.ContainsKey($parameterSetMetadata.ResourceType))
|
|
329
|
+
{
|
|
330
|
+
$ExistedCmdletInfo = $resourceTypes[$parameterSetMetadata.ResourceType].commands | Where-Object { $_.name -eq $cmdletName }
|
|
331
|
+
if ($ExistedCmdletInfo)
|
|
332
|
+
{
|
|
333
|
+
$ExistedCmdletInfo = Merge-WithExistCmdletMetadata -ExistedCmdletInfo $ExistedCmdletInfo -ParameterSetMetadata $parameterSetMetadata
|
|
334
|
+
}
|
|
335
|
+
else
|
|
336
|
+
{
|
|
337
|
+
$cmdletInfo = New-MetadataForCmdlet -ParameterSetMetadata $parameterSetMetadata
|
|
338
|
+
$resourceTypes[$parameterSetMetadata.ResourceType].commands += $cmdletInfo
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else
|
|
342
|
+
{
|
|
343
|
+
$cmdletInfo = New-MetadataForCmdlet -ParameterSetMetadata $parameterSetMetadata
|
|
344
|
+
$resourceTypes[$parameterSetMetadata.ResourceType] = [ordered]@{
|
|
345
|
+
resourceType = $parameterSetMetadata.ResourceType
|
|
346
|
+
apiVersion = $parameterSetMetadata.ApiVersion
|
|
347
|
+
learnMore = @{
|
|
348
|
+
url = "https://learn.microsoft.com/powershell/module/$rootModuleName".ToLower()
|
|
349
|
+
}
|
|
350
|
+
commands = @($cmdletInfo)
|
|
351
|
+
provider = $parameterSetMetadata.Provider
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
$UXFolder = '${$lib.path.relative($project.baseFolder, $project.uxFolder)}'
|
|
357
|
+
if (Test-Path $UXFolder)
|
|
358
|
+
{
|
|
359
|
+
Remove-Item -Path $UXFolder -Recurse
|
|
360
|
+
}
|
|
361
|
+
$null = New-Item -ItemType Directory -Path $UXFolder
|
|
362
|
+
|
|
363
|
+
foreach ($resourceType in $resourceTypes.Keys)
|
|
364
|
+
{
|
|
365
|
+
$resourceTypeFileName = $resourceType -replace "/", "-"
|
|
366
|
+
if ($resourceTypeFileName -eq "")
|
|
367
|
+
{
|
|
368
|
+
continue
|
|
369
|
+
}
|
|
370
|
+
$resourceTypeInfo = $resourceTypes[$resourceType]
|
|
371
|
+
$provider = $resourceTypeInfo.provider
|
|
372
|
+
$providerFolder = "$UXFolder/$provider"
|
|
373
|
+
if (-not (Test-Path $providerFolder))
|
|
374
|
+
{
|
|
375
|
+
$null = New-Item -ItemType Directory -Path $providerFolder
|
|
376
|
+
}
|
|
377
|
+
$resourceTypeInfo.Remove("provider")
|
|
378
|
+
$resourceTypeInfo | ConvertTo-Json -Depth 10 | Out-File "$providerFolder/$resourceTypeFileName.json"
|
|
379
|
+
}
|
|
@@ -14,7 +14,7 @@ To generate documentation, the process is now integrated into the `build-module.
|
|
|
14
14
|
To test the cmdlets, we use [Pester](https://github.com/pester/Pester). Tests scripts (`.ps1`) should be added to the `${$lib.path.relative($project.baseFolder, $project.testFolder)}` folder. To execute the Pester tests, run the `test-module.ps1` script. This will run all tests in `playback` mode within the `test` folder. To read more about testing cmdlets, look at the [README.md](${$lib.path.relative($project.baseFolder, $project.examplesFolder)}/README.md) in the `${$lib.path.relative($project.baseFolder, $project.examplesFolder)}` folder.
|
|
15
15
|
|
|
16
16
|
## Packing `${$project.moduleName}`
|
|
17
|
-
To pack `${$project.moduleName}` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://
|
|
17
|
+
To pack `${$project.moduleName}` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://learn.microsoft.com/powershell/module/powershellget/register-psrepository). Additionally, this package is in a format for distribution to the [PSGallery](https://www.powershellgallery.com/). For signing an Azure module, please contact the [Azure PowerShell](https://github.com/Azure/azure-powershell) team.
|
|
18
18
|
|
|
19
19
|
## Module Script Details
|
|
20
20
|
There are multiple scripts created for performing different actions for developing `${$project.moduleName}`.
|
|
@@ -8,7 +8,7 @@ This directory contains a module to handle *internal only* cmdlets. Cmdlets that
|
|
|
8
8
|
- Packaged: yes
|
|
9
9
|
|
|
10
10
|
## Details
|
|
11
|
-
The `${$lib.path.relative($project.internalFolder, $project.psm1Internal)}` file is generated to this folder. This module file handles the hidden cmdlets. These cmdlets will not be exported by `${$project.moduleName}`. Instead, this sub-module is imported by the `${$lib.path.relative($project.internalFolder, $project.psm1Custom)}` module, allowing you to use hidden cmdlets in your custom, exposed cmdlets. To call these cmdlets in your custom scripts, simply use [module-qualified calls](https://
|
|
11
|
+
The `${$lib.path.relative($project.internalFolder, $project.psm1Internal)}` file is generated to this folder. This module file handles the hidden cmdlets. These cmdlets will not be exported by `${$project.moduleName}`. Instead, this sub-module is imported by the `${$lib.path.relative($project.internalFolder, $project.psm1Custom)}` module, allowing you to use hidden cmdlets in your custom, exposed cmdlets. To call these cmdlets in your custom scripts, simply use [module-qualified calls](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_command_precedence?view=powershell-6#qualified-names). For example, `${$project.moduleName}.internal\Get-Example` would call an internal cmdlet named `Get-Example`.
|
|
12
12
|
|
|
13
13
|
## Purpose
|
|
14
14
|
This allows you to include REST specifications for services that you *do not wish to expose from your module*, but simply want to call within custom cmdlets. For example, if you want to make a custom cmdlet that uses `Storage` services, you could include a simplified `Storage` REST specification that has only the operations you need. When you run the generator and build this module, note the generated `Storage` cmdlets. Then, in your readme configuration, use [cmdlet hiding](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md#cmdlet-hiding-exportation-suppression) on the `Storage` cmdlets and they will *only be exposed to the custom cmdlets* you want to write, and not be exported as part of `${$project.moduleName}`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function New-AzDeployment {
|
|
2
|
-
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Resources.Models.
|
|
2
|
+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.Resources.Models.IDeploymentExtended')]
|
|
3
3
|
[CmdletBinding(DefaultParameterSetName='CreateWithTemplateFileParameterFile', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
|
|
4
4
|
[Microsoft.Azure.PowerShell.Cmdlets.Resources.Description('You can provide the template and parameters directly in the request or link to JSON files.')]
|
|
5
5
|
param(
|
|
@@ -8,4 +8,4 @@ This directory contains the documentation of the cmdlets for the `Az.Resources`
|
|
|
8
8
|
- Packaged: yes
|
|
9
9
|
|
|
10
10
|
## Details
|
|
11
|
-
The process of documentation generation loads `Az.Resources` and analyzes the exported cmdlets from the module. It recognizes the [help comments](https://
|
|
11
|
+
The process of documentation generation loads `Az.Resources` and analyzes the exported cmdlets from the module. It recognizes the [help comments](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) that are generated into the scripts in the `..\exports` folder. Additionally, when writing custom cmdlets in the `..\custom` folder, you can use the help comments syntax, which decorate the exported scripts at build-time. The documentation examples are taken from the `..\examples` folder.
|
|
@@ -14,7 +14,7 @@ To generate documentation, the process is now integrated into the `build-module.
|
|
|
14
14
|
To test the cmdlets, we use [Pester](https://github.com/pester/Pester). Tests scripts (`.ps1`) should be added to the `test` folder. To execute the Pester tests, run the `test-module.ps1` script. This will run all tests in `playback` mode within the `test` folder. To read more about testing cmdlets, look at the [README.md](examples/README.md) in the `examples` folder.
|
|
15
15
|
|
|
16
16
|
## Packing `Az.Resources`
|
|
17
|
-
To pack `Az.Resources` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://
|
|
17
|
+
To pack `Az.Resources` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://learn.microsoft.com/powershell/module/powershellget/register-psrepository). Additionally, this package is in a format for distribution to the [PSGallery](https://www.powershellgallery.com/). For signing an Azure module, please contact the [Azure PowerShell](https://github.com/Azure/azure-powershell) team.
|
|
18
18
|
|
|
19
19
|
## Module Script Details
|
|
20
20
|
There are multiple scripts created for performing different actions for developing `Az.Resources`.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<projectUrl>https://github.com/Azure/azure-powershell</projectUrl>
|
|
11
11
|
<description>Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
|
|
12
12
|
|
|
13
|
-
For more information on account credential management, please visit the following: https://
|
|
13
|
+
For more information on account credential management, please visit the following: https://learn.microsoft.com/powershell/azure/authenticate-azureps</description>
|
|
14
14
|
<releaseNotes>* Added 'SshCredentialFactory' to support get ssh credential of vm from msal.
|
|
15
15
|
* Fixed the bug of cmdlet fails when -DefaultProfile is set to service principal login context. [#16617]
|
|
16
16
|
* Fixed the issue that authorization does not work in Dogfood environment</releaseNotes>
|
|
@@ -32,7 +32,7 @@ Copyright = 'Microsoft Corporation. All rights reserved.'
|
|
|
32
32
|
# Description of the functionality provided by this module
|
|
33
33
|
Description = 'Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
|
|
34
34
|
|
|
35
|
-
For more information on account credential management, please visit the following: https://
|
|
35
|
+
For more information on account credential management, please visit the following: https://learn.microsoft.com/powershell/azure/authenticate-azureps'
|
|
36
36
|
|
|
37
37
|
# Minimum version of the PowerShell engine required by this module
|
|
38
38
|
PowerShellVersion = '5.1'
|