Skip to content

Commit a83629c

Browse files
committed
Updating files from the sdk
1 parent c7bdb0e commit a83629c

File tree

2 files changed

+134
-16
lines changed

2 files changed

+134
-16
lines changed

scripts/FileCopy.ps1

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT License.
33
Param(
44
$ModulesToGenerate = @(),
5-
[string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "../../msgraph-sdk-powershell/config/ModulesMapping.jsonc"),
5+
[string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "../microsoftgraph/config/ModulesMapping.jsonc"),
66
[string] $SDKDocsPath = (Join-Path $PSScriptRoot "../../msgraph-sdk-powershell/src"),
77
[string] $WorkLoadDocsPath = (Join-Path $PSScriptRoot "../microsoftgraph")
88
)
@@ -93,33 +93,34 @@ function Copy-Files{
9393
Write-Host -ForegroundColor DarkYellow "Copying v1 markdown files to " $destination
9494
Get-ChildItem $DocPath -Recurse -File | ForEach-Object {
9595
Write-Host "File $_"
96-
Copy-Item $_ -Destination $destination
96+
Write-Host "Destination $destination"
97+
#Copy-Item $_ -Destination $destination
9798
}
9899
}
99100
}
100101
}
101102

102103

103104

104-
Set-Location microsoftgraph-docs-powershell
105-
$date = Get-Date -Format "dd-MM-yyyy"
106-
$proposedBranch = "weekly_v2_docs_update_$date"
107-
$exists = git branch -l $proposedBranch
108-
if ([string]::IsNullOrEmpty($exists)) {
109-
git checkout -b $proposedBranch
110-
}else{
111-
Write-Host "Branch already exists"
112-
git checkout $proposedBranch
113-
}
114-
if (-not (Test-Path $ModuleMappingConfigPath)) {
115-
Write-Error "Module mapping file not be found: $ModuleMappingConfigPath."
116-
}
105+
# Set-Location microsoftgraph-docs-powershell
106+
# $date = Get-Date -Format "dd-MM-yyyy"
107+
# $proposedBranch = "weekly_v2_docs_update_$date"
108+
# $exists = git branch -l $proposedBranch
109+
# if ([string]::IsNullOrEmpty($exists)) {
110+
# git checkout -b $proposedBranch
111+
# }else{
112+
# Write-Host "Branch already exists"
113+
# git checkout $proposedBranch
114+
# }
115+
# if (-not (Test-Path $ModuleMappingConfigPath)) {
116+
# Write-Error "Module mapping file not be found: $ModuleMappingConfigPath."
117+
# }
117118
if ($ModulesToGenerate.Count -eq 0) {
118119
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable
119120
$ModulesToGenerate = $ModuleMapping.Keys
120121
}
121122

122-
Set-Location ..\microsoftgraph-docs-powershell
123+
# Set-Location ..\microsoftgraph-docs-powershell
123124
Write-Host -ForegroundColor Green "-------------finished checking out to today's branch-------------"
124125
Start-Copy -ModulesToGenerate $ModulesToGenerate
125126
Write-Host -ForegroundColor Green "-------------Done-------------"

