Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Nov 15, 2024

Conversation

mreishus
Copy link
Contributor

@mreishus mreishus commented Nov 14, 2024

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:

  • 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 (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

  • Go to '..'

Copy link
Contributor

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 Team Review, ...).
  • ✅ 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 🤖


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!

@mreishus mreishus marked this pull request as ready for review November 14, 2024 23:23
@mreishus mreishus added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] In Progress labels Nov 14, 2024
@anomiex
Copy link
Contributor

anomiex commented Nov 15, 2024

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
Copy link
Contributor Author

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": "[email protected]+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b13 2e16436146b7688f19b"

@mreishus
Copy link
Contributor Author

I see, so it says this:

Run pnpm/[email protected]
Running self-installer...
  Error: Multiple versions of pnpm specified:
    - version 9.3.0 in the GitHub Action config with the key "version"
    - version [email protected] in the package.json with the key "packageManager"

In reference to this which is also not autoupdating:

PNPM_VERSION=9.3.0

@mreishus
Copy link
Contributor Author

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
Copy link
Contributor Author

mreishus commented Nov 15, 2024

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

  • Option 1: Add "packageManager": "[email protected]" to package.json.
    • Devbox users turn corepack on and let it install the pnpm version specified here.
    • This lines up with the engines.pnpm in the same file as well as PNPM_VERSION in .github/versions.sh.
  • Option 2: Add use-node-version=22.9.0 to .npmrc.
    • Devbox users turn corepack off and add a pnpm version satisfying the current requirements to their devbox. Then pnpm will install this node version.
    • This aligns with .nvmrc.

@anomiex
Copy link
Contributor

anomiex commented Nov 15, 2024

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
Copy link
Contributor Author

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

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

I added the linting check I had asked for earlier. If that looks good to you, let's go ahead.

@github-actions github-actions bot added the Actions GitHub actions used to automate some of the work around releases and repository management label Nov 15, 2024
@mreishus mreishus merged commit c23823d into trunk Nov 15, 2024
53 checks passed
@mreishus mreishus deleted the add/corepack branch November 15, 2024 18:59
@github-actions github-actions bot removed the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions GitHub actions used to automate some of the work around releases and repository management
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants