Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 797 forks source link

package.json: Add packageManager field for corepack compatibility #40201

Closed mreishus closed 1 week ago

mreishus commented 1 week ago

Proposed changes:

This aligns with the version currently used in the GitHub Actions workflow and falls within the engines.pnpm range.

When using the repo with Devbox and Corepack, Corepack may attempt to download a newer pnpm version outside this range. Adding the packageManager field improves compatibility for Corepack users, ensuring consistency across local development and CI environments without impacting others.

I chose 9.3 specifically because it lines up with that's in the github actions.

Other information:

Jetpack product discussion

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

Testing instructions:

github-actions[bot] commented 1 week ago

Thank you for your PR!

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

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 :robot:


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!

anomiex commented 1 week ago

We didn't stay with 9.3.0 specifically. We don't want to constantly chase updates, so as long as things keep working we let the ^9.3.0 in .engines.pnpm allow later versions to be used. To keep that behavior, it looks like we should set manage-package-manager-versions=false in .npmrc so pnpm 10 (once that comes out and we switch to it) doesn't try to exactly match this field.

Probably we should also add something to the existing version checks to verify that this aligns with all the other pnpm version fields.

mreishus commented 1 week ago

So, I first tried 9.11 and one of the checks failed. I'll repush that to see what it was. Sadly, it seems like this field cannot take a range. If I don't provide this value and use devbox+corepack, it starts writing to it, like: + "packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b13 2e16436146b7688f19b"

mreishus commented 1 week ago

I see, so it says this:

Run pnpm/action-setup@v4.0.0
Running self-installer...
  Error: Multiple versions of pnpm specified:
    - version 9.3.0 in the GitHub Action config with the key "version"
    - version pnpm@9.11.0 in the package.json with the key "packageManager"

In reference to this which is also not autoupdating: https://github.com/Automattic/jetpack/blob/5878fb5a5a07b94580fe4dec8c057e7b6125c124/.github/versions.sh#L5

mreishus commented 1 week ago

We could try this, is this too many static versions? I know @sgomes is currently trying to get JP to work in devbox without corepack (we're both using devbox now). Maybe we won't need this..

mreishus commented 1 week ago

Ok, we found two ways to get JP to work in Devbox; but both require changing files committed to the repo.

anomiex commented 1 week ago

I didn't have any objection to setting packageManager to 9.3.0, matching .github/version.sh. As long as we set the npmrc setting so local pnpm doesn't try to enforce that version once we move to v10.

Option 2: Add use-node-version=22.9.0 to .npmrc.

Again, we don't really want to force a particular version of node on everyone.

mreishus commented 1 week ago

OK, I updated it to provide the info for corepack users.