Skip to content

Commit 8eff8b8

Browse files
Compress MgCommandMetadata.json to reduce whitespace/package size for Microsoft.Graph.Authentication (#3346)
* PostGeneration\NewCommandMetadata: Compress MgCommandMetadata.json with `-Compress` on `ConvertTo-Json` * PostGeneration\AuthModuleMetadata: Compress MgCommandMetadata.json with `-Compress` on `ConvertTo-Json` --------- Co-authored-by: Ramses Sanchez-Hernandez <63934382+ramsessanchez@users.noreply.github.com>
1 parent 8a4bcd6 commit 8eff8b8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

tools/PostGeneration/AuthModuleMetadata.ps1

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if ($null -eq $ConnectCommand) {
2020
Uri = $null
2121
}
2222
# Update the file
23-
$FinalConnectMgGraphOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
23+
$FinalConnectMgGraphOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
2424

2525
$FinalConnectMgGraphOutPut | Set-Content -Path $CommandMetadataFile -Force
2626
Write-Host "Connect-MgGraph command added to the list of commands in MgCommandMetadata.json"
@@ -43,7 +43,7 @@ if ($null -eq $AddEnvironmentCommand) {
4343
Uri = $null
4444
}
4545
# Update the file
46-
$FinalAddEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
46+
$FinalAddEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
4747

4848
$FinalAddEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force
4949
Write-Host "Add-MgEnvironment command added to the list of commands in MgCommandMetadata.json"
@@ -65,7 +65,7 @@ if ($null -eq $GetEnvironmentCommand) {
6565
Uri = $null
6666
}
6767
# Update the file
68-
$FinalGetEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
68+
$FinalGetEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
6969

7070
$FinalGetEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force
7171
Write-Host "Get-MgEnvironment command added to the list of commands in MgCommandMetadata.json"
@@ -87,7 +87,7 @@ if ($null -eq $RemoveEnvironmentCommand) {
8787
Uri = $null
8888
}
8989
# Update the file
90-
$FinalRemoveEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
90+
$FinalRemoveEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
9191

9292
$FinalRemoveEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force
9393
Write-Host "Remove-MgEnvironment command added to the list of commands in MgCommandMetadata.json"
@@ -109,7 +109,7 @@ if ($null -eq $SetEnvironmentCommand) {
109109
Uri = $null
110110
}
111111
# Update the file
112-
$FinalSetEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
112+
$FinalSetEnvironmentOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
113113

114114
$FinalSetEnvironmentOutPut | Set-Content -Path $CommandMetadataFile -Force
115115
Write-Host "Set-MgEnvironment command added to the list of commands in MgCommandMetadata.json"
@@ -131,7 +131,7 @@ if ($null -eq $DisconnectCommand) {
131131
Uri = $null
132132
}
133133
# Update the file
134-
$FinalDisconnectOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
134+
$FinalDisconnectOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
135135

136136
$FinalDisconnectOutPut | Set-Content -Path $CommandMetadataFile -Force
137137
Write-Host "Disconnect-MgGraph command added to the list of commands in MgCommandMetadata.json"
@@ -153,7 +153,7 @@ if ($null -eq $FindCommand) {
153153
Uri = $null
154154
}
155155
# Update the file
156-
$FinalFindOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
156+
$FinalFindOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
157157

158158
$FinalFindOutPut | Set-Content -Path $CommandMetadataFile -Force
159159
Write-Host "Find-MgGraphCommand command added to the list of commands in MgCommandMetadata.json"
@@ -175,7 +175,7 @@ if ($null -eq $FindPermissionCommand) {
175175
Uri = $null
176176
}
177177
# Update the file
178-
$FinalFindPermissionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
178+
$FinalFindPermissionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
179179

180180
$FinalFindPermissionOutPut | Set-Content -Path $CommandMetadataFile -Force
181181
Write-Host "Find-MgGraphPermission command added to the list of commands in MgCommandMetadata.json"
@@ -197,7 +197,7 @@ if ($null -eq $GetContextCommand) {
197197
Uri = $null
198198
}
199199
# Update the file
200-
$FinalGetContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
200+
$FinalGetContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
201201

202202
$FinalGetContextOutPut | Set-Content -Path $CommandMetadataFile -Force
203203
Write-Host "Get-MgContext command added to the list of commands in MgCommandMetadata.json"
@@ -219,7 +219,7 @@ if ($null -eq $GetGraphOptionCommand) {
219219
Uri = $null
220220
}
221221
# Update the file
222-
$FinalGetGraphOptionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
222+
$FinalGetGraphOptionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
223223

224224
$FinalGetGraphOptionOutPut | Set-Content -Path $CommandMetadataFile -Force
225225
Write-Host "Get-MgGraphOption command added to the list of commands in MgCommandMetadata.json"
@@ -241,7 +241,7 @@ if ($null -eq $GetRequestContextCommand) {
241241
Uri = $null
242242
}
243243
# Update the file
244-
$FinalGetRequestContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
244+
$FinalGetRequestContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
245245

246246
$FinalGetRequestContextOutPut | Set-Content -Path $CommandMetadataFile -Force
247247
Write-Host "Get-MgRequestContext command added to the list of commands in MgCommandMetadata.json"
@@ -263,7 +263,7 @@ if ($null -eq $InvokeRequestCommand) {
263263
Uri = $null
264264
}
265265
# Update the file
266-
$FinalInvokeRequestOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
266+
$FinalInvokeRequestOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
267267

268268
$FinalInvokeRequestOutPut | Set-Content -Path $CommandMetadataFile -Force
269269
Write-Host "Invoke-MgGraphRequest command added to the list of commands in MgCommandMetadata.json"
@@ -285,7 +285,7 @@ if ($null -eq $SetGraphOptionCommand) {
285285
Uri = $null
286286
}
287287
# Update the file
288-
$FinalSetGraphOptionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
288+
$FinalSetGraphOptionOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
289289

290290
$FinalSetGraphOptionOutPut | Set-Content -Path $CommandMetadataFile -Force
291291
Write-Host "Set-MgGraphOption command added to the list of commands in MgCommandMetadata.json"
@@ -307,7 +307,7 @@ if ($null -eq $SetRequestContextCommand) {
307307
Uri = $null
308308
}
309309
# Update the file
310-
$FinalSetRequestContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10
310+
$FinalSetRequestContextOutPut = $CommandMetadata | ConvertTo-Json -Depth 10 -Compress
311311

312312
$FinalSetRequestContextOutPut | Set-Content -Path $CommandMetadataFile -Force
313313
Write-Host "Set-MgRequestContext command added to the list of commands in MgCommandMetadata.json"

tools/PostGeneration/NewCommandMetadata.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ if ($CommandPathMapping.Count -eq 0) {
161161
}
162162
else {
163163
Write-Debug "Writing metadata to $MgCommandMetadataFile."
164-
$CommandPathMapping.GetEnumerator() | Sort-Object Name | Select-Object -ExpandProperty Value | ConvertTo-Json -Depth 4 | Out-File -FilePath $MgCommandMetadataFile
164+
$CommandPathMapping.GetEnumerator() | Sort-Object Name | Select-Object -ExpandProperty Value | ConvertTo-Json -Depth 4 -Compress | Out-File -FilePath $MgCommandMetadataFile
165165
}
166166
$stopwatch.Stop()
167167
Write-Debug "Generated command metadata file in '$($Stopwatch.Elapsed.TotalSeconds)`s."

0 commit comments

Comments
 (0)