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

How commit all patches at onece? #7291

Open
1 task
WormGirl opened this issue Nov 9, 2023 · 8 comments
Open
1 task

How commit all patches at onece? #7291

WormGirl opened this issue Nov 9, 2023 · 8 comments

Comments

@WormGirl
Copy link

WormGirl commented Nov 9, 2023

Contribution

Describe the user story

I have many patches, how to commit all patches, use somethings like pnpm patch-commit D:\project\demo\patchesTemp, this will commit all patches at patchesTemp folder
image

Describe the solution you'd like

support somethings like pnpm patch-commit D:\project\demo\patchesTemp, this will commit all patches at patchesTemp folder

Describe the drawbacks of your solution

I need to deal some package to remove some file is not use. this package dealed by node, I have many patches to commit.

Describe alternatives you've considered

empty

@KSXGitHub
Copy link
Contributor

I don't know what you are trying to say. Can you be more specific? What is your condition? What is it that you're trying to do? And why aren't existing commands insufficient?

@WormGirl
Copy link
Author

WormGirl commented Nov 10, 2023

/> I don't know what you are trying to say. Can you be more specific? What is your condition? What is it that you're trying to do? And why aren't existing commands insufficient?

It is a scenario where I need to traverse all the packages under node_modules, replace and delete some things. This is how I do it. First find all the packages to be modified, and then run pnpm patch ${pkg} --edit-dir ${path.resolve(patchTemp, pkg)} Extract all the packages to be modified into the patchTemp directory, and then modify all the packages in the patchTemp directory. After the modification is completed, I want to submit all the packages in the patchTemp directory at once instead of traversing all the packages to run pnpm patch-commit ${path.resolve(patchTemp, pkg)}. And there is a problem with each commit, that is, each commit will frequently trigger the preinstall hook. I have done some things in this hook. I don’t want to execute this hook once for each package commit, but I want all packages to be commit together. Make sure the hook only fires once

@KSXGitHub
Copy link
Contributor

Since your edit dir belongs to the same directory as your workspace, I have a feeling that you might be better served with overrides instead of patch. You can set the override to a local link for example.

If you insist on patch. I can tell you that patches in pnpm are just a patchedDependencies object and the patchfiles. The patchfiles can be generated by git diff --recursive --unified node_modules/package/ patchesTemp/package/ (remember to normalize the filenames inside the patchfiles).

Mass patch-commit (i.e. patch-commit patchesTemp/*) would certainly be a cool feature to be added to pnpm. But until it is implemented, I suggest you use one of the above solutions for now.

@WormGirl
Copy link
Author

WormGirl commented Nov 14, 2023

I think I can try git diff and then write patchedDependencies myself. Overrides may not be suitable. I only want patches to be submitted to the code repository.

@WormGirl
Copy link
Author

WormGirl commented Nov 14, 2023

Since your edit dir belongs to the same directory as your workspace, I have a feeling that you might be better served with overrides instead of patch. You can set the override to a local link f
/or example.

If you insist on patch. I can tell you that patches in pnpm are just a patchedDependencies object and the patchfiles. The patchfiles can be generated by git diff --recursive --unified node_modules/package/ patchesTemp/package/ (remember to normalize the filenames inside the patchfiles).

Mass patch-commit (i.e. patch-commit patchesTemp/*) would certainly be a cool feature to be added to pnpm. But until it is implemented, I suggest you use one of the above solutions for now.

This error always appears during install. It seems to be caused by the file name being too long. Is there any way to solve this? I set LongPathsEnabled in the Windows registry to 1, but it doesn't work.

ENAMETOOLONG: name too long, chdir 'D:\project\demo-vm_1.0.0\vm-web' -> 'D:\project\demo-vm_1.0.0\vm-web\node_modules\.pnpm\@babel+plugin-bugfix-safari-id-destructuring-collision-in-function-expression@7.18.6_patch_ha_gzpqrymxcpjn6jqop3mkqe3p44\node_modules\@babel\plugin-bugfix-safari-id-destructuring-collision-in-function-expression'

pnpm: ENAMETOOLONG: name too long, chdir 'D:\project\demo-vm_1.0.0\vm-web' -> 'D:\project\demo-vm_1.0.0\vm-web\node_modules\.pnpm\@babel+plugin-bugfix-safari-id-destructuring-collision-in-function-expression@7.18.6_patch_ha_gzpqrymxcpjn6jqop3mkqe3p44\node_modules\@babel\plugin-bugfix-safari-id-destructuring-collision-in-function-expression'
    at process.wrappedChdir (node:internal/bootstrap/switches/does_own_process_state:112:14)
    at process.chdir (C:\Users\liuminqing\AppData\Local\pnpm\global\5\.pnpm\pnpm@8.10.3\node_modules\pnpm\dist\pnpm.cjs:56:15)
    at process.chdir (C:\Users\liuminqing\AppData\Local\pnpm\global\5\.pnpm\pnpm@8.10.3\node_modules\pnpm\dist\pnpm.cjs:13607:15)
    at process.chdir (node:internal/worker:102:5)
    at applyPatchToDir (C:\Users\liuminqing\AppData\Local\pnpm\global\5\.pnpm\pnpm@8.10.3\node_modules\pnpm\dist\pnpm.cjs:128726:15)
    at buildDependency (C:\Users\liuminqing\AppData\Local\pnpm\global\5\.pnpm\pnpm@8.10.3\node_modules\pnpm\dist\pnpm.cjs:128856:54)

@KSXGitHub
Copy link
Contributor

I don't have Windows so it's hard for me to reproduce. Anyway, can you try WSL?

@WangJincheng4869
Copy link

的确,pnpm 并不支持 LongPathsEnabled 参数,希望日后可以支持。

@RexSkz
Copy link
Contributor

RexSkz commented Feb 28, 2024

PNPM may not be able to solve the LongPathsEnabled issue; it may be related to this issue in Node.js: nodejs/node#50753, there is a PR but it's not merged yet: nodejs/node#51097

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

No branches or pull requests

4 participants