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

fix: --fix-lockfile should not remove the fields like hasBin and depr… #6784

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SoonIter
Copy link
Contributor

@SoonIter SoonIter commented Jul 9, 2023

closes #6600

@SoonIter SoonIter requested a review from zkochan as a code owner July 9, 2023 18:42
@SoonIter SoonIter force-pushed the fix/fix-lockfile-arg branch from 8268761 to 0be9fc5 Compare July 9, 2023 19:53
@SoonIter
Copy link
Contributor Author

@zkochan
'deprecated' field can only be regenerated by fully resolution to registry from packageManifest

if (!skipResolution || options.skipFetch === true || Boolean(pkgId?.startsWith('file:')) || wantedDependency.optional === true) {

However, 'hasBin' and 'prepare' can be regenerated from pkg here

hasBin = Boolean((pkg.bin && !(pkg.bin === '' || Object.keys(pkg.bin).length === 0)) ?? pkg.directories?.bin)

Maybe I can preserve the deprecated field here and it is a workaround

// Ignore some fields when fixing lockfile, so these fields can be regenerated
// and make sure it's up to date
if (
opts.fixLockfile &&
(ctx.wantedLockfile.packages != null) &&
!isEmpty(ctx.wantedLockfile.packages)
) {
ctx.wantedLockfile.packages = mapValues(({ dependencies, optionalDependencies, resolution }) => ({
// These fields are needed to avoid losing information of the locked dependencies if these fields are not broken
// If these fields are broken, they will also be regenerated
dependencies,
optionalDependencies,
resolution,
}), ctx.wantedLockfile.packages)
}

i think let '--fix-lockfile' the same as 'BROKEN_LOCKFILE' behavior is acceptable.

@SoonIter SoonIter force-pushed the fix/fix-lockfile-arg branch from b286922 to 15e42be Compare July 11, 2023 07:05
@PoomSmart
Copy link

Any ETA for this PR to be merged?

@SoonIter
Copy link
Contributor Author

SoonIter commented Dec 2, 2024

I'm running out of time and won't be able to update this PR. another PR is welcome. If anyone intends to regenerate these lockfile fields, they can give "pnpm i --lockfile-only" a try

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.

pnpm i --fix-lockfile removes 'hasBin' 'deprecated' fields and not regenerated them
3 participants