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

[rush] Rush update should update shrinkwrap when globalPackageExtension has changed #4901

Closed
kenrick95 opened this issue Aug 23, 2024 · 0 comments · Fixed by #4913
Closed

Comments

@kenrick95
Copy link
Contributor

kenrick95 commented Aug 23, 2024

Summary

Similar to #4820

Discovered when doing #4898

Repro steps

  1. In a Rush repo, with PNPM as package manager, add a dependency to a file
  2. Do a rush update
  3. Then change globalPackageExtension
  4. Do a rush update

Expected result:

Rush should update the lockfile

Actual result:

Rush skips the checks and didn't update lockfile

Workaround is that we should run rush update --recheck

Details

When globalPackageExtension has been updated and libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts needs to mark shrinkwrapIsUpToDate as false too.

However, package extension is represented as a checksum in the shrinkwrap file (packageExtensionsChecksum). That means we need to calculate the checksum of pnpm-config.json's globalPackageExtension and compare it wit the checksum from the shrinkwrap file.

I checked how pnpm did it (ref) and I guess we can copy the part, but what's missing is the sortKeys function. In pnpm, it is using [email protected] but not sure if we should introduce an external dependencies for this case... What do you think?

const packageExtensionsChecksum = isEmpty(opts.packageExtensions ?? {}) ? undefined : createObjectChecksum(opts.packageExtensions!)


export function createObjectChecksum (obj: Record<string, unknown>) {
  const s = JSON.stringify(sortKeys(obj, { deep: true }))
  return crypto.createHash('md5').update(s).digest('hex')
}

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.132.0
rushVersion from rush.json? 5.129.7
useWorkspaces from rush.json? true
Operating system? Mac
Would you consider contributing a PR? Yes
Node.js version (node -v)? 18.20.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant