Skip to content

Conversation

@Cliffback
Copy link

Changes

Switches from using corepack use [email protected] to parse it manually the same way corepack does it themselves. Have been struggling with renovate not updating pnpm correctly, and this is a suggestion for a solution to fix it, based on the outline in #37772

Context

Please select one of the following:

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Consulted with MS Copilot / GPT 5 to understand the original code + a getting a few suggestions for the parsing and tests, but worked through everything myself

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests, but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository:

const [algo, b64] = integrity.split('-', 2);
const hex = Buffer.from(b64, 'base64').toString('hex');

const expectedLen = algo === 'sha512' ? 128 : algo === 'sha256' ? 64 : null;
Copy link
Author

@Cliffback Cliffback Dec 8, 2025

Choose a reason for hiding this comment

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

Technically sha384 could also be a possible algo, so could either add a check for correct length for 384 as well, or change to only check lenght on sha512, which should be the most common algo.

await writeLocalFile(packageFileName, existingPackageFileContent);

// Asumming that corepack only needs to modify the package.json file in the root folder
// Asumming that only the root package.json needs to modification
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't change

Copy link
Author

@Cliffback Cliffback Dec 8, 2025

Choose a reason for hiding this comment

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

Ah, okay. Thought to remove the mention of corepack since corepack use is not run anymore.

Won't it be confusing to still have corepack in the comment? Corepack is not modifying any files anymore.

But I'll of course revert to the original comment if that's preferred

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is still a corepack change, we can remove use command where necessary.

We should also link the original source and logic in the comment, btw so it's easier to reference in future.

Copy link
Author

@Cliffback Cliffback Dec 8, 2025

Choose a reason for hiding this comment

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

Yeah, point taken, we are basically mimicking corepack. Will revert and also add a link to corepackUtils.ts#L300

Copy link
Author

Choose a reason for hiding this comment

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

@RahulGautamSingh updated just now, looks better?

) {
const integrity = (
await exec(
`npm view ${depName}@${newVersion} dist.integrity`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this only return sha512, right?

Copy link
Author

Choose a reason for hiding this comment

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

AFAIK as long as using the official npm registry, only sha512 will be returned (from 2017 and onward)

However with other registries this might not be the case. Corepack's own readme mentions sha224 for yarn for example, and was the reason for assuming more than sha512.

But I guess for renovate can we assume to always use the official npm registry, and then expect only sha512?

Copy link
Collaborator

Choose a reason for hiding this comment

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

But I guess for renovate can we assume to always use the official npm registry, and then expect only sha512?

@viceice thoughts?? I don't think npm regsitry will always be the case.

Copy link
Member

Choose a reason for hiding this comment

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

we can't assume that. we should throw an artifact error if there's something missing

Copy link
Member

Choose a reason for hiding this comment

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

we should reuse the response from npm datasource instead of calling npm CLI here.

datasource can maybe return it as digest

@Cliffback
Copy link
Author

Is the PR title okay, or should it reflect the actual issue it fixes?
(avoiding prepare scripts #3772 / fixing the broken packageManager field #36904)?

@RahulGautamSingh
Copy link
Collaborator

The PR title is fine

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

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

see comment. we should return the integrity value via the getDigest function of the npm manager if it's not already available in the usual npm response.

) {
const integrity = (
await exec(
`npm view ${depName}@${newVersion} dist.integrity`,
Copy link
Member

Choose a reason for hiding this comment

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

we should reuse the response from npm datasource instead of calling npm CLI here.

datasource can maybe return it as digest

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent install scripts from being run when using corepack use

3 participants