From 05a09d82aa07937fcbf2ebd10436988e0cf1a9c6 Mon Sep 17 00:00:00 2001 From: Tomas Kracmar Date: Wed, 4 Nov 2026 11:45:51 +0100 Subject: [PATCH] refactor: make the module manifest the only version source The project version was stamped into the banner of every file and kept in sync by Bump-Version.ps1, which rewrote them with regexes. It had already drifted: ElysiumSettings.txt.sample still said 2.4.4. Now that src/Elysium/Elysium.psd1 carries ModuleVersion and both the module and the Elysium.Common.ps1 loader read $ElysiumVersion from it, the banner "Version:" lines and Bump-Version.ps1 have no job left. Removed both. Releasing is: change ModuleVersion, add the CHANGELOG entry, commit, tag - documented in the README's versioning section. AGENTS.md: project structure now lists the module layout, and agents are told not to add version numbers back into banners. --- AGENTS.md | 8 +- Bump-Version.ps1 | 162 ------------------------------------- Elysium.ps1 | 1 - ElysiumSettings.txt.sample | 1 - Extract-NTHashes.ps1 | 1 - Prepare-KHDBStorage.ps1 | 1 - README.md | 2 +- Test-WeakADPasswords.ps1 | 1 - Uninstall.ps1 | 1 - Update-KHDB.ps1 | 1 - Update-LithnetStore.ps1 | 1 - decrypt.py | 1 - 12 files changed, 8 insertions(+), 173 deletions(-) delete mode 100644 Bump-Version.ps1 diff --git a/AGENTS.md b/AGENTS.md index 9ca9400..51446eb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,8 +25,13 @@ The tool performs three core workflows: ``` Elysium.ps1 # Main menu / orchestrator script -Elysium.Common.ps1 # Shared helpers: pwsh relauncher, Windows PS fallback +Elysium.Common.ps1 # Transitional loader: dot-sources src/Elysium/Private/*.ps1 into the calling script ElysiumSettings.txt # Live configuration (key=value format, # comments) + +src/Elysium/Elysium.psd1 # Module manifest; ModuleVersion is the single source of the project version +src/Elysium/Elysium.psm1 # Root module: dot-sources Private/ and Public/ +src/Elysium/Private/ # Shared helpers: Relaunch, Settings, Storage (Azure/S3/SigV4), AdPreflight +src/Elysium/Public/ # Exported cmdlets (root scripts are being converted into these) ElysiumSettings.txt.sample # Documented template for operators Update-KHDB.ps1 # KHDB downloader: manifest + shard incremental update @@ -122,4 +127,5 @@ No CI pipeline exists. The one automated check is `python3 tests/test_decrypt.py - Do **not** introduce new package-manager files (e.g., `package.json`, `pyproject.toml`, `Cargo.toml`). This project is intentionally dependency-light and script-driven. - When adding new settings, keep the `key=value` flat format and update both `ElysiumSettings.txt.sample` and any parser that reads the file. - If you add a new operational script, include the standard banner, strict mode, transcript logging, and the `Elysium.Common.ps1` relauncher pattern. +- The version lives only in `src/Elysium/Elysium.psd1` (`ModuleVersion`); code reads it as `$ElysiumVersion`. Do not add version numbers to file banners. - The `.gitignore` excludes `khdb.txt`, `ElysiumSettings.txt`, `Reports/`, `khdb-shards/`, and `khdb-manifest.json`. Exception: `khdb.txt` has been tracked since the first commit, so the ignore rule does not apply to it. Do not `git rm` it casually - client clones have a locally modified `khdb.txt`, and an upstream deletion makes their `git pull` fail. diff --git a/Bump-Version.ps1 b/Bump-Version.ps1 deleted file mode 100644 index 0092f13..0000000 --- a/Bump-Version.ps1 +++ /dev/null @@ -1,162 +0,0 @@ -################################################## -## ____ ___ ____ _____ _ _ _____ _____ ## -## / ___/ _ \| _ \| ____| | \ | | ____|_ _| ## -## | | | | | | |_) | _| | \| | _| | | ## -## | |__| |_| | _ <| |___ _| |\ | |___ | | ## -## \____\__\_\_| \_\_____(_)_| \_|_____| |_| ## -## Move fast and fix things. ## -################################################## -## Project: Elysium ## -## File: Bump-Version.ps1 ## -## Version: 2.4.6 ## -## Support: support@cqre.net ## -################################################## - -#Requires -Version 5.1 - -<# -.SYNOPSIS - Bumps the unified Elysium version across all project files. - -.DESCRIPTION - Updates the centralized $ElysiumVersion variable, ASCII headers in all - operational scripts, the settings template, and runtime references - (User-Agent, usage beacon, etc.). Optionally stubs a new CHANGELOG entry. - -.PARAMETER NewVersion - The new version string to apply (e.g. 2.2.2). - -.PARAMETER SkipChangelog - Do not print a CHANGELOG entry stub. - -.EXAMPLE - .\Bump-Version.ps1 -NewVersion 2.2.2 -#> -param( - [Parameter(Mandatory = $true)] - [string]$NewVersion, - - [switch]$SkipChangelog -) - -$ErrorActionPreference = 'Stop' -Set-StrictMode -Version Latest - -$scriptRoot = $PSScriptRoot -if (-not $scriptRoot) { $scriptRoot = (Get-Location).Path } - -# --------------------------------------------------------------------------- -# Validate input -# --------------------------------------------------------------------------- -if ($NewVersion -notmatch '^\d+\.\d+\.\d+$') { - throw "Version must be in semantic format X.Y.Z (e.g. 2.2.2). Got: '$NewVersion'" -} - -# --------------------------------------------------------------------------- -# Determine current version from Elysium.Common.ps1 -# --------------------------------------------------------------------------- -$commonPath = Join-Path -Path $scriptRoot -ChildPath 'Elysium.Common.ps1' -if (-not (Test-Path -LiteralPath $commonPath)) { - throw "Elysium.Common.ps1 not found at $commonPath" -} - -$commonContent = Get-Content -LiteralPath $commonPath -Raw -$currentVersionMatch = [regex]::Match($commonContent, "\`$script:ElysiumVersion\s*=\s*'([^']+)'") -if (-not $currentVersionMatch.Success) { - throw "Could not determine current version from Elysium.Common.ps1" -} -$oldVersion = $currentVersionMatch.Groups[1].Value - -if ($oldVersion -eq $NewVersion) { - Write-Warning "Current version is already $NewVersion. Nothing to do." - return -} - -Write-Host "Bumping Elysium from $oldVersion -> $NewVersion" - -# --------------------------------------------------------------------------- -# Helper: replace in file -# --------------------------------------------------------------------------- -function Edit-FileVersion { - param( - [string]$Path, - [string]$Old, - [string]$New - ) - $content = Get-Content -LiteralPath $Path -Raw - $newContent = $content.Replace($Old, $New) - if ($newContent -eq $content) { - Write-Verbose " No changes in $(Split-Path -Leaf $Path)" - } else { - Set-Content -LiteralPath $Path -Value $newContent -NoNewline -Encoding UTF8 - Write-Host " Updated $(Split-Path -Leaf $Path)" - } -} - -# --------------------------------------------------------------------------- -# 1. Central version variable -# --------------------------------------------------------------------------- -Write-Host "`n[1/4] Updating centralized version variable..." -Edit-FileVersion -Path $commonPath -Old "`$script:ElysiumVersion = '$oldVersion'" -New "`$script:ElysiumVersion = '$NewVersion'" - -# --------------------------------------------------------------------------- -# 2. ASCII headers in scripts and templates -# --------------------------------------------------------------------------- -Write-Host "`n[2/4] Updating script headers..." -$headerTargets = Get-ChildItem -Path $scriptRoot -File | Where-Object { - $_.Extension -in @('.ps1', '.py') -or $_.Name -eq 'ElysiumSettings.txt.sample' -} -foreach ($file in $headerTargets) { - $content = Get-Content -LiteralPath $file.FullName -Raw - # The header pattern: ## Version: X.Y.Z ## - $pattern = "## Version:\s+$([regex]::Escape($oldVersion))\s+##" - $replacement = "## Version: $NewVersion ##" - $newContent = [regex]::Replace($content, $pattern, $replacement) - if ($newContent -ne $content) { - Set-Content -LiteralPath $file.FullName -Value $newContent -NoNewline -Encoding UTF8 - Write-Host " Updated $($file.Name)" - } -} - -# --------------------------------------------------------------------------- -# 3. Runtime references (safety net) -# --------------------------------------------------------------------------- -Write-Host "`n[3/4] Updating runtime version references..." -$runtimeTargets = Get-ChildItem -Path $scriptRoot -Filter '*.ps1' -File -foreach ($file in $runtimeTargets) { - $content = Get-Content -LiteralPath $file.FullName -Raw - $newContent = $content - # User-Agent patterns: 'Elysium/2.2.1 (+...)' or "Elysium/2.2.1 (+...)" - $newContent = [regex]::Replace($newContent, - "Elysium/$([regex]::Escape($oldVersion))", - "Elysium/$NewVersion") - # Literal string assignments: version = '2.2.1' - $newContent = [regex]::Replace($newContent, - "version\s*=\s*'$([regex]::Escape($oldVersion))'", - "version = '$NewVersion'") - if ($newContent -ne $content) { - Set-Content -LiteralPath $file.FullName -Value $newContent -NoNewline -Encoding UTF8 - Write-Host " Updated runtime refs in $($file.Name)" - } -} - -# --------------------------------------------------------------------------- -# 4. CHANGELOG stub -# --------------------------------------------------------------------------- -if (-not $SkipChangelog) { - Write-Host "`n[4/4] CHANGELOG entry stub (copy-paste ready):" - $today = (Get-Date).ToString('yyyy-MM-dd') - $stub = @" - ---- - -## [$NewVersion] - $today - -### Changed -- (describe your change here) -"@ - Write-Host $stub - Write-Host "`nAppend the above to CHANGELOG.md, then commit and tag." -} - -Write-Host "`nDone. Review the changes with: git diff --stat" diff --git a/Elysium.ps1 b/Elysium.ps1 index a29828e..07d1b76 100644 --- a/Elysium.ps1 +++ b/Elysium.ps1 @@ -7,7 +7,6 @@ ################################################## ## Project: Elysium ## ## File: Elysium.ps1 ## -## Version: 2.4.6 ## ## Support: support@cqre.net ## ################################################## diff --git a/ElysiumSettings.txt.sample b/ElysiumSettings.txt.sample index 2e82c14..3c7720d 100644 --- a/ElysiumSettings.txt.sample +++ b/ElysiumSettings.txt.sample @@ -8,7 +8,6 @@ ################################################## ## Project: Elysium ## ## File: ElysiumSettings.txt ## -## Version: 2.4.4 ## ## Support: support@cqre.net ## ################################################## diff --git a/Extract-NTHashes.ps1 b/Extract-NTHashes.ps1 index c1c8a7a..012c195 100644 --- a/Extract-NTHashes.ps1 +++ b/Extract-NTHashes.ps1 @@ -7,7 +7,6 @@ ################################################## ## Project: Elysium ## ## File: Extract-NTHashes.ps1 ## -## Version: 2.4.6 ## ## Support: support@cqre.net ## ################################################## diff --git a/Prepare-KHDBStorage.ps1 b/Prepare-KHDBStorage.ps1 index caf8f71..9f88103 100644 --- a/Prepare-KHDBStorage.ps1 +++ b/Prepare-KHDBStorage.ps1 @@ -7,7 +7,6 @@ ################################################## ## Project: Elysium ## ## File: Prepare-KHDBStorage.ps1 ## -## Version: 2.4.6 ## ## Support: support@cqre.net ## ################################################## diff --git a/README.md b/README.md index da2203c..ede4acc 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Sensitive operations are confined only to the dedicated host. In the third step, ## Versioning and Releases -Elysium uses a **unified project version** starting with v2.2.0. Every script, the settings template, and the documentation share the same version number so you can verify consistency at a glance by checking the header of any `.ps1` file. Releases are tagged in Git (`v..`) and documented in `CHANGELOG.md`. +Elysium uses a **unified project version** starting with v2.2.0. The version is defined once, as `ModuleVersion` in `src/Elysium/Elysium.psd1`; the scripts read it from there at runtime (User-Agent, usage beacon, diagnostic dumps). To release, change `ModuleVersion`, add the `CHANGELOG.md` entry, commit, and tag `v..`. Prior to v2.2.0, each script carried its own version number; those historical versions are preserved in the changelog for reference. diff --git a/Test-WeakADPasswords.ps1 b/Test-WeakADPasswords.ps1 index 01a43a3..4392d2b 100644 --- a/Test-WeakADPasswords.ps1 +++ b/Test-WeakADPasswords.ps1 @@ -8,7 +8,6 @@ ################################################## ## Project: Elysium ## ## File: Test-WeakADPasswords.ps1 ## -## Version: 2.4.6 ## ## Support: support@cqre.net ## ################################################## diff --git a/Uninstall.ps1 b/Uninstall.ps1 index 908e94b..52c6b34 100644 --- a/Uninstall.ps1 +++ b/Uninstall.ps1 @@ -7,7 +7,6 @@ ################################################## ## Project: Elysium ## ## File: Uninstall.ps1 ## -## Version: 2.4.6 ## ## Support: support@cqre.net ## ################################################## diff --git a/Update-KHDB.ps1 b/Update-KHDB.ps1 index 5ba5d89..c72950d 100644 --- a/Update-KHDB.ps1 +++ b/Update-KHDB.ps1 @@ -7,7 +7,6 @@ ################################################## ## Project: Elysium ## ## File: Update-KHDB.ps1 ## -## Version: 2.4.6 ## ## Support: support@cqre.net ## ################################################## diff --git a/Update-LithnetStore.ps1 b/Update-LithnetStore.ps1 index 34dd284..1a692b0 100644 --- a/Update-LithnetStore.ps1 +++ b/Update-LithnetStore.ps1 @@ -7,7 +7,6 @@ ################################################## ## Project: Elysium ## ## File: Update-LithnetStore.ps1 ## -## Version: 2.4.6 ## ## Support: support@cqre.net ## ################################################## diff --git a/decrypt.py b/decrypt.py index 34e5a48..ebbc7c8 100644 --- a/decrypt.py +++ b/decrypt.py @@ -7,7 +7,6 @@ ################################################## ## Project: Elysium ## ## File: decrypt.py ## -## Version: 1.1.0 ## ## Support: support@cqre.net ## ##################################################