ds300 / patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨
MIT License
10.17k stars 283 forks source link

Improved DX for `patch-package --partial` #486

Open karlhorky opened 10 months ago

karlhorky commented 10 months ago

As a user of patch-package --partial, I would love if this mode would evolve into an interactive mode which allows for discarding conflicting hunks of the patch (to allow editing of the patch without users editing files in node_modules/) with a workflow similar to:

  1. User runs patch-package --partial
  2. All patches which apply are applied as normal, without any user interaction
  3. Any patches containing hunks which do not fully apply are presented to the user hunk by hunk to resolve conflicts
    1. Similar to git add --patch, a conflicting hunk is shown to the user with the question "Discard?"
    2. If the user answers "yes" to the "Discard?" question, the hunk will be removed from the patch file by patch-package
    3. Possible additional improvement: if the user answers "yes" to all "Discard?" questions for a patch, the patch file will be updated with the current version number of the package
    4. If the user answers "no" to any of the "Discard?" questions, the patch process is aborted with exit code 1

Making it default: This new interactive mode could arguably also become the default for patch-package, and the --partial option dropped - falling back to the previous (non-partial) default mode if the terminal is non-TTY.

Alternatives considered

A (simpler) alternative would be a new flag --discard-conflicts or similar, which would be a non-interactive command that would act as if the user answered "yes" to all of the "Discard?" questions mentioned above.