11<#
22. SYNOPSIS
3- Generates function metadata cache for CIPP module
3+ Generates function permission cache for modules
44. PARAMETER ModuleName
5- Name of the module (used in output filename and metadata )
5+ Name of the module (used in output filename and cache )
66#>
77[CmdletBinding ()]
88param (
@@ -15,18 +15,12 @@ param(
1515 [Parameter ()]
1616 [string ]$ModuleName ,
1717
18- [string ]$FunctionPattern = ' *.ps1' ,
19-
20- [switch ]$IncludeParameters ,
21-
22- [switch ]$IncludeHelp ,
23-
24- [switch ]$IncludeAll
18+ [string ]$FunctionPattern = ' *.ps1'
2519)
2620
2721Write-Host " Starting metadata generation..." - ForegroundColor Cyan
2822Write-Host " Module: $ ( if ($ModuleName ){$ModuleName }else {' Not Specified' }) " - ForegroundColor Cyan
29- Write-Host " Mode: $ ( if ( $IncludeAll ){ ' Full ' } elseif ( $IncludeParameters -and $IncludeHelp ){ ' Parameters + Help ' } elseif ( $IncludeParameters ){ ' Parameters Only ' } elseif ( $IncludeHelp ){ ' Help Only ' } else { ' Minimal (Role/Functionality) ' } ) " - ForegroundColor Cyan
23+ Write-Host " Mode: Minimal (Role/Functionality)" - ForegroundColor Cyan
3024
3125$metadata = @ {
3226 ModuleName = if ($ModuleName ) { $ModuleName } else { ' Unknown' }
@@ -40,13 +34,7 @@ Write-Host "Found $($functionFiles.Count) function files to process" -Foreground
4034
4135$parseErrors = @ ()
4236$processed = 0
43- $stats = @ {
44- Role = 0
45- Functionality = 0
46- Synopsis = 0
47- Description = 0
48- Parameters = 0
49- }
37+ $stats = @ { Role = 0 ; Functionality = 0 }
5038
5139foreach ($file in $functionFiles ) {
5240 $processed ++
@@ -84,115 +72,16 @@ foreach ($file in $functionFiles) {
8472 # Extract help content
8573 $help = $functionDef.GetHelpContent ()
8674
87- # Build function metadata
75+ # Build function metadata (only Role and Functionality)
8876 $funcMeta = [ordered ]@ {}
89-
90- # Always include Role and Functionality
9177 if ($help.Role ) {
9278 $funcMeta.Role = $help.Role.Trim ()
9379 $stats.Role ++
9480 }
95-
9681 if ($help.Functionality ) {
9782 $funcMeta.Functionality = $help.Functionality.Trim ()
9883 $stats.Functionality ++
9984 }
100-
101- # Include help content if requested
102- if ($IncludeHelp -or $IncludeAll ) {
103- if ($help.Synopsis ) {
104- $funcMeta.Synopsis = $help.Synopsis.Trim ()
105- $stats.Synopsis ++
106- }
107-
108- if ($help.Description.Text ) {
109- $funcMeta.Description = $help.Description.Text.Trim ()
110- $stats.Description ++
111- }
112- }
113-
114- # Include parameters if requested
115- if ($IncludeParameters -or $IncludeAll ) {
116- $parameters = [ordered ]@ {}
117-
118- foreach ($param in $functionDef.Parameters ) {
119- $paramName = $param.Name.VariablePath.UserPath
120-
121- $paramType = if ($param.StaticType ) {
122- $param.StaticType.Name
123- } else {
124- ' Object'
125- }
126-
127- $mandatory = $false
128- $validateSet = $null
129- $validateRange = $null
130- $validatePattern = $null
131- $paramHelp = $null
132-
133- foreach ($attribute in $param.Attributes ) {
134- $attrTypeName = $attribute.TypeName.Name
135-
136- if ($attrTypeName -eq ' Parameter' ) {
137- $mandatoryArg = $attribute.NamedArguments | Where-Object { $_.ArgumentName -eq ' Mandatory' }
138- if ($mandatoryArg ) {
139- $mandatory = $mandatoryArg.Argument.Value
140- }
141- }
142-
143- if ($attrTypeName -eq ' ValidateSet' ) {
144- $validateSet = @ ($attribute.PositionalArguments.Value )
145- }
146-
147- if ($attrTypeName -eq ' ValidateRange' ) {
148- $validateRange = @ {
149- Min = $attribute.PositionalArguments [0 ].Value
150- Max = $attribute.PositionalArguments [1 ].Value
151- }
152- }
153-
154- if ($attrTypeName -eq ' ValidatePattern' ) {
155- $validatePattern = $attribute.PositionalArguments [0 ].Value
156- }
157- }
158-
159- if ($help.Parameters ) {
160- $paramHelp = $help.Parameters.Parameter | Where-Object { $_.Name -eq $paramName } | Select-Object - First 1
161- }
162-
163- $paramInfo = [ordered ]@ {
164- Type = $paramType
165- }
166-
167- if ($mandatory ) {
168- $paramInfo.Mandatory = $mandatory
169- }
170-
171- if ($validateSet ) {
172- $paramInfo.ValidateSet = $validateSet
173- }
174-
175- if ($validateRange ) {
176- $paramInfo.ValidateRange = $validateRange
177- }
178-
179- if ($validatePattern ) {
180- $paramInfo.ValidatePattern = $validatePattern
181- }
182-
183- if ($paramHelp -and $paramHelp.Description.Text ) {
184- $paramInfo.Description = $paramHelp.Description.Text.Trim ()
185- }
186-
187- $parameters [$paramName ] = $paramInfo
188- }
189-
190- if ($parameters.Count -gt 0 ) {
191- $funcMeta.Parameters = $parameters
192- $stats.Parameters ++
193- }
194- }
195-
19685 if ($funcMeta.Count -gt 0 ) {
19786 $metadata.Functions [$functionName ] = $funcMeta
19887 }
@@ -309,13 +198,6 @@ Write-Host "Functions processed: $($metadata.Functions.Count)" -ForegroundColor
309198Write-Host " `n Metadata Statistics:" - ForegroundColor Cyan
310199Write-Host " Functions with Role: $ ( $stats.Role ) " - ForegroundColor Gray
311200Write-Host " Functions with Functionality: $ ( $stats.Functionality ) " - ForegroundColor Gray
312- if ($IncludeHelp -or $IncludeAll ) {
313- Write-Host " Functions with Synopsis: $ ( $stats.Synopsis ) " - ForegroundColor Gray
314- Write-Host " Functions with Description: $ ( $stats.Description ) " - ForegroundColor Gray
315- }
316- if ($IncludeParameters -or $IncludeAll ) {
317- Write-Host " Functions with Parameters: $ ( $stats.Parameters ) " - ForegroundColor Gray
318- }
319201
320202if ($parseErrors ) {
321203 Write-Warning " `n Parse errors encountered in $ ( $parseErrors.Count ) files:"
0 commit comments