Add pnpm plugin for node_modules pruning and validation#21
Open
exo-nikita wants to merge 2 commits into
Open
Conversation
The plugin exposes `hooks` for `.pnpmfile.cjs` and a `prune` helper (also wired as `stasis prune`) that walks node_modules, keeps every package.json, keeps and sha512-validates every file listed in stasis.lock.json, and removes everything else. Both entry points refuse to operate unless `enableGlobalVirtualStore` is false.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds a new pnpm plugin to Stasis that validates and prunes
node_modulesdirectories based on a lockfile manifest. The plugin ensures that only files explicitly listed instasis.lock.jsonare present, with hash verification to detect tampering or corruption.Key Changes
New pnpm plugin (
src/pnpm.cjs): Provides hooks and utilities for managing pnpm-basednode_modulestreesprune()function: Walksnode_modules, validates file hashes against lockfile, removes unlisted files, and cleans up empty directoriesafterAllResolved()hook: Integrates with pnpm's.pnpmfile.cjsto enforce configuration constraintsassertGlobalVirtualStoreDisabled(): Validates that pnpm's global virtual store is disabled (required for correct operation)sha512integrity(): Computes SHA-512 integrity hashes for file verificationCLI command (
bin/stasis.js): Addedstasis prune [path]command to invoke the pruning functionality from the command lineComprehensive test suite (
tests/pnpm.test.js): 8 tests covering:package.jsonfilesenableGlobalVirtualStoreDocumentation (
doc/file-formats.md): Added section explaining the pnpm plugin usage, configuration, and behaviorPackage exports (
package.json): Exported the pnpm plugin as@exodus/stasis/pnpmImplementation Details
node_modulestree non-recursively using a stack to avoid symlink issues (pnpm uses symlinks extensively)package.jsonfiles are preserved regardless of lockfile entriesenableGlobalVirtualStoreis disabled via environment variable checkshttps://claude.ai/code/session_01HmfdTNRR9un7aqRgH3HDDV