feat: Add package pinning command (pin/unpin)
#967
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature: Package Pinning (
pin/unpin) ImplementationThis Pull Request introduces package pinning functionality. This feature allows users to lock an installed module's version, preventing accidental or automatic upgrades, downgrades, or removal until explicitly unpinned.
1. Overview
This feature enhances IPM's stability and dependency management by implementing a mechanism to lock installed modules. This ensures production or critical modules remain fixed at a specific version, protecting them from core IPM modification commands.
The implementation relies on a new persistent storage class to track pinned modules.
2. New Commands:
pinandunpin2.1.
pinCommandMarks a specific, installed module as pinned to prevent future modification operations.
Usage Examples:
2.2.
unpinCommandRemoves the pinned status from an installed module, allowing future ZPM operations (install, reinstall,uninstall, update) to proceed normally.
Usage Examples:
3. Architectural and Visibility Changes
3.1. Storage Mechanism
A new independent storage class,
%IPM.Storage.PinnedModule, was created to manage the list of all modules marked as pinned, their version, and their current status.3.2. Visibility and Discovery
listcommand: The status-Pinnedis appended to the version number for easy identification (e.g.,web-fslog 1.0.0-Pinned).list -pmodifier: A new modifier,-p(or--pinned), was implemented. This allows users to quickly list and audit only the modules that are currently pinned.4. Operational Blocking (Integrity Check)
The pinning status is checked at the codebase level within the execution logic for all modification commands. If a module is pinned, the command is blocked and a specific error is returned.
installERROR! The module web-fslog is pinned unable to installreinstallERROR! The module web-fslog is pinned unable to reinstalluninstallERROR! The module web-fslog is pinned unable to uninstallupdateERROR! The module web-fslog is pinned unable to updateVerification Trace for Blocking
The following sequence confirms the blocking mechanism when a module is pinned:
Verification Trace for Unlocking
The following sequence confirms that the
unpincommand correctly restores the ability to modify the package:5. Unit Testing Results
Integration and unit tests were created to validate the entire lifecycle of the pin feature and its interaction with core ZPM commands. All 20 assertions passed.
web-fslog).installcommand on the pinned module (AssertStatusNotOK).reinstallcommand on the pinned module (AssertStatusNotOK).uninstallcommand on the pinned module (AssertStatusNotOK).updatecommand on the pinned module (AssertStatusNotOK).unpincommand on a module that was already unpinned (AssertStatusNotOK).Resolves #968