- Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathGenerateHelp.ps1
65 lines (58 loc) · 2.39 KB
/
GenerateHelp.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
[CmdletBinding()]
Param(
$ModulesToGenerate=@(),
[string] $ModuleMappingConfigPath= (Join-Path$PSScriptRoot"..\config\ModulesMapping.jsonc")
)
# Install PlatyPS
if (!(Get-Module-Name PlatyPS -ListAvailable)) {
Install-Module PlatyPS -Force
}
Import-Module PlatyPS -Force -Scope Global
# Errors in PlatyPS validation.
$ErrorActionPreference='Continue'
$LASTEXITCODE=$null
if ($PSEdition-ne'Core') {
Write-Error'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.'
}
if (-not (Test-Path$ModuleMappingConfigPath)) {
Write-Error"Module mapping file not be found: $ModuleMappingConfigPath."
}
if ($ModulesToGenerate.Count-eq0) {
[HashTable] $ModuleMapping=Get-Content$ModuleMappingConfigPath|ConvertFrom-Json-AsHashTable
$ModulesToGenerate=$ModuleMapping.Keys
}
$ModulePrefix="Microsoft.Graph"
Import-Module (Join-Path$PSScriptRoot"..\src\Authentication\Authentication\artifacts\Microsoft.Graph.Authentication.psd1") -Force -Scope Global
$ModulesToGenerate|ForEach-Object {
$ModuleName=$_
$modulePath=Join-Path$PSScriptRoot"..\src\$ModuleName\$ModuleName\$ModulePrefix.$ModuleName.psd1"
Write-Host"Current Module Path $modulePath"
#Handle Beta docs and examples
$betaModuleDocs=Join-Path$PSScriptRoot"..\src\$ModuleName\$ModuleName\docs\v1.0-beta"
$betaModuleExamples=Join-Path$PSScriptRoot"..\src\$ModuleName\$ModuleName\examples\v1.0-beta"
Write-Host$betaModuleDocs
if (Test-Path$betaModuleDocs) {
git add $betaModuleDocs
git add $betaModuleExamples
}
else {
Write-Warning"Beta Docs for $ModuleName not Found"
}
#Handle v1.0 docs and examples
$v1ModuleDocs=Join-Path$PSScriptRoot"..\src\$ModuleName\$ModuleName\docs\v1.0"
$v1ModuleExamples=Join-Path$PSScriptRoot"..\src\$ModuleName\$ModuleName\examples\v1.0"
Write-Host$v1ModuleDocs
if (Test-Path$v1ModuleDocs) {
Write-Host$v1ModuleDocs
git add $v1ModuleDocs
git add $v1ModuleExamples
}
else {
Write-Warning"v1.0 Docs for $ModuleName not Found"
}
git status
git commit -m "Docs Generation for $ModuleName [run ci]"
}
Write-Host-ForegroundColor Green "-------------Done-------------"