@@ -38,6 +38,33 @@ if (![string]::IsNullOrEmpty($settingsPath) -and (Test-Path -Path $settingsPath)
3838 }
3939 }
4040 }
41+
42+ LogGroup ' Validate settings against schema' {
43+ $schemaPath = Join-Path $PSScriptRoot ' Settings.schema.json'
44+ if (Test-Path - Path $schemaPath ) {
45+ Write-Host ' Validating settings against schema...'
46+ $schema = Get-Content $schemaPath - Raw
47+
48+ # Convert settings to JSON for validation
49+ $settingsJson = $settings | ConvertTo-Json - Depth 10
50+
51+ try {
52+ $isValid = Test-Json - Json $settingsJson - Schema $schema - ErrorAction Stop
53+ if ($isValid ) {
54+ Write-Host ' ✓ Settings conform to schema'
55+ } else {
56+ throw ' Settings do not conform to the schema'
57+ }
58+ } catch {
59+ Write-Error " Schema validation failed: $_ "
60+ Write-Error ' Your settings file does not match the expected schema structure.'
61+ Write-Error ' Please refer to the schema documentation: https://github.com/PSModule/Get-PSModuleSettings#schema'
62+ throw
63+ }
64+ } else {
65+ Write-Warning " Schema file not found at [$schemaPath ]. Skipping validation."
66+ }
67+ }
4168} else {
4269 Write-Host ' No settings file present.'
4370 $settings = @ {}
@@ -134,15 +161,14 @@ $settings = [pscustomobject]@{
134161 Skip = $settings.Publish.Module.Skip ?? $false
135162 AutoCleanup = $settings.Publish.Module.AutoCleanup ?? $true
136163 AutoPatching = $settings.Publish.Module.AutoPatching ?? $true
137- IncrementalPrerelease = $settings.Publish.Module.IncrementalPrerelease ?? $true
164+ IncrementalPrerelease = $settings.Publish.Module.IncrementalPrerelease ?? $true ø
138165 DatePrereleaseFormat = $settings.Publish.Module.DatePrereleaseFormat ?? ' '
139166 VersionPrefix = $settings.Publish.Module.VersionPrefix ?? ' v'
140167 MajorLabels = $settings.Publish.Module.MajorLabels ?? ' major, breaking'
141168 MinorLabels = $settings.Publish.Module.MinorLabels ?? ' minor, feature'
142169 PatchLabels = $settings.Publish.Module.PatchLabels ?? ' patch, fix'
143170 IgnoreLabels = $settings.Publish.Module.IgnoreLabels ?? ' NoRelease'
144171 }
145-
146172 }
147173 Linter = [pscustomobject ]@ {
148174 Skip = $settings.Linter.Skip ?? $false
0 commit comments