scripts/RemoveWrongDocs.ps1

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
Param(
4+
$ModulesToGenerate = @(),
5+
[string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "../microsoftgraph/config/ModulesMapping.jsonc"),
6+
[string] $SDKDocsPath = (Join-Path $PSScriptRoot "../../msgraph-sdk-powershell/src"),
7+
[string] $WorkLoadDocsPath = (Join-Path $PSScriptRoot "../microsoftgraph")
8+
)
9+
function Get-GraphMapping {
10+
$graphMapping = @{}
11+
$graphMapping.Add("v1.0", "v1.0")
12+
$graphMapping.Add("beta", "beta")
13+
return $graphMapping
14+
}
15+
16+
function Start-Copy {
17+
Param(
18+
$ModulesToGenerate = @()
19+
)
20+
21+
$ModulePrefix = "Microsoft.Graph"
22+
$GraphMapping = Get-GraphMapping
23+
$GraphMapping.Keys | ForEach-Object {
24+
$graphProfile = $_
25+
$profilePath = "graph-powershell-1.0"
26+
if($graphProfile -eq "beta"){
27+
$profilePath = "graph-powershell-beta"
28+
}
29+
Get-FilesByProfile -GraphProfile $graphProfile -GraphProfilePath $profilePath -ModulePrefix $ModulePrefix -ModulesToGenerate $ModulesToGenerate
30+
}
31+
32+
}
33+
function Get-FilesByProfile{
34+
Param(
35+
[ValidateSet("beta", "v1.0")]
36+
[string] $GraphProfile = "v1.0",
37+
[ValidateNotNullOrEmpty()]
38+
[string] $GraphProfilePath = "graph-powershell-1.0",
39+
[ValidateNotNullOrEmpty()]
40+
[string] $ModulePrefix = "Microsoft.Graph",
41+
[ValidateNotNullOrEmpty()]
42+
$ModulesToGenerate = @()
43+
)
44+
45+
$ModulesToGenerate | ForEach-Object {
46+
$ModuleName = $_
47+
$docs = Join-Path $SDKDocsPath $ModuleName $GraphProfile "docs"
48+
Copy-Files -DocPath $docs -GraphProfilePath $GraphProfilePath -Module $ModuleName -ModulePrefix $ModulePrefix -GraphProfile $GraphProfile
49+
}
50+
51+
}
52+
function Copy-Files{
53+
param(
54+
[ValidateSet("beta", "v1.0")]
55+
[string] $GraphProfile = "v1.0",
56+
[ValidateNotNullOrEmpty()]
57+
[string] $GraphProfilePath = "graph-powershell-1.0",
58+
[ValidateNotNullOrEmpty()]
59+
[string] $Module = "Users",
60+
[ValidateNotNullOrEmpty()]
61+
[string] $ModulePrefix = "Microsoft.Graph",
62+
[ValidateNotNullOrEmpty()]
63+
[string] $DocPath = "..\msgraph-sdk-powershell\src\Users\v1.0\docs"
64+
)
65+
$Path = "$ModulePrefix.$ModuleName"
66+
$ModifiedModuleName = $Module
67+
if($GraphProfile -eq 'beta'){
68+
$Path = "$ModulePrefix.Beta.$ModuleName"
69+
$ModifiedModuleName = "Beta.$Module"
70+
}
71+
$destination = Join-Path $WorkLoadDocsPath $GraphProfilePath $Path
72+
73+
Write-Host -ForegroundColor DarkYellow "Copying v1 markdown files to " $destination
74+
Get-ChildItem $destination -Recurse -File | ForEach-Object {
75+
$Command = [System.IO.Path]::GetFileNameWithoutExtension($_)
76+
if($Command -eq "Microsoft.Graph.$ModifiedModuleName" -or $Command -eq "README"){
77+
#Extract URI path
78+
}else{
79+
$CommandDetails = Find-MgGraphCommand -Command $Command
80+
if($CommandDetails){
81+
if(-not($CommandDetails.Module -eq $ModifiedModuleName)){
82+
Remove-Item $_
83+
}
84+
}else{
85+
Remove-Item $_
86+
}
87+
}
88+
89+
}
90+
}
91+
92+
93+
94+
95+
96+
# Set-Location microsoftgraph-docs-powershell
97+
# $date = Get-Date -Format "dd-MM-yyyy"
98+
# $proposedBranch = "weekly_v2_docs_update_$date"
99+
# $exists = git branch -l $proposedBranch
100+
# if ([string]::IsNullOrEmpty($exists)) {
101+
# git checkout -b $proposedBranch
102+
# }else{
103+
# Write-Host "Branch already exists"
104+
# git checkout $proposedBranch
105+
# }
106+
# if (-not (Test-Path $ModuleMappingConfigPath)) {
107+
# Write-Error "Module mapping file not be found: $ModuleMappingConfigPath."
108+
# }
109+
if ($ModulesToGenerate.Count -eq 0) {
110+
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable
111+
$ModulesToGenerate = $ModuleMapping.Keys
112+
}
113+
114+
#Set-Location ..\microsoftgraph-docs-powershell
115+
Write-Host -ForegroundColor Green "-------------finished checking out to today's branch-------------"
116+
Start-Copy -ModulesToGenerate $ModulesToGenerate
117+
Write-Host -ForegroundColor Green "-------------Done-------------"

0 commit comments

Comments
 (0)