|
1 |
| -param ($cliDocsFolderPath) |
| 1 | +param ($cliDocsFolderPath, $workingDirectory) |
2 | 2 |
|
3 | 3 | if ($null -eq $cliDocsFolderPath -or $cliDocsFolderPath -eq "") {
|
4 | 4 | write-host "Please pass path to cli docs folder"
|
5 | 5 | exit
|
6 | 6 | }
|
7 | 7 |
|
| 8 | +if ($null -eq $workingDirectory -or $workingDirectory -eq "") { |
| 9 | + write-host "Please pass path to working directory" |
| 10 | + exit |
| 11 | +} |
| 12 | + |
8 | 13 | $allCommands = Get-ChildItem -Path "$cliDocsFolderPath\docs\cmd\*.mdx" -Recurse -Force -Exclude "_global*"
|
9 | 14 |
|
10 | 15 | $globalContent = Get-Content "$cliDocsFolderPath\docs\cmd\_global.mdx"
|
11 | 16 | $globalContent = $globalContent.Replace('```md definition-list', '').Replace('```', '')
|
12 | 17 | [hashtable]$global = @{}
|
13 | 18 | $global.Add('content', $globalContent)
|
14 |
| -New-Object -TypeName psobject -Property $global | ConvertTo-Json | Out-File "..\data\global.json" |
| 19 | +New-Object -TypeName psobject -Property $global | ConvertTo-Json | Out-File "$workingDirectory\data\global.json" |
15 | 20 |
|
16 | 21 | [hashtable]$commandSnippets = @{}
|
17 | 22 | [hashtable]$m365Model = @{}
|
@@ -65,11 +70,11 @@ $orderedCommandSnippets = [ordered]@{}
|
65 | 70 | foreach ($Item in ($commandSnippets.GetEnumerator() | Sort-Object -Property Key)) {
|
66 | 71 | $orderedCommandSnippets[$Item.Key] = $Item.Value
|
67 | 72 | }
|
68 |
| -New-Object -TypeName psobject -Property $orderedCommandSnippets | ConvertTo-Json | Out-File "..\snippets\cliForMicrosoft365.code-snippets" |
| 73 | +New-Object -TypeName psobject -Property $orderedCommandSnippets | ConvertTo-Json | Out-File "$workingDirectory\snippets\cliForMicrosoft365.code-snippets" |
69 | 74 |
|
70 | 75 | $m365Model.Add('commands', $commands)
|
71 | 76 | $orderedM365Model = [ordered]@{}
|
72 | 77 | foreach ($Item in ($m365Model.GetEnumerator() | Sort-Object -Property Key)) {
|
73 | 78 | $orderedM365Model[$Item.Key] = $Item.Value
|
74 | 79 | }
|
75 |
| -New-Object -TypeName psobject -Property $orderedM365Model | ConvertTo-Json | Out-File "..\data\m365Model.json" |
| 80 | +New-Object -TypeName psobject -Property $orderedM365Model | ConvertTo-Json | Out-File "$workingDirectory\data\m365Model.json" |
0 commit comments