Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build/Create-EntraModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ if($Module -eq 'Entra'){
}else{
$typeDefsPath=(Join-Path $PSScriptRoot "/Beta-TypeDefs.txt")
}
if($Root){
$moduleBuilder.CreateRootModuleManifest($Module)
}else{
$moduleBuilder.CreateModuleHelp($Module)
$moduleBuilder.CreateSubModuleFile($Module, $typeDefsPath)
$moduleBuilder.CreateModuleManifest($Module)
}


if($Root){
$moduleBuilder.CreateRootModuleManifest($Module)
Expand Down
23 changes: 19 additions & 4 deletions src/EntraModuleBuilder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,19 @@ Set-StrictMode -Version 5
return $subModules.Name
}
}
[string[]] GetSubModuleManifestFiles([string] $Module, [string]$DirectoryPath) {
# Check if the directory exists
# Define the pattern for matching submodule files
$pattern = if ($module -like "Microsoft.Graph.Entra.Beta.*") {
"Microsoft.Graph.Entra.Beta.*.psd1"
} else {
"Microsoft.Graph.Entra.*.psd1"
}

if (-Not (Test-Path -Path $DirectoryPath)) {
Log-Message "[EntraModuleBuilder]: Directory does not exist: $directoryPath" -ForegroundColor Red
return $null # Return null if directory does not exist
}

[string[]] GetSubModuleFileNames([string] $Module, [string]$DirectoryPath) {
# Check if the directory exists
Expand All @@ -216,6 +229,7 @@ Set-StrictMode -Version 5
Log-Message "[EntraModuleBuilder]: No .psd1 files found in the directory: $directoryPath" -Level 'INFO'
return @() # Return an empty array if no files are found
} else {

# Return the names of the .psd1 files
return $subModules | ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension($_.Name) }
}
Expand Down Expand Up @@ -319,7 +333,8 @@ foreach (`$subModule in `$subModules) {
}
$manifestPath = Join-Path $this.OutputDirectory -ChildPath "$($moduleName).psd1"

$subModules=$this.GetSubModuleFileNames($Module,$this.OutputDirectory)
$subModules=$this.GetSubModuleManifestFiles($Module,$this.OutputDirectory)

$requiredModules=@()
foreach($module in $subModules){
if($module -ne $moduleName){
Expand All @@ -341,6 +356,8 @@ foreach (`$subModule in `$subModules) {
DotNetFrameworkVersion = $([System.Version]::Parse('4.7.2'))
PowerShellVersion = $([System.Version]::Parse('5.1'))
CompatiblePSEditions = @('Desktop','Core')
RequiredModules=$requiredModules
NestedModules = $nestedModules
NestedModules = @()
}

Expand All @@ -351,7 +368,7 @@ foreach (`$subModule in `$subModules) {
Log-Message "[EntraModuleBuilder]: Starting Root Module Manifest generation" -Level 'INFO'

New-ModuleManifest @moduleSettings
Update-ModuleManifest -Path $manifestPath -PrivateData $PSData
Update-ModuleManifest -Path $manifestPath -PrivateData $PSData -Verbose

# Construct the entries for the RequiredModules section
$requiredModulesEntries = $requiredModules | ForEach-Object {
Expand Down Expand Up @@ -511,7 +528,6 @@ $($requiredModulesEntries -join ",`n")
try{
New-ModuleManifest @moduleSettings
Update-ModuleManifest -Path $manifestPath -PrivateData $PSData

# Validate the module manifest
$manifestValidationResult = Test-ModuleManifest -Path $manifestPath

Expand All @@ -531,7 +547,6 @@ $($requiredModulesEntries -join ",`n")

}


#Create the Root Module Manifest

# $this.CreateRootModuleManifest($module)
Expand Down