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

feat: add patch and patch-commit commands #4900

Merged
merged 11 commits into from Jun 20, 2022
Merged

feat: add patch and patch-commit commands #4900

merged 11 commits into from Jun 20, 2022

Conversation

zkochan
Copy link
Member

@zkochan zkochan commented Jun 19, 2022

close #3077
close #2675

@zkochan zkochan mentioned this pull request Jun 19, 2022
2 tasks
@zkochan zkochan marked this pull request as ready for review June 20, 2022 00:49
@zkochan zkochan requested a review from a team June 20, 2022 01:10
@zkochan zkochan added this to the v7.4 milestone Jun 20, 2022
@zkochan
Copy link
Member Author

zkochan commented Jun 20, 2022

Currently, for the patch to be applied, node_modules should be removed and reinstalled.

@zkochan zkochan merged commit 47b5e45 into main Jun 20, 2022
@zkochan zkochan deleted the patch-commands branch June 20, 2022 13:00
Comment on lines +1 to +8
# @pnpm/plugin-commands-patches

> Commands for creating patches

## Installation

```sh
pnpm add @pnpm/plugin-commands-patches
Copy link
Contributor

Choose a reason for hiding this comment

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

typos → plugin-commands-patching

Comment on lines +16 to +21
```
pnpm patch-commit <path to temp folder>
```

This will create a patch file and write it to `<project>/patches/express@1.0.0.patch`.
Also, it will reference this new patch file from the `patchedDependencies` field in `package.json`:
Copy link
Contributor

Choose a reason for hiding this comment

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

... so this should be compatible with patch-package

putting .scripts.postinstall = "patch-package" in package.json should be safe
as double-patching fails, and patch-package only prints warnings, but no fatal errors
so the install process will continue

@Jack-Works
Copy link
Member

👀 I'm wondering if we can git init and create a new commit in the patch folder, then developers can use IDE tools to see how much they changed to the package by git diff. That doesn't affect how it works but sounds very useful.

`pnpm patch <pkg>` prepares a package for patching. For instance, if you want to patch express v1, run:

```
pnpm patch express@1.0.0
Copy link
Contributor

Choose a reason for hiding this comment

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

running this hangs for me, using 7.3.0.
is the feature fully released?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I see, I need to wait for 7.4

Copy link
Member Author

Choose a reason for hiding this comment

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

🚢 7.4.0-0

@renovate renovate bot mentioned this pull request Aug 1, 2022
1 task
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.

Patching packages during installation Consider adding support for Yarn v2’s patch: protocol
4 participants