From 790d02fec60f2ac75ed98ffa1c90a8298a9f6d4a Mon Sep 17 00:00:00 2001 From: Nicolas Fabert <195452170+Nico77600@users.noreply.github.com> Date: Mon, 12 Oct 2026 14:00:06 +0100 Subject: [PATCH] Align runtime disclaimer with project README --- package/Invoke-MessageTraceReport.ps1 | 6 +++++ package/README.md | 7 ++++++ tests/MessageTraceReport.Tests.ps1 | 36 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/package/Invoke-MessageTraceReport.ps1 b/package/Invoke-MessageTraceReport.ps1 index d0e99ca..a93ca28 100644 --- a/package/Invoke-MessageTraceReport.ps1 +++ b/package/Invoke-MessageTraceReport.ps1 @@ -149,6 +149,12 @@ Version : 1.1.0 Exit codes : 0 = success, 1 = failure, 2 = finished but incomplete (see the summary). Documentation : docs\MessageTraceReport-Guide.md (or .html) + + Disclaimer: + This Script is a Personal project. + It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft. + + As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production. #> [CmdletBinding()] param( diff --git a/package/README.md b/package/README.md index 4fb6e79..2ee098e 100644 --- a/package/README.md +++ b/package/README.md @@ -58,3 +58,10 @@ notepad .\config\MessageTraceReport.config.psd1 # TenantId, AppId, Certif Project page, releases and change log: https://github.com/Nico77600/MessageTraceReport License: [MIT](LICENSE). Third-party components: [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). + +## Disclaimer + +This Script is a Personal project. +It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft. + +As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production. diff --git a/tests/MessageTraceReport.Tests.ps1 b/tests/MessageTraceReport.Tests.ps1 index fa9bddc..f1899dc 100644 --- a/tests/MessageTraceReport.Tests.ps1 +++ b/tests/MessageTraceReport.Tests.ps1 @@ -87,6 +87,42 @@ AfterAll { Remove-Item -LiteralPath $script:Work -Recurse -Force -ErrorAction SilentlyContinue } +Describe 'Runtime disclaimer' { + BeforeAll { + $script:DisclaimerRepo = Split-Path $PSScriptRoot -Parent + $script:DisclaimerConfig = Get-Content (Join-Path $script:DisclaimerRepo '.github\ci.json') -Raw | ConvertFrom-Json + $script:DisclaimerRuntime = Join-Path $script:DisclaimerRepo $script:DisclaimerConfig.runtimeRoot + $script:DisclaimerPattern = '(?ms)^## Disclaimer[ \t]*\r?\n(?.*?)(?=^##[ \t]|\z)' + $rootReadme = [IO.File]::ReadAllText((Join-Path $script:DisclaimerRepo 'README.md')) + $matches = [regex]::Matches($rootReadme, $script:DisclaimerPattern) + if ($matches.Count -ne 1) { throw 'The root README must contain exactly one canonical disclaimer.' } + $script:CanonicalDisclaimer = $matches[0].Groups['Body'].Value.Trim().Replace("`r`n", "`n") + function ConvertTo-DisclaimerParagraphs([string]$Text) { + (($Text.Trim() -split '\r?\n[ \t]*\r?\n') | ForEach-Object { ($_ -replace '\s+', ' ').Trim() }) -join "`n`n" + } + } + + It 'keeps the runtime README disclaimer identical to the canonical root section' { + $readme = [IO.File]::ReadAllText((Join-Path $script:DisclaimerRuntime 'README.md')) + $matches = [regex]::Matches($readme, $script:DisclaimerPattern) + $matches.Count | Should -Be 1 + $matches[0].Groups['Body'].Value.Trim().Replace("`r`n", "`n") | Should -BeExactly $script:CanonicalDisclaimer + } + + It 'keeps the public entry script disclaimer attached to its help with the same wording and paragraphs' { + $path = Join-Path $script:DisclaimerRuntime $script:DisclaimerConfig.packageEntry + $errors = $null + $ast = [Management.Automation.Language.Parser]::ParseFile($path, [ref]$null, [ref]$errors) + @($errors).Count | Should -Be 0 + $help = $ast.GetHelpContent() + $help | Should -Not -BeNullOrEmpty + $notes = $help.Notes + [regex]::Matches($notes, '(?m)^[ \t]*Disclaimer:[ \t]*$').Count | Should -Be 1 + $body = [regex]::Match($notes, '(?s)(?:^|\r?\n)[ \t]*Disclaimer:[ \t]*\r?\n(?.*)\z').Groups['Body'].Value + (ConvertTo-DisclaimerParagraphs $body) | Should -BeExactly (ConvertTo-DisclaimerParagraphs $script:CanonicalDisclaimer) + } +} + Describe 'Configuration' { It 'reports every missing value of the delivered configuration at once' { $path = Join-Path $script:Root 'config\MessageTraceReport.config.psd1'