Skip to content

Optimize MaintainModule internals and improve command metadata#47

Merged
rwidmark merged 9 commits into
devfrom
copilot/optimize-code-speed-memory
Apr 16, 2026
Merged

Optimize MaintainModule internals and improve command metadata#47
rwidmark merged 9 commits into
devfrom
copilot/optimize-code-speed-memory

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown

This updates MaintainModule to be leaner and more predictable while improving command UX. It tightens parameter metadata and validation, makes -Verbose / -WhatIf behavior flow through nested operations, and removes a few cross-platform rough edges.

  • Performance and structure

    • Reduced unnecessary allocations during installed-module discovery and version processing.
    • Replaced repeated lookups with focused helpers for:
      • caller preference propagation
      • module name normalization/deduplication
      • latest repository version lookup
    • Simplified internal data flow so update/install/uninstall paths share less duplicated logic.
  • Command surface improvements

    • Added missing HelpMessage metadata across parameters.
    • Strengthened validation on user-facing inputs such as module names and version collections.
    • Kept SupportsShouldProcess behavior consistent so nested actions respect -WhatIf and -Verbose.
  • Compatibility

    • Updated the manifest to declare both Desktop and Core editions.
    • Stopped exporting variables from the module manifest.
    • Switched the publish script to Join-Path for path handling that works cleanly on Windows and macOS.
  • Robustness

    • Added explicit version parsing error handling for installed module metadata.
    • Documented the repository lookup behavior where only the newest version is required.
  • Documentation

    • Added README notes for -Verbose and -WhatIf usage.

Example:

Update-rsModule -Module 'Pester' -UninstallOldVersion -WhatIf -Verbose

This now previews both update and cleanup actions while surfacing the internal decision flow through verbose output.

Copilot AI and others added 7 commits April 16, 2026 18:15
Agent-Logs-Url: https://github.com/rwidmark/MaintainModule/sessions/84d3a26e-f762-4e08-bba7-b496a8d897a9

Co-authored-by: rwidmark <76907327+rwidmark@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rwidmark/MaintainModule/sessions/84d3a26e-f762-4e08-bba7-b496a8d897a9

Co-authored-by: rwidmark <76907327+rwidmark@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rwidmark/MaintainModule/sessions/84d3a26e-f762-4e08-bba7-b496a8d897a9

Co-authored-by: rwidmark <76907327+rwidmark@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rwidmark/MaintainModule/sessions/84d3a26e-f762-4e08-bba7-b496a8d897a9

Co-authored-by: rwidmark <76907327+rwidmark@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rwidmark/MaintainModule/sessions/84d3a26e-f762-4e08-bba7-b496a8d897a9

Co-authored-by: rwidmark <76907327+rwidmark@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rwidmark/MaintainModule/sessions/84d3a26e-f762-4e08-bba7-b496a8d897a9

Co-authored-by: rwidmark <76907327+rwidmark@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors MaintainModule internals to reduce allocations and improve predictability, while enhancing command UX via tighter parameter metadata/validation and clearer guidance for -Verbose/-WhatIf behavior.

Changes:

  • Refactored module/version discovery helpers (caller preference propagation, module name normalization/deduplication, latest repository lookup).
  • Tightened parameter metadata and validation (HelpMessage additions, more specific validation attributes, AllowPrerelease as a switch).
  • Improved cross-platform/publishing and packaging metadata (manifest editions/exports; Join-Path in publish script; README notes).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
publish.ps1 Uses Join-Path for cross-platform module path construction before publishing.
README.md Adds usage notes for -WhatIf/-Verbose on state-changing commands.
MaintainModule/MaintainModule.psm1 Adds internal helpers and refactors update/uninstall flows; strengthens validation and error handling.
MaintainModule/MaintainModule.psd1 Declares CompatiblePSEditions and stops exporting variables from the manifest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread MaintainModule/MaintainModule.psm1 Outdated
Comment thread MaintainModule/MaintainModule.psm1 Outdated
rwidmark and others added 2 commits April 16, 2026 20:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rwidmark rwidmark marked this pull request as ready for review April 16, 2026 18:35
@rwidmark rwidmark merged commit 3be69eb into dev Apr 16, 2026
@rwidmark rwidmark deleted the copilot/optimize-code-speed-memory branch April 16, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants