Skip to content

Conversation

@kraftbj
Copy link
Contributor

@kraftbj kraftbj commented Jan 7, 2026

Note: Built on top of #46462 (git hooks feature branch)

Proposed changes:

  • Mount the host pnpm store in Docker for better performance and caching
  • Adds automatic migration when pnpm store location changes
  • Uses two-step approach to handle pnpm store migration gracefully

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable?

Jetpack product discussion

N/A - CLI tooling improvement

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  • Run jp init-hooks to set up git hooks
  • Run jp --help to verify the CLI works correctly
  • Observe that the host pnpm store is mounted for better performance

Auto-detect and mount the host's pnpm store into the monorepo Docker
container, allowing it to reuse already-downloaded packages. This
significantly speeds up pnpm install operations and reduces disk usage.

Implementation:
- Detect host pnpm store using 'pnpm store path' command
- Strip version suffix to get parent directory for version management
- Fallback to default location (~/.local/share/pnpm/store) if pnpm not installed
- Only mount if store directory exists (graceful fallback)
- Configure pnpm via .npmrc in container's /root directory
- Refactored docker run to use bash arrays for cleaner code

The feature is:
- Always-on by default (no opt-in required)
- Zero configuration
- Fully backward compatible
- Transparent to users
When the pnpm store location changes, set CI=true for that container
run to let pnpm auto-approve node_modules cleanup. This prevents the
ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY error without manually
removing directories.

The script now:
- Detects when store-dir configuration changes in .npmrc
- Sets CI=true only when store location changed (not always)
- Shows warning message to inform user of automatic rebuild
- Lets pnpm handle the cleanup properly
Detect store mismatch by checking node_modules/.modules.yaml and run
a separate migration step before the user's command to preserve
interactivity.

When migration is needed:
1. Run 'pnpm install' with CI=true to auto-approve node_modules cleanup
2. Run the user's original command with CI="${CI:-}" for full interactivity

This ensures:
- Automatic migration for users adopting the host store feature
- No ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY errors
- Full interactive prompt support in jetpack commands
- No overhead after initial migration (single docker run)

The detection checks node_modules/.modules.yaml storeDir field to
determine if migration is needed, which is more reliable than checking
.npmrc changes.
@kraftbj kraftbj self-assigned this Jan 7, 2026
@kraftbj kraftbj added the [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it label Jan 7, 2026
@github-actions github-actions bot added the Docker label Jan 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docker [Status] In Progress [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